@telepath-computer/autofile 0.3.0 → 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/README.md +33 -19
- package/dist/blobs.d.ts +9 -22
- package/dist/blobs.js +35 -171
- package/dist/blobs.js.map +1 -1
- package/dist/cli.js +15 -9
- package/dist/cli.js.map +1 -1
- package/dist/http.d.ts +2 -2
- package/dist/http.js +10 -5
- package/dist/http.js.map +1 -1
- 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 +3 -1
- package/dist/json.js +81 -2
- package/dist/json.js.map +1 -1
- 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 +1 -1
- package/dist/schema.js +8 -2
- package/dist/schema.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +58 -38
- package/dist/server.js.map +1 -1
- package/dist/store.d.ts +90 -110
- package/dist/store.js +532 -524
- package/dist/store.js.map +1 -1
- package/dist/watch.d.ts +6 -18
- package/dist/watch.js +73 -191
- package/dist/watch.js.map +1 -1
- package/package.json +7 -1
package/dist/store.d.ts
CHANGED
|
@@ -1,132 +1,112 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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.
|
|
5
6
|
*/
|
|
6
|
-
import type
|
|
7
|
+
import { type JsonObject } from "./json.js";
|
|
8
|
+
import { type PreparedSchema } from "./schema.js";
|
|
7
9
|
export type { JsonObject, JsonPrimitive, JsonValue } from "./json.js";
|
|
8
|
-
|
|
10
|
+
/** One reason an operation was refused, with an address when applicable. */
|
|
11
|
+
export interface AutofileProblem {
|
|
9
12
|
uri?: string;
|
|
10
13
|
message: string;
|
|
11
14
|
}
|
|
12
|
-
|
|
13
|
-
|
|
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[]);
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
writeLockPath?: string;
|
|
18
|
-
}
|
|
19
|
-
/** Transport-sensitive permissions for a record write. */
|
|
20
|
-
export interface RecordWriteOptions {
|
|
21
|
-
allowLocalPaths?: boolean;
|
|
22
|
-
}
|
|
23
|
-
export interface Store {
|
|
24
|
-
findRecords(input: FindRecordsInput): Promise<FindRecordsResult | Refusal>;
|
|
25
|
-
getRecord(input: GetRecordInput): Promise<RecordResult | Refusal>;
|
|
26
|
-
createRecord(input: CreateRecordInput, options?: RecordWriteOptions): Promise<UriResult | Refusal>;
|
|
27
|
-
updateRecord(input: UpdateRecordInput, options?: RecordWriteOptions): Promise<UriResult | Refusal>;
|
|
28
|
-
deleteRecord(input: DeleteRecordInput): Promise<UriResult | Refusal>;
|
|
29
|
-
listTypes(input: Record<string, never>): Promise<ListTypesResult>;
|
|
30
|
-
getType(input: GetTypeInput): Promise<TypeResult | Refusal>;
|
|
31
|
-
createType(input: CreateTypeInput): Promise<UriResult | Refusal>;
|
|
32
|
-
updateType(input: UpdateTypeInput): Promise<UpdateTypeResult | Refusal>;
|
|
33
|
-
deleteType(input: DeleteTypeInput): Promise<UriResult | Refusal>;
|
|
34
|
-
listResources(): Promise<StoreResource[]>;
|
|
35
|
-
getResourceMetadata(uri: string): Promise<StoreResource | undefined>;
|
|
36
|
-
listResourceFolder(folder: string): Promise<StoreResource[]>;
|
|
37
|
-
listTypeResources(type: string): Promise<StoreResource[]>;
|
|
38
|
-
readResource(uri: string): Promise<StoreResourceContents | undefined>;
|
|
39
|
-
}
|
|
40
|
-
export interface FindRecordsInput {
|
|
41
|
-
type: string;
|
|
42
|
-
q?: string;
|
|
43
|
-
where?: JsonObject;
|
|
44
|
-
limit?: number;
|
|
45
|
-
fields?: string[];
|
|
46
|
-
cursor?: string;
|
|
47
|
-
}
|
|
48
|
-
export interface GetRecordInput {
|
|
20
|
+
/** A record with its address, identity, and optional display title. */
|
|
21
|
+
export interface AutofileRecord {
|
|
49
22
|
uri: string;
|
|
50
|
-
}
|
|
51
|
-
export interface CreateRecordInput {
|
|
52
23
|
type: string;
|
|
53
|
-
key
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
export interface UpdateRecordInput {
|
|
57
|
-
uri: string;
|
|
58
|
-
patch: JsonObject;
|
|
59
|
-
}
|
|
60
|
-
export interface DeleteRecordInput {
|
|
61
|
-
uri: string;
|
|
62
|
-
}
|
|
63
|
-
export interface GetTypeInput {
|
|
64
|
-
type: string;
|
|
65
|
-
}
|
|
66
|
-
export interface CreateTypeInput {
|
|
67
|
-
type: string;
|
|
68
|
-
description: string;
|
|
69
|
-
schema: JsonObject;
|
|
70
|
-
titleField?: string;
|
|
71
|
-
}
|
|
72
|
-
export interface UpdateTypeInput {
|
|
73
|
-
type: string;
|
|
74
|
-
description?: string;
|
|
75
|
-
schema?: JsonObject;
|
|
76
|
-
titleField?: string | null;
|
|
77
|
-
}
|
|
78
|
-
export interface DeleteTypeInput {
|
|
79
|
-
type: string;
|
|
80
|
-
}
|
|
81
|
-
export interface UriResult {
|
|
82
|
-
uri: string;
|
|
83
|
-
}
|
|
84
|
-
export interface FindRecordsResult {
|
|
85
|
-
records: RecordResult[];
|
|
86
|
-
errors: StoreError[];
|
|
87
|
-
cursor?: string;
|
|
88
|
-
}
|
|
89
|
-
export interface RecordResult extends UriResult {
|
|
24
|
+
key: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
problems?: AutofileProblem[];
|
|
90
27
|
createdAt: string;
|
|
91
28
|
updatedAt: string;
|
|
92
29
|
value: JsonObject;
|
|
93
|
-
error?: string;
|
|
94
30
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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;
|
|
98
39
|
}
|
|
99
|
-
|
|
100
|
-
|
|
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;
|
|
101
48
|
}
|
|
102
|
-
|
|
49
|
+
/** The fields stored in a type declaration. */
|
|
50
|
+
export interface TypeDefinition {
|
|
103
51
|
description: string;
|
|
104
52
|
schema: JsonObject;
|
|
105
53
|
titleField?: string;
|
|
106
|
-
}
|
|
107
|
-
export interface UpdateTypeResult extends UriResult {
|
|
108
|
-
errors: StoreError[];
|
|
109
|
-
}
|
|
110
|
-
/** Plain metadata for one resource recognized in the data folder. */
|
|
111
|
-
export interface StoreResource extends UriResult {
|
|
112
|
-
name: string;
|
|
113
|
-
mimeType: string;
|
|
114
54
|
title?: string;
|
|
115
|
-
description?: string;
|
|
116
|
-
size?: number;
|
|
117
|
-
lastModified?: string;
|
|
118
55
|
}
|
|
119
|
-
/**
|
|
120
|
-
export
|
|
56
|
+
/** A type declaration together with its name and address. */
|
|
57
|
+
export interface TypeDeclaration extends TypeDefinition {
|
|
121
58
|
uri: string;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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;
|
|
128
66
|
};
|
|
129
|
-
/**
|
|
130
|
-
export
|
|
131
|
-
|
|
132
|
-
|
|
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
|
+
}
|