@rizom/brain 0.2.0-alpha.45 → 0.2.0-alpha.47
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/brain.js +866 -1072
- package/dist/entities.d.ts +154 -0
- package/dist/entities.js +172 -0
- package/dist/entities.js.map +242 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +504 -0
- package/dist/index.js.map +586 -0
- package/dist/interfaces.d.ts +129 -0
- package/dist/interfaces.js +172 -0
- package/dist/interfaces.js.map +285 -0
- package/dist/plugins.d.ts +523 -0
- package/dist/plugins.js +178 -0
- package/dist/plugins.js.map +298 -0
- package/dist/services.d.ts +115 -0
- package/dist/services.js +172 -0
- package/dist/services.js.map +290 -0
- package/dist/site.js +166 -166
- package/dist/site.js.map +17 -17
- package/dist/templates.d.ts +62 -0
- package/dist/templates.js +172 -0
- package/dist/templates.js.map +206 -0
- package/package.json +26 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export interface BaseEntity {
|
|
4
|
+
id: string;
|
|
5
|
+
entityType: string;
|
|
6
|
+
content: string;
|
|
7
|
+
created: string;
|
|
8
|
+
updated: string;
|
|
9
|
+
metadata: Record<string, unknown>;
|
|
10
|
+
contentHash?: string;
|
|
11
|
+
}
|
|
12
|
+
export type EntityInput<T extends BaseEntity = BaseEntity> = Omit<
|
|
13
|
+
T,
|
|
14
|
+
"created" | "updated" | "contentHash"
|
|
15
|
+
> &
|
|
16
|
+
Partial<Pick<T, "created" | "updated" | "contentHash">>;
|
|
17
|
+
export interface EntityMutationResult {
|
|
18
|
+
entityId: string;
|
|
19
|
+
jobId: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateInput {
|
|
22
|
+
entityType: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
content?: string;
|
|
25
|
+
prompt?: string;
|
|
26
|
+
url?: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface CreateExecutionContext {
|
|
30
|
+
interfaceType?: string;
|
|
31
|
+
userId?: string;
|
|
32
|
+
channelId?: string;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
export interface CreateResult {
|
|
36
|
+
entityId: string;
|
|
37
|
+
jobId?: string;
|
|
38
|
+
entityType: string;
|
|
39
|
+
}
|
|
40
|
+
export type CreateInterceptionResult =
|
|
41
|
+
| { kind: "continue"; input: CreateInput }
|
|
42
|
+
| { kind: "handled"; result: CreateResult };
|
|
43
|
+
export type CreateInterceptor = (
|
|
44
|
+
input: CreateInput,
|
|
45
|
+
context: CreateExecutionContext,
|
|
46
|
+
) => Promise<CreateInterceptionResult> | CreateInterceptionResult;
|
|
47
|
+
|
|
48
|
+
export interface EntityAdapter<TEntity extends BaseEntity = BaseEntity> {
|
|
49
|
+
entityType: string;
|
|
50
|
+
schema: z.ZodSchema<TEntity>;
|
|
51
|
+
frontmatterSchema?: z.ZodTypeAny;
|
|
52
|
+
toMarkdown(entity: TEntity): string;
|
|
53
|
+
fromMarkdown(markdown: string, id?: string): TEntity;
|
|
54
|
+
}
|
|
55
|
+
export interface EntityTypeConfig {
|
|
56
|
+
embeddable?: boolean;
|
|
57
|
+
weight?: number;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
}
|
|
60
|
+
export class BaseEntityAdapter<
|
|
61
|
+
TEntity extends BaseEntity = BaseEntity,
|
|
62
|
+
> implements EntityAdapter<TEntity> {
|
|
63
|
+
readonly entityType: string;
|
|
64
|
+
readonly schema: z.ZodSchema<TEntity>;
|
|
65
|
+
readonly frontmatterSchema?: z.ZodTypeAny;
|
|
66
|
+
constructor(config: {
|
|
67
|
+
entityType: string;
|
|
68
|
+
schema: z.ZodSchema<TEntity>;
|
|
69
|
+
frontmatterSchema?: z.ZodTypeAny;
|
|
70
|
+
});
|
|
71
|
+
toMarkdown(entity: TEntity): string;
|
|
72
|
+
fromMarkdown(markdown: string, id?: string): TEntity;
|
|
73
|
+
}
|
|
74
|
+
export const baseEntitySchema: z.ZodSchema<BaseEntity>;
|
|
75
|
+
export const BASE_ENTITY_TYPE: "base";
|
|
76
|
+
|
|
77
|
+
export interface SearchResult<TEntity extends BaseEntity = BaseEntity> {
|
|
78
|
+
entity: TEntity;
|
|
79
|
+
score: number;
|
|
80
|
+
excerpt?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface ListOptions {
|
|
83
|
+
limit?: number;
|
|
84
|
+
offset?: number;
|
|
85
|
+
publishedOnly?: boolean;
|
|
86
|
+
[key: string]: unknown;
|
|
87
|
+
}
|
|
88
|
+
export interface SearchOptions extends ListOptions {
|
|
89
|
+
entityType?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface DataSourceCapabilities {
|
|
93
|
+
list?: boolean;
|
|
94
|
+
get?: boolean;
|
|
95
|
+
search?: boolean;
|
|
96
|
+
generate?: boolean;
|
|
97
|
+
transform?: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface BaseDataSourceContext {
|
|
100
|
+
entityService?: unknown;
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
export interface DataSource<TQuery = unknown, TResult = unknown> {
|
|
104
|
+
id: string;
|
|
105
|
+
name?: string;
|
|
106
|
+
capabilities?: DataSourceCapabilities;
|
|
107
|
+
fetch(query?: TQuery, context?: BaseDataSourceContext): Promise<TResult>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface PaginationInfo {
|
|
111
|
+
page: number;
|
|
112
|
+
pageSize: number;
|
|
113
|
+
totalItems: number;
|
|
114
|
+
totalPages: number;
|
|
115
|
+
hasNext: boolean;
|
|
116
|
+
hasPrevious: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface PaginateOptions {
|
|
119
|
+
page?: number;
|
|
120
|
+
pageSize?: number;
|
|
121
|
+
limit?: number;
|
|
122
|
+
offset?: number;
|
|
123
|
+
}
|
|
124
|
+
export interface PaginateResult<T> {
|
|
125
|
+
items: T[];
|
|
126
|
+
pagination: PaginationInfo;
|
|
127
|
+
}
|
|
128
|
+
export const paginationInfoSchema: z.ZodSchema<PaginationInfo>;
|
|
129
|
+
export function paginateItems<T>(
|
|
130
|
+
items: T[],
|
|
131
|
+
options?: PaginateOptions,
|
|
132
|
+
): PaginateResult<T>;
|
|
133
|
+
export function buildPaginationInfo(
|
|
134
|
+
totalItems: number,
|
|
135
|
+
options?: PaginateOptions,
|
|
136
|
+
): PaginationInfo;
|
|
137
|
+
|
|
138
|
+
export interface FrontmatterConfig {
|
|
139
|
+
includeFields?: string[];
|
|
140
|
+
excludeFields?: string[];
|
|
141
|
+
}
|
|
142
|
+
export function generateMarkdownWithFrontmatter(
|
|
143
|
+
content: string,
|
|
144
|
+
metadata?: Record<string, unknown>,
|
|
145
|
+
config?: FrontmatterConfig,
|
|
146
|
+
): string;
|
|
147
|
+
export function parseMarkdownWithFrontmatter(markdown: string): {
|
|
148
|
+
content: string;
|
|
149
|
+
metadata: Record<string, unknown>;
|
|
150
|
+
};
|
|
151
|
+
export function generateFrontmatter(
|
|
152
|
+
metadata: Record<string, unknown>,
|
|
153
|
+
config?: FrontmatterConfig,
|
|
154
|
+
): string;
|