@feltdb/feltkit 0.3.10 → 0.3.12
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 +86 -3
- package/dist/app.js +63 -2
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.d.ts +39 -1
- package/dist/appboundry/build.js +77 -7
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +79 -2
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/appboundry/host.d.ts +44 -0
- package/dist/appboundry/host.js +456 -0
- package/dist/appboundry/host.js.map +1 -0
- package/dist/appboundry/runtime.d.ts +44 -0
- package/dist/appboundry/runtime.js +99 -0
- package/dist/appboundry/runtime.js.map +1 -0
- package/dist/cli/entry.d.ts +1 -0
- package/dist/cli/entry.js +4 -0
- package/dist/cli/entry.js.map +1 -0
- package/dist/cli/main.js +459 -8
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/skills.d.ts +8 -0
- package/dist/cli/skills.js +37 -0
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/test-reporter.d.ts +9 -0
- package/dist/cli/test-reporter.js +26 -0
- package/dist/cli/test-reporter.js.map +1 -0
- package/dist/errors.d.ts +7 -1
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/platform/changes.d.ts +340 -0
- package/dist/platform/changes.js +353 -0
- package/dist/platform/changes.js.map +1 -0
- package/dist/platform/deployments.d.ts +653 -0
- package/dist/platform/deployments.js +530 -0
- package/dist/platform/deployments.js.map +1 -0
- package/dist/platform/operations.d.ts +74 -0
- package/dist/platform/operations.js +198 -0
- package/dist/platform/operations.js.map +1 -0
- package/dist/platform/platform.d.ts +78 -0
- package/dist/platform/platform.js +264 -0
- package/dist/platform/platform.js.map +1 -0
- package/dist/platform/server.d.ts +25 -0
- package/dist/platform/server.js +165 -0
- package/dist/platform/server.js.map +1 -0
- package/dist/platform/source.d.ts +27 -0
- package/dist/platform/source.js +142 -0
- package/dist/platform/source.js.map +1 -0
- package/dist/runtime/backup-environment.d.ts +25 -0
- package/dist/runtime/backup-environment.js +60 -0
- package/dist/runtime/backup-environment.js.map +1 -0
- package/dist/runtime/backup.d.ts +87 -0
- package/dist/runtime/backup.js +175 -0
- package/dist/runtime/backup.js.map +1 -0
- package/dist/runtime/capabilities.d.ts +1 -1
- package/dist/runtime/capabilities.js +19 -2
- package/dist/runtime/capabilities.js.map +1 -1
- package/dist/runtime/context.d.ts +7 -0
- package/dist/runtime/contract.js +5 -1
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/data.d.ts +28 -0
- package/dist/runtime/data.js +49 -1
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/instance.js +17 -0
- package/dist/runtime/instance.js.map +1 -1
- package/dist/runtime/loader.js +6 -2
- package/dist/runtime/loader.js.map +1 -1
- package/dist/runtime/migration-context.d.ts +25 -0
- package/dist/runtime/migration-context.js +69 -0
- package/dist/runtime/migration-context.js.map +1 -0
- package/dist/runtime/outbox.d.ts +7 -0
- package/dist/runtime/outbox.js +47 -0
- package/dist/runtime/outbox.js.map +1 -0
- package/dist/runtime/readiness.js +12 -0
- package/dist/runtime/readiness.js.map +1 -1
- package/dist/runtime/runtime.d.ts +65 -1
- package/dist/runtime/runtime.js +380 -66
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/services.d.ts +30 -0
- package/dist/runtime/services.js +82 -1
- package/dist/runtime/services.js.map +1 -1
- package/dist/runtime/state-contract.d.ts +167 -0
- package/dist/runtime/state-contract.js +438 -0
- package/dist/runtime/state-contract.js.map +1 -0
- package/dist/runtime/transactions.d.ts +199 -0
- package/dist/runtime/transactions.js +246 -0
- package/dist/runtime/transactions.js.map +1 -0
- package/dist/schema.d.ts +42 -2
- package/dist/schema.js +58 -2
- package/dist/schema.js.map +1 -1
- package/dist/server/admin.d.ts +1 -0
- package/dist/server/admin.js +27 -0
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +45 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/project.d.ts +5 -0
- package/dist/server/project.js +13 -2
- package/dist/server/project.js.map +1 -1
- package/dist/testing/index.d.ts +24 -0
- package/dist/testing/index.js +31 -0
- package/dist/testing/index.js.map +1 -1
- package/package.json +5 -5
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-agent/SKILL.md +1 -1
- package/skills/feltkit-build/SKILL.md +33 -2
- package/skills/feltkit-data/SKILL.md +12 -1
- package/skills/feltkit-operations/SKILL.md +1 -1
- package/skills/feltkit-services/SKILL.md +22 -2
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { SendNotificationInput } from "./services.js";
|
|
2
|
+
/** Named sequences: one record per stream holding its last committed value. */
|
|
3
|
+
export declare const SEQUENCES_COLLECTION = "_feltkit_sequences";
|
|
4
|
+
/** What a sequence name may be (unchanged since 0.3.11). */
|
|
5
|
+
export declare const SEQUENCE_NAME: RegExp;
|
|
6
|
+
export declare function checkSequenceName(name: unknown): string;
|
|
7
|
+
/**
|
|
8
|
+
* The record id a sequence is stored under. A name that is a valid FeltDB id is its own id (every
|
|
9
|
+
* sequence committed before 0.3.12). A name with ":" (which FeltDB ids cannot hold, so no such
|
|
10
|
+
* sequence was ever committed) is stored as "_" + the name with "." written ".d" and ":" written
|
|
11
|
+
* ".c": injective, and never equal to a name, since names cannot start with "_".
|
|
12
|
+
*/
|
|
13
|
+
export declare function sequenceRecordId(name: string): string;
|
|
14
|
+
/** A stored sequence record. */
|
|
15
|
+
export interface SequenceRecord {
|
|
16
|
+
id: string;
|
|
17
|
+
/** The stream's name (records before 0.3.12 have none: their id is the name). */
|
|
18
|
+
name?: string;
|
|
19
|
+
value: number;
|
|
20
|
+
transactionId: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Per-mutation allocation: what each stream's committed value was (and its record version), and
|
|
24
|
+
* the last number handed out. `operations()` are the guarded writes that commit it.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SequenceAllocations {
|
|
27
|
+
#private;
|
|
28
|
+
/** The next number of `name`; `read(id)` loads its committed record the first time. */
|
|
29
|
+
next(name: string, read: (id: string) => Promise<{
|
|
30
|
+
value?: unknown;
|
|
31
|
+
__version: number;
|
|
32
|
+
} | null>): Promise<number>;
|
|
33
|
+
/**
|
|
34
|
+
* The writes that advance each stream used, each guarded on the version read: a concurrent
|
|
35
|
+
* commit of the same stream refuses the whole transaction (PRECONDITION_FAILED on this record).
|
|
36
|
+
* A stream drawn from but not advanced (impossible today) writes nothing.
|
|
37
|
+
*/
|
|
38
|
+
operations(transactionId: string): Array<Record<string, unknown>>;
|
|
39
|
+
get used(): boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Opt-in re-execution on sequence contention (`app.mutation({ retry: { sequenceConflicts: n } })`).
|
|
43
|
+
* The runtime re-runs the handler, at most `n` more times, only when its commit was refused on a
|
|
44
|
+
* sequence record (FeltDB names the first failing precondition) and the attempt used no
|
|
45
|
+
* `ctx.services` (an effect outside the transaction). A refused commit wrote nothing.
|
|
46
|
+
*/
|
|
47
|
+
export interface RetryPolicy {
|
|
48
|
+
sequenceConflicts: number;
|
|
49
|
+
}
|
|
50
|
+
export declare const MAX_SEQUENCE_RETRIES = 10;
|
|
51
|
+
export declare function checkRetryPolicy(retry: unknown, kind: string): RetryPolicy | undefined;
|
|
52
|
+
/** Whether a refused commit is a sequence conflict: FeltDB's conflict detail names a sequence record. */
|
|
53
|
+
export declare function isSequenceConflict(failure: unknown, collection?: string): boolean;
|
|
54
|
+
/** After-commit effects (`ctx.afterCommit`). */
|
|
55
|
+
export declare const OUTBOX_COLLECTION = "_feltkit_outbox";
|
|
56
|
+
/** A pending record not performed after this long is recovered by the worker (its process likely stopped). */
|
|
57
|
+
export declare const OUTBOX_RECOVER_AFTER_MS = 30000;
|
|
58
|
+
/** A record left `performing` this long (its performer stopped mid-way) is recovered too. */
|
|
59
|
+
export declare const OUTBOX_PERFORMING_STALE_MS: number;
|
|
60
|
+
export type OutboxEffect = {
|
|
61
|
+
service: "notifications";
|
|
62
|
+
method: "send";
|
|
63
|
+
input: SendNotificationInput;
|
|
64
|
+
} | {
|
|
65
|
+
service: "webhooks";
|
|
66
|
+
method: "emit";
|
|
67
|
+
type: string;
|
|
68
|
+
payload: Record<string, unknown>;
|
|
69
|
+
} | {
|
|
70
|
+
service: "jobs";
|
|
71
|
+
method: "enqueue";
|
|
72
|
+
type: string;
|
|
73
|
+
payload: Record<string, unknown>;
|
|
74
|
+
options?: {
|
|
75
|
+
runAt?: string;
|
|
76
|
+
maxAttempts?: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export type OutboxState = "pending" | "performing" | "done" | "failed";
|
|
80
|
+
export interface OutboxRecord {
|
|
81
|
+
id: string;
|
|
82
|
+
requestId: string;
|
|
83
|
+
function: string;
|
|
84
|
+
principalId: string;
|
|
85
|
+
effect: OutboxEffect;
|
|
86
|
+
state: OutboxState;
|
|
87
|
+
createdAt: number;
|
|
88
|
+
updatedAt: number;
|
|
89
|
+
attempts: number;
|
|
90
|
+
error?: {
|
|
91
|
+
code: string;
|
|
92
|
+
message: string;
|
|
93
|
+
};
|
|
94
|
+
/** What the effect produced (a job id, a delivery count), when known. */
|
|
95
|
+
result?: Record<string, unknown>;
|
|
96
|
+
/** Who moved a failed record back to pending, and when (operator retry). */
|
|
97
|
+
retriedBy?: string;
|
|
98
|
+
__version?: number;
|
|
99
|
+
}
|
|
100
|
+
/** What `ctx.afterCommit` offers. Each call returns the outbox id; the effect's own result comes after commit. */
|
|
101
|
+
export interface AfterCommit {
|
|
102
|
+
readonly notifications: {
|
|
103
|
+
send(input: SendNotificationInput): {
|
|
104
|
+
outboxId: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
readonly webhooks: {
|
|
108
|
+
emit(type: string, payload: Record<string, unknown>): {
|
|
109
|
+
outboxId: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
readonly jobs: {
|
|
113
|
+
enqueue(type: string, payload?: Record<string, unknown>, options?: {
|
|
114
|
+
runAt?: string;
|
|
115
|
+
maxAttempts?: number;
|
|
116
|
+
}): {
|
|
117
|
+
outboxId: string;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* `ctx.afterCommit` for one mutation. `stage` adds a record to the mutation's transaction;
|
|
123
|
+
* `enabled` names the services this application turned on; `newId` makes an outbox id (a
|
|
124
|
+
* valid FeltDB record id).
|
|
125
|
+
*/
|
|
126
|
+
export declare function afterCommit(options: {
|
|
127
|
+
caller: string;
|
|
128
|
+
principal: {
|
|
129
|
+
id: string;
|
|
130
|
+
} | null;
|
|
131
|
+
requestId: string;
|
|
132
|
+
enabled: {
|
|
133
|
+
notifications: boolean;
|
|
134
|
+
webhooks: boolean;
|
|
135
|
+
jobs: boolean;
|
|
136
|
+
};
|
|
137
|
+
stage: (record: OutboxRecord) => void;
|
|
138
|
+
newId: () => string;
|
|
139
|
+
now?: () => number;
|
|
140
|
+
}): AfterCommit;
|
|
141
|
+
/** Whether `record` should be (re)performed by a recovery pass at `now`. */
|
|
142
|
+
export declare function isRecoverable(record: Pick<OutboxRecord, "state" | "updatedAt">, now: number): boolean;
|
|
143
|
+
/** The record claimed by a performer (pending → performing). */
|
|
144
|
+
export declare function claimed(record: OutboxRecord, now: number): OutboxRecord;
|
|
145
|
+
/** The record once its effect was performed (done) or refused (failed). */
|
|
146
|
+
export declare function settled(record: OutboxRecord, outcome: {
|
|
147
|
+
ok: true;
|
|
148
|
+
result?: Record<string, unknown>;
|
|
149
|
+
} | {
|
|
150
|
+
ok: false;
|
|
151
|
+
error: {
|
|
152
|
+
code: string;
|
|
153
|
+
message: string;
|
|
154
|
+
};
|
|
155
|
+
}, now: number): OutboxRecord;
|
|
156
|
+
/** An operator's retry: a failed record back to pending, keeping its attempts and last error. */
|
|
157
|
+
export declare function retried(record: OutboxRecord, by: string, now: number): OutboxRecord;
|
|
158
|
+
/** The error a failed effect records. */
|
|
159
|
+
export declare function effectError(error: unknown): {
|
|
160
|
+
code: string;
|
|
161
|
+
message: string;
|
|
162
|
+
};
|
|
163
|
+
/** Where outbox records live, as the performer needs it: read one, and write one guarded on its version. */
|
|
164
|
+
export interface OutboxStore {
|
|
165
|
+
get(id: string): Promise<(OutboxRecord & {
|
|
166
|
+
__version: number;
|
|
167
|
+
}) | null>;
|
|
168
|
+
/** Write `value` only if the record is still at `version`; throws otherwise (nothing written). */
|
|
169
|
+
put(id: string, version: number, value: OutboxRecord): Promise<void>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The write that records `claim` done with `result`, guarded on the claim's version: an effect
|
|
173
|
+
* that commits it in its own transaction (a job or webhook deliveries, through AppPort Services'
|
|
174
|
+
* transaction context) is created exactly when the record says done, and a stale claim creates
|
|
175
|
+
* nothing.
|
|
176
|
+
*/
|
|
177
|
+
export declare function completion(claim: OutboxRecord & {
|
|
178
|
+
__version: number;
|
|
179
|
+
}, result: Record<string, unknown>, now?: number): Record<string, unknown>;
|
|
180
|
+
/**
|
|
181
|
+
* Perform one after-commit effect, the same way on every runtime: claim the record (pending or
|
|
182
|
+
* stale performing → performing, version-checked, so two performers never both perform it),
|
|
183
|
+
* perform it, and record done (with its result) or failed (with the error). `perform` may instead
|
|
184
|
+
* commit the done write itself, in the transaction that creates the effect (`complete(result)`
|
|
185
|
+
* gives it); then nothing more is written. Never throws: the mutation has committed; a failure is
|
|
186
|
+
* on the record. `skipped`: gone, already settled, or claimed by another performer.
|
|
187
|
+
*/
|
|
188
|
+
export declare function performOutbox(store: OutboxStore, id: string, perform: (record: OutboxRecord, complete: (result: Record<string, unknown>) => Record<string, unknown>) => Promise<Record<string, unknown> | void>, options?: {
|
|
189
|
+
now?: () => number;
|
|
190
|
+
warn?: (message: string) => void;
|
|
191
|
+
}): Promise<"done" | "failed" | "skipped">;
|
|
192
|
+
export declare function describeEffect(effect: OutboxEffect): string;
|
|
193
|
+
/** An outbox store over a FeltDB-shaped handle (`collection(name).get`, `transaction({ operations })`). */
|
|
194
|
+
export declare function outboxStore(db: {
|
|
195
|
+
collection(name: string): {
|
|
196
|
+
get(id: string): Promise<unknown>;
|
|
197
|
+
};
|
|
198
|
+
transaction(request: never): Promise<unknown>;
|
|
199
|
+
}): OutboxStore;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The transaction contract of `ctx.db.sequence` and `ctx.afterCommit` (docs/TRANSACTIONS.md),
|
|
3
|
+
* as code both runtimes use: FeltKit's runtime (runtime/data.ts, runtime/outbox.ts) and, bundled
|
|
4
|
+
* into an AppBoundry artifact, the guest (appboundry/guest.ts) and FeltKit's reference host.
|
|
5
|
+
* It imports nothing from Node or FeltDB.
|
|
6
|
+
*
|
|
7
|
+
* Sequences: per stream (the name), strictly increasing and gapless in commit order, consumed
|
|
8
|
+
* only by a committed mutation; no order between streams. Outbox: a record per effect, committed
|
|
9
|
+
* with the mutation or not at all, then performed and recorded done or failed. A job or webhook
|
|
10
|
+
* event is created in the transaction that records it done (exactly once per committed effect); a
|
|
11
|
+
* notification is sent with the record id as its idempotency key.
|
|
12
|
+
*/
|
|
13
|
+
import { FeltKitError, isFeltKitError } from "../errors.js";
|
|
14
|
+
// ---------------------------------------------------------------------------------------------
|
|
15
|
+
// Sequences
|
|
16
|
+
/** Named sequences: one record per stream holding its last committed value. */
|
|
17
|
+
export const SEQUENCES_COLLECTION = "_feltkit_sequences";
|
|
18
|
+
/** What a sequence name may be (unchanged since 0.3.11). */
|
|
19
|
+
export const SEQUENCE_NAME = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/;
|
|
20
|
+
/** What FeltDB accepts as a record id. */
|
|
21
|
+
const RECORD_ID = /^[A-Za-z0-9._-]{1,128}$/;
|
|
22
|
+
export function checkSequenceName(name) {
|
|
23
|
+
if (typeof name !== "string" || !SEQUENCE_NAME.test(name)) {
|
|
24
|
+
throw new FeltKitError("INVALID_ARGUMENT", `Sequence name ${JSON.stringify(name)} must be 1-128 letters, digits, "_", ".", ":" or "-", starting with a letter or digit.`);
|
|
25
|
+
}
|
|
26
|
+
return name;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The record id a sequence is stored under. A name that is a valid FeltDB id is its own id (every
|
|
30
|
+
* sequence committed before 0.3.12). A name with ":" (which FeltDB ids cannot hold, so no such
|
|
31
|
+
* sequence was ever committed) is stored as "_" + the name with "." written ".d" and ":" written
|
|
32
|
+
* ".c": injective, and never equal to a name, since names cannot start with "_".
|
|
33
|
+
*/
|
|
34
|
+
export function sequenceRecordId(name) {
|
|
35
|
+
checkSequenceName(name);
|
|
36
|
+
if (RECORD_ID.test(name))
|
|
37
|
+
return name;
|
|
38
|
+
const id = `_${name.replace(/\./g, ".d").replace(/:/g, ".c")}`;
|
|
39
|
+
if (!RECORD_ID.test(id))
|
|
40
|
+
throw new FeltKitError("INVALID_ARGUMENT", `Sequence name ${JSON.stringify(name)} is too long to store (${id.length} characters encoded, at most 128): use fewer ":" and "." or a shorter name.`);
|
|
41
|
+
return id;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Per-mutation allocation: what each stream's committed value was (and its record version), and
|
|
45
|
+
* the last number handed out. `operations()` are the guarded writes that commit it.
|
|
46
|
+
*/
|
|
47
|
+
export class SequenceAllocations {
|
|
48
|
+
#streams = new Map();
|
|
49
|
+
/** The next number of `name`; `read(id)` loads its committed record the first time. */
|
|
50
|
+
async next(name, read) {
|
|
51
|
+
let stream = this.#streams.get(name);
|
|
52
|
+
if (!stream) {
|
|
53
|
+
const id = sequenceRecordId(name);
|
|
54
|
+
const record = await read(id);
|
|
55
|
+
const committed = typeof record?.value === "number" ? record.value : 0;
|
|
56
|
+
stream = { id, version: record ? record.__version : null, committed, next: committed };
|
|
57
|
+
this.#streams.set(name, stream);
|
|
58
|
+
}
|
|
59
|
+
stream.next += 1;
|
|
60
|
+
return stream.next;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The writes that advance each stream used, each guarded on the version read: a concurrent
|
|
64
|
+
* commit of the same stream refuses the whole transaction (PRECONDITION_FAILED on this record).
|
|
65
|
+
* A stream drawn from but not advanced (impossible today) writes nothing.
|
|
66
|
+
*/
|
|
67
|
+
operations(transactionId) {
|
|
68
|
+
const out = [];
|
|
69
|
+
for (const [name, s] of this.#streams) {
|
|
70
|
+
if (s.next === s.committed)
|
|
71
|
+
continue;
|
|
72
|
+
const value = { id: s.id, name, value: s.next, transactionId };
|
|
73
|
+
out.push(s.version === null ? { collection: SEQUENCES_COLLECTION, id: s.id, requireAbsent: true, value } : { collection: SEQUENCES_COLLECTION, id: s.id, ifVersion: s.version, value });
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
get used() {
|
|
78
|
+
return this.#streams.size > 0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export const MAX_SEQUENCE_RETRIES = 10;
|
|
82
|
+
export function checkRetryPolicy(retry, kind) {
|
|
83
|
+
if (retry === undefined)
|
|
84
|
+
return undefined;
|
|
85
|
+
if (kind !== "mutation")
|
|
86
|
+
throw new TypeError("`retry` applies to mutations only: a query writes nothing and never conflicts.");
|
|
87
|
+
const n = retry?.sequenceConflicts;
|
|
88
|
+
if (!Number.isInteger(n) || n < 1 || n > MAX_SEQUENCE_RETRIES) {
|
|
89
|
+
throw new TypeError(`retry.sequenceConflicts must be an integer from 1 to ${MAX_SEQUENCE_RETRIES} (got ${JSON.stringify(n)}).`);
|
|
90
|
+
}
|
|
91
|
+
return { sequenceConflicts: n };
|
|
92
|
+
}
|
|
93
|
+
/** Whether a refused commit is a sequence conflict: FeltDB's conflict detail names a sequence record. */
|
|
94
|
+
export function isSequenceConflict(failure, collection = SEQUENCES_COLLECTION) {
|
|
95
|
+
const f = failure;
|
|
96
|
+
return !!f && f.collection === collection && f.predicate !== "fence";
|
|
97
|
+
}
|
|
98
|
+
// ---------------------------------------------------------------------------------------------
|
|
99
|
+
// The after-commit outbox
|
|
100
|
+
/** After-commit effects (`ctx.afterCommit`). */
|
|
101
|
+
export const OUTBOX_COLLECTION = "_feltkit_outbox";
|
|
102
|
+
/** A pending record not performed after this long is recovered by the worker (its process likely stopped). */
|
|
103
|
+
export const OUTBOX_RECOVER_AFTER_MS = 30_000;
|
|
104
|
+
/** A record left `performing` this long (its performer stopped mid-way) is recovered too. */
|
|
105
|
+
export const OUTBOX_PERFORMING_STALE_MS = OUTBOX_RECOVER_AFTER_MS * 10;
|
|
106
|
+
/** A copy that is plain JSON (what a FeltDB record can hold). */
|
|
107
|
+
function json(value) {
|
|
108
|
+
return JSON.parse(JSON.stringify(value ?? null));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* `ctx.afterCommit` for one mutation. `stage` adds a record to the mutation's transaction;
|
|
112
|
+
* `enabled` names the services this application turned on; `newId` makes an outbox id (a
|
|
113
|
+
* valid FeltDB record id).
|
|
114
|
+
*/
|
|
115
|
+
export function afterCommit(options) {
|
|
116
|
+
const add = (effect) => {
|
|
117
|
+
if (!options.principal)
|
|
118
|
+
throw new FeltKitError("UNAUTHORIZED", "Authentication is required to use services");
|
|
119
|
+
if (!options.enabled[effect.service]) {
|
|
120
|
+
throw new FeltKitError("CONFIGURATION", `The ${effect.service[0].toUpperCase()}${effect.service.slice(1)} service is not enabled.`, { hint: `Enable it with feltkit({ services: { ${effect.service}: true } }).` });
|
|
121
|
+
}
|
|
122
|
+
const now = (options.now ?? Date.now)();
|
|
123
|
+
const id = options.newId();
|
|
124
|
+
options.stage({ id, requestId: options.requestId, function: options.caller, principalId: options.principal.id, effect: json(effect), state: "pending", createdAt: now, updatedAt: now, attempts: 0 });
|
|
125
|
+
return { outboxId: id };
|
|
126
|
+
};
|
|
127
|
+
const text = (value, what) => {
|
|
128
|
+
if (typeof value !== "string" || !value.trim())
|
|
129
|
+
throw new FeltKitError("INVALID_ARGUMENT", `${what} must be a non-empty string.`);
|
|
130
|
+
return value;
|
|
131
|
+
};
|
|
132
|
+
return Object.freeze({
|
|
133
|
+
notifications: Object.freeze({
|
|
134
|
+
send: (input) => {
|
|
135
|
+
if (!input || typeof input !== "object")
|
|
136
|
+
throw new FeltKitError("INVALID_ARGUMENT", "send() needs a notification object.");
|
|
137
|
+
text(input.recipient, "recipient");
|
|
138
|
+
text(input.type, "type");
|
|
139
|
+
text(input.title, "title");
|
|
140
|
+
return add({ service: "notifications", method: "send", input });
|
|
141
|
+
},
|
|
142
|
+
}),
|
|
143
|
+
webhooks: Object.freeze({
|
|
144
|
+
emit: (type, payload) => add({ service: "webhooks", method: "emit", type: text(type, "type"), payload: payload ?? {} }),
|
|
145
|
+
}),
|
|
146
|
+
jobs: Object.freeze({
|
|
147
|
+
enqueue: (type, payload = {}, opts) => add({ service: "jobs", method: "enqueue", type: text(type, "type"), payload, ...(opts ? { options: opts } : {}) }),
|
|
148
|
+
}),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/** Whether `record` should be (re)performed by a recovery pass at `now`. */
|
|
152
|
+
export function isRecoverable(record, now) {
|
|
153
|
+
return (record.state === "pending" && now - record.updatedAt >= OUTBOX_RECOVER_AFTER_MS) || (record.state === "performing" && now - record.updatedAt >= OUTBOX_PERFORMING_STALE_MS);
|
|
154
|
+
}
|
|
155
|
+
/** The record claimed by a performer (pending → performing). */
|
|
156
|
+
export function claimed(record, now) {
|
|
157
|
+
return { ...strip(record), state: "performing", attempts: (record.attempts ?? 0) + 1, updatedAt: now };
|
|
158
|
+
}
|
|
159
|
+
/** The record once its effect was performed (done) or refused (failed). */
|
|
160
|
+
export function settled(record, outcome, now) {
|
|
161
|
+
const { error: _e, ...rest } = strip(record);
|
|
162
|
+
return outcome.ok ? { ...rest, state: "done", updatedAt: now, ...(outcome.result ? { result: outcome.result } : {}) } : { ...rest, state: "failed", updatedAt: now, error: outcome.error };
|
|
163
|
+
}
|
|
164
|
+
/** An operator's retry: a failed record back to pending, keeping its attempts and last error. */
|
|
165
|
+
export function retried(record, by, now) {
|
|
166
|
+
if (record.state !== "failed")
|
|
167
|
+
throw new FeltKitError("FAILED_PRECONDITION", `After-commit effect ${record.id} is ${record.state}; only a failed effect can be retried.`);
|
|
168
|
+
return { ...strip(record), state: "pending", updatedAt: now, retriedBy: by };
|
|
169
|
+
}
|
|
170
|
+
function strip(record) {
|
|
171
|
+
const { __version: _v, ...rest } = record;
|
|
172
|
+
return rest;
|
|
173
|
+
}
|
|
174
|
+
/** The error a failed effect records. */
|
|
175
|
+
export function effectError(error) {
|
|
176
|
+
return isFeltKitError(error) ? { code: error.code, message: error.message } : { code: error?.code ?? "INTERNAL", message: error?.message ?? String(error) };
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The write that records `claim` done with `result`, guarded on the claim's version: an effect
|
|
180
|
+
* that commits it in its own transaction (a job or webhook deliveries, through AppPort Services'
|
|
181
|
+
* transaction context) is created exactly when the record says done, and a stale claim creates
|
|
182
|
+
* nothing.
|
|
183
|
+
*/
|
|
184
|
+
export function completion(claim, result, now = Date.now()) {
|
|
185
|
+
return { collection: OUTBOX_COLLECTION, id: claim.id, expectedVersion: claim.__version, value: settled(claim, { ok: true, ...(Object.keys(result).length ? { result } : {}) }, now) };
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Perform one after-commit effect, the same way on every runtime: claim the record (pending or
|
|
189
|
+
* stale performing → performing, version-checked, so two performers never both perform it),
|
|
190
|
+
* perform it, and record done (with its result) or failed (with the error). `perform` may instead
|
|
191
|
+
* commit the done write itself, in the transaction that creates the effect (`complete(result)`
|
|
192
|
+
* gives it); then nothing more is written. Never throws: the mutation has committed; a failure is
|
|
193
|
+
* on the record. `skipped`: gone, already settled, or claimed by another performer.
|
|
194
|
+
*/
|
|
195
|
+
export async function performOutbox(store, id, perform, options = {}) {
|
|
196
|
+
const now = options.now ?? Date.now;
|
|
197
|
+
const current = await store.get(id).catch(() => null);
|
|
198
|
+
if (!current || current.state === "done" || current.state === "failed")
|
|
199
|
+
return "skipped";
|
|
200
|
+
try {
|
|
201
|
+
await store.put(id, current.__version, claimed(current, now()));
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return "skipped";
|
|
205
|
+
}
|
|
206
|
+
const claim = await store.get(id);
|
|
207
|
+
if (!claim || claim.state !== "performing")
|
|
208
|
+
return "skipped";
|
|
209
|
+
let outcome;
|
|
210
|
+
let completed = false;
|
|
211
|
+
const complete = (result) => {
|
|
212
|
+
completed = true;
|
|
213
|
+
return completion(claim, result, now());
|
|
214
|
+
};
|
|
215
|
+
try {
|
|
216
|
+
const result = await perform(claim, complete);
|
|
217
|
+
// Committed with the effect: done is already recorded.
|
|
218
|
+
if (completed)
|
|
219
|
+
return "done";
|
|
220
|
+
outcome = { ok: true, ...(result && Object.keys(result).length ? { result } : {}) };
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
outcome = { ok: false, error: effectError(error) };
|
|
224
|
+
options.warn?.(`after-commit ${describeEffect(claim.effect)} from ${claim.function} failed: ${outcome.error.message}`);
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
await store.put(id, claim.__version, settled(claim, outcome, now()));
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
options.warn?.(`after-commit ${id}: could not record ${outcome.ok ? "done" : "failed"}: ${error.message}`);
|
|
231
|
+
}
|
|
232
|
+
return outcome.ok ? "done" : "failed";
|
|
233
|
+
}
|
|
234
|
+
export function describeEffect(effect) {
|
|
235
|
+
return effect.service === "notifications" ? `notifications.send ${effect.input.type}` : `${effect.service}.${effect.method} ${effect.type}`;
|
|
236
|
+
}
|
|
237
|
+
/** An outbox store over a FeltDB-shaped handle (`collection(name).get`, `transaction({ operations })`). */
|
|
238
|
+
export function outboxStore(db) {
|
|
239
|
+
return {
|
|
240
|
+
get: async (id) => (await db.collection(OUTBOX_COLLECTION).get(id)) ?? null,
|
|
241
|
+
put: async (id, version, value) => {
|
|
242
|
+
await db.transaction({ operations: [{ collection: OUTBOX_COLLECTION, id, ifVersion: version, value: strip(value) }] });
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=transactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../src/runtime/transactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG5D,gGAAgG;AAChG,YAAY;AAEZ,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAEzD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAG,qCAAqC,CAAC;AACnE,0CAA0C;AAC1C,MAAM,SAAS,GAAG,yBAAyB,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,IAAa;IAC7C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,YAAY,CAAC,kBAAkB,EAAE,iBAAiB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,wFAAwF,CAAC,CAAC;IAC5K,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;IAC/D,I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|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
* validates every write made through `ctx.db`; writes made through the raw FeltDB
|
|
10
10
|
* escape hatch are not validated.
|
|
11
11
|
*/
|
|
12
|
-
import { s, type Schema } from "@appport/sdk";
|
|
13
|
-
export { s };
|
|
12
|
+
import { s as appportSchema, type Schema } from "@appport/sdk";
|
|
14
13
|
export type { Schema };
|
|
15
14
|
/** Shorthand field types accepted wherever a schema is expected. */
|
|
16
15
|
export type FieldShorthand = "string" | "number" | "boolean" | "string?" | "number?" | "boolean?";
|
|
@@ -54,3 +53,44 @@ export declare function validate(schema: Schema, value: unknown): {
|
|
|
54
53
|
ok: false;
|
|
55
54
|
issues: ValidationIssueJSON[];
|
|
56
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* An object schema FeltKit knows the shape of, so it can be narrowed or extended without
|
|
58
|
+
* restating fields. `s.doc(collection)` starts one from a collection; `pick`, `omit` and
|
|
59
|
+
* `extend` return new ones (the original is unchanged). Undeclared fields are rejected,
|
|
60
|
+
* like every `s.object`: an output schema is the published contract.
|
|
61
|
+
*/
|
|
62
|
+
export interface ShapeSchema<T> extends Schema<T> {
|
|
63
|
+
readonly shape: Readonly<ShapeInput>;
|
|
64
|
+
/** Only these fields. */
|
|
65
|
+
pick<K extends keyof T & string>(...keys: K[]): ShapeSchema<Simplify<Pick<T, K>>>;
|
|
66
|
+
/** Every field but these. */
|
|
67
|
+
omit<K extends keyof T & string>(...keys: K[]): ShapeSchema<Simplify<Omit<T, K>>>;
|
|
68
|
+
/** More fields (computed or joined values); a key already present is replaced. */
|
|
69
|
+
extend<S extends ShapeInput>(shape: S): ShapeSchema<Simplify<Omit<T, keyof S> & InferShape<S>>>;
|
|
70
|
+
}
|
|
71
|
+
/** A stored record of a collection: its declared fields plus `id` and `__version`. */
|
|
72
|
+
declare function doc<S extends ShapeInput>(collection: {
|
|
73
|
+
readonly shape: S;
|
|
74
|
+
}): ShapeSchema<Doc<S>>;
|
|
75
|
+
/** JSON Schema keyword carrying a reference's target collection (read by the state-contract compiler). */
|
|
76
|
+
export declare const REFERENCE_KEYWORD = "x-feltkit-reference";
|
|
77
|
+
/**
|
|
78
|
+
* The id of a record in another collection. FeltDB enforces it when the application's
|
|
79
|
+
* schema is active: a written value must name an existing record, and a record cannot be
|
|
80
|
+
* deleted while another still references it (restrict on delete; nothing is cascaded).
|
|
81
|
+
*/
|
|
82
|
+
declare function ref(collection: string | {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
}): Schema<string>;
|
|
85
|
+
/** An object schema with `pick`, `omit` and `extend`. */
|
|
86
|
+
declare function shaped<S extends ShapeInput>(shape: S): ShapeSchema<Simplify<InferShape<S>>>;
|
|
87
|
+
/**
|
|
88
|
+
* AppPort's schema builder, plus FeltKit's `s.doc(collection)` (a collection's stored
|
|
89
|
+
* record, stated once), `s.shape({...})` (an object schema with pick / omit / extend) and
|
|
90
|
+
* `s.ref(collection)` (a reference to a record of another collection).
|
|
91
|
+
*/
|
|
92
|
+
export declare const s: typeof appportSchema & {
|
|
93
|
+
readonly doc: typeof doc;
|
|
94
|
+
readonly shape: typeof shaped;
|
|
95
|
+
readonly ref: typeof ref;
|
|
96
|
+
};
|
package/dist/schema.js
CHANGED
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
* validates every write made through `ctx.db`; writes made through the raw FeltDB
|
|
10
10
|
* escape hatch are not validated.
|
|
11
11
|
*/
|
|
12
|
-
import { s } from "@appport/sdk";
|
|
13
|
-
export { s };
|
|
12
|
+
import { s as appportSchema } from "@appport/sdk";
|
|
14
13
|
export const RESERVED_FIELDS = ["id", "__version"];
|
|
15
14
|
export function toSchema(field) {
|
|
16
15
|
if (typeof field !== "string") {
|
|
@@ -41,4 +40,61 @@ export function validate(schema, value) {
|
|
|
41
40
|
issues: (result.issues ?? []).map((issue) => ({ path: (issue.path ?? []).join(".") || "(root)", message: issue.message })),
|
|
42
41
|
};
|
|
43
42
|
}
|
|
43
|
+
function shapeSchema(shape) {
|
|
44
|
+
const schema = shapeToObjectSchema(shape);
|
|
45
|
+
const known = (keys, verb) => {
|
|
46
|
+
for (const key of keys)
|
|
47
|
+
if (!(key in shape))
|
|
48
|
+
throw new TypeError(`${verb}("${key}"): no such field (fields: ${Object.keys(shape).join(", ")}).`);
|
|
49
|
+
};
|
|
50
|
+
return Object.freeze({
|
|
51
|
+
appport: "schema",
|
|
52
|
+
shape: Object.freeze({ ...shape }),
|
|
53
|
+
validate: (value, path) => schema.validate(value, path),
|
|
54
|
+
toJSONSchema: () => schema.toJSONSchema(),
|
|
55
|
+
pick: (...keys) => {
|
|
56
|
+
known(keys, "pick");
|
|
57
|
+
return shapeSchema(Object.fromEntries(Object.entries(shape).filter(([key]) => keys.includes(key))));
|
|
58
|
+
},
|
|
59
|
+
omit: (...keys) => {
|
|
60
|
+
known(keys, "omit");
|
|
61
|
+
return shapeSchema(Object.fromEntries(Object.entries(shape).filter(([key]) => !keys.includes(key))));
|
|
62
|
+
},
|
|
63
|
+
extend: (more) => shapeSchema({ ...shape, ...more }),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** A stored record of a collection: its declared fields plus `id` and `__version`. */
|
|
67
|
+
function doc(collection) {
|
|
68
|
+
if (!collection || typeof collection !== "object" || !collection.shape)
|
|
69
|
+
throw new TypeError("s.doc() needs a collection from app.collection(...).");
|
|
70
|
+
return shapeSchema({ id: appportSchema.string(), ...collection.shape, __version: appportSchema.number() });
|
|
71
|
+
}
|
|
72
|
+
/** JSON Schema keyword carrying a reference's target collection (read by the state-contract compiler). */
|
|
73
|
+
export const REFERENCE_KEYWORD = "x-feltkit-reference";
|
|
74
|
+
/**
|
|
75
|
+
* The id of a record in another collection. FeltDB enforces it when the application's
|
|
76
|
+
* schema is active: a written value must name an existing record, and a record cannot be
|
|
77
|
+
* deleted while another still references it (restrict on delete; nothing is cascaded).
|
|
78
|
+
*/
|
|
79
|
+
function ref(collection) {
|
|
80
|
+
const target = typeof collection === "string" ? collection : collection?.name;
|
|
81
|
+
if (typeof target !== "string" || !target)
|
|
82
|
+
throw new TypeError("s.ref() needs a collection from app.collection(...) or its name.");
|
|
83
|
+
const inner = appportSchema.string({ minLength: 1 });
|
|
84
|
+
return Object.freeze({
|
|
85
|
+
appport: "schema",
|
|
86
|
+
validate: (value, path) => inner.validate(value, path),
|
|
87
|
+
toJSONSchema: () => ({ ...inner.toJSONSchema(), [REFERENCE_KEYWORD]: target }),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** An object schema with `pick`, `omit` and `extend`. */
|
|
91
|
+
function shaped(shape) {
|
|
92
|
+
return shapeSchema(shape);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* AppPort's schema builder, plus FeltKit's `s.doc(collection)` (a collection's stored
|
|
96
|
+
* record, stated once), `s.shape({...})` (an object schema with pick / omit / extend) and
|
|
97
|
+
* `s.ref(collection)` (a reference to a record of another collection).
|
|
98
|
+
*/
|
|
99
|
+
export const s = Object.freeze({ ...appportSchema, doc, shape: shaped, ref });
|
|
44
100
|
//# sourceMappingURL=schema.js.map
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAe,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,IAAI,aAAa,EAAe,MAAM,cAAc,CAAC;AAuC/D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,WAAW,CAAU,CAAC;AAE5D,MAAM,UAAU,QAAQ,CAAC,KAAiB;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,KAAK,IAAK,KAA8B,CAAC,OAAO,KAAK,QAAQ,EAAE,CA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