@synap-core/types 0.3.3 → 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.
@@ -1,14 +1,64 @@
1
- import { Document } from '@synap/database/schema';
2
- export { Document, DocumentSession, DocumentVersion, NewDocument, NewDocumentSession, NewDocumentVersion } from '@synap/database/schema';
3
-
4
1
  /**
5
2
  * Document Types
6
3
  *
7
- * Re-exports document types from database schema (single source of truth).
8
- *
9
- * @see {@link file:///.../packages/database/src/schema/documents.ts}
4
+ * Standalone type definitions for documents.
5
+ * Compatible with @synap/database schema but works independently.
6
+ */
7
+ /**
8
+ * Document - Rich text document with version history
9
+ */
10
+ interface Document {
11
+ id: string;
12
+ userId: string;
13
+ title: string | null;
14
+ type: 'note' | 'whiteboard' | 'canvas' | 'code' | 'other';
15
+ content?: string;
16
+ yjsState?: Uint8Array;
17
+ contentFormat: 'markdown' | 'prosemirror' | 'tiptap' | 'yjs' | 'raw';
18
+ version: number;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ deletedAt?: Date;
22
+ }
23
+ /**
24
+ * NewDocument - For creating a new document
25
+ */
26
+ type NewDocument = Omit<Document, 'id' | 'version' | 'createdAt' | 'updatedAt' | 'deletedAt'>;
27
+ /**
28
+ * UpdateDocument - For updating a document
10
29
  */
11
-
12
30
  type UpdateDocument = Partial<Omit<Document, 'id' | 'userId' | 'createdAt' | 'updatedAt'>>;
31
+ /**
32
+ * DocumentVersion - Version history entry
33
+ */
34
+ interface DocumentVersion {
35
+ id: string;
36
+ documentId: string;
37
+ userId: string;
38
+ version: number;
39
+ content?: string;
40
+ yjsState?: Uint8Array;
41
+ message?: string;
42
+ createdAt: Date;
43
+ }
44
+ /**
45
+ * NewDocumentVersion - For creating a version
46
+ */
47
+ type NewDocumentVersion = Omit<DocumentVersion, 'id' | 'createdAt'>;
48
+ /**
49
+ * DocumentSession - Collaboration session
50
+ */
51
+ interface DocumentSession {
52
+ id: string;
53
+ documentId: string;
54
+ userId: string;
55
+ cursorPosition?: string;
56
+ lastActivity: Date;
57
+ createdAt: Date;
58
+ }
59
+ /**
60
+ * NewDocumentSession - For creating a session
61
+ */
62
+ type NewDocumentSession = Omit<DocumentSession, 'id' | 'createdAt' | 'lastActivity'>;
13
63
 
14
- export type { UpdateDocument };
64
+ export type { Document, DocumentSession, DocumentVersion, NewDocument, NewDocumentSession, NewDocumentVersion, UpdateDocument };
@@ -1,5 +1,4 @@
1
1
  import { z } from 'zod';
2
- export { Entity as DBEntity, NewEntity as NewEntityDB } from '@synap/database/schema';
3
2
 
4
3
  /**
5
4
  * Entity Metadata Schemas
@@ -363,9 +362,8 @@ declare function safeValidateEntityMetadata<T extends EntityType>(type: T, metad
363
362
  /**
364
363
  * Entity Types
365
364
  *
366
- * Re-exports base entity types from database and adds discriminated unions.
367
- *
368
- * @see {@link file:///.../packages/database/src/schema/entities.ts}
365
+ * Standalone entity type definitions with discriminated unions.
366
+ * Works independently without @synap/database.
369
367
  */
370
368
 
371
369
  /**
@@ -1,12 +1,10 @@
1
1
  import { z } from 'zod';
2
- export { InboxItem as DBInboxItem, NewInboxItem } from '@synap/database/schema';
3
2
 
4
3
  /**
5
4
  * Inbox Item Schemas & Types
6
5
  *
7
- * Re-exports inbox types from database and adds provider-specific schemas.
8
- *
9
- * @see {@link file:///.../packages/database/src/schema/inbox-items.ts}
6
+ * Standalone inbox type definitions.
7
+ * Works independently without @synap/database.
10
8
  */
11
9
 
12
10
  /**
@@ -88,8 +86,8 @@ declare const INBOX_SCHEMAS: {
88
86
  count: number;
89
87
  }>, "many">>;
90
88
  }, "strip", z.ZodTypeAny, {
91
- channel: string;
92
89
  user: string;
90
+ channel: string;
93
91
  text: string;
94
92
  threadTs?: string | undefined;
95
93
  reactions?: {
@@ -97,8 +95,8 @@ declare const INBOX_SCHEMAS: {
97
95
  count: number;
98
96
  }[] | undefined;
99
97
  }, {
100
- channel: string;
101
98
  user: string;
99
+ channel: string;
102
100
  text: string;
103
101
  threadTs?: string | undefined;
104
102
  reactions?: {
@@ -142,6 +140,10 @@ type InboxItem = {
142
140
  data: InboxItemData[K];
143
141
  };
144
142
  }[InboxItemType];
143
+ /**
144
+ * NewInboxItem - For creating new inbox items
145
+ */
146
+ type NewInboxItem = Omit<InboxItem, 'id' | 'createdAt' | 'updatedAt'>;
145
147
  /**
146
148
  * Specific inbox item types
147
149
  */
@@ -161,4 +163,4 @@ declare function isEmailInboxItem(item: InboxItem): item is EmailInboxItem;
161
163
  declare function isCalendarInboxItem(item: InboxItem): item is CalendarInboxItem;
162
164
  declare function isSlackInboxItem(item: InboxItem): item is SlackInboxItem;
163
165
 
164
- export { type CalendarInboxItem, type EmailInboxItem, INBOX_SCHEMAS, type InboxItem, type InboxItemType, type SlackInboxItem, isCalendarInboxItem, isEmailInboxItem, isSlackInboxItem };
166
+ export { type CalendarInboxItem, type EmailInboxItem, INBOX_SCHEMAS, type InboxItem, type InboxItemType, type NewInboxItem, type SlackInboxItem, isCalendarInboxItem, isEmailInboxItem, isSlackInboxItem };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export { BaseEntity, ENTITY_SCHEMAS, Entity, EntityMetadata, EntityType, Event, File, NewEntity, Note, Person, Task, UpdateEntity, isEntityOfType, isEvent, isFile, isNote, isPerson, isTask, safeValidateEntityMetadata, validateEntityMetadata } from './entities/index.js';
2
- export { UpdateDocument } from './documents/index.js';
3
- export { Entity as DBEntity, InboxItem as DBInboxItem, Document, DocumentSession, DocumentVersion, EntityEnrichment, EntityRelationship, NewDocument, NewDocumentSession, NewDocumentVersion, NewEntity as NewEntityDB, NewEntityEnrichment, NewEntityRelationship, NewInboxItem, NewReasoningTrace, NewRelation, NewUserEntityState, NewUserPreference as NewUserPreferences, NewView, NewWorkspace, NewWorkspaceInvite, NewWorkspaceMember, ReasoningTrace, Relation, UserEntityState, UserPreference as UserPreferences, View, Workspace, WorkspaceInvite, WorkspaceMember } from '@synap/database/schema';
4
- export { CalendarInboxItem, EmailInboxItem, INBOX_SCHEMAS, InboxItem, InboxItemType, SlackInboxItem, isCalendarInboxItem, isEmailInboxItem, isSlackInboxItem } from './inbox/index.js';
5
- export { CreateWorkspaceInput, InviteMemberInput, UpdateWorkspaceInput, WorkspaceRole, WorkspaceType } from './workspaces/index.js';
6
- export { CalendarConfig, ColumnDefinition, CreateViewInput, FilterRule, GanttConfig, GridConfig, KanbanConfig, ListConfig, SaveViewInput, SortRule, SwitchViewLayoutInput, TableViewConfig, UpdateViewInput, ViewType } from './views/index.js';
7
- export { CreateRelationInput, RelationType, RelationWithEntities } from './relations/index.js';
8
- export { Theme, UpdatePreferencesInput } from './preferences/index.js';
2
+ export { Document, DocumentSession, DocumentVersion, NewDocument, NewDocumentSession, NewDocumentVersion, UpdateDocument } from './documents/index.js';
3
+ export { EntityEnrichment, EntityRelationship, NewEntityEnrichment, NewEntityRelationship, NewReasoningTrace, NewUserEntityState, ReasoningTrace, UserEntityState } from './users/index.js';
4
+ export { CalendarInboxItem, EmailInboxItem, INBOX_SCHEMAS, InboxItem, InboxItemType, NewInboxItem, SlackInboxItem, isCalendarInboxItem, isEmailInboxItem, isSlackInboxItem } from './inbox/index.js';
5
+ export { CreateWorkspaceInput, InviteMemberInput, NewWorkspace, NewWorkspaceInvite, NewWorkspaceMember, UpdateWorkspaceInput, Workspace, WorkspaceInvite, WorkspaceMember, WorkspaceRole, WorkspaceType } from './workspaces/index.js';
6
+ export { CalendarConfig, ColumnDefinition, CreateViewInput, FilterRule, GanttConfig, GridConfig, KanbanConfig, ListConfig, NewView, SaveViewInput, SortRule, SwitchViewLayoutInput, TableViewConfig, UpdateViewInput, View, ViewType } from './views/index.js';
7
+ export { CreateRelationInput, NewRelation, Relation, RelationType, RelationWithEntities } from './relations/index.js';
8
+ export { NewUserPreferences, Theme, UpdatePreferencesInput, UserPreferences } from './preferences/index.js';
9
9
  export { CollaborationEvent, CursorUpdate, PresenceInit, PresenceStatus, UserJoinedEvent, UserLeftEvent, UserPresence } from './realtime/index.js';
10
10
  export { AIProposalEvent, AIProposalStatusEvent, ChatMessageEvent, ChatStreamEvent, DocumentUpdatedEvent, DocumentVersionCreatedEvent, DomainClientToServerEvents, DomainEventName, DomainEventNames, DomainServerToClientEvents, EntityCreatedEvent, EntityDeletedEvent, EntityUpdatedEvent } from './events/index.js';
11
11
  export { Array as YArray, Doc as YDoc, Map as YMap, Text as YText } from 'yjs';
package/dist/index.js CHANGED
@@ -1,10 +1,5 @@
1
- import {
2
- INBOX_SCHEMAS,
3
- isCalendarInboxItem,
4
- isEmailInboxItem,
5
- isSlackInboxItem
6
- } from "./chunk-ZFFMXKF2.js";
7
- import "./chunk-2BEUWD3P.js";
1
+ import "./chunk-QAWJ6GM3.js";
2
+ import "./chunk-ZTGPGYVX.js";
8
3
  import "./chunk-IZA3UKBT.js";
9
4
  import "./chunk-7LKCNZXD.js";
10
5
  import {
@@ -18,13 +13,18 @@ import {
18
13
  safeValidateEntityMetadata,
19
14
  validateEntityMetadata
20
15
  } from "./chunk-RIUK6OEK.js";
16
+ import {
17
+ INBOX_SCHEMAS,
18
+ isCalendarInboxItem,
19
+ isEmailInboxItem,
20
+ isSlackInboxItem
21
+ } from "./chunk-ZFFMXKF2.js";
21
22
  import {
22
23
  DomainEventNames
23
24
  } from "./chunk-6OHYLFUB.js";
24
- import "./chunk-QAWJ6GM3.js";
25
- import "./chunk-2N5ZC5EB.js";
26
25
  import "./chunk-X5L3VJJZ.js";
27
- import "./chunk-ZTGPGYVX.js";
26
+ import "./chunk-2N5ZC5EB.js";
27
+ import "./chunk-2BEUWD3P.js";
28
28
  export {
29
29
  DomainEventNames,
30
30
  ENTITY_SCHEMAS,
@@ -1,17 +1,25 @@
1
- import { UserPreference } from '@synap/database/schema';
2
- export { NewUserPreference as NewUserPreferences, UserPreference as UserPreferences } from '@synap/database/schema';
3
-
4
1
  /**
5
2
  * User Preferences Types
6
3
  *
7
- * Re-exports user preferences types from database schema (single source of truth).
8
- *
9
- * Note: Database exports `UserPreference` (singular), we alias to `UserPreferences` for API consistency.
10
- *
11
- * @see {@link file:///.../packages/database/src/schema/user-preferences.ts}
4
+ * Standalone type definitions for user preferences.
5
+ * Works independently without @synap/database.
12
6
  */
13
-
14
- type Theme = UserPreference['theme'];
7
+ type Theme = 'light' | 'dark' | 'system';
8
+ /**
9
+ * UserPreferences - User's app preferences
10
+ */
11
+ interface UserPreferences {
12
+ id: string;
13
+ userId: string;
14
+ theme: Theme;
15
+ uiPreferences?: Record<string, unknown>;
16
+ graphPreferences?: Record<string, unknown>;
17
+ onboardingCompleted: boolean;
18
+ onboardingStep?: string;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ }
22
+ type NewUserPreferences = Omit<UserPreferences, 'id' | 'createdAt' | 'updatedAt'>;
15
23
  interface UpdatePreferencesInput {
16
24
  theme?: Theme;
17
25
  uiPreferences?: Record<string, unknown>;
@@ -20,4 +28,4 @@ interface UpdatePreferencesInput {
20
28
  onboardingStep?: string;
21
29
  }
22
30
 
23
- export type { Theme, UpdatePreferencesInput };
31
+ export type { NewUserPreferences, Theme, UpdatePreferencesInput, UserPreferences };
@@ -1,14 +1,27 @@
1
- export { NewRelation, Relation } from '@synap/database/schema';
2
-
3
1
  /**
4
2
  * Relation Types
5
3
  *
6
- * Re-exports relation types from database schema (single source of truth).
7
- *
8
- * @see {@link file:///.../packages/database/src/schema/relations.ts}
4
+ * Standalone type definitions for relations.
5
+ * Compatible with @synap/database schema but works independently.
9
6
  */
10
-
11
- type RelationType = 'related_to' | 'parent_of' | 'child_of' | 'blocks' | 'mentioned_in' | 'linked_to';
7
+ type RelationType = 'related_to' | 'parent_of' | 'child_of' | 'blocks' | 'depends_on' | 'mentioned_in' | 'mentions' | 'linked_to' | 'assigned_to' | 'attended_by' | 'links_to';
8
+ /**
9
+ * Relation - Edge in the knowledge graph
10
+ */
11
+ interface Relation {
12
+ id: string;
13
+ userId: string;
14
+ sourceEntityId: string;
15
+ targetEntityId: string;
16
+ type: RelationType;
17
+ metadata?: Record<string, unknown>;
18
+ createdAt: Date;
19
+ updatedAt?: Date;
20
+ }
21
+ /**
22
+ * NewRelation - For creating a new relation
23
+ */
24
+ type NewRelation = Omit<Relation, 'id' | 'createdAt' | 'updatedAt'>;
12
25
  interface CreateRelationInput {
13
26
  sourceEntityId: string;
14
27
  targetEntityId: string;
@@ -33,4 +46,4 @@ interface RelationWithEntities {
33
46
  };
34
47
  }
35
48
 
36
- export type { CreateRelationInput, RelationType, RelationWithEntities };
49
+ export type { CreateRelationInput, NewRelation, Relation, RelationType, RelationWithEntities };
@@ -1 +1,67 @@
1
- export { EntityEnrichment, EntityRelationship, NewEntityEnrichment, NewEntityRelationship, NewReasoningTrace, NewUserEntityState, ReasoningTrace, UserEntityState } from '@synap/database/schema';
1
+ /**
2
+ * User Types
3
+ *
4
+ * Standalone type definitions for user-related entities.
5
+ * Works independently without @synap/database.
6
+ */
7
+ /**
8
+ * UserEntityState - Tracks user-specific entity state
9
+ */
10
+ interface UserEntityState {
11
+ id: string;
12
+ userId: string;
13
+ entityId: string;
14
+ isFavorite: boolean;
15
+ isArchived: boolean;
16
+ lastViewedAt?: Date;
17
+ customTags?: string[];
18
+ notes?: string;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ }
22
+ type NewUserEntityState = Omit<UserEntityState, 'id' | 'createdAt' | 'updatedAt'>;
23
+ /**
24
+ * EntityEnrichment - AI-generated entity enhancements
25
+ */
26
+ interface EntityEnrichment {
27
+ id: string;
28
+ entityId: string;
29
+ enrichmentType: 'summary' | 'keywords' | 'sentiment' | 'category' | 'suggestions';
30
+ content: Record<string, unknown>;
31
+ confidence: number;
32
+ source: 'ai' | 'user' | 'system';
33
+ createdAt: Date;
34
+ expiresAt?: Date;
35
+ }
36
+ type NewEntityEnrichment = Omit<EntityEnrichment, 'id' | 'createdAt'>;
37
+ /**
38
+ * EntityRelationship - User-defined relationships between entities
39
+ */
40
+ interface EntityRelationship {
41
+ id: string;
42
+ userId: string;
43
+ sourceEntityId: string;
44
+ targetEntityId: string;
45
+ relationshipType: string;
46
+ metadata?: Record<string, unknown>;
47
+ createdAt: Date;
48
+ }
49
+ type NewEntityRelationship = Omit<EntityRelationship, 'id' | 'createdAt'>;
50
+ /**
51
+ * ReasoningTrace - AI reasoning logs
52
+ */
53
+ interface ReasoningTrace {
54
+ id: string;
55
+ entityId?: string;
56
+ requestId: string;
57
+ step: number;
58
+ thought: string;
59
+ action?: string;
60
+ observation?: string;
61
+ model: string;
62
+ tokensUsed: number;
63
+ createdAt: Date;
64
+ }
65
+ type NewReasoningTrace = Omit<ReasoningTrace, 'id' | 'createdAt'>;
66
+
67
+ export type { EntityEnrichment, EntityRelationship, NewEntityEnrichment, NewEntityRelationship, NewReasoningTrace, NewUserEntityState, ReasoningTrace, UserEntityState };
@@ -1,14 +1,29 @@
1
- export { NewView, View } from '@synap/database/schema';
2
-
3
1
  /**
4
2
  * View Types
5
3
  *
6
- * Re-exports view types from database schema (single source of truth).
4
+ * Standalone view type definitions.
5
+ * Works independently without @synap/database.
7
6
  * Extended with Table Inversion System configuration types.
8
- *
9
- * @see {@link file:///.../packages/database/src/schema/views.ts}
10
7
  */
11
-
8
+ /**
9
+ * View - A saved view configuration
10
+ */
11
+ interface View {
12
+ id: string;
13
+ userId: string;
14
+ workspaceId?: string;
15
+ name: string;
16
+ type: ViewType;
17
+ description?: string;
18
+ metadata?: Record<string, unknown>;
19
+ content?: unknown;
20
+ isPublic: boolean;
21
+ version: number;
22
+ createdAt: Date;
23
+ updatedAt: Date;
24
+ deletedAt?: Date;
25
+ }
26
+ type NewView = Omit<View, 'id' | 'version' | 'createdAt' | 'updatedAt' | 'deletedAt'>;
12
27
  /**
13
28
  * View types - categorized by rendering approach
14
29
  *
@@ -132,4 +147,4 @@ interface SwitchViewLayoutInput {
132
147
  newLayout: TableViewConfig['layout'];
133
148
  }
134
149
 
135
- export type { CalendarConfig, ColumnDefinition, CreateViewInput, FilterRule, GanttConfig, GridConfig, KanbanConfig, ListConfig, SaveViewInput, SortRule, SwitchViewLayoutInput, TableViewConfig, UpdateViewInput, ViewType };
150
+ export type { CalendarConfig, ColumnDefinition, CreateViewInput, FilterRule, GanttConfig, GridConfig, KanbanConfig, ListConfig, NewView, SaveViewInput, SortRule, SwitchViewLayoutInput, TableViewConfig, UpdateViewInput, View, ViewType };
@@ -1,16 +1,55 @@
1
- import { Workspace, WorkspaceMember } from '@synap/database/schema';
2
- export { NewWorkspace, NewWorkspaceInvite, NewWorkspaceMember, Workspace, WorkspaceInvite, WorkspaceMember } from '@synap/database/schema';
3
-
4
1
  /**
5
2
  * Workspace Types
6
3
  *
7
- * Re-exports workspace types from database schema (single source of truth).
8
- *
9
- * @see {@link file:///.../packages/database/src/schema/workspaces.ts}
4
+ * Standalone type definitions for workspaces.
5
+ * Works independently without @synap/database.
10
6
  */
11
-
12
- type WorkspaceType = Workspace['type'];
13
- type WorkspaceRole = WorkspaceMember['role'];
7
+ type WorkspaceType = 'personal' | 'team' | 'shared' | 'public';
8
+ type WorkspaceRole = 'owner' | 'admin' | 'member' | 'viewer' | 'guest';
9
+ /**
10
+ * Workspace - Container for entities and views
11
+ */
12
+ interface Workspace {
13
+ id: string;
14
+ ownerId: string;
15
+ name: string;
16
+ slug: string;
17
+ description?: string;
18
+ type: WorkspaceType;
19
+ settings?: Record<string, unknown>;
20
+ iconUrl?: string;
21
+ createdAt: Date;
22
+ updatedAt: Date;
23
+ deletedAt?: Date;
24
+ }
25
+ type NewWorkspace = Omit<Workspace, 'id' | 'createdAt' | 'updatedAt' | 'deletedAt'>;
26
+ /**
27
+ * WorkspaceMember - User membership in workspace
28
+ */
29
+ interface WorkspaceMember {
30
+ id: string;
31
+ workspaceId: string;
32
+ userId: string;
33
+ role: WorkspaceRole;
34
+ joinedAt: Date;
35
+ invitedBy?: string;
36
+ }
37
+ type NewWorkspaceMember = Omit<WorkspaceMember, 'id' | 'joinedAt'>;
38
+ /**
39
+ * WorkspaceInvite - Pending invitation
40
+ */
41
+ interface WorkspaceInvite {
42
+ id: string;
43
+ workspaceId: string;
44
+ email: string;
45
+ role: WorkspaceRole;
46
+ token: string;
47
+ invitedBy: string;
48
+ expiresAt: Date;
49
+ acceptedAt?: Date;
50
+ createdAt: Date;
51
+ }
52
+ type NewWorkspaceInvite = Omit<WorkspaceInvite, 'id' | 'createdAt' | 'acceptedAt'>;
14
53
  interface CreateWorkspaceInput {
15
54
  name: string;
16
55
  description?: string;
@@ -27,4 +66,4 @@ interface InviteMemberInput {
27
66
  role: WorkspaceRole;
28
67
  }
29
68
 
30
- export type { CreateWorkspaceInput, InviteMemberInput, UpdateWorkspaceInput, WorkspaceRole, WorkspaceType };
69
+ export type { CreateWorkspaceInput, InviteMemberInput, NewWorkspace, NewWorkspaceInvite, NewWorkspaceMember, UpdateWorkspaceInput, Workspace, WorkspaceInvite, WorkspaceMember, WorkspaceRole, WorkspaceType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synap-core/types",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -53,6 +53,11 @@
53
53
  "import": "./dist/events/index.js"
54
54
  }
55
55
  },
56
+ "scripts": {
57
+ "build": "tsup",
58
+ "dev": "tsup --watch",
59
+ "type-check": "tsc --noEmit"
60
+ },
56
61
  "dependencies": {
57
62
  "zod": "^3.25.0",
58
63
  "yjs": "^13.6.11"
@@ -61,18 +66,5 @@
61
66
  "@types/node": "^20.0.0",
62
67
  "tsup": "^8.0.0",
63
68
  "typescript": "^5.6.0"
64
- },
65
- "peerDependencies": {
66
- "@synap/database": "1.0.0"
67
- },
68
- "peerDependenciesMeta": {
69
- "@synap/database": {
70
- "optional": true
71
- }
72
- },
73
- "scripts": {
74
- "build": "tsup",
75
- "dev": "tsup --watch",
76
- "type-check": "tsc --noEmit"
77
69
  }
78
70
  }
@@ -1,22 +1,69 @@
1
1
  /**
2
2
  * Document Types
3
3
  *
4
- * Re-exports document types from database schema (single source of truth).
5
- *
6
- * @see {@link file:///.../packages/database/src/schema/documents.ts}
4
+ * Standalone type definitions for documents.
5
+ * Compatible with @synap/database schema but works independently.
7
6
  */
8
7
 
9
- // Direct re-exports from database
10
- export type {
11
- Document,
12
- NewDocument,
13
- DocumentVersion,
14
- NewDocumentVersion,
15
- DocumentSession,
16
- NewDocumentSession,
17
- } from '@synap/database/schema';
8
+ /**
9
+ * Document - Rich text document with version history
10
+ */
11
+ export interface Document {
12
+ id: string;
13
+ userId: string;
14
+ title: string | null;
15
+ type: 'note' | 'whiteboard' | 'canvas' | 'code' | 'other';
16
+ content?: string;
17
+ yjsState?: Uint8Array;
18
+ contentFormat: 'markdown' | 'prosemirror' | 'tiptap' | 'yjs' | 'raw';
19
+ version: number;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ deletedAt?: Date;
23
+ }
18
24
 
19
- // Derived/helper types for API operations
20
- import type { Document } from '@synap/database/schema';
25
+ /**
26
+ * NewDocument - For creating a new document
27
+ */
28
+ export type NewDocument = Omit<Document, 'id' | 'version' | 'createdAt' | 'updatedAt' | 'deletedAt'>;
21
29
 
30
+ /**
31
+ * UpdateDocument - For updating a document
32
+ */
22
33
  export type UpdateDocument = Partial<Omit<Document, 'id' | 'userId' | 'createdAt' | 'updatedAt'>>;
34
+
35
+ /**
36
+ * DocumentVersion - Version history entry
37
+ */
38
+ export interface DocumentVersion {
39
+ id: string;
40
+ documentId: string;
41
+ userId: string;
42
+ version: number;
43
+ content?: string;
44
+ yjsState?: Uint8Array;
45
+ message?: string;
46
+ createdAt: Date;
47
+ }
48
+
49
+ /**
50
+ * NewDocumentVersion - For creating a version
51
+ */
52
+ export type NewDocumentVersion = Omit<DocumentVersion, 'id' | 'createdAt'>;
53
+
54
+ /**
55
+ * DocumentSession - Collaboration session
56
+ */
57
+ export interface DocumentSession {
58
+ id: string;
59
+ documentId: string;
60
+ userId: string;
61
+ cursorPosition?: string;
62
+ lastActivity: Date;
63
+ createdAt: Date;
64
+ }
65
+
66
+ /**
67
+ * NewDocumentSession - For creating a session
68
+ */
69
+ export type NewDocumentSession = Omit<DocumentSession, 'id' | 'createdAt' | 'lastActivity'>;
@@ -1,17 +1,10 @@
1
1
  /**
2
2
  * Entity Types
3
3
  *
4
- * Re-exports base entity types from database and adds discriminated unions.
5
- *
6
- * @see {@link file:///.../packages/database/src/schema/entities.ts}
4
+ * Standalone entity type definitions with discriminated unions.
5
+ * Works independently without @synap/database.
7
6
  */
8
7
 
9
- // Direct re-exports from database
10
- export type {
11
- Entity as DBEntity, // Alias to avoid conflict with our discriminated union
12
- NewEntity as NewEntityDB,
13
- } from '@synap/database/schema';
14
-
15
8
  import type { EntityType, EntityMetadata } from './schemas.js';
16
9
 
17
10
  /**
@@ -1,19 +1,12 @@
1
1
  /**
2
2
  * Inbox Item Schemas & Types
3
3
  *
4
- * Re-exports inbox types from database and adds provider-specific schemas.
5
- *
6
- * @see {@link file:///.../packages/database/src/schema/inbox-items.ts}
4
+ * Standalone inbox type definitions.
5
+ * Works independently without @synap/database.
7
6
  */
8
7
 
9
8
  import { z } from 'zod';
10
9
 
11
- // Direct re-exports from database
12
- export type {
13
- InboxItem as DBInboxItem, // Base DB type
14
- NewInboxItem,
15
- } from '@synap/database/schema';
16
-
17
10
  /**
18
11
  * Inbox item data schemas - provider-specific
19
12
  */
@@ -100,6 +93,11 @@ export type InboxItem = {
100
93
  }
101
94
  }[InboxItemType];
102
95
 
96
+ /**
97
+ * NewInboxItem - For creating new inbox items
98
+ */
99
+ export type NewInboxItem = Omit<InboxItem, 'id' | 'createdAt' | 'updatedAt'>;
100
+
103
101
  /**
104
102
  * Specific inbox item types
105
103
  */
@@ -1,23 +1,28 @@
1
1
  /**
2
2
  * User Preferences Types
3
3
  *
4
- * Re-exports user preferences types from database schema (single source of truth).
5
- *
6
- * Note: Database exports `UserPreference` (singular), we alias to `UserPreferences` for API consistency.
7
- *
8
- * @see {@link file:///.../packages/database/src/schema/user-preferences.ts}
4
+ * Standalone type definitions for user preferences.
5
+ * Works independently without @synap/database.
9
6
  */
10
7
 
11
- // Direct re-exports from database (with alias for consistency)
12
- export type {
13
- UserPreference as UserPreferences,
14
- NewUserPreference as NewUserPreferences,
15
- } from '@synap/database/schema';
8
+ export type Theme = 'light' | 'dark' | 'system';
16
9
 
17
- // Derived types
18
- import type { UserPreference } from '@synap/database/schema';
10
+ /**
11
+ * UserPreferences - User's app preferences
12
+ */
13
+ export interface UserPreferences {
14
+ id: string;
15
+ userId: string;
16
+ theme: Theme;
17
+ uiPreferences?: Record<string, unknown>;
18
+ graphPreferences?: Record<string, unknown>;
19
+ onboardingCompleted: boolean;
20
+ onboardingStep?: string;
21
+ createdAt: Date;
22
+ updatedAt: Date;
23
+ }
19
24
 
20
- export type Theme = UserPreference['theme'];
25
+ export type NewUserPreferences = Omit<UserPreferences, 'id' | 'createdAt' | 'updatedAt'>;
21
26
 
22
27
  // Input types for API operations
23
28
  export interface UpdatePreferencesInput {
@@ -1,25 +1,42 @@
1
1
  /**
2
2
  * Relation Types
3
3
  *
4
- * Re-exports relation types from database schema (single source of truth).
5
- *
6
- * @see {@link file:///.../packages/database/src/schema/relations.ts}
4
+ * Standalone type definitions for relations.
5
+ * Compatible with @synap/database schema but works independently.
7
6
  */
8
7
 
9
- // Direct re-exports from database
10
- export type {
11
- Relation,
12
- NewRelation,
13
- } from '@synap/database/schema';
14
-
15
8
  // Relation type definitions
16
9
  export type RelationType =
17
10
  | 'related_to' // Generic relationship
18
11
  | 'parent_of' // Hierarchy (parent → child)
19
12
  | 'child_of' // Inverse hierarchy (child → parent)
20
13
  | 'blocks' // Dependencies (X blocks Y)
14
+ | 'depends_on' // Inverse dependency (Y depends on X)
21
15
  | 'mentioned_in' // Content references
22
- | 'linked_to'; // User-created links
16
+ | 'mentions' // Inverse content reference
17
+ | 'linked_to' // User-created links
18
+ | 'assigned_to' // Task assignments
19
+ | 'attended_by' // Event attendees
20
+ | 'links_to'; // File/document links
21
+
22
+ /**
23
+ * Relation - Edge in the knowledge graph
24
+ */
25
+ export interface Relation {
26
+ id: string;
27
+ userId: string;
28
+ sourceEntityId: string;
29
+ targetEntityId: string;
30
+ type: RelationType;
31
+ metadata?: Record<string, unknown>;
32
+ createdAt: Date;
33
+ updatedAt?: Date;
34
+ }
35
+
36
+ /**
37
+ * NewRelation - For creating a new relation
38
+ */
39
+ export type NewRelation = Omit<Relation, 'id' | 'createdAt' | 'updatedAt'>;
23
40
 
24
41
  // Input types for API operations
25
42
  export interface CreateRelationInput {
@@ -1,20 +1,73 @@
1
1
  /**
2
2
  * User Types
3
3
  *
4
- * Re-exports user-related types from database and adds custom types.
5
- *
6
- * @see {@link file:///.../packages/database/src/schema/user-entity-state.ts}
7
- * @see {@link file:///.../packages/database/src/schema/enrichments.ts}
4
+ * Standalone type definitions for user-related entities.
5
+ * Works independently without @synap/database.
6
+ */
7
+
8
+ /**
9
+ * UserEntityState - Tracks user-specific entity state
10
+ */
11
+ export interface UserEntityState {
12
+ id: string;
13
+ userId: string;
14
+ entityId: string;
15
+ isFavorite: boolean;
16
+ isArchived: boolean;
17
+ lastViewedAt?: Date;
18
+ customTags?: string[];
19
+ notes?: string;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ }
23
+
24
+ export type NewUserEntityState = Omit<UserEntityState, 'id' | 'createdAt' | 'updatedAt'>;
25
+
26
+ /**
27
+ * EntityEnrichment - AI-generated entity enhancements
28
+ */
29
+ export interface EntityEnrichment {
30
+ id: string;
31
+ entityId: string;
32
+ enrichmentType: 'summary' | 'keywords' | 'sentiment' | 'category' | 'suggestions';
33
+ content: Record<string, unknown>;
34
+ confidence: number;
35
+ source: 'ai' | 'user' | 'system';
36
+ createdAt: Date;
37
+ expiresAt?: Date;
38
+ }
39
+
40
+ export type NewEntityEnrichment = Omit<EntityEnrichment, 'id' | 'createdAt'>;
41
+
42
+ /**
43
+ * EntityRelationship - User-defined relationships between entities
44
+ */
45
+ export interface EntityRelationship {
46
+ id: string;
47
+ userId: string;
48
+ sourceEntityId: string;
49
+ targetEntityId: string;
50
+ relationshipType: string;
51
+ metadata?: Record<string, unknown>;
52
+ createdAt: Date;
53
+ }
54
+
55
+ export type NewEntityRelationship = Omit<EntityRelationship, 'id' | 'createdAt'>;
56
+
57
+ /**
58
+ * ReasoningTrace - AI reasoning logs
8
59
  */
60
+ export interface ReasoningTrace {
61
+ id: string;
62
+ entityId?: string;
63
+ requestId: string;
64
+ step: number;
65
+ thought: string;
66
+ action?: string;
67
+ observation?: string;
68
+ model: string;
69
+ tokensUsed: number;
70
+ createdAt: Date;
71
+ }
9
72
 
10
- // Direct re-exports from database
11
- export type {
12
- UserEntityState,
13
- NewUserEntityState,
14
- EntityEnrichment,
15
- NewEntityEnrichment,
16
- EntityRelationship,
17
- NewEntityRelationship,
18
- ReasoningTrace,
19
- NewReasoningTrace,
20
- } from '@synap/database/schema';
73
+ export type NewReasoningTrace = Omit<ReasoningTrace, 'id' | 'createdAt'>;
@@ -1,17 +1,31 @@
1
1
  /**
2
2
  * View Types
3
3
  *
4
- * Re-exports view types from database schema (single source of truth).
4
+ * Standalone view type definitions.
5
+ * Works independently without @synap/database.
5
6
  * Extended with Table Inversion System configuration types.
6
- *
7
- * @see {@link file:///.../packages/database/src/schema/views.ts}
8
7
  */
9
8
 
10
- // Direct re-exports from database
11
- export type {
12
- View,
13
- NewView,
14
- } from '@synap/database/schema';
9
+ /**
10
+ * View - A saved view configuration
11
+ */
12
+ export interface View {
13
+ id: string;
14
+ userId: string;
15
+ workspaceId?: string;
16
+ name: string;
17
+ type: ViewType;
18
+ description?: string;
19
+ metadata?: Record<string, unknown>;
20
+ content?: unknown;
21
+ isPublic: boolean;
22
+ version: number;
23
+ createdAt: Date;
24
+ updatedAt: Date;
25
+ deletedAt?: Date;
26
+ }
27
+
28
+ export type NewView = Omit<View, 'id' | 'version' | 'createdAt' | 'updatedAt' | 'deletedAt'>;
15
29
 
16
30
  // =============================================================================
17
31
  // View Type Enum
@@ -1,26 +1,62 @@
1
1
  /**
2
2
  * Workspace Types
3
3
  *
4
- * Re-exports workspace types from database schema (single source of truth).
5
- *
6
- * @see {@link file:///.../packages/database/src/schema/workspaces.ts}
4
+ * Standalone type definitions for workspaces.
5
+ * Works independently without @synap/database.
6
+ */
7
+
8
+ export type WorkspaceType = 'personal' | 'team' | 'shared' | 'public';
9
+ export type WorkspaceRole = 'owner' | 'admin' | 'member' | 'viewer' | 'guest';
10
+
11
+ /**
12
+ * Workspace - Container for entities and views
13
+ */
14
+ export interface Workspace {
15
+ id: string;
16
+ ownerId: string;
17
+ name: string;
18
+ slug: string;
19
+ description?: string;
20
+ type: WorkspaceType;
21
+ settings?: Record<string, unknown>;
22
+ iconUrl?: string;
23
+ createdAt: Date;
24
+ updatedAt: Date;
25
+ deletedAt?: Date;
26
+ }
27
+
28
+ export type NewWorkspace = Omit<Workspace, 'id' | 'createdAt' | 'updatedAt' | 'deletedAt'>;
29
+
30
+ /**
31
+ * WorkspaceMember - User membership in workspace
32
+ */
33
+ export interface WorkspaceMember {
34
+ id: string;
35
+ workspaceId: string;
36
+ userId: string;
37
+ role: WorkspaceRole;
38
+ joinedAt: Date;
39
+ invitedBy?: string;
40
+ }
41
+
42
+ export type NewWorkspaceMember = Omit<WorkspaceMember, 'id' | 'joinedAt'>;
43
+
44
+ /**
45
+ * WorkspaceInvite - Pending invitation
7
46
  */
47
+ export interface WorkspaceInvite {
48
+ id: string;
49
+ workspaceId: string;
50
+ email: string;
51
+ role: WorkspaceRole;
52
+ token: string;
53
+ invitedBy: string;
54
+ expiresAt: Date;
55
+ acceptedAt?: Date;
56
+ createdAt: Date;
57
+ }
8
58
 
9
- // Direct re-exports from database (automatic sync, no manual maintenance needed)
10
- export type {
11
- Workspace,
12
- NewWorkspace,
13
- WorkspaceMember,
14
- NewWorkspaceMember,
15
- WorkspaceInvite,
16
- NewWorkspaceInvite,
17
- } from '@synap/database/schema';
18
-
19
- // Derived types for API convenience
20
- import type { Workspace, WorkspaceMember } from '@synap/database/schema';
21
-
22
- export type WorkspaceType = Workspace['type'];
23
- export type WorkspaceRole = WorkspaceMember['role'];
59
+ export type NewWorkspaceInvite = Omit<WorkspaceInvite, 'id' | 'createdAt' | 'acceptedAt'>;
24
60
 
25
61
  // Input types for API operations
26
62
  export interface CreateWorkspaceInput {