@synap-core/api-types 1.0.9 → 1.0.10

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/index.d.ts CHANGED
@@ -1,18 +1,39 @@
1
+ import * as _trpc_server from '@trpc/server';
2
+ import { z } from 'zod';
3
+ import * as _synap_core_types from '@synap-core/types';
1
4
  // Generated by dts-bundle-generator v9.5.1
2
5
 
3
6
  import { Sql } from 'postgres';
4
7
 
5
- type FilterOperator = "equals" | "not_equals" | "contains" | "not_contains" | "in" | "not_in" | "is_empty" | "is_not_empty" | "greater_than" | "less_than" | "greater_than_or_equal" | "less_than_or_equal";
6
- interface EntityFilter {
8
+ /**
9
+ * View Query Types
10
+ *
11
+ * Single source of truth for all view query and filter types.
12
+ */
13
+ /**
14
+ * Filter operator types
15
+ */
16
+ export type FilterOperator = "equals" | "not_equals" | "contains" | "not_contains" | "in" | "not_in" | "is_empty" | "is_not_empty" | "greater_than" | "less_than" | "greater_than_or_equal" | "less_than_or_equal";
17
+ /**
18
+ * Filter definition for entity queries
19
+ */
20
+ export interface EntityFilter {
7
21
  field: string;
8
22
  operator: FilterOperator;
9
23
  value?: unknown;
10
24
  }
11
- interface SortRule {
25
+ /**
26
+ * Sort rule for entity queries
27
+ */
28
+ export interface SortRule {
12
29
  field: string;
13
30
  direction: "asc" | "desc";
14
31
  }
15
- interface EntityQuery {
32
+ /**
33
+ * Query definition for structured views
34
+ * Defines which entities to show and how to filter them
35
+ */
36
+ export interface EntityQuery {
16
37
  /** Entity types to include */
17
38
  entityTypes?: string[];
18
39
  /** Specific entity IDs (for fixed sets) */
@@ -30,7 +51,7 @@ interface EntityQuery {
30
51
  /** Group by field (for kanban, timeline) */
31
52
  groupBy?: string;
32
53
  }
33
- interface ColumnDisplayConfig {
54
+ export interface ColumnDisplayConfig {
34
55
  type: "text" | "badge" | "date" | "user" | "url" | "boolean" | "progress" | "rating" | "image" | "file";
35
56
  params?: {
36
57
  colors?: Record<string, string>;
@@ -44,7 +65,7 @@ interface ColumnDisplayConfig {
44
65
  icon?: string;
45
66
  };
46
67
  }
47
- interface ColumnConfig {
68
+ export interface ColumnConfig {
48
69
  id: string;
49
70
  field: string;
50
71
  width?: number;
@@ -52,7 +73,7 @@ interface ColumnConfig {
52
73
  title?: string;
53
74
  display?: ColumnDisplayConfig;
54
75
  }
55
- interface FormattingRule {
76
+ export interface FormattingRule {
56
77
  id: string;
57
78
  name?: string;
58
79
  target: "row" | "cell" | "card";
@@ -66,7 +87,7 @@ interface FormattingRule {
66
87
  icon?: string;
67
88
  };
68
89
  }
69
- interface RenderSettings {
90
+ export interface RenderSettings {
70
91
  rowHeight?: "compact" | "default" | "tall";
71
92
  formatting?: FormattingRule[];
72
93
  columns?: ColumnConfig[];
@@ -85,12 +106,20 @@ interface RenderSettings {
85
106
  nodeColorField?: string;
86
107
  edgeLabelField?: string;
87
108
  }
88
- interface StructuredViewConfig {
109
+ export interface StructuredViewConfig {
89
110
  category: "structured";
90
111
  query: EntityQuery;
91
112
  render?: RenderSettings;
92
113
  }
93
- interface WorkerMetadata {
114
+ /**
115
+ * Worker Registry - Static worker metadata for Admin UI
116
+ *
117
+ * V2.0: Simplified registry with only active workers
118
+ *
119
+ * Pattern: Table workers handle {table}.{crud}.requested events
120
+ * and emit {table}.{crud}.completed events.
121
+ */
122
+ export interface WorkerMetadata {
94
123
  id: string;
95
124
  name: string;
96
125
  description: string;
@@ -98,7 +127,35 @@ interface WorkerMetadata {
98
127
  outputs?: string[];
99
128
  category: "table" | "shared" | "ai";
100
129
  }
101
- type TableAction = "create.requested" | "create.approved" | "create.validated" | "update.requested" | "update.approved" | "update.validated" | "delete.requested" | "delete.approved" | "delete.validated";
130
+ /**
131
+ * @synap/events - Schema-Driven Event Generator
132
+ *
133
+ * This module generates event types and payload schemas from Drizzle database tables.
134
+ *
135
+ * V2.0 CONSOLIDATED PATTERN: {table}.{action}.{modifier}
136
+ *
137
+ * Actions: create | update | delete
138
+ * Modifiers: requested | validated
139
+ *
140
+ * Examples:
141
+ * entities.create.requested ← Intent submitted (by user or AI)
142
+ * entities.create.validated ← Change confirmed and applied
143
+ * entities.update.requested ← Update intent
144
+ * entities.update.validated ← Update confirmed
145
+ *
146
+ * No direct actions (e.g., entities.create) - all changes go through requested→validated flow.
147
+ */
148
+ /**
149
+ * Standard CRUD actions with modifiers for table events
150
+ *
151
+ * V2.1: Added 'approved' modifier for 3-phase flow
152
+ *
153
+ * Flow:
154
+ * 1. requested: Intent (user/AI wants to do something)
155
+ * 2. approved: Validated (permissions checked, user approved if needed)
156
+ * 3. validated: Completed (DB operation done, entity exists)
157
+ */
158
+ export type TableAction = "create.requested" | "create.approved" | "create.validated" | "update.requested" | "update.approved" | "update.validated" | "delete.requested" | "delete.approved" | "delete.validated";
102
159
  declare const CORE_TABLES: readonly [
103
160
  "entities",
104
161
  "documents",
@@ -114,9 +171,20 @@ declare const CORE_TABLES: readonly [
114
171
  "views",
115
172
  "userPreferences"
116
173
  ];
117
- type CoreTable = (typeof CORE_TABLES)[number];
118
- type GeneratedEventType = `${CoreTable}.create.requested` | `${CoreTable}.create.validated` | `${CoreTable}.update.requested` | `${CoreTable}.update.validated` | `${CoreTable}.delete.requested` | `${CoreTable}.delete.validated`;
119
- interface EventRecord {
174
+ export type CoreTable = (typeof CORE_TABLES)[number];
175
+ /**
176
+ * Flat list of all generated event types (for type checking)
177
+ *
178
+ * V2.0: Only requested/validated patterns
179
+ */
180
+ export type GeneratedEventType = `${CoreTable}.create.requested` | `${CoreTable}.create.validated` | `${CoreTable}.update.requested` | `${CoreTable}.update.validated` | `${CoreTable}.delete.requested` | `${CoreTable}.delete.validated`;
181
+ /**
182
+ * EventRecord - Database representation of an event
183
+ *
184
+ * This is the format returned from the database.
185
+ * It maps directly to the events_timescale table structure.
186
+ */
187
+ export interface EventRecord {
120
188
  id: string;
121
189
  timestamp: Date;
122
190
  aggregateId: string;
@@ -130,7 +198,12 @@ interface EventRecord {
130
198
  correlationId?: string;
131
199
  source: string;
132
200
  }
133
- interface Context extends Record<string, unknown> {
201
+ /**
202
+ * tRPC Context
203
+ *
204
+ * PostgreSQL-only with Ory Kratos session authentication for multi-user support.
205
+ */
206
+ export interface Context extends Record<string, unknown> {
134
207
  db: any;
135
208
  authenticated: boolean;
136
209
  userId?: string | null;
package/dist/index.js CHANGED
@@ -1,15 +0,0 @@
1
- /**
2
- * @synap/api-types
3
- *
4
- * Type-only exports for Synap API Router.
5
- * Frontend-safe package with no server dependencies.
6
- *
7
- * @example
8
- * ```typescript
9
- * import type { AppRouter } from '@synap/api-types';
10
- *
11
- * const trpc = createTRPCReact<AppRouter>();
12
- * ```
13
- */
14
- export {};
15
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synap-core/api-types",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Type definitions for Synap API Router - tRPC types for frontend",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "src"
18
18
  ],
19
19
  "scripts": {
20
- "build": "dts-bundle-generator -o dist/index.d.ts src/index.ts --no-check --export-referenced-types=false --external-types=postgres",
20
+ "build": "dts-bundle-generator -o dist/index.d.ts src/index.ts --no-check && node scripts/inject-imports.js",
21
21
  "typecheck": "tsc --noEmit"
22
22
  },
23
23
  "dependencies": {
@@ -25,6 +25,7 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@synap/api": "workspace:*",
28
+ "@trpc/server": "^11.8.1",
28
29
  "drizzle-orm": "^0.45.1",
29
30
  "dts-bundle-generator": "^9.5.1",
30
31
  "postgres": "^3.4.8",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}