@telepath-computer/autofile 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +88 -2
- package/dist/blobs.d.ts +21 -0
- package/dist/blobs.js +159 -0
- package/dist/blobs.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +186 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.js +258 -0
- package/dist/config.js.map +1 -0
- package/dist/http.d.ts +10 -0
- package/dist/http.js +157 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +11 -0
- package/dist/json.js +82 -0
- package/dist/json.js.map +1 -0
- package/dist/mcp-resources.d.ts +31 -0
- package/dist/mcp-resources.js +111 -0
- package/dist/mcp-resources.js.map +1 -0
- package/dist/mcp-tools.d.ts +113 -0
- package/dist/mcp-tools.js +89 -0
- package/dist/mcp-tools.js.map +1 -0
- package/dist/mcp-upload.d.ts +16 -0
- package/dist/mcp-upload.js +81 -0
- package/dist/mcp-upload.js.map +1 -0
- package/dist/mcp-watch.d.ts +18 -0
- package/dist/mcp-watch.js +165 -0
- package/dist/mcp-watch.js.map +1 -0
- package/dist/schema.d.ts +25 -0
- package/dist/schema.js +241 -0
- package/dist/schema.js.map +1 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.js +257 -0
- package/dist/server.js.map +1 -0
- package/dist/store.d.ts +112 -0
- package/dist/store.js +1389 -0
- package/dist/store.js.map +1 -0
- package/dist/watch.d.ts +8 -0
- package/dist/watch.js +195 -0
- package/dist/watch.js.map +1 -0
- package/package.json +52 -4
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autofile owns one data folder: record and type operations, blob uploads and
|
|
3
|
+
* reads, and shared change subscriptions. Operations read current files;
|
|
4
|
+
* protocol adapters translate these values without owning a second persistence
|
|
5
|
+
* implementation.
|
|
6
|
+
*/
|
|
7
|
+
import { type JsonObject } from "./json.js";
|
|
8
|
+
import { type PreparedSchema } from "./schema.js";
|
|
9
|
+
export type { JsonObject, JsonPrimitive, JsonValue } from "./json.js";
|
|
10
|
+
/** One reason an operation was refused, with an address when applicable. */
|
|
11
|
+
export interface AutofileProblem {
|
|
12
|
+
uri?: string;
|
|
13
|
+
message: string;
|
|
14
|
+
}
|
|
15
|
+
/** A refused operation, with every problem the caller can correct. */
|
|
16
|
+
export declare class AutofileError extends Error {
|
|
17
|
+
readonly problems: AutofileProblem[];
|
|
18
|
+
constructor(problems: AutofileProblem[]);
|
|
19
|
+
}
|
|
20
|
+
/** A record with its address, identity, and optional display title. */
|
|
21
|
+
export interface AutofileRecord {
|
|
22
|
+
uri: string;
|
|
23
|
+
type: string;
|
|
24
|
+
key: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
problems?: AutofileProblem[];
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
value: JsonObject;
|
|
30
|
+
}
|
|
31
|
+
/** Optional filters and paging controls; where and fields apply only to value. */
|
|
32
|
+
export interface RecordQuery {
|
|
33
|
+
type?: string | string[];
|
|
34
|
+
q?: string;
|
|
35
|
+
where?: JsonObject;
|
|
36
|
+
fields?: string[];
|
|
37
|
+
limit?: number;
|
|
38
|
+
cursor?: string;
|
|
39
|
+
}
|
|
40
|
+
/** One page of matching records and records that could not be returned. */
|
|
41
|
+
export interface RecordQueryResult {
|
|
42
|
+
records: AutofileRecord[];
|
|
43
|
+
unreadable: {
|
|
44
|
+
uri: string;
|
|
45
|
+
message: string;
|
|
46
|
+
}[];
|
|
47
|
+
cursor?: string;
|
|
48
|
+
}
|
|
49
|
+
/** The fields stored in a type declaration. */
|
|
50
|
+
export interface TypeDefinition {
|
|
51
|
+
description: string;
|
|
52
|
+
schema: JsonObject;
|
|
53
|
+
titleField?: string;
|
|
54
|
+
title?: string;
|
|
55
|
+
}
|
|
56
|
+
/** A type declaration together with its name and address. */
|
|
57
|
+
export interface TypeDeclaration extends TypeDefinition {
|
|
58
|
+
uri: string;
|
|
59
|
+
type: string;
|
|
60
|
+
problems?: AutofileProblem[];
|
|
61
|
+
}
|
|
62
|
+
/** Changes to a declaration; null removes the title or title field. */
|
|
63
|
+
export type TypeChanges = Partial<Omit<TypeDefinition, "titleField" | "title">> & {
|
|
64
|
+
titleField?: string | null;
|
|
65
|
+
title?: string | null;
|
|
66
|
+
};
|
|
67
|
+
/** A record or type was created, changed, or deleted. */
|
|
68
|
+
export interface ChangeEvent {
|
|
69
|
+
uri: string;
|
|
70
|
+
kind: "created" | "changed" | "deleted";
|
|
71
|
+
}
|
|
72
|
+
type ChangeListener = (changes: ChangeEvent[]) => void | Promise<void>;
|
|
73
|
+
/** Handles failures from this subscription or from change monitoring. */
|
|
74
|
+
export interface WatchOptions {
|
|
75
|
+
onError?: (error: Error) => void;
|
|
76
|
+
}
|
|
77
|
+
/** The store implementation. Construction resolves paths but performs no I/O. */
|
|
78
|
+
export declare class Autofile {
|
|
79
|
+
#private;
|
|
80
|
+
constructor(options: {
|
|
81
|
+
folder: string;
|
|
82
|
+
});
|
|
83
|
+
readonly records: {
|
|
84
|
+
find: (query?: RecordQuery) => Promise<RecordQueryResult>;
|
|
85
|
+
get: (uri: string) => Promise<AutofileRecord | undefined>;
|
|
86
|
+
create: (type: string, value: JsonObject, options?: {
|
|
87
|
+
key?: string;
|
|
88
|
+
}) => Promise<AutofileRecord>;
|
|
89
|
+
update: (uri: string, patch: JsonObject) => Promise<AutofileRecord>;
|
|
90
|
+
delete: (uri: string) => Promise<void>;
|
|
91
|
+
};
|
|
92
|
+
readonly types: {
|
|
93
|
+
list: () => Promise<TypeDeclaration[]>;
|
|
94
|
+
get: (name: string) => Promise<TypeDeclaration | undefined>;
|
|
95
|
+
create: (name: string, definition: TypeDefinition) => Promise<TypeDeclaration>;
|
|
96
|
+
update: (name: string, changes: TypeChanges) => Promise<TypeDeclaration>;
|
|
97
|
+
delete: (name: string) => Promise<void>;
|
|
98
|
+
};
|
|
99
|
+
readonly blobs: {
|
|
100
|
+
put: (bytes: Uint8Array, mediaType: string) => Promise<string>;
|
|
101
|
+
get: (uri: string) => Promise<{
|
|
102
|
+
bytes: Uint8Array;
|
|
103
|
+
mimeType: string;
|
|
104
|
+
} | undefined>;
|
|
105
|
+
};
|
|
106
|
+
/** Checks a schema without accessing storage or checking link targets. */
|
|
107
|
+
static prepareSchema(schema: JsonObject): Promise<PreparedSchema>;
|
|
108
|
+
/** Subscribes after the shared watcher is ready; the returned function unsubscribes. */
|
|
109
|
+
watch(onChange: ChangeListener, options?: WatchOptions): Promise<() => Promise<void>>;
|
|
110
|
+
/** Stops change subscriptions. Future operations on this instance are refused. */
|
|
111
|
+
close(): Promise<void>;
|
|
112
|
+
}
|