@undefineds.co/models 0.2.15 → 0.2.18
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 +26 -28
- package/dist/agent.providers.js +11 -0
- package/dist/agent.repository.d.ts +1 -1
- package/dist/ai-config/index.d.ts +10 -2
- package/dist/ai-config/index.js +53 -15
- package/dist/ai-model.schema.js +4 -3
- package/dist/ai-provider.schema.js +1 -1
- package/dist/approval.schema.d.ts +7 -1
- package/dist/approval.schema.js +6 -8
- package/dist/audit.presentation.d.ts +23 -0
- package/dist/audit.presentation.js +275 -0
- package/dist/audit.schema.d.ts +1 -1
- package/dist/audit.schema.js +3 -8
- package/dist/chat.repository.d.ts +1 -1
- package/dist/chat.utils.d.ts +9 -0
- package/dist/chat.utils.js +33 -0
- package/dist/contact.repository.d.ts +1 -1
- package/dist/contact.schema.d.ts +8 -0
- package/dist/contact.schema.js +12 -0
- package/dist/credential.schema.js +1 -1
- package/dist/discovery/models.json +29 -0
- package/dist/discovery/providers.json +10 -0
- package/dist/grant.schema.d.ts +28 -1
- package/dist/grant.schema.js +21 -7
- package/dist/index.d.ts +10 -8
- package/dist/index.js +9 -7
- package/dist/message.repository.d.ts +1 -1
- package/dist/namespaces.js +11 -0
- package/dist/profile.repository.d.ts +7 -7
- package/dist/repository.d.ts +1 -99
- package/dist/repository.js +1 -189
- package/dist/schema.d.ts +34 -0
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.js +1 -1
- package/dist/session/session.schema.d.ts +2 -1
- package/dist/session/session.schema.js +11 -7
- package/dist/session.repository.d.ts +1 -1
- package/dist/sidecar/persistence-mapping.d.ts +2 -2
- package/dist/sidecar/sidecar-events.d.ts +192 -6
- package/dist/sidecar/sidecar-events.js +10 -0
- package/dist/thread.repository.d.ts +1 -1
- package/dist/vocab/sidecar.vocab.d.ts +17 -0
- package/dist/vocab/sidecar.vocab.js +17 -0
- package/dist/watch/index.d.ts +55 -0
- package/dist/watch/index.js +349 -12
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -20,11 +20,12 @@ export * from './profile.js';
|
|
|
20
20
|
export * from './profile.repository.js';
|
|
21
21
|
export * from './profile.schema.js';
|
|
22
22
|
// Contact - 联系人 (unified index for Solid users, external users, and AI agents)
|
|
23
|
-
export { contactTable, ContactClass, ContactType, isAgentContact, isGroupContact, } from './contact.schema.js';
|
|
23
|
+
export { ContactGender, contactTable, ContactClass, ContactType, isAgentContact, isGroupContact, normalizeContactGender, } from './contact.schema.js';
|
|
24
24
|
export { contactRepository } from './contact.repository.js';
|
|
25
25
|
// Chat & Message - 聊天和消息
|
|
26
26
|
export { chatResource, chatTable, } from './chat.schema.js';
|
|
27
27
|
export { chatRepository } from './chat.repository.js';
|
|
28
|
+
export { extractChatIdFromChatRef, extractChatThreadRef, extractThreadIdFromThreadRef, resolveThreadChatId, toTimestamp, } from './chat.utils.js';
|
|
28
29
|
export { threadResource, threadTable, } from './thread.schema.js';
|
|
29
30
|
export { threadRepository } from './thread.repository.js';
|
|
30
31
|
export { messageResource, messageTable, } from './message.schema.js';
|
|
@@ -49,12 +50,13 @@ export { DEFAULT_AGENT_PROVIDERS, } from './agent.providers.js';
|
|
|
49
50
|
// 其他模型
|
|
50
51
|
// ============================================
|
|
51
52
|
// Session - 会话管理
|
|
52
|
-
export { sessionResource, sessionTable,
|
|
53
|
+
export { sessionResource, sessionTable, buildRuntimeSessionIri, extractRuntimeSessionId, } from './session/index.js';
|
|
53
54
|
export { sessionRepository } from './session.repository.js';
|
|
54
55
|
// Approval / Audit / Grant / Inbox Notification
|
|
55
|
-
export { approvalResource, approvalTable,
|
|
56
|
-
export { auditResource, auditTable,
|
|
57
|
-
export {
|
|
56
|
+
export { approvalResource, approvalTable, extractApprovalIdFromApprovalRef, } from './approval.schema.js';
|
|
57
|
+
export { auditResource, auditTable, extractAuditIdFromAuditRef, } from './audit.schema.js';
|
|
58
|
+
export { buildAuditDetailRecord, buildAuditPresentation, createResolvedAuthTimestampsIndex, formatAuditActorRole, formatInboxStatusLabel, } from './audit.presentation.js';
|
|
59
|
+
export { grantResource, grantTable, } from './grant.schema.js';
|
|
58
60
|
export { inboxNotificationTable, } from './inbox-notification.schema.js';
|
|
59
61
|
// Sidecar vocab + runtime contracts
|
|
60
62
|
export { ApprovalVocab, AuditVocab, GrantVocab, InboxNotificationVocab } from './vocab/sidecar.vocab.js';
|
|
@@ -68,10 +70,10 @@ export { extensionSchema } from './extension/index.js';
|
|
|
68
70
|
export { credentialTable, } from "./credential.schema.js";
|
|
69
71
|
export { aiProviderTable, } from "./ai-provider.schema.js";
|
|
70
72
|
export { aiModelTable, } from "./ai-model.schema.js";
|
|
71
|
-
export {
|
|
73
|
+
export { aiConfigModelRef, aiConfigProviderRef, buildAIConfigMutationPlan, buildAIConfigProviderStateMap, getAIConfigDefaultBaseUrl, getAIConfigProviderCatalog, getAIConfigProviderFamilyIds, getAIConfigProviderMetadata, getDefaultAIConfigCredentialId, normalizeAIConfigProviderId, normalizeAIConfigModelId, normalizeAIConfigResourceId, sameAIConfigProviderFamily, } from './ai-config/index.js';
|
|
72
74
|
export { buildAcpPermissionResponse, buildWatchThreadMetadata, buildWatchTranscriptMessages, buildWatchUserInputResponse, createWatchSessionId, detectWatchAuthFailure, formatWatchAutoFallbackMessage, formatWatchBackendAuthMessage, extractWatchSessionIdFromJsonLine, getWatchArchiveRelativePaths, getWatchAuthLoginCommand, looksLikeWatchAuthFailureText, normalizeAcpInteractionRequest, normalizeAcpRequest, normalizeAcpSessionNotification, normalizeCodexAppServerNotification, normalizeCodexAppServerRequest, normalizeWatchCredentialSource, parseWatchClaudeAuthStatus, parseWatchJsonLine, parseWatchJsonProtocolLine, resolveWatchAutoApprovalDecision, resolveWatchCredentialSourceResolution, resolveWatchInteractionAutoResponse, resolveWatchQuestionAnswer, shouldAttemptCloudCredentialProbe, WATCH_EVENTS_FILE_NAME, WATCH_HOME_DIRNAME, WATCH_SESSIONS_DIRNAME, WATCH_SESSION_FILE_NAME, } from './watch/index.js';
|
|
73
75
|
export { applySolidComunicaPatches, } from './comunica-patches.js';
|
|
74
|
-
export { createRepositoryDescriptor, definePodRepository,
|
|
76
|
+
export { createRepositoryDescriptor, definePodRepository, initSolidTables, } from './repository.js';
|
|
75
77
|
// Import Job - 导入任务
|
|
76
78
|
export { importJobSchema } from './import/index.js';
|
|
77
79
|
// ============================================
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const messageRepository: import("
|
|
1
|
+
export declare const messageRepository: import("@undefineds.co/drizzle-solid/dist/core/repository").PodRepositoryDescriptor<import("@undefineds.co/drizzle-solid/dist/core/schema").PodTableWithColumns<import("@undefineds.co/drizzle-solid/dist/core/schema").ResolvedColumns<{
|
|
2
2
|
id: import("@undefineds.co/drizzle-solid/dist/core/schema").PodStringColumn<false, false>;
|
|
3
3
|
chat: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
4
4
|
thread: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
package/dist/namespaces.js
CHANGED
|
@@ -164,8 +164,19 @@ export const UDFS = createNamespace('udfs', 'https://undefineds.co/ns#', {
|
|
|
164
164
|
entry: 'entry',
|
|
165
165
|
context: 'context',
|
|
166
166
|
policy: 'policy',
|
|
167
|
+
pageKind: 'pageKind',
|
|
168
|
+
summary: 'summary',
|
|
169
|
+
body: 'body',
|
|
170
|
+
tags: 'tags',
|
|
171
|
+
source: 'source',
|
|
172
|
+
sourceHash: 'sourceHash',
|
|
173
|
+
compiledAt: 'compiledAt',
|
|
174
|
+
compiledFrom: 'compiledFrom',
|
|
175
|
+
related: 'related',
|
|
167
176
|
approval: 'approval',
|
|
177
|
+
approvalOptions: 'approvalOptions',
|
|
168
178
|
effect: 'effect',
|
|
179
|
+
expiresAt: 'expiresAt',
|
|
169
180
|
riskCeiling: 'riskCeiling',
|
|
170
181
|
revokedAt: 'revokedAt',
|
|
171
182
|
archivedAt: 'archivedAt',
|
|
@@ -20,9 +20,9 @@ export declare const profileRepository: {
|
|
|
20
20
|
field: "name" | "favorite" | "inbox" | "id" | "nick" | "avatar" | "note" | "email" | "phone" | "region" | "gender";
|
|
21
21
|
direction: "asc" | "desc";
|
|
22
22
|
} | undefined;
|
|
23
|
-
cache?: import("
|
|
24
|
-
invalidations: import("
|
|
25
|
-
list: (db: import("
|
|
23
|
+
cache?: import("@undefineds.co/drizzle-solid/dist/core/repository.js").RepositoryCacheOptions;
|
|
24
|
+
invalidations: import("@undefineds.co/drizzle-solid/dist/core/repository.js").RepositoryInvalidations;
|
|
25
|
+
list: (db: import("@undefineds.co/drizzle-solid/dist/driver.js").SolidDatabase, filters?: Record<string, unknown> | undefined) => Promise<{
|
|
26
26
|
id: string;
|
|
27
27
|
name: string;
|
|
28
28
|
nick: string;
|
|
@@ -35,7 +35,7 @@ export declare const profileRepository: {
|
|
|
35
35
|
favorite: string;
|
|
36
36
|
inbox: string;
|
|
37
37
|
}[]>;
|
|
38
|
-
detail: (db: import("
|
|
38
|
+
detail: (db: import("@undefineds.co/drizzle-solid/dist/driver.js").SolidDatabase, id: string) => Promise<{
|
|
39
39
|
id: string;
|
|
40
40
|
name: string;
|
|
41
41
|
nick: string;
|
|
@@ -48,7 +48,7 @@ export declare const profileRepository: {
|
|
|
48
48
|
favorite: string;
|
|
49
49
|
inbox: string;
|
|
50
50
|
} | null>;
|
|
51
|
-
create?: ((db: import("
|
|
51
|
+
create?: ((db: import("@undefineds.co/drizzle-solid/dist/driver.js").SolidDatabase, input: {
|
|
52
52
|
id?: string | undefined;
|
|
53
53
|
name?: string | undefined;
|
|
54
54
|
nick?: string | undefined;
|
|
@@ -73,7 +73,7 @@ export declare const profileRepository: {
|
|
|
73
73
|
favorite: string;
|
|
74
74
|
inbox: string;
|
|
75
75
|
}>) | undefined;
|
|
76
|
-
update?: ((db: import("
|
|
76
|
+
update?: ((db: import("@undefineds.co/drizzle-solid/dist/driver.js").SolidDatabase, id: string, input: {
|
|
77
77
|
id?: string | null | undefined;
|
|
78
78
|
name?: string | null | undefined;
|
|
79
79
|
nick?: string | null | undefined;
|
|
@@ -98,7 +98,7 @@ export declare const profileRepository: {
|
|
|
98
98
|
favorite: string;
|
|
99
99
|
inbox: string;
|
|
100
100
|
}>) | undefined;
|
|
101
|
-
remove?: (db: import("
|
|
101
|
+
remove?: (db: import("@undefineds.co/drizzle-solid/dist/driver.js").SolidDatabase, id: string) => Promise<{
|
|
102
102
|
id: string;
|
|
103
103
|
}>;
|
|
104
104
|
};
|
package/dist/repository.d.ts
CHANGED
|
@@ -1,99 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export interface AnyPodTable {
|
|
3
|
-
resolveUri?: (id: string) => string;
|
|
4
|
-
config?: {
|
|
5
|
-
name?: string;
|
|
6
|
-
base?: string;
|
|
7
|
-
};
|
|
8
|
-
getResourcePath?: () => string;
|
|
9
|
-
}
|
|
10
|
-
export interface PodExecutableQuery<TRow = unknown> {
|
|
11
|
-
where(condition: unknown): PodExecutableQuery<TRow>;
|
|
12
|
-
whereByIri?(iri: string | string[]): PodExecutableQuery<TRow>;
|
|
13
|
-
orderBy(...args: unknown[]): PodExecutableQuery<TRow>;
|
|
14
|
-
execute(): Promise<TRow[]>;
|
|
15
|
-
}
|
|
16
|
-
export interface PodInsertQuery {
|
|
17
|
-
values(values: unknown): {
|
|
18
|
-
execute(): Promise<unknown[]>;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export interface PodUpdateQuery {
|
|
22
|
-
set(values: unknown): PodMutationQuery;
|
|
23
|
-
}
|
|
24
|
-
export interface PodMutationQuery {
|
|
25
|
-
where(condition: unknown): PodMutationQuery;
|
|
26
|
-
whereByIri?(iri: string): PodMutationQuery;
|
|
27
|
-
execute(): Promise<unknown[]>;
|
|
28
|
-
}
|
|
29
|
-
export interface SolidDatabase<TSchema extends Record<string, unknown> = Record<string, unknown>> {
|
|
30
|
-
init?(tables: AnyPodTable[] | AnyPodTable, ...rest: unknown[]): Promise<void>;
|
|
31
|
-
select(fields?: unknown): {
|
|
32
|
-
from(table: AnyPodTable): PodExecutableQuery;
|
|
33
|
-
};
|
|
34
|
-
insert(table: AnyPodTable): PodInsertQuery;
|
|
35
|
-
update(table: AnyPodTable): PodUpdateQuery;
|
|
36
|
-
delete(table: AnyPodTable): PodMutationQuery;
|
|
37
|
-
findByIri?<T = unknown>(table: AnyPodTable, iri: string): Promise<T | null>;
|
|
38
|
-
updateByIri?<T = unknown>(table: AnyPodTable, iri: string, data: Record<string, unknown>): Promise<T | null>;
|
|
39
|
-
deleteByIri?(table: AnyPodTable, iri: string): Promise<unknown>;
|
|
40
|
-
subscribe?(table: AnyPodTable, options: unknown): Promise<{
|
|
41
|
-
unsubscribe?: () => void;
|
|
42
|
-
} | (() => void)>;
|
|
43
|
-
}
|
|
44
|
-
export declare function initSolidTables(db: SolidDatabase, tables: AnyPodTable[]): Promise<void>;
|
|
45
|
-
export declare function resolvePodUri(webId: string, table: {
|
|
46
|
-
resolveUri?: (id: string) => string;
|
|
47
|
-
}, id: string): string;
|
|
48
|
-
export declare function findPodRowByStorageId<T>(db: SolidDatabase, webId: string, table: AnyPodTable, id: string): Promise<T | null>;
|
|
49
|
-
export declare function whereByPodStorageId<TTable extends AnyPodTable>(webId: string, table: TTable, query: PodMutationQuery, id: string): PodMutationQuery;
|
|
50
|
-
export interface RepositoryCacheOptions {
|
|
51
|
-
staleTime?: number;
|
|
52
|
-
gcTime?: number;
|
|
53
|
-
}
|
|
54
|
-
export type RepositoryScope = 'list' | 'detail' | string;
|
|
55
|
-
export interface RepositoryInvalidations {
|
|
56
|
-
create?: RepositoryScope[];
|
|
57
|
-
update?: RepositoryScope[];
|
|
58
|
-
remove?: RepositoryScope[];
|
|
59
|
-
}
|
|
60
|
-
export interface RepositoryFilterContext<TTable extends PodTable<any>, Filters> {
|
|
61
|
-
table: TTable;
|
|
62
|
-
filters?: Filters;
|
|
63
|
-
}
|
|
64
|
-
export interface PodRepositoryDescriptor<TTable extends PodTable<any>, Row extends Record<string, unknown> = InferTableData<TTable>, Insert = InferInsertData<TTable>, Update = InferUpdateData<TTable>, Filters extends Record<string, unknown> = Record<string, unknown>> {
|
|
65
|
-
namespace: string;
|
|
66
|
-
resourcePath: string;
|
|
67
|
-
searchableFields?: (keyof Row & string)[];
|
|
68
|
-
defaultSort?: {
|
|
69
|
-
field: keyof Row & string;
|
|
70
|
-
direction: 'asc' | 'desc';
|
|
71
|
-
};
|
|
72
|
-
cache?: RepositoryCacheOptions;
|
|
73
|
-
invalidations: RepositoryInvalidations;
|
|
74
|
-
list: (db: SolidDatabase, filters?: Filters) => Promise<Row[]>;
|
|
75
|
-
detail: (db: SolidDatabase, id: string) => Promise<Row | null>;
|
|
76
|
-
create?: (db: SolidDatabase, input: Insert) => Promise<Row>;
|
|
77
|
-
update?: (db: SolidDatabase, id: string, input: Update) => Promise<Row>;
|
|
78
|
-
remove?: (db: SolidDatabase, id: string) => Promise<{
|
|
79
|
-
id: string;
|
|
80
|
-
}>;
|
|
81
|
-
}
|
|
82
|
-
export interface PodRepositoryOptions<TTable extends PodTable<any>, Row extends Record<string, unknown> = InferTableData<TTable>, Filters extends Record<string, unknown> = Record<string, unknown>> {
|
|
83
|
-
namespace: string;
|
|
84
|
-
table: TTable;
|
|
85
|
-
searchableFields?: (keyof Row & string)[];
|
|
86
|
-
searchAccessor?: (filters?: Filters) => string | undefined;
|
|
87
|
-
defaultSort?: {
|
|
88
|
-
field: keyof Row & string;
|
|
89
|
-
direction: 'asc' | 'desc';
|
|
90
|
-
};
|
|
91
|
-
cache?: RepositoryCacheOptions;
|
|
92
|
-
invalidations?: Partial<RepositoryInvalidations>;
|
|
93
|
-
transform?: (row: Row) => Row;
|
|
94
|
-
filter?: (context: RepositoryFilterContext<TTable, Filters>) => QueryCondition | undefined;
|
|
95
|
-
disableMutations?: Partial<Record<'create' | 'update' | 'remove', boolean>>;
|
|
96
|
-
}
|
|
97
|
-
export declare function resolveRowId(row: Partial<Record<string, unknown>> | null): string | null;
|
|
98
|
-
export declare function createRepositoryDescriptor<TTable extends PodTable<any>, Row extends Record<string, unknown> = InferTableData<TTable>, Insert = InferInsertData<TTable>, Update = InferUpdateData<TTable>, Filters extends Record<string, unknown> = Record<string, unknown>>(options: PodRepositoryOptions<TTable, Row, Filters>): PodRepositoryDescriptor<TTable, Row, Insert, Update, Filters>;
|
|
99
|
-
export declare const definePodRepository: typeof createRepositoryDescriptor;
|
|
1
|
+
export { createRepositoryDescriptor, definePodRepository, initSolidTables, type AnyPodTable, type PodRepositoryDescriptor, type RepositoryCacheOptions, type RepositoryInvalidations, type RepositoryScope, type SolidDatabase, } from '@undefineds.co/drizzle-solid';
|
package/dist/repository.js
CHANGED
|
@@ -1,189 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export async function initSolidTables(db, tables) {
|
|
3
|
-
await db.init?.(tables);
|
|
4
|
-
}
|
|
5
|
-
export function resolvePodUri(webId, table, id) {
|
|
6
|
-
const relativeUri = typeof table.resolveUri === 'function' ? table.resolveUri(id) : id;
|
|
7
|
-
if (/^https?:\/\//.test(relativeUri)) {
|
|
8
|
-
return relativeUri;
|
|
9
|
-
}
|
|
10
|
-
return new URL(relativeUri.replace(/^\//, ''), `${resolvePodBaseUrl(webId)}/`).toString();
|
|
11
|
-
}
|
|
12
|
-
export async function findPodRowByStorageId(db, webId, table, id) {
|
|
13
|
-
if (typeof db.findByIri === 'function') {
|
|
14
|
-
return await db.findByIri(table, resolvePodUri(webId, table, id));
|
|
15
|
-
}
|
|
16
|
-
const rows = await db.select().from(table).execute();
|
|
17
|
-
return rows.find((row) => row?.id === id) ?? null;
|
|
18
|
-
}
|
|
19
|
-
export function whereByPodStorageId(webId, table, query, id) {
|
|
20
|
-
if (typeof query.whereByIri === 'function') {
|
|
21
|
-
return query.whereByIri(resolvePodUri(webId, table, id));
|
|
22
|
-
}
|
|
23
|
-
return query.where({ id });
|
|
24
|
-
}
|
|
25
|
-
function resolvePodBaseUrl(webId) {
|
|
26
|
-
try {
|
|
27
|
-
const target = new URL(webId);
|
|
28
|
-
const pathParts = target.pathname.split('/').filter(Boolean);
|
|
29
|
-
const ownerSegment = pathParts[0] ?? '';
|
|
30
|
-
return `${target.origin}/${ownerSegment}`.replace(/\/+$/, '');
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return webId.replace('/profile/card#me', '').replace(/\/$/, '');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export function resolveRowId(row) {
|
|
37
|
-
if (!row)
|
|
38
|
-
return null;
|
|
39
|
-
// Try @id first (standard RDF format)
|
|
40
|
-
const subject = row['@id'] ?? row.subject;
|
|
41
|
-
if (typeof subject === 'string' && subject.length > 0)
|
|
42
|
-
return subject;
|
|
43
|
-
// Try id field
|
|
44
|
-
const id = row.id;
|
|
45
|
-
if (typeof id === 'string' && id.length > 0)
|
|
46
|
-
return id;
|
|
47
|
-
// Handle drizzle-solid insert result format: {success: true, source: 'http://...'}
|
|
48
|
-
const source = row.source;
|
|
49
|
-
if (typeof source === 'string' && source.length > 0)
|
|
50
|
-
return source;
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
export function createRepositoryDescriptor(options) {
|
|
54
|
-
const { namespace, table, searchableFields, defaultSort, cache, } = options;
|
|
55
|
-
const searchAccessor = options.searchAccessor ?? ((filters) => {
|
|
56
|
-
const value = filters ? filters.search : undefined;
|
|
57
|
-
return typeof value === 'string' ? value : undefined;
|
|
58
|
-
});
|
|
59
|
-
const transformRow = options.transform ?? ((row) => row);
|
|
60
|
-
const invalidations = {
|
|
61
|
-
create: options.invalidations?.create ?? ['list'],
|
|
62
|
-
update: options.invalidations?.update ?? ['list', 'detail'],
|
|
63
|
-
remove: options.invalidations?.remove ?? ['list', 'detail'],
|
|
64
|
-
};
|
|
65
|
-
const resolveColumn = (field) => {
|
|
66
|
-
const column = table[field];
|
|
67
|
-
if (column)
|
|
68
|
-
return column;
|
|
69
|
-
const tableName = table.config?.name;
|
|
70
|
-
return tableName ? `${tableName}.${field}` : field;
|
|
71
|
-
};
|
|
72
|
-
const buildWhereClause = (filters) => {
|
|
73
|
-
const clauses = [];
|
|
74
|
-
const term = searchAccessor(filters)?.trim();
|
|
75
|
-
if (term && searchableFields?.length) {
|
|
76
|
-
const pattern = `%${term}%`;
|
|
77
|
-
const searchClauses = searchableFields
|
|
78
|
-
.map((field) => like(resolveColumn(field), pattern));
|
|
79
|
-
if (searchClauses.length === 1) {
|
|
80
|
-
clauses.push(searchClauses[0]);
|
|
81
|
-
}
|
|
82
|
-
else if (searchClauses.length > 1) {
|
|
83
|
-
clauses.push(or(...searchClauses));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const customFilter = options.filter?.({ table, filters });
|
|
87
|
-
if (customFilter) {
|
|
88
|
-
clauses.push(customFilter);
|
|
89
|
-
}
|
|
90
|
-
if (clauses.length === 0)
|
|
91
|
-
return undefined;
|
|
92
|
-
return clauses.length === 1 ? clauses[0] : and(...clauses);
|
|
93
|
-
};
|
|
94
|
-
const list = async (db, filters) => {
|
|
95
|
-
let query = db.select().from(table);
|
|
96
|
-
const whereClause = buildWhereClause(filters);
|
|
97
|
-
if (whereClause) {
|
|
98
|
-
query = query.where(whereClause);
|
|
99
|
-
}
|
|
100
|
-
if (defaultSort) {
|
|
101
|
-
query = query.orderBy(resolveColumn(defaultSort.field), defaultSort.direction);
|
|
102
|
-
}
|
|
103
|
-
const rows = await query.execute();
|
|
104
|
-
return rows.map((row) => transformRow(row));
|
|
105
|
-
};
|
|
106
|
-
const detail = async (db, id) => {
|
|
107
|
-
const record = typeof db.findByIri === 'function'
|
|
108
|
-
? await db.findByIri(table, id)
|
|
109
|
-
: null;
|
|
110
|
-
return record ? transformRow(record) : null;
|
|
111
|
-
};
|
|
112
|
-
const create = options.disableMutations?.create
|
|
113
|
-
? undefined
|
|
114
|
-
: async (db, input) => {
|
|
115
|
-
// Generate an ID if not provided
|
|
116
|
-
const inputId = input.id;
|
|
117
|
-
const generatedId = typeof inputId === 'string' && inputId.length > 0
|
|
118
|
-
? inputId
|
|
119
|
-
: crypto.randomUUID();
|
|
120
|
-
const inputWithId = { ...input, id: generatedId };
|
|
121
|
-
const result = await db.insert(table).values(inputWithId).execute();
|
|
122
|
-
// drizzle-solid returns [{success, source}] or the created row
|
|
123
|
-
const firstResult = Array.isArray(result) ? result?.[0] : result;
|
|
124
|
-
// If result is actual row data (not drizzle-solid success format), return it
|
|
125
|
-
if (firstResult && typeof firstResult === 'object' && !('success' in firstResult)) {
|
|
126
|
-
return transformRow(firstResult);
|
|
127
|
-
}
|
|
128
|
-
// Handle drizzle-solid format: {success: true, source: "http://..."}
|
|
129
|
-
const sourceUrl = firstResult && typeof firstResult === 'object' && 'source' in firstResult
|
|
130
|
-
? firstResult.source
|
|
131
|
-
: null;
|
|
132
|
-
// Return synthetic row immediately for optimistic update
|
|
133
|
-
// The real data will be fetched via invalidateQueries
|
|
134
|
-
const baseUrl = sourceUrl ? sourceUrl.replace(/\/[^/]+\.ttl$/, '') : '';
|
|
135
|
-
const syntheticId = sourceUrl
|
|
136
|
-
? `${baseUrl}/${generatedId}.ttl`
|
|
137
|
-
: generatedId;
|
|
138
|
-
return {
|
|
139
|
-
...inputWithId,
|
|
140
|
-
id: generatedId,
|
|
141
|
-
'@id': syntheticId,
|
|
142
|
-
subject: syntheticId,
|
|
143
|
-
source: sourceUrl,
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
const update = options.disableMutations?.update
|
|
147
|
-
? undefined
|
|
148
|
-
: async (db, id, input) => {
|
|
149
|
-
const query = db
|
|
150
|
-
.update(table)
|
|
151
|
-
.set(input);
|
|
152
|
-
const scopedQuery = typeof query.whereByIri === 'function'
|
|
153
|
-
? query.whereByIri(id)
|
|
154
|
-
: query.where({ '@id': id });
|
|
155
|
-
await scopedQuery.execute();
|
|
156
|
-
const next = await detail(db, id);
|
|
157
|
-
if (!next) {
|
|
158
|
-
throw new Error(`Failed to load ${namespace} record after update`);
|
|
159
|
-
}
|
|
160
|
-
return next;
|
|
161
|
-
};
|
|
162
|
-
const remove = options.disableMutations?.remove
|
|
163
|
-
? undefined
|
|
164
|
-
: async (db, id) => {
|
|
165
|
-
const query = db.delete(table);
|
|
166
|
-
const scopedQuery = typeof query.whereByIri === 'function'
|
|
167
|
-
? query.whereByIri(id)
|
|
168
|
-
: query.where({ '@id': id });
|
|
169
|
-
await scopedQuery.execute();
|
|
170
|
-
return { id };
|
|
171
|
-
};
|
|
172
|
-
const resourcePath = typeof table.getResourcePath === 'function'
|
|
173
|
-
? table.getResourcePath()
|
|
174
|
-
: (table.config?.base ?? '');
|
|
175
|
-
return {
|
|
176
|
-
namespace,
|
|
177
|
-
resourcePath,
|
|
178
|
-
searchableFields,
|
|
179
|
-
defaultSort,
|
|
180
|
-
cache,
|
|
181
|
-
invalidations,
|
|
182
|
-
list,
|
|
183
|
-
detail,
|
|
184
|
-
create,
|
|
185
|
-
update,
|
|
186
|
-
remove,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
export const definePodRepository = createRepositoryDescriptor;
|
|
1
|
+
export { createRepositoryDescriptor, definePodRepository, initSolidTables, } from '@undefineds.co/drizzle-solid';
|
package/dist/schema.d.ts
CHANGED
|
@@ -204,8 +204,11 @@ export declare const solidResources: {
|
|
|
204
204
|
decisionRole: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
205
205
|
onBehalfOf: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
206
206
|
reason: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
207
|
+
context: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
208
|
+
approvalOptions: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
207
209
|
policyVersion: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
208
210
|
createdAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
|
211
|
+
expiresAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
209
212
|
resolvedAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
210
213
|
}>>;
|
|
211
214
|
auditResource: import("@undefineds.co/drizzle-solid/dist/core/schema").PodTableWithColumns<import("@undefineds.co/drizzle-solid/dist/core/schema").ResolvedColumns<{
|
|
@@ -228,8 +231,22 @@ export declare const solidResources: {
|
|
|
228
231
|
rdfType: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "uri", true, true>;
|
|
229
232
|
target: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
230
233
|
action: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
234
|
+
title: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
235
|
+
summary: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
236
|
+
body: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
237
|
+
schema: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
238
|
+
pageKind: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
239
|
+
wikiStatus: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
240
|
+
tags: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
241
|
+
source: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
242
|
+
sourceHash: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
243
|
+
compiledAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
244
|
+
compiledFrom: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "uri", false, false>;
|
|
245
|
+
related: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "uri", false, false>;
|
|
231
246
|
effect: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
232
247
|
riskCeiling: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
248
|
+
policy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
249
|
+
context: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
233
250
|
decisionBy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
234
251
|
decisionRole: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
235
252
|
onBehalfOf: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
@@ -450,8 +467,11 @@ export declare const solidSchema: {
|
|
|
450
467
|
decisionRole: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
451
468
|
onBehalfOf: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
452
469
|
reason: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
470
|
+
context: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
471
|
+
approvalOptions: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
453
472
|
policyVersion: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
454
473
|
createdAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
|
474
|
+
expiresAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
455
475
|
resolvedAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
456
476
|
}>>;
|
|
457
477
|
auditTable: import("@undefineds.co/drizzle-solid/dist/core/schema").PodTableWithColumns<import("@undefineds.co/drizzle-solid/dist/core/schema").ResolvedColumns<{
|
|
@@ -474,8 +494,22 @@ export declare const solidSchema: {
|
|
|
474
494
|
rdfType: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "uri", true, true>;
|
|
475
495
|
target: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
476
496
|
action: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
497
|
+
title: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
498
|
+
summary: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
499
|
+
body: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
500
|
+
schema: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
501
|
+
pageKind: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
502
|
+
wikiStatus: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
503
|
+
tags: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
504
|
+
source: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
505
|
+
sourceHash: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
506
|
+
compiledAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
507
|
+
compiledFrom: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "uri", false, false>;
|
|
508
|
+
related: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "uri", false, false>;
|
|
477
509
|
effect: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
478
510
|
riskCeiling: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
511
|
+
policy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
512
|
+
context: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
479
513
|
decisionBy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
480
514
|
decisionRole: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
481
515
|
onBehalfOf: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
package/dist/session/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { sessionResource, sessionTable,
|
|
1
|
+
export { sessionResource, sessionTable, buildRuntimeSessionIri, extractRuntimeSessionId, type SessionType, type SessionStatus, type SessionRow, type SessionInsert, type SessionUpdate, } from './session.schema';
|
package/dist/session/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { sessionResource, sessionTable,
|
|
1
|
+
export { sessionResource, sessionTable, buildRuntimeSessionIri, extractRuntimeSessionId, } from './session.schema.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type SessionType = 'direct' | 'group' | 'imported-readonly';
|
|
2
2
|
export type SessionStatus = 'active' | 'paused' | 'completed' | 'error' | 'archived';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function buildRuntimeSessionIri(sessionId: string): string;
|
|
4
|
+
export declare function extractRuntimeSessionId(sessionRef: string | null | undefined): string | null;
|
|
4
5
|
/**
|
|
5
6
|
* Runtime / collaboration session resource.
|
|
6
7
|
*
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { object, podTable, string, timestamp, uri, id, integer } from '@undefineds.co/drizzle-solid';
|
|
1
|
+
import { extractPodResourceTemplateValue, object, podTable, string, timestamp, uri, id, integer } from '@undefineds.co/drizzle-solid';
|
|
2
2
|
import { DCTerms, UDFS } from '../namespaces.js';
|
|
3
3
|
import { chatResource } from '../chat.schema.js';
|
|
4
4
|
import { threadResource } from '../thread.schema.js';
|
|
5
|
-
export function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export function buildRuntimeSessionIri(sessionId) {
|
|
6
|
+
return `urn:linx:runtime-session:${sessionId}`;
|
|
7
|
+
}
|
|
8
|
+
export function extractRuntimeSessionId(sessionRef) {
|
|
9
|
+
if (!sessionRef)
|
|
10
|
+
return null;
|
|
11
|
+
const runtimeMatch = sessionRef.match(/^urn:linx:runtime-session:(.+)$/);
|
|
12
|
+
if (runtimeMatch?.[1])
|
|
13
|
+
return runtimeMatch[1];
|
|
14
|
+
return extractPodResourceTemplateValue(sessionResource, sessionRef);
|
|
11
15
|
}
|
|
12
16
|
/**
|
|
13
17
|
* Runtime / collaboration session resource.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const sessionRepository: import("
|
|
1
|
+
export declare const sessionRepository: import("@undefineds.co/drizzle-solid/dist/core/repository").PodRepositoryDescriptor<import("@undefineds.co/drizzle-solid/dist/core/schema").PodTableWithColumns<import("@undefineds.co/drizzle-solid/dist/core/schema").ResolvedColumns<{
|
|
2
2
|
id: import("@undefineds.co/drizzle-solid/dist/core/schema").PodStringColumn<false, false>;
|
|
3
3
|
ownerWebId: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
4
4
|
chat: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
@@ -9,10 +9,10 @@ export type ChatSessionProjection = {
|
|
|
9
9
|
policy?: string;
|
|
10
10
|
policyVersion?: string;
|
|
11
11
|
};
|
|
12
|
-
export type ApprovalProjectionInsert = Pick<ApprovalInsert, 'session' | 'toolCallId' | 'toolName' | 'target' | 'action' | 'risk' | 'status' | 'policyVersion'>;
|
|
12
|
+
export type ApprovalProjectionInsert = Pick<ApprovalInsert, 'session' | 'toolCallId' | 'toolName' | 'target' | 'action' | 'risk' | 'status' | 'context' | 'approvalOptions' | 'policyVersion' | 'expiresAt'>;
|
|
13
13
|
export type ApprovalProjectionUpdate = Partial<Pick<ApprovalUpdate, 'status' | 'assignedTo' | 'decisionBy' | 'decisionRole' | 'onBehalfOf' | 'reason' | 'policyVersion' | 'resolvedAt'>>;
|
|
14
14
|
export type AuditProjectionInsert = Pick<AuditInsert, 'action' | 'actor' | 'actorRole' | 'onBehalfOf' | 'session' | 'entry' | 'toolCallId' | 'toolName' | 'approval' | 'policy' | 'policyVersion'>;
|
|
15
|
-
export type GrantProjectionInsert = Pick<GrantInsert, 'target' | 'action' | 'effect' | 'riskCeiling' | 'decisionBy' | 'decisionRole' | 'onBehalfOf'>;
|
|
15
|
+
export type GrantProjectionInsert = Pick<GrantInsert, 'target' | 'action' | 'title' | 'summary' | 'body' | 'schema' | 'pageKind' | 'wikiStatus' | 'tags' | 'source' | 'sourceHash' | 'compiledAt' | 'compiledFrom' | 'related' | 'effect' | 'riskCeiling' | 'policy' | 'context' | 'decisionBy' | 'decisionRole' | 'onBehalfOf'>;
|
|
16
16
|
export type InboxNotificationProjectionInsert = Pick<InboxNotificationInsert, 'actor' | 'object'>;
|
|
17
17
|
export declare const SidecarEventToPodMapping: {
|
|
18
18
|
readonly tool_call_waiting_approval: {
|