@feltdb/feltkit 0.0.0-stage → 0.1.1

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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -2
  3. package/bin/feltkit.js +3 -0
  4. package/dist/app.d.ts +151 -0
  5. package/dist/app.js +130 -0
  6. package/dist/app.js.map +1 -0
  7. package/dist/cli/deploy.d.ts +8 -0
  8. package/dist/cli/deploy.js +125 -0
  9. package/dist/cli/deploy.js.map +1 -0
  10. package/dist/cli/main.d.ts +9 -0
  11. package/dist/cli/main.js +365 -0
  12. package/dist/cli/main.js.map +1 -0
  13. package/dist/cli/output.d.ts +18 -0
  14. package/dist/cli/output.js +87 -0
  15. package/dist/cli/output.js.map +1 -0
  16. package/dist/client/index.d.ts +125 -0
  17. package/dist/client/index.js +306 -0
  18. package/dist/client/index.js.map +1 -0
  19. package/dist/dashboard/assets/index-BLnBFDJs.css +1 -0
  20. package/dist/dashboard/assets/index-CxJGCspE.js +15 -0
  21. package/dist/dashboard/index.html +16 -0
  22. package/dist/errors.d.ts +31 -0
  23. package/dist/errors.js +54 -0
  24. package/dist/errors.js.map +1 -0
  25. package/dist/index.d.ts +18 -0
  26. package/dist/index.js +12 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/react/index.d.ts +40 -0
  29. package/dist/react/index.js +85 -0
  30. package/dist/react/index.js.map +1 -0
  31. package/dist/runtime/activity.d.ts +97 -0
  32. package/dist/runtime/activity.js +99 -0
  33. package/dist/runtime/activity.js.map +1 -0
  34. package/dist/runtime/authority.d.ts +78 -0
  35. package/dist/runtime/authority.js +176 -0
  36. package/dist/runtime/authority.js.map +1 -0
  37. package/dist/runtime/changes.d.ts +34 -0
  38. package/dist/runtime/changes.js +85 -0
  39. package/dist/runtime/changes.js.map +1 -0
  40. package/dist/runtime/context.d.ts +51 -0
  41. package/dist/runtime/context.js +2 -0
  42. package/dist/runtime/context.js.map +1 -0
  43. package/dist/runtime/data.d.ts +139 -0
  44. package/dist/runtime/data.js +374 -0
  45. package/dist/runtime/data.js.map +1 -0
  46. package/dist/runtime/environment.d.ts +36 -0
  47. package/dist/runtime/environment.js +62 -0
  48. package/dist/runtime/environment.js.map +1 -0
  49. package/dist/runtime/instance.d.ts +77 -0
  50. package/dist/runtime/instance.js +230 -0
  51. package/dist/runtime/instance.js.map +1 -0
  52. package/dist/runtime/loader.d.ts +11 -0
  53. package/dist/runtime/loader.js +99 -0
  54. package/dist/runtime/loader.js.map +1 -0
  55. package/dist/runtime/projects.d.ts +51 -0
  56. package/dist/runtime/projects.js +139 -0
  57. package/dist/runtime/projects.js.map +1 -0
  58. package/dist/runtime/runtime.d.ts +178 -0
  59. package/dist/runtime/runtime.js +448 -0
  60. package/dist/runtime/runtime.js.map +1 -0
  61. package/dist/runtime/services.d.ts +177 -0
  62. package/dist/runtime/services.js +418 -0
  63. package/dist/runtime/services.js.map +1 -0
  64. package/dist/runtime/sessions.d.ts +55 -0
  65. package/dist/runtime/sessions.js +107 -0
  66. package/dist/runtime/sessions.js.map +1 -0
  67. package/dist/schema.d.ts +56 -0
  68. package/dist/schema.js +44 -0
  69. package/dist/schema.js.map +1 -0
  70. package/dist/server/admin.d.ts +115 -0
  71. package/dist/server/admin.js +326 -0
  72. package/dist/server/admin.js.map +1 -0
  73. package/dist/server/http.d.ts +19 -0
  74. package/dist/server/http.js +99 -0
  75. package/dist/server/http.js.map +1 -0
  76. package/dist/server/index.d.ts +52 -0
  77. package/dist/server/index.js +296 -0
  78. package/dist/server/index.js.map +1 -0
  79. package/dist/server/mcp.d.ts +12 -0
  80. package/dist/server/mcp.js +77 -0
  81. package/dist/server/mcp.js.map +1 -0
  82. package/dist/server/project.d.ts +60 -0
  83. package/dist/server/project.js +331 -0
  84. package/dist/server/project.js.map +1 -0
  85. package/dist/server/public.d.ts +14 -0
  86. package/dist/server/public.js +15 -0
  87. package/dist/server/public.js.map +1 -0
  88. package/dist/testing/index.d.ts +20 -0
  89. package/dist/testing/index.js +64 -0
  90. package/dist/testing/index.js.map +1 -0
  91. package/package.json +84 -4
@@ -0,0 +1,177 @@
1
+ /**
2
+ * AppPort Services on the application's FeltDB instance.
3
+ *
4
+ * Two construction paths, chosen by the installed @appport/services:
5
+ *
6
+ * >= 0.5.0 "shared-instance": the package's own `createServices({ db })`, given the
7
+ * shared instance's "appport-services" handle. FeltKit asserts the services
8
+ * really use that handle and refuses to start otherwise.
9
+ * 0.4.x "composed": `createServices()` would open a second FeltDB instance, so
10
+ * FeltKit builds Files from the package's public classes on the handle.
11
+ * Only Files is available on this path.
12
+ *
13
+ * Either way, every effect passes AppPort Services' gateway, whose authorizer is
14
+ * FeltKit's policy (see Authority.serviceAuthorizer), and evidence is written to the
15
+ * same instance.
16
+ *
17
+ * Services offered to application code, and why the rest are not:
18
+ *
19
+ * files available (both paths)
20
+ * notifications available (shared-instance path): in-app channel, delivered inline;
21
+ * a principal reads only notifications addressed to it
22
+ * configuration available (shared-instance path): variables for this environment
23
+ * apikeys, webhooks, jobs, schedules, intelligence: not offered; see UNAVAILABLE.
24
+ *
25
+ * File *bytes*: AppPort Files stores metadata and a `storageKey`. The local FeltDB
26
+ * runtime has no content store (`storeContent` requires a FeltDB server), so FeltKit
27
+ * stores bytes in `_feltkit_file_content` in the same instance and verifies the
28
+ * SHA-256 checksum on read. Upload is two commits (metadata, then bytes); if the
29
+ * second fails FeltKit deletes the metadata through the same authorized service.
30
+ */
31
+ import type { StateFirstDB } from "@feltdb/core";
32
+ import { FileService, ServiceGateway, type ConfigurationService, type NotificationService } from "@appport/services";
33
+ import type { Authority, Principal } from "./authority.js";
34
+ export declare const FILE_CONTENT_COLLECTION = "_feltkit_file_content";
35
+ export declare const DEFAULT_MAX_FILE_BYTES: number;
36
+ export interface FileInfo {
37
+ id: string;
38
+ name: string;
39
+ contentType?: string;
40
+ size: number;
41
+ checksum?: string;
42
+ owner: string;
43
+ metadata: Record<string, unknown>;
44
+ createdAt: string;
45
+ updatedAt?: string;
46
+ }
47
+ export interface UploadInput {
48
+ name: string;
49
+ contentType?: string;
50
+ /** Text, or bytes. */
51
+ content: string | Uint8Array;
52
+ metadata?: Record<string, string | number | boolean>;
53
+ }
54
+ export interface FilesReader {
55
+ list(filter?: {
56
+ metadata?: Record<string, string | number | boolean>;
57
+ }): Promise<FileInfo[]>;
58
+ get(id: string): Promise<FileInfo>;
59
+ read(id: string): Promise<{
60
+ file: FileInfo;
61
+ bytes: Uint8Array;
62
+ text(): string;
63
+ }>;
64
+ }
65
+ export interface FilesWriter extends FilesReader {
66
+ upload(input: UploadInput): Promise<FileInfo>;
67
+ remove(id: string): Promise<void>;
68
+ }
69
+ export interface NotificationInfo {
70
+ id: string;
71
+ recipient: string;
72
+ type: string;
73
+ title: string;
74
+ body?: string;
75
+ data?: Record<string, unknown>;
76
+ priority: string;
77
+ status: string;
78
+ createdAt: string;
79
+ createdBy?: string;
80
+ readAt?: string;
81
+ }
82
+ export interface SendNotificationInput {
83
+ recipient: string;
84
+ type: string;
85
+ title: string;
86
+ body?: string;
87
+ data?: Record<string, unknown>;
88
+ priority?: "low" | "normal" | "high" | "urgent";
89
+ /** Deduplicates: sending the same key again returns the first notification. */
90
+ idempotencyKey?: string;
91
+ }
92
+ /** A principal reads, marks, and dismisses only notifications addressed to it. */
93
+ export interface NotificationsReader {
94
+ list(filter?: {
95
+ unread?: boolean;
96
+ type?: string;
97
+ }): Promise<NotificationInfo[]>;
98
+ get(id: string): Promise<NotificationInfo>;
99
+ }
100
+ export interface NotificationsWriter extends NotificationsReader {
101
+ send(input: SendNotificationInput): Promise<NotificationInfo>;
102
+ markRead(id: string): Promise<NotificationInfo>;
103
+ dismiss(id: string): Promise<NotificationInfo>;
104
+ }
105
+ /** Variables for the current environment. Secrets (credential references) are not offered. */
106
+ export interface ConfigurationReader {
107
+ get(name: string): Promise<string | null>;
108
+ list(): Promise<Record<string, string>>;
109
+ }
110
+ export interface ConfigurationWriter extends ConfigurationReader {
111
+ set(name: string, value: string): Promise<void>;
112
+ remove(name: string): Promise<void>;
113
+ }
114
+ export interface BoundServices {
115
+ files: FilesReader | FilesWriter;
116
+ notifications: NotificationsReader | NotificationsWriter;
117
+ configuration: ConfigurationReader | ConfigurationWriter;
118
+ }
119
+ export type ServicesMode = "shared-instance" | "composed";
120
+ export interface ServicesConfig {
121
+ files?: boolean | {
122
+ maxBytes?: number;
123
+ };
124
+ notifications?: boolean;
125
+ configuration?: boolean;
126
+ }
127
+ export interface ServiceStatus {
128
+ id: string;
129
+ name: string;
130
+ description: string;
131
+ package: string;
132
+ version: string;
133
+ installed: boolean;
134
+ configured: boolean;
135
+ connected: boolean;
136
+ healthy: boolean | null;
137
+ detail: string;
138
+ collections: string[];
139
+ capabilities: string[];
140
+ lastCheckedAt?: string;
141
+ lastError?: {
142
+ at: string;
143
+ message: string;
144
+ };
145
+ /** Whether application code can use it in this installation. */
146
+ available: boolean;
147
+ }
148
+ /** The first @appport/services release whose createServices() accepts the host's instance. */
149
+ export declare const SHARED_INSTANCE_SERVICES = "0.5.0";
150
+ export declare function supportsSharedInstance(version: string): boolean;
151
+ export declare const CONFIGURATION_ENVIRONMENT: Record<string, "development" | "staging" | "production">;
152
+ export declare class ServicesHost {
153
+ #private;
154
+ readonly mode: ServicesMode;
155
+ readonly gateway: ServiceGateway;
156
+ readonly files: FileService | null;
157
+ readonly notifications: NotificationService | null;
158
+ readonly configuration: ConfigurationService | null;
159
+ /** The instance handle every service store uses. Tests check it belongs to the shared instance. */
160
+ readonly db: StateFirstDB;
161
+ constructor(options: {
162
+ servicesDb: StateFirstDB;
163
+ contentDb: StateFirstDB;
164
+ applicationId: string;
165
+ authority: Authority;
166
+ config: ServicesConfig;
167
+ environment: string;
168
+ });
169
+ get tenantId(): string;
170
+ /** Allow `principal` to cause service effects while request `requestId` runs. */
171
+ enter(requestId: string, principal: Principal | null): () => void;
172
+ /** The `ctx.services` object for one invocation. `reads` collects collections read, for reactivity. */
173
+ bind(principal: Principal | null, requestId: string, reads: Set<string>, writable: boolean, used?: Set<string>): BoundServices;
174
+ /** A live check: the store answers through the shared instance. Never authorizes anything. */
175
+ check(): Promise<void>;
176
+ status(connected: boolean): ServiceStatus[];
177
+ }
@@ -0,0 +1,418 @@
1
+ import { createServices, FeltDbEffectEvidenceStore, FeltDbFileAuditSink, FeltDbFileStore, FileService, ServiceGateway, isServiceAuthorityError, } from "@appport/services";
2
+ import { createHash, randomUUID } from "node:crypto";
3
+ import { readFileSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { FeltKitError } from "../errors.js";
7
+ export const FILE_CONTENT_COLLECTION = "_feltkit_file_content";
8
+ export const DEFAULT_MAX_FILE_BYTES = 1024 * 1024;
9
+ let servicesVersion;
10
+ function packageVersion() {
11
+ if (servicesVersion)
12
+ return servicesVersion;
13
+ try {
14
+ // The package is ESM-only and does not export package.json; resolve it from the entry.
15
+ const entry = fileURLToPath(import.meta.resolve("@appport/services"));
16
+ const pkg = join(entry, "..", "..", "..", "package.json");
17
+ servicesVersion = JSON.parse(readFileSync(pkg, "utf8")).version;
18
+ }
19
+ catch {
20
+ servicesVersion = "unknown";
21
+ }
22
+ return servicesVersion;
23
+ }
24
+ /** The first @appport/services release whose createServices() accepts the host's instance. */
25
+ export const SHARED_INSTANCE_SERVICES = "0.5.0";
26
+ export function supportsSharedInstance(version) {
27
+ const [major = 0, minor = 0] = version.split(".").map((n) => Number.parseInt(n, 10));
28
+ return Number.isFinite(major) && (major > 0 || minor >= 5);
29
+ }
30
+ /**
31
+ * Services that are not offered to application code, with the concrete reason.
32
+ * The first reason applies when the installed package cannot share the instance.
33
+ */
34
+ const UNAVAILABLE = [
35
+ ["apikeys", "API keys", "Tenant-scoped machine credentials", "FeltKit authenticates callers with sessions; it does not yet accept API keys as an identity, so issued keys would authenticate nothing."],
36
+ ["webhooks", "Webhooks", "Durable signed outbound delivery", "Delivery signs payloads with a credential resolved by a credential provider (AuthBoundry custody). FeltKit has no credential provider, so deliveries could not be signed."],
37
+ ["jobs", "Jobs", "Durable background execution with leases", "Application jobs re-authorize every run as their enqueuing principal; FeltKit cannot yet resolve that principal's roles outside a live request."],
38
+ ["schedules", "Schedules", "Recurring jobs", "Built on application jobs (see Jobs)."],
39
+ ["intelligence", "Intelligence", "Model provider configuration", "Provider credentials need a credential provider, which FeltKit does not have."],
40
+ ];
41
+ export const CONFIGURATION_ENVIRONMENT = {
42
+ development: "development",
43
+ test: "development",
44
+ production: "production",
45
+ };
46
+ function toInfo(file) {
47
+ return {
48
+ id: file.id,
49
+ name: file.name,
50
+ ...(file.contentType ? { contentType: file.contentType } : {}),
51
+ size: file.size,
52
+ ...(file.checksum ? { checksum: file.checksum } : {}),
53
+ owner: file.owner,
54
+ metadata: (file.metadata ?? {}),
55
+ createdAt: file.createdAt,
56
+ ...(file.updatedAt ? { updatedAt: file.updatedAt } : {}),
57
+ };
58
+ }
59
+ function translate(error) {
60
+ if (isServiceAuthorityError(error)) {
61
+ const code = error.code;
62
+ if (code === "DENIED")
63
+ throw new FeltKitError("FORBIDDEN", error.message, { cause: error });
64
+ if (code === "UNAUTHENTICATED")
65
+ throw new FeltKitError("UNAUTHORIZED", error.message, { cause: error });
66
+ if (code === "INVALID_REQUEST")
67
+ throw new FeltKitError("INVALID_ARGUMENT", error.message, { cause: error });
68
+ throw new FeltKitError("UNAVAILABLE", error.message, { cause: error });
69
+ }
70
+ const name = String(error?.name ?? "");
71
+ const message = error?.message ?? String(error);
72
+ if (name.endsWith("NotFoundError"))
73
+ throw new FeltKitError("NOT_FOUND", message, { cause: error });
74
+ if (name.endsWith("ValidationError") || name.endsWith("SensitiveDataError"))
75
+ throw new FeltKitError("INVALID_ARGUMENT", message, { cause: error });
76
+ if (name.endsWith("AuthorizationError"))
77
+ throw new FeltKitError("FORBIDDEN", message, { cause: error });
78
+ throw error;
79
+ }
80
+ export class ServicesHost {
81
+ mode;
82
+ gateway;
83
+ files;
84
+ notifications;
85
+ configuration;
86
+ /** The instance handle every service store uses. Tests check it belongs to the shared instance. */
87
+ db;
88
+ #official;
89
+ #content;
90
+ #environment;
91
+ #tenantId;
92
+ #applicationId;
93
+ #maxBytes;
94
+ /** requestId → principal for invocations currently allowed to cause service effects */
95
+ #bound = new Map();
96
+ #lastError;
97
+ #lastChecked;
98
+ constructor(options) {
99
+ this.#applicationId = options.applicationId;
100
+ this.#tenantId = options.applicationId;
101
+ this.#content = options.contentDb;
102
+ this.#environment = CONFIGURATION_ENVIRONMENT[options.environment] ?? "staging";
103
+ this.db = options.servicesDb;
104
+ const config = options.config;
105
+ this.#maxBytes = typeof config.files === "object" ? config.files.maxBytes ?? DEFAULT_MAX_FILE_BYTES : DEFAULT_MAX_FILE_BYTES;
106
+ const authorizer = options.authority.serviceAuthorizer((runId) => (runId ? this.#bound.get(runId) ?? null : null));
107
+ const version = packageVersion();
108
+ if (supportsSharedInstance(version)) {
109
+ // The package's own construction, on the shared instance.
110
+ const official = createServices({ db: options.servicesDb, application: options.applicationId, authorizer });
111
+ if (official._getDb !== options.servicesDb) {
112
+ throw new FeltKitError("CONFIGURATION", `@appport/services ${version} did not use the application's FeltDB instance. Refusing to start with a second database.`);
113
+ }
114
+ this.mode = "shared-instance";
115
+ this.#official = official;
116
+ this.gateway = official.gateway;
117
+ this.files = config.files ? official.files : null;
118
+ this.notifications = config.notifications ? official.notifications : null;
119
+ this.configuration = config.configuration ? official.configuration : null;
120
+ return;
121
+ }
122
+ for (const service of ["notifications", "configuration"]) {
123
+ if (config[service]) {
124
+ throw new FeltKitError("CONFIGURATION", `services.${service} needs @appport/services ${SHARED_INSTANCE_SERVICES} or newer (installed: ${version}).`, {
125
+ hint: `Older releases can only run ${service} on a FeltDB instance of their own, and FeltKit does not run a second database.`,
126
+ });
127
+ }
128
+ }
129
+ this.mode = "composed";
130
+ this.#official = null;
131
+ this.gateway = new ServiceGateway({ application: options.applicationId, authorizer, evidence: new FeltDbEffectEvidenceStore(options.servicesDb) });
132
+ this.files = config.files ? new FileService({ store: new FeltDbFileStore(options.servicesDb), auditSink: new FeltDbFileAuditSink(options.servicesDb), authority: this.gateway }) : null;
133
+ this.notifications = null;
134
+ this.configuration = null;
135
+ }
136
+ get tenantId() {
137
+ return this.#tenantId;
138
+ }
139
+ /** Allow `principal` to cause service effects while request `requestId` runs. */
140
+ enter(requestId, principal) {
141
+ if (!principal)
142
+ return () => { };
143
+ this.#bound.set(requestId, principal);
144
+ return () => this.#bound.delete(requestId);
145
+ }
146
+ #verified(principal, requestId) {
147
+ if (!principal)
148
+ throw new FeltKitError("UNAUTHORIZED", "Authentication is required to use services");
149
+ const verified = this.gateway.identify({
150
+ principalId: principal.id,
151
+ principalType: principal.type,
152
+ tenantId: this.#tenantId,
153
+ applicationId: this.#applicationId,
154
+ runId: requestId,
155
+ });
156
+ if (!verified)
157
+ throw new FeltKitError("UNAUTHORIZED", "The principal could not be verified for services");
158
+ return verified;
159
+ }
160
+ #require(service, name) {
161
+ if (!service) {
162
+ throw new FeltKitError("CONFIGURATION", `The ${name} service is not enabled.`, { hint: `Enable it with feltkit({ services: { ${name}: true } }).` });
163
+ }
164
+ return service;
165
+ }
166
+ #requireFiles() {
167
+ if (!this.files) {
168
+ throw new FeltKitError("CONFIGURATION", "The Files service is not enabled.", { hint: "Enable it with feltkit({ services: { files: true } })." });
169
+ }
170
+ return this.files;
171
+ }
172
+ #record(promise) {
173
+ return promise.catch((error) => {
174
+ if (!isServiceAuthorityError(error) || error.code !== "DENIED") {
175
+ this.#lastError = { at: new Date().toISOString(), message: error.message };
176
+ }
177
+ return translate(error);
178
+ });
179
+ }
180
+ /** The `ctx.services` object for one invocation. `reads` collects collections read, for reactivity. */
181
+ bind(principal, requestId, reads, writable, used = new Set()) {
182
+ const notifications = this.#bindNotifications(principal, requestId, reads, writable, used);
183
+ const configuration = this.#bindConfiguration(principal, requestId, reads, writable, used);
184
+ const use = () => used.add("files");
185
+ const reader = {
186
+ list: async (filter = {}) => {
187
+ use();
188
+ const service = this.#requireFiles();
189
+ reads.add("files");
190
+ const items = await this.#record(service.list(this.#tenantId, this.#verified(principal, requestId)));
191
+ const wanted = Object.entries(filter.metadata ?? {});
192
+ return items
193
+ .filter((item) => wanted.every(([key, value]) => item.metadata?.[key] === value))
194
+ .map(toInfo)
195
+ .sort((a, b) => a.createdAt.localeCompare(b.createdAt));
196
+ },
197
+ get: async (id) => {
198
+ use();
199
+ const service = this.#requireFiles();
200
+ reads.add("files");
201
+ return toInfo(await this.#record(service.get(this.#tenantId, id, this.#verified(principal, requestId))));
202
+ },
203
+ read: async (id) => {
204
+ const file = await reader.get(id);
205
+ reads.add(FILE_CONTENT_COLLECTION);
206
+ const contentId = String((await this.#record(this.#requireFiles().get(this.#tenantId, id, this.#verified(principal, requestId)))).storageKey).replace(/^feltkit-content:/, "");
207
+ const record = (await this.#content.collection(FILE_CONTENT_COLLECTION).get(contentId)) ?? null;
208
+ if (!record)
209
+ throw new FeltKitError("NOT_FOUND", `The content for file ${id} is missing.`);
210
+ const bytes = new Uint8Array(Buffer.from(record.data, "base64"));
211
+ const checksum = createHash("sha256").update(bytes).digest("hex");
212
+ if (checksum !== record.checksum || (file.checksum && checksum !== file.checksum)) {
213
+ throw new FeltKitError("INTERNAL", `File ${id} failed its checksum; the stored bytes do not match the recorded digest.`);
214
+ }
215
+ return { file, bytes, text: () => new TextDecoder().decode(bytes) };
216
+ },
217
+ };
218
+ if (!writable)
219
+ return { files: reader, notifications, configuration };
220
+ const writer = {
221
+ ...reader,
222
+ upload: async (input) => {
223
+ use();
224
+ const service = this.#requireFiles();
225
+ if (!input || typeof input.name !== "string" || !input.name.trim())
226
+ throw new FeltKitError("INVALID_ARGUMENT", "upload() needs a file name.");
227
+ const bytes = typeof input.content === "string" ? new TextEncoder().encode(input.content) : input.content;
228
+ if (!(bytes instanceof Uint8Array))
229
+ throw new FeltKitError("INVALID_ARGUMENT", "upload() content must be a string or Uint8Array.");
230
+ if (bytes.byteLength > this.#maxBytes) {
231
+ throw new FeltKitError("PAYLOAD_TOO_LARGE", `Files are limited to ${this.#maxBytes} bytes on this runtime (got ${bytes.byteLength}).`);
232
+ }
233
+ const checksum = createHash("sha256").update(bytes).digest("hex");
234
+ const contentId = randomUUID();
235
+ const verified = this.#verified(principal, requestId);
236
+ const created = await this.#record(service.create({
237
+ name: input.name.trim(),
238
+ ...(input.contentType ? { contentType: input.contentType } : {}),
239
+ size: bytes.byteLength,
240
+ checksum,
241
+ storageKey: `feltkit-content:${contentId}`,
242
+ ...(input.metadata ? { metadata: input.metadata } : {}),
243
+ }, verified));
244
+ try {
245
+ await this.#content.transaction({
246
+ operations: [
247
+ {
248
+ collection: FILE_CONTENT_COLLECTION,
249
+ id: contentId,
250
+ requireAbsent: true,
251
+ value: { id: contentId, fileId: created.id, data: Buffer.from(bytes).toString("base64"), size: bytes.byteLength, checksum },
252
+ },
253
+ ],
254
+ });
255
+ }
256
+ catch (error) {
257
+ await service.delete(this.#tenantId, created.id, verified).catch(() => undefined);
258
+ throw new FeltKitError("UNAVAILABLE", `Storing file content failed; the file record was removed: ${error.message}`, { cause: error });
259
+ }
260
+ return toInfo(created);
261
+ },
262
+ remove: async (id) => {
263
+ use();
264
+ const service = this.#requireFiles();
265
+ const verified = this.#verified(principal, requestId);
266
+ const current = await this.#record(service.get(this.#tenantId, id, verified));
267
+ await this.#record(service.delete(this.#tenantId, id, verified));
268
+ const contentId = String(current.storageKey).replace(/^feltkit-content:/, "");
269
+ const content = await this.#content.collection(FILE_CONTENT_COLLECTION).get(contentId);
270
+ if (content)
271
+ await this.#content.transaction({ operations: [{ collection: FILE_CONTENT_COLLECTION, id: contentId, ifVersion: content.__version }] });
272
+ },
273
+ };
274
+ return { files: writer, notifications, configuration };
275
+ }
276
+ #bindNotifications(principal, requestId, reads, writable, used) {
277
+ const service = () => (used.add("notifications"), reads.add("notifications"), this.#require(this.notifications, "notifications"));
278
+ const me = () => this.#verified(principal, requestId);
279
+ const reader = {
280
+ list: async (filter = {}) => {
281
+ const s = service();
282
+ const verified = me();
283
+ const page = await this.#record(s.list(this.#tenantId, { recipient: verified.principalId, ...(filter.unread ? { unread: true } : {}), ...(filter.type ? { type: filter.type } : {}) }, verified));
284
+ return page.items.map(toNotification);
285
+ },
286
+ get: async (id) => toNotification(await this.#record(service().get(this.#tenantId, id, me()))),
287
+ };
288
+ if (!writable)
289
+ return reader;
290
+ return {
291
+ ...reader,
292
+ send: async (input) => {
293
+ const s = service();
294
+ if (!input || typeof input.recipient !== "string" || !input.recipient)
295
+ throw new FeltKitError("INVALID_ARGUMENT", "send() needs a recipient.");
296
+ const result = await this.#record(s.notify({
297
+ recipient: input.recipient,
298
+ type: input.type,
299
+ title: input.title,
300
+ ...(input.body !== undefined ? { body: input.body } : {}),
301
+ ...(input.data !== undefined ? { data: input.data } : {}),
302
+ ...(input.priority ? { priority: input.priority } : {}),
303
+ ...(input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : {}),
304
+ channels: ["in-app"],
305
+ }, me()));
306
+ return toNotification(result.notification);
307
+ },
308
+ markRead: async (id) => toNotification(await this.#record(service().markRead(this.#tenantId, id, me()))),
309
+ dismiss: async (id) => toNotification(await this.#record(service().dismiss(this.#tenantId, id, me()))),
310
+ };
311
+ }
312
+ #bindConfiguration(principal, requestId, reads, writable, used) {
313
+ const service = () => (used.add("configuration"), reads.add("ConfigurationVariables"), this.#require(this.configuration, "configuration"));
314
+ const scope = { tenantId: this.#tenantId, applicationId: this.#applicationId, environment: this.#environment };
315
+ const list = async () => {
316
+ const result = await this.#record(service().list(scope, this.#verified(principal, requestId)));
317
+ return Object.fromEntries(result.variables.map((v) => [v.name, v.value]));
318
+ };
319
+ const reader = {
320
+ list,
321
+ get: async (name) => (await list())[name] ?? null,
322
+ };
323
+ if (!writable)
324
+ return reader;
325
+ return {
326
+ ...reader,
327
+ set: async (name, value) => {
328
+ const s = service();
329
+ const verified = this.#verified(principal, requestId);
330
+ const existing = await this.#record(s.list(scope, verified));
331
+ const input = { ...scope, name, value };
332
+ if (existing.variables.some((v) => v.name === name))
333
+ await this.#record(s.updateVariable(input, verified));
334
+ else
335
+ await this.#record(s.createVariable(input, verified));
336
+ },
337
+ remove: async (name) => {
338
+ await this.#record(service().delete({ ...scope, name, kind: "variable" }, this.#verified(principal, requestId)));
339
+ },
340
+ };
341
+ }
342
+ /** A live check: the store answers through the shared instance. Never authorizes anything. */
343
+ async check() {
344
+ const at = new Date().toISOString();
345
+ try {
346
+ // Reads the services' own collections through the shared handle. Authorizes nothing.
347
+ for (const collection of ["files", "notifications", "ConfigurationVariables", "service_effect_evidence"])
348
+ await this.db.collection(collection).find({}, { limit: 1 });
349
+ this.#lastChecked = { at, ok: true, detail: `Stores reachable through the shared FeltDB instance (${this.mode === "shared-instance" ? "createServices({ db })" : "composed from public classes"}).` };
350
+ }
351
+ catch (error) {
352
+ this.#lastChecked = { at, ok: false, detail: `Stores unreachable: ${error.message}` };
353
+ }
354
+ }
355
+ status(connected) {
356
+ const version = packageVersion();
357
+ const installed = version !== "unknown";
358
+ const shared = this.mode === "shared-instance";
359
+ const healthy = this.#lastChecked?.ok ?? null;
360
+ const mounted = (id, name, description, service, collections, capabilities, supported) => ({
361
+ id,
362
+ name,
363
+ description,
364
+ package: "@appport/services",
365
+ version,
366
+ installed,
367
+ configured: service !== null,
368
+ connected: connected && service !== null,
369
+ healthy: service === null ? null : healthy,
370
+ available: supported && service !== null && connected,
371
+ detail: !supported
372
+ ? `Needs @appport/services ${SHARED_INSTANCE_SERVICES} or newer (installed: ${version}); older releases run it only on a second database.`
373
+ : service === null
374
+ ? `Not enabled. Add services: { ${id}: true } to feltkit({ ... }).`
375
+ : this.#lastChecked?.detail ?? "Not checked yet.",
376
+ collections,
377
+ capabilities,
378
+ ...(this.#lastChecked && service !== null ? { lastCheckedAt: this.#lastChecked.at } : {}),
379
+ ...(this.#lastError && service !== null ? { lastError: this.#lastError } : {}),
380
+ });
381
+ return [
382
+ mounted("files", "Files", "File records with ownership, audit, and authorization. Bytes are stored in the same FeltDB instance.", this.files, ["files", "file_audit_events", "service_effect_evidence", FILE_CONTENT_COLLECTION], ["files.read", "files.write", "files.delete"], true),
383
+ mounted("notifications", "Notifications", "Durable in-app notifications. Each principal reads only its own.", this.notifications, ["notifications", "notification_deliveries", "notification_audit_events"], ["notifications.send", "notifications.read", "notifications.update", "notifications.delete"], shared),
384
+ mounted("configuration", "Configuration", `Variables for this environment (stored as "${this.#environment}").`, this.configuration, ["ConfigurationVariables", "ConfigurationAuditEvents"], ["configuration.read", "configuration.write", "configuration.delete"], shared),
385
+ ...UNAVAILABLE.map(([id, name, description, reason]) => ({
386
+ id,
387
+ name,
388
+ description,
389
+ package: "@appport/services",
390
+ version,
391
+ installed,
392
+ configured: false,
393
+ connected: false,
394
+ healthy: null,
395
+ available: false,
396
+ detail: `Not available in FeltKit: ${reason}`,
397
+ collections: [],
398
+ capabilities: [],
399
+ })),
400
+ ];
401
+ }
402
+ }
403
+ function toNotification(item) {
404
+ return {
405
+ id: item.id,
406
+ recipient: item.recipient,
407
+ type: item.type,
408
+ title: item.title,
409
+ ...(item.body !== undefined ? { body: item.body } : {}),
410
+ ...(item.data !== undefined ? { data: item.data } : {}),
411
+ priority: item.priority ?? "normal",
412
+ status: item.status,
413
+ createdAt: item.createdAt,
414
+ ...(item.createdBy ? { createdBy: item.createdBy } : {}),
415
+ ...(item.readAt ? { readAt: item.readAt } : {}),
416
+ };
417
+ }
418
+ //# sourceMappingURL=services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/runtime/services.ts"],"names":[],"mappings":"AA+BA,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,cAAc,EACd,uBAAuB,GAKxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAA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