@rizom/brain 0.2.0-alpha.80 → 0.2.0-alpha.82
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 +720 -693
- package/dist/entities.d.ts +25 -5
- package/dist/entities.js +64 -64
- package/dist/entities.js.map +11 -10
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/migrations/entity-service/0001_sleepy_mandroid.sql +1 -0
- package/dist/migrations/entity-service/meta/0001_snapshot.json +139 -0
- package/dist/migrations/entity-service/meta/_journal.json +7 -0
- package/dist/plugins.d.ts +22 -5
- package/dist/plugins.js +71 -71
- package/dist/plugins.js.map +19 -18
- package/dist/services.d.ts +19 -2
- package/dist/services.js +68 -68
- package/dist/services.js.map +10 -9
- package/dist/site.js +178 -178
- package/dist/site.js.map +34 -30
- package/dist/templates.d.ts +3 -3
- package/dist/templates.js.map +1 -1
- package/package.json +1 -1
package/dist/entities.d.ts
CHANGED
|
@@ -79,6 +79,9 @@ interface EntityJobOptions {
|
|
|
79
79
|
priority?: number;
|
|
80
80
|
maxRetries?: number;
|
|
81
81
|
}
|
|
82
|
+
declare const canonicalContentVisibilitySchema: z.ZodEnum<["public", "shared", "restricted"]>;
|
|
83
|
+
type ContentVisibility = z.infer<typeof canonicalContentVisibilitySchema>;
|
|
84
|
+
type RawContentVisibility = ContentVisibility | "private";
|
|
82
85
|
/**
|
|
83
86
|
* Options for entity creation (extends EntityJobOptions with deduplication)
|
|
84
87
|
*/
|
|
@@ -120,6 +123,7 @@ declare const baseEntitySchema: z.ZodObject<{
|
|
|
120
123
|
content: z.ZodString;
|
|
121
124
|
created: z.ZodString;
|
|
122
125
|
updated: z.ZodString;
|
|
126
|
+
visibility: z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodEnum<["public", "shared", "restricted"]>, z.ZodLiteral<"private">]>>, "public" | "shared" | "restricted", "public" | "shared" | "restricted" | "private" | undefined>;
|
|
123
127
|
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
124
128
|
contentHash: z.ZodString;
|
|
125
129
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -128,6 +132,7 @@ declare const baseEntitySchema: z.ZodObject<{
|
|
|
128
132
|
content: string;
|
|
129
133
|
created: string;
|
|
130
134
|
updated: string;
|
|
135
|
+
visibility: "public" | "shared" | "restricted";
|
|
131
136
|
metadata: Record<string, unknown>;
|
|
132
137
|
contentHash: string;
|
|
133
138
|
}, {
|
|
@@ -138,6 +143,7 @@ declare const baseEntitySchema: z.ZodObject<{
|
|
|
138
143
|
updated: string;
|
|
139
144
|
metadata: Record<string, unknown>;
|
|
140
145
|
contentHash: string;
|
|
146
|
+
visibility?: "public" | "shared" | "restricted" | "private" | undefined;
|
|
141
147
|
}>;
|
|
142
148
|
/**
|
|
143
149
|
* Base entity type - generic to support typed metadata
|
|
@@ -149,6 +155,7 @@ interface BaseEntity<TMetadata = Record<string, unknown>> {
|
|
|
149
155
|
content: string;
|
|
150
156
|
created: string;
|
|
151
157
|
updated: string;
|
|
158
|
+
visibility: ContentVisibility;
|
|
152
159
|
metadata: TMetadata;
|
|
153
160
|
/** SHA256 hash of content for change detection */
|
|
154
161
|
contentHash: string;
|
|
@@ -157,10 +164,11 @@ interface BaseEntity<TMetadata = Record<string, unknown>> {
|
|
|
157
164
|
* Entity input type for creation - allows partial entities with optional system fields
|
|
158
165
|
* contentHash is excluded because it's computed automatically by the entity service
|
|
159
166
|
*/
|
|
160
|
-
type EntityInput<T extends BaseEntity> = Omit<T, "id" | "created" | "updated" | "contentHash"> & {
|
|
167
|
+
type EntityInput<T extends BaseEntity> = Omit<T, "id" | "created" | "updated" | "contentHash" | "visibility"> & {
|
|
161
168
|
id?: string;
|
|
162
169
|
created?: string;
|
|
163
170
|
updated?: string;
|
|
171
|
+
visibility?: RawContentVisibility;
|
|
164
172
|
};
|
|
165
173
|
/**
|
|
166
174
|
* Search result type
|
|
@@ -231,7 +239,7 @@ type CreateInterceptor = (input: CreateInput, executionContext: CreateExecutionC
|
|
|
231
239
|
*/
|
|
232
240
|
interface EntityAdapter<TEntity extends BaseEntity<TMetadata>, TMetadata = Record<string, unknown>> {
|
|
233
241
|
entityType: string;
|
|
234
|
-
schema: z.
|
|
242
|
+
schema: z.ZodType<TEntity, z.ZodTypeDef, unknown>;
|
|
235
243
|
toMarkdown(entity: TEntity): string;
|
|
236
244
|
fromMarkdown(markdown: string): Partial<TEntity>;
|
|
237
245
|
extractMetadata(entity: TEntity): TMetadata;
|
|
@@ -272,6 +280,7 @@ interface ListOptions<TMetadata = Record<string, unknown>> {
|
|
|
272
280
|
sortFields?: SortField[];
|
|
273
281
|
filter?: {
|
|
274
282
|
metadata?: Partial<TMetadata>;
|
|
283
|
+
visibilityScope?: ContentVisibility;
|
|
275
284
|
};
|
|
276
285
|
/** Filter to only entities with metadata.status = "published" */
|
|
277
286
|
publishedOnly?: boolean;
|
|
@@ -288,6 +297,7 @@ interface SearchOptions {
|
|
|
288
297
|
sortDirection?: "asc" | "desc";
|
|
289
298
|
/** Score multipliers per entity type - applied after initial search */
|
|
290
299
|
weight?: Record<string, number>;
|
|
300
|
+
visibilityScope?: ContentVisibility;
|
|
291
301
|
}
|
|
292
302
|
/**
|
|
293
303
|
* Configuration for entity type registration
|
|
@@ -309,6 +319,11 @@ interface EntityTypeConfig {
|
|
|
309
319
|
interface GetEntityRequest {
|
|
310
320
|
entityType: string;
|
|
311
321
|
id: string;
|
|
322
|
+
/**
|
|
323
|
+
* Optional visibility scope. Undefined fails closed to "public" — callers
|
|
324
|
+
* with elevated access must opt up explicitly.
|
|
325
|
+
*/
|
|
326
|
+
visibilityScope?: ContentVisibility;
|
|
312
327
|
}
|
|
313
328
|
type GetEntityRawRequest = GetEntityRequest;
|
|
314
329
|
interface ListEntitiesRequest {
|
|
@@ -358,7 +373,12 @@ interface ICoreEntityService {
|
|
|
358
373
|
getEntityTypes(): string[];
|
|
359
374
|
hasEntityType(type: string): boolean;
|
|
360
375
|
countEntities(request: CountEntitiesRequest): Promise<number>;
|
|
361
|
-
|
|
376
|
+
/**
|
|
377
|
+
* Group counts by entity type. Fails closed: undefined visibilityScope
|
|
378
|
+
* filters to public-only counts so aggregate insights cannot reveal
|
|
379
|
+
* non-public entity existence.
|
|
380
|
+
*/
|
|
381
|
+
getEntityCounts(visibilityScope?: ContentVisibility): Promise<Array<{
|
|
362
382
|
entityType: string;
|
|
363
383
|
count: number;
|
|
364
384
|
}>>;
|
|
@@ -397,7 +417,7 @@ interface BodyTemplateProvider {
|
|
|
397
417
|
}
|
|
398
418
|
interface BaseEntityAdapterConfig<TEntity extends BaseEntity<TMetadata>, TMetadata extends object> {
|
|
399
419
|
entityType: string;
|
|
400
|
-
schema: z.
|
|
420
|
+
schema: z.ZodType<TEntity, z.ZodTypeDef, unknown>;
|
|
401
421
|
frontmatterSchema: z.ZodObject<z.ZodRawShape>;
|
|
402
422
|
isSingleton?: boolean;
|
|
403
423
|
hasBody?: boolean;
|
|
@@ -415,7 +435,7 @@ interface BaseEntityAdapterConfig<TEntity extends BaseEntity<TMetadata>, TMetada
|
|
|
415
435
|
*/
|
|
416
436
|
declare abstract class BaseEntityAdapter<TEntity extends BaseEntity<TMetadata>, TMetadata extends object = Record<string, unknown>, TFrontmatter = TMetadata> implements EntityAdapter<TEntity, TMetadata> {
|
|
417
437
|
readonly entityType: string;
|
|
418
|
-
readonly schema: z.
|
|
438
|
+
readonly schema: z.ZodType<TEntity, z.ZodTypeDef, unknown>;
|
|
419
439
|
readonly frontmatterSchema: z.ZodObject<z.ZodRawShape>;
|
|
420
440
|
readonly isSingleton?: boolean;
|
|
421
441
|
readonly hasBody?: boolean;
|