feat: all fields optional
This commit is contained in:
@@ -26,7 +26,7 @@ const init: Migration = {
|
|||||||
table.text('text').nullable();
|
table.text('text').nullable();
|
||||||
table.string('source').nullable();
|
table.string('source').nullable();
|
||||||
table.string('sourceId').nullable();
|
table.string('sourceId').nullable();
|
||||||
table.string('type').notNullable();
|
table.string('type').nullable();
|
||||||
table.integer('typeVersion').nullable();
|
table.integer('typeVersion').nullable();
|
||||||
table.jsonb('metadata').nullable();
|
table.jsonb('metadata').nullable();
|
||||||
|
|
||||||
@@ -78,9 +78,9 @@ type DocumentRow = {
|
|||||||
text: string | null;
|
text: string | null;
|
||||||
source: string | null;
|
source: string | null;
|
||||||
sourceId: string | null;
|
sourceId: string | null;
|
||||||
type: string;
|
type: string | null;
|
||||||
typeVersion: number | null;
|
typeVersion: number | null;
|
||||||
metadata: unknown;
|
metadata: unknown | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DocumentChunkRow = {
|
type DocumentChunkRow = {
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ const documentSchema = z
|
|||||||
text: z.string().nullable(),
|
text: z.string().nullable(),
|
||||||
source: z.string().nullable(),
|
source: z.string().nullable(),
|
||||||
sourceId: z.string().nullable(),
|
sourceId: z.string().nullable(),
|
||||||
type: z.string(),
|
type: z.string().nullable(),
|
||||||
typeVersion: z.int().nullable(),
|
typeVersion: z.int().nullable(),
|
||||||
metadata: z.unknown(),
|
metadata: z.unknown().nullable(),
|
||||||
})
|
})
|
||||||
.meta({ id: 'Document' });
|
.meta({ id: 'Document' });
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ const documentUpsertSchema = z
|
|||||||
text: z.string().nullish(),
|
text: z.string().nullish(),
|
||||||
source: z.string().nullish(),
|
source: z.string().nullish(),
|
||||||
sourceId: z.string().nullish(),
|
sourceId: z.string().nullish(),
|
||||||
type: z.string().optional(),
|
type: z.string().nullish(),
|
||||||
typeVersion: z.int().nullish(),
|
typeVersion: z.int().nullish(),
|
||||||
metadata: z.unknown().nullish(),
|
metadata: z.unknown().nullish(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -120,8 +120,6 @@ class DocumentsService extends EventEmitter<DocumentsServiceEvents> {
|
|||||||
} as const;
|
} as const;
|
||||||
} else {
|
} else {
|
||||||
await trx<TableRows['documents']>(tableNames.documents).insert({
|
await trx<TableRows['documents']>(tableNames.documents).insert({
|
||||||
metadata: {},
|
|
||||||
type: 'raw',
|
|
||||||
...document,
|
...document,
|
||||||
content: base64ToMaybeBuffer(document.content),
|
content: base64ToMaybeBuffer(document.content),
|
||||||
id,
|
id,
|
||||||
@@ -136,7 +134,7 @@ class DocumentsService extends EventEmitter<DocumentsServiceEvents> {
|
|||||||
source: null,
|
source: null,
|
||||||
sourceId: null,
|
sourceId: null,
|
||||||
typeVersion: null,
|
typeVersion: null,
|
||||||
metadata: {},
|
metadata: null,
|
||||||
...document,
|
...document,
|
||||||
content: base64ToMaybeBuffer(document.content) || null,
|
content: base64ToMaybeBuffer(document.content) || null,
|
||||||
deletedAt: null,
|
deletedAt: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user