@rjromeoent/ein-supabase 0.2.1 → 0.2.3

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.
@@ -3,7 +3,6 @@ export declare const DOCUMENT_INTAKE_EDGE_FUNCTIONS: {
3
3
  readonly createBatch: "document-intake-create-batch";
4
4
  readonly registerFiles: "document-intake-register-files";
5
5
  readonly processFile: "document-intake-process-file";
6
- readonly processFileWorker: "document-intake-process-file-worker";
7
6
  readonly processingReaper: "document-intake-processing-reaper";
8
7
  readonly getBatch: "document-intake-get-batch";
9
8
  readonly listBatches: "document-intake-list-batches";
@@ -14,6 +13,8 @@ export declare const DOCUMENT_INTAKE_EDGE_FUNCTIONS: {
14
13
  export type DocumentIntakeEndpointKey = keyof typeof DOCUMENT_INTAKE_EDGE_FUNCTIONS;
15
14
  export type DocumentIntakeEdgeFunctionName = (typeof DOCUMENT_INTAKE_EDGE_FUNCTIONS)[DocumentIntakeEndpointKey];
16
15
  export type DocumentIntakeDomainKey = "availability" | string;
16
+ export type DocumentIntakeProcessorOutputMode = "inline" | "summary_only" | "storage_artifact";
17
+ export type DocumentIntakeProcessorResultStatus = "completed" | "failed" | "partial";
17
18
  export type DocumentIntakeBatchStatus = "draft" | "uploading" | "uploaded" | "processing" | "extracting" | "ready_for_review" | "submitting" | "submitted" | "normalizing" | "completed" | "completed_with_exceptions" | "failed" | "canceled";
18
19
  export type DocumentIntakeFileStatus = "pending_upload" | "uploaded" | "queued" | "processing" | "extracting" | "parsed" | "ready_for_review" | "failed" | "ignored" | "canceled";
19
20
  export type DocumentIntakeProcessingStatus = "queued" | "running" | "succeeded" | "failed" | "canceled";
@@ -21,7 +22,7 @@ export type DocumentIntakeReviewStatus = "needs_review" | "accepted" | "rejected
21
22
  export type DocumentFindingSeverity = "info" | "warning" | "error";
22
23
  export type DocumentFindingSource = "parser" | "validator" | "ai" | "reconciliation" | "system";
23
24
  export type DocumentFindingScope = "batch" | "file" | "chunk" | "record" | "record_group" | "entity" | "evidence";
24
- export type DocumentFindingAction = "resolve" | "dismiss" | "reopen" | "request_ai_verification" | "apply_reconciliation_operation" | "edit_record" | "map_entity" | "create_entity";
25
+ export type DocumentFindingAction = "resolve" | "dismiss" | "reopen" | "request_ai_verification" | "apply_reconciliation_operation" | "edit_record" | "map_entity" | "request_entity_review" | "create_entity";
25
26
  export type DocumentFindingStatus = "open" | "resolved" | "dismissed" | "superseded";
26
27
  export type DocumentFindingStatusUpdate = Extract<DocumentFindingStatus, "open" | "resolved" | "dismissed">;
27
28
  export type DocumentFindingActionStatus = "applied" | "queued" | "rejected" | "failed";
@@ -34,6 +35,116 @@ export interface DocumentIntakeErrorResponse {
34
35
  error: string;
35
36
  details?: unknown;
36
37
  }
38
+ export interface DocumentIntakeProcessorSourceDto extends JsonRecord {
39
+ signed_url?: string | null;
40
+ data_base64?: string | null;
41
+ file_name?: string | null;
42
+ mime_type?: string | null;
43
+ byte_size?: number | null;
44
+ }
45
+ export interface DocumentIntakeProcessorRouteDto extends JsonRecord {
46
+ domain_key?: DocumentIntakeDomainKey;
47
+ document_family?: string | null;
48
+ layout_hint?: string | null;
49
+ layout_variant?: string | null;
50
+ processor_key: string;
51
+ processor_version: string;
52
+ source_kind?: string | null;
53
+ source_extension?: string | null;
54
+ source_mime_type?: string | null;
55
+ strategy?: string | null;
56
+ include_rects?: boolean | null;
57
+ route_source?: string | null;
58
+ evidence?: string[];
59
+ }
60
+ export interface DocumentIntakeProcessorOptionsDto extends JsonRecord {
61
+ output_mode?: DocumentIntakeProcessorOutputMode;
62
+ allow_ai_fallback?: boolean;
63
+ max_pages?: number;
64
+ max_rows?: number;
65
+ }
66
+ export interface DocumentIntakeProcessorResultSinkDto extends JsonRecord {
67
+ provider: "supabase_storage" | string;
68
+ bucket: string;
69
+ path: string;
70
+ }
71
+ export interface DocumentIntakeProcessorRequestDto<TDefaultContext extends JsonRecord = JsonRecord> extends JsonRecord {
72
+ version: "document_intake_process_request_v1" | string;
73
+ organization_id: string;
74
+ domain_key: DocumentIntakeDomainKey;
75
+ source_system?: string | null;
76
+ batch_id: string;
77
+ file_id: string;
78
+ processing_job_id: string;
79
+ processing_chunk_id?: string | null;
80
+ source: DocumentIntakeProcessorSourceDto;
81
+ default_context?: TDefaultContext;
82
+ routing: DocumentIntakeProcessorRouteDto;
83
+ options?: DocumentIntakeProcessorOptionsDto;
84
+ result_sink?: DocumentIntakeProcessorResultSinkDto | null;
85
+ }
86
+ export interface DocumentIntakeProcessorResultArtifactDto extends JsonRecord {
87
+ version?: "document_intake_process_result_artifact_ref_v1" | string;
88
+ kind?: "document_intake_process_result" | string;
89
+ provider: "supabase_storage" | string;
90
+ storage_bucket: string;
91
+ storage_path: string;
92
+ content_type?: string | null;
93
+ logical_content_type?: string | null;
94
+ content_encoding?: "gzip" | string | null;
95
+ byte_size?: number | null;
96
+ uncompressed_byte_size?: number | null;
97
+ candidate_count?: number | null;
98
+ finding_count?: number | null;
99
+ }
100
+ export interface DocumentIntakeProcessorTimingStageDto extends JsonRecord {
101
+ name: string;
102
+ elapsed_ms: number;
103
+ }
104
+ export interface DocumentIntakeProcessorTimingDto extends JsonRecord {
105
+ total_ms: number;
106
+ stages: DocumentIntakeProcessorTimingStageDto[];
107
+ }
108
+ export interface DocumentIntakeProcessorSummaryDto extends JsonRecord {
109
+ candidate_count: number;
110
+ inline_candidate_count?: number;
111
+ finding_count: number;
112
+ inline_finding_count?: number;
113
+ processor_key?: string | null;
114
+ processor_version?: string | null;
115
+ output_mode?: DocumentIntakeProcessorOutputMode | string;
116
+ diagnostics?: JsonRecord | null;
117
+ result_artifact?: DocumentIntakeProcessorResultArtifactDto | null;
118
+ }
119
+ export interface DocumentIntakeProcessorResultDto<TCandidate extends JsonRecord = JsonRecord, TFinding extends JsonRecord = JsonRecord> extends JsonRecord {
120
+ version: "document_intake_process_result_v1" | string;
121
+ status: DocumentIntakeProcessorResultStatus | string;
122
+ error_code?: string | null;
123
+ error_message?: string | null;
124
+ domain_key: DocumentIntakeDomainKey;
125
+ batch_id: string;
126
+ file_id: string;
127
+ processing_job_id: string;
128
+ processing_chunk_id?: string | null;
129
+ candidates: TCandidate[];
130
+ findings: TFinding[];
131
+ reconciliation_operations?: JsonRecord[];
132
+ evidence_artifacts?: JsonRecord[];
133
+ entity_resolutions?: JsonRecord[];
134
+ tool_runs?: JsonRecord[];
135
+ ai_invocations?: AiModelInvocationSummaryDto[];
136
+ result_artifacts?: DocumentIntakeProcessorResultArtifactDto[];
137
+ timing?: DocumentIntakeProcessorTimingDto;
138
+ summary: DocumentIntakeProcessorSummaryDto;
139
+ }
140
+ export interface DocumentIntakeProcessorResultArtifactPayloadDto<TCandidate extends JsonRecord = JsonRecord, TFinding extends JsonRecord = JsonRecord> extends JsonRecord {
141
+ version?: "document_intake_process_result_artifact_v1" | string;
142
+ artifact_version?: "document_intake_process_result_artifact_v1" | string;
143
+ created_at?: string;
144
+ generated_at?: string;
145
+ request?: JsonRecord;
146
+ result: DocumentIntakeProcessorResultDto<TCandidate, TFinding>;
147
+ }
37
148
  export interface DocumentIntakeBatchDto<TDefaultContext extends JsonRecord = JsonRecord, TMetadata extends JsonRecord = JsonRecord> {
38
149
  id: string;
39
150
  organization_id: string;
@@ -192,6 +303,7 @@ export interface DocumentFindingDto<TMetadata extends JsonRecord = JsonRecord> {
192
303
  candidate_record_id: string | null;
193
304
  candidate_key: string | null;
194
305
  candidate_index: number | null;
306
+ entity_review_request_id: string | null;
195
307
  severity: DocumentFindingSeverity | string;
196
308
  source: DocumentFindingSource | string;
197
309
  scope: DocumentFindingScope | string;
@@ -399,6 +511,7 @@ export interface DocumentIntakeProcessFileRequest {
399
511
  }
400
512
  export interface DocumentIntakeProcessFileResponse {
401
513
  fileId: string;
514
+ domainKey?: DocumentIntakeDomainKey;
402
515
  parsedRows: number;
403
516
  processingJobId?: string;
404
517
  queuedRows?: number;
@@ -407,6 +520,12 @@ export interface DocumentIntakeProcessFileResponse {
407
520
  pageCount?: number;
408
521
  asyncWorkerFunction?: DocumentIntakeEdgeFunctionName | string;
409
522
  documentProcessorFallbackUsed?: boolean;
523
+ parserFindings?: number;
524
+ cloudRunProcessor?: {
525
+ route: DocumentIntakeProcessorRouteDto;
526
+ resultArtifact?: DocumentIntakeProcessorResultArtifactDto | null;
527
+ summary?: DocumentIntakeProcessorSummaryDto | null;
528
+ };
410
529
  counts?: JsonRecord;
411
530
  error?: string;
412
531
  [key: string]: unknown;
@@ -2,7 +2,6 @@ export const DOCUMENT_INTAKE_EDGE_FUNCTIONS = {
2
2
  createBatch: "document-intake-create-batch",
3
3
  registerFiles: "document-intake-register-files",
4
4
  processFile: "document-intake-process-file",
5
- processFileWorker: "document-intake-process-file-worker",
6
5
  processingReaper: "document-intake-processing-reaper",
7
6
  getBatch: "document-intake-get-batch",
8
7
  listBatches: "document-intake-list-batches",
@@ -0,0 +1,233 @@
1
+ import type { AiModelInvocationSummaryDto } from "./document-intake.js";
2
+ import type { JsonRecord } from "./json.js";
3
+ export declare const ENTITY_REVIEW_EDGE_FUNCTIONS: {
4
+ readonly listRequests: "entity-review-list-requests";
5
+ readonly getRequest: "entity-review-get-request";
6
+ readonly createRequest: "entity-review-create-request";
7
+ readonly updateRequest: "entity-review-update-request";
8
+ readonly decideRequest: "entity-review-decide-request";
9
+ readonly listPolicies: "entity-review-list-policies";
10
+ readonly upsertPolicy: "entity-review-upsert-policy";
11
+ };
12
+ export type EntityReviewEndpointKey = keyof typeof ENTITY_REVIEW_EDGE_FUNCTIONS;
13
+ export type EntityReviewEdgeFunctionName = (typeof ENTITY_REVIEW_EDGE_FUNCTIONS)[EntityReviewEndpointKey];
14
+ export type EntityReviewStatus = "open" | "queued" | "in_review" | "needs_info" | "approved" | "rejected" | "ignored" | "superseded";
15
+ export type EntityReviewAction = "create" | "map" | "merge" | "reject" | "ignore";
16
+ export type EntityReviewAutomationMode = "manual_only" | "ai_suggest" | "ai_auto_approve";
17
+ export type EntityReviewDecisionSource = "human" | "ai" | "system";
18
+ export type EntityReviewDecision = "approve_create" | "approve_map" | "approve_merge" | "reject" | "ignore" | "needs_info";
19
+ export type EntityReviewDecisionStatus = "recorded" | "applied" | "failed" | "superseded";
20
+ export interface EntityReviewTargetRefDto<TMetadata extends JsonRecord = JsonRecord> extends JsonRecord {
21
+ schema: string;
22
+ table: string;
23
+ id: string;
24
+ label?: string | null;
25
+ metadata?: TMetadata;
26
+ }
27
+ export interface EntityReviewRequestDto<TMetadata extends JsonRecord = JsonRecord> extends JsonRecord {
28
+ id: string;
29
+ organization_id: string;
30
+ source_system: string;
31
+ source_domain: string | null;
32
+ source_batch_id: string | null;
33
+ source_file_id: string | null;
34
+ source_job_id: string | null;
35
+ source_candidate_id: string | null;
36
+ source_finding_id: string | null;
37
+ source_entity_resolution_id: string | null;
38
+ entity_role: string;
39
+ target_schema: string;
40
+ target_table: string;
41
+ source_value: string;
42
+ normalized_value: string | null;
43
+ status: EntityReviewStatus | string;
44
+ requested_action: EntityReviewAction | string;
45
+ recommended_action: EntityReviewAction | string | null;
46
+ recommended_target?: EntityReviewTargetRefDto | null;
47
+ recommended_payload?: JsonRecord | null;
48
+ confidence: number | null;
49
+ priority: number;
50
+ title: string | null;
51
+ description: string | null;
52
+ evidence_refs?: JsonRecord[];
53
+ metadata?: TMetadata | null;
54
+ requested_by_profile_id: string | null;
55
+ assigned_to_profile_id: string | null;
56
+ ai_model_invocation_id: string | null;
57
+ ai_model_invocation?: AiModelInvocationSummaryDto | null;
58
+ created_at: string;
59
+ updated_at: string;
60
+ decided_at: string | null;
61
+ decided_by_profile_id: string | null;
62
+ }
63
+ export interface EntityReviewCandidateDto<TPayload extends JsonRecord = JsonRecord> extends JsonRecord {
64
+ id: string;
65
+ request_id: string;
66
+ target_schema: string;
67
+ target_table: string;
68
+ target_id: string;
69
+ target_label: string;
70
+ match_score: number | null;
71
+ rank: number | null;
72
+ payload?: TPayload | null;
73
+ created_at: string;
74
+ }
75
+ export interface EntityReviewDecisionDto<TPayload extends JsonRecord = JsonRecord> extends JsonRecord {
76
+ id: string;
77
+ request_id: string;
78
+ decision: EntityReviewDecision | string;
79
+ source: EntityReviewDecisionSource | string;
80
+ decided_by_profile_id: string | null;
81
+ ai_model_invocation_id: string | null;
82
+ ai_model_invocation?: AiModelInvocationSummaryDto | null;
83
+ payload?: TPayload | null;
84
+ result?: JsonRecord | null;
85
+ status: EntityReviewDecisionStatus | string;
86
+ created_at: string;
87
+ }
88
+ export interface EntityReviewRequestSourceDto<TMetadata extends JsonRecord = JsonRecord> extends JsonRecord {
89
+ id: string;
90
+ request_id: string;
91
+ source_system: string;
92
+ source_domain: string | null;
93
+ source_batch_id: string | null;
94
+ source_file_id: string | null;
95
+ source_job_id: string | null;
96
+ source_candidate_id: string | null;
97
+ source_finding_id: string | null;
98
+ source_entity_resolution_id: string | null;
99
+ source_record_key: string | null;
100
+ evidence_refs?: JsonRecord[];
101
+ metadata?: TMetadata | null;
102
+ created_at: string;
103
+ }
104
+ export interface EntityReviewAutomationPolicyDto<TMetadata extends JsonRecord = JsonRecord> extends JsonRecord {
105
+ id: string;
106
+ organization_id: string;
107
+ source_system: string | null;
108
+ source_domain: string | null;
109
+ target_schema: string;
110
+ target_table: string;
111
+ entity_role: string;
112
+ requested_action: EntityReviewAction | string;
113
+ mode: EntityReviewAutomationMode | string;
114
+ min_confidence: number | null;
115
+ require_human_for_low_confidence: boolean;
116
+ priority: number;
117
+ is_enabled: boolean;
118
+ effective_from: string | null;
119
+ effective_until: string | null;
120
+ metadata?: TMetadata | null;
121
+ created_at: string;
122
+ updated_at: string;
123
+ }
124
+ export interface EntityReviewAiInvocationSummaryDto<TMetadata extends JsonRecord = JsonRecord> extends JsonRecord {
125
+ model_invocation: AiModelInvocationSummaryDto<TMetadata>;
126
+ request_id?: string | null;
127
+ policy_id?: string | null;
128
+ decision_id?: string | null;
129
+ agent_key?: string | null;
130
+ automation_mode?: EntityReviewAutomationMode | string | null;
131
+ }
132
+ export interface EntityReviewListRequestsRequest extends JsonRecord {
133
+ status?: EntityReviewStatus | EntityReviewStatus[] | string | string[];
134
+ sourceSystem?: string;
135
+ sourceDomain?: string;
136
+ targetSchema?: string;
137
+ targetTable?: string;
138
+ entityRole?: string;
139
+ limit?: number;
140
+ offset?: number;
141
+ }
142
+ export interface EntityReviewListRequestsResponse {
143
+ requests: EntityReviewRequestDto[];
144
+ }
145
+ export interface EntityReviewGetRequestRequest extends JsonRecord {
146
+ requestId: string;
147
+ }
148
+ export interface EntityReviewGetRequestResponse {
149
+ request: EntityReviewRequestDto;
150
+ candidates?: EntityReviewCandidateDto[];
151
+ decisions?: EntityReviewDecisionDto[];
152
+ sources?: EntityReviewRequestSourceDto[];
153
+ }
154
+ export interface EntityReviewCreateRequestRequest<TMetadata extends JsonRecord = JsonRecord> extends JsonRecord {
155
+ sourceSystem: string;
156
+ sourceDomain?: string | null;
157
+ sourceBatchId?: string | null;
158
+ sourceFileId?: string | null;
159
+ sourceJobId?: string | null;
160
+ sourceCandidateId?: string | null;
161
+ sourceFindingId?: string | null;
162
+ sourceEntityResolutionId?: string | null;
163
+ entityRole: string;
164
+ targetSchema: string;
165
+ targetTable: string;
166
+ sourceValue: string;
167
+ normalizedValue?: string | null;
168
+ requestedAction: EntityReviewAction;
169
+ recommendedAction?: EntityReviewAction | null;
170
+ recommendedTarget?: EntityReviewTargetRefDto | null;
171
+ recommendedPayload?: JsonRecord | null;
172
+ confidence?: number | null;
173
+ priority?: number;
174
+ title?: string | null;
175
+ description?: string | null;
176
+ evidenceRefs?: JsonRecord[];
177
+ metadata?: TMetadata;
178
+ }
179
+ export interface EntityReviewCreateRequestResponse {
180
+ request: EntityReviewRequestDto;
181
+ }
182
+ export interface EntityReviewUpdateRequestRequest<TMetadata extends JsonRecord = JsonRecord> extends JsonRecord {
183
+ requestId: string;
184
+ status?: EntityReviewStatus;
185
+ assignedToProfileId?: string | null;
186
+ priority?: number;
187
+ metadata?: TMetadata;
188
+ }
189
+ export interface EntityReviewUpdateRequestResponse {
190
+ request: EntityReviewRequestDto;
191
+ }
192
+ export interface EntityReviewDecideRequestRequest<TPayload extends JsonRecord = JsonRecord> extends JsonRecord {
193
+ requestId: string;
194
+ decision: EntityReviewDecision;
195
+ source?: EntityReviewDecisionSource;
196
+ payload?: TPayload;
197
+ }
198
+ export interface EntityReviewDecideRequestResponse {
199
+ request: EntityReviewRequestDto;
200
+ decision: EntityReviewDecisionDto;
201
+ }
202
+ export interface EntityReviewListPoliciesRequest extends JsonRecord {
203
+ sourceSystem?: string | null;
204
+ sourceDomain?: string | null;
205
+ targetSchema?: string;
206
+ targetTable?: string;
207
+ entityRole?: string;
208
+ requestedAction?: EntityReviewAction;
209
+ includeDisabled?: boolean;
210
+ }
211
+ export interface EntityReviewListPoliciesResponse {
212
+ policies: EntityReviewAutomationPolicyDto[];
213
+ }
214
+ export interface EntityReviewUpsertPolicyRequest<TMetadata extends JsonRecord = JsonRecord> extends JsonRecord {
215
+ policyId?: string;
216
+ sourceSystem?: string | null;
217
+ sourceDomain?: string | null;
218
+ targetSchema: string;
219
+ targetTable: string;
220
+ entityRole: string;
221
+ requestedAction: EntityReviewAction;
222
+ mode: EntityReviewAutomationMode;
223
+ minConfidence?: number | null;
224
+ requireHumanForLowConfidence?: boolean;
225
+ priority?: number;
226
+ isEnabled?: boolean;
227
+ effectiveFrom?: string | null;
228
+ effectiveUntil?: string | null;
229
+ metadata?: TMetadata;
230
+ }
231
+ export interface EntityReviewUpsertPolicyResponse {
232
+ policy: EntityReviewAutomationPolicyDto;
233
+ }
@@ -0,0 +1,9 @@
1
+ export const ENTITY_REVIEW_EDGE_FUNCTIONS = {
2
+ listRequests: "entity-review-list-requests",
3
+ getRequest: "entity-review-get-request",
4
+ createRequest: "entity-review-create-request",
5
+ updateRequest: "entity-review-update-request",
6
+ decideRequest: "entity-review-decide-request",
7
+ listPolicies: "entity-review-list-policies",
8
+ upsertPolicy: "entity-review-upsert-policy",
9
+ };
@@ -10202,6 +10202,25 @@ export type Database = {
10202
10202
  ref_counts: number[];
10203
10203
  }[];
10204
10204
  };
10205
+ find_duplicate_event_editions: {
10206
+ Args: {
10207
+ p_organization_id: string;
10208
+ p_similarity_threshold?: number;
10209
+ };
10210
+ Returns: {
10211
+ cluster_key: string;
10212
+ cluster_year: number;
10213
+ edition_count: number;
10214
+ edition_ids: string[];
10215
+ edition_names: string[];
10216
+ end_dates: string[];
10217
+ fk_row_counts: number[];
10218
+ scope_label: string;
10219
+ start_dates: string[];
10220
+ venue_ids: string[];
10221
+ venue_labels: string[];
10222
+ }[];
10223
+ };
10205
10224
  find_duplicate_venues: {
10206
10225
  Args: {
10207
10226
  p_organization_id: string;
@@ -10497,6 +10516,14 @@ export type Database = {
10497
10516
  };
10498
10517
  Returns: Json;
10499
10518
  };
10519
+ merge_event_editions: {
10520
+ Args: {
10521
+ p_canonical_id: string;
10522
+ p_dry_run?: boolean;
10523
+ p_duplicate_ids: string[];
10524
+ };
10525
+ Returns: Json;
10526
+ };
10500
10527
  merge_persons: {
10501
10528
  Args: {
10502
10529
  p_keep_id: string;
@@ -11385,6 +11412,7 @@ export type Database = {
11385
11412
  created_at: string;
11386
11413
  domain_key: string;
11387
11414
  entity_key: string;
11415
+ entity_review_request_id: string | null;
11388
11416
  entity_role: string;
11389
11417
  evidence_refs: Json;
11390
11418
  file_id: string | null;
@@ -11414,6 +11442,7 @@ export type Database = {
11414
11442
  created_at?: string;
11415
11443
  domain_key: string;
11416
11444
  entity_key: string;
11445
+ entity_review_request_id?: string | null;
11417
11446
  entity_role: string;
11418
11447
  evidence_refs?: Json;
11419
11448
  file_id?: string | null;
@@ -11443,6 +11472,7 @@ export type Database = {
11443
11472
  created_at?: string;
11444
11473
  domain_key?: string;
11445
11474
  entity_key?: string;
11475
+ entity_review_request_id?: string | null;
11446
11476
  entity_role?: string;
11447
11477
  evidence_refs?: Json;
11448
11478
  file_id?: string | null;
@@ -11820,6 +11850,7 @@ export type Database = {
11820
11850
  created_at: string;
11821
11851
  document_family: string | null;
11822
11852
  domain_key: string;
11853
+ entity_review_request_id: string | null;
11823
11854
  evidence_refs: Json;
11824
11855
  feature_key: string | null;
11825
11856
  file_id: string | null;
@@ -11856,6 +11887,7 @@ export type Database = {
11856
11887
  created_at?: string;
11857
11888
  document_family?: string | null;
11858
11889
  domain_key: string;
11890
+ entity_review_request_id?: string | null;
11859
11891
  evidence_refs?: Json;
11860
11892
  feature_key?: string | null;
11861
11893
  file_id?: string | null;
@@ -11892,6 +11924,7 @@ export type Database = {
11892
11924
  created_at?: string;
11893
11925
  document_family?: string | null;
11894
11926
  domain_key?: string;
11927
+ entity_review_request_id?: string | null;
11895
11928
  evidence_refs?: Json;
11896
11929
  feature_key?: string | null;
11897
11930
  file_id?: string | null;
@@ -12344,6 +12377,361 @@ export type Database = {
12344
12377
  [_ in never]: never;
12345
12378
  };
12346
12379
  };
12380
+ entity_review: {
12381
+ Tables: {
12382
+ automation_policies: {
12383
+ Row: {
12384
+ action: string;
12385
+ ai_agent_key: string | null;
12386
+ ai_agent_version: string | null;
12387
+ created_at: string;
12388
+ effective_from: string | null;
12389
+ effective_until: string | null;
12390
+ enabled: boolean;
12391
+ entity_role: string;
12392
+ id: string;
12393
+ metadata: Json;
12394
+ minimum_confidence: number | null;
12395
+ mode: string;
12396
+ organization_id: string;
12397
+ priority: number;
12398
+ requires_evidence: boolean;
12399
+ source_domain: string | null;
12400
+ source_system: string | null;
12401
+ target_schema: string;
12402
+ target_table: string;
12403
+ updated_at: string;
12404
+ };
12405
+ Insert: {
12406
+ action: string;
12407
+ ai_agent_key?: string | null;
12408
+ ai_agent_version?: string | null;
12409
+ created_at?: string;
12410
+ effective_from?: string | null;
12411
+ effective_until?: string | null;
12412
+ enabled?: boolean;
12413
+ entity_role: string;
12414
+ id?: string;
12415
+ metadata?: Json;
12416
+ minimum_confidence?: number | null;
12417
+ mode: string;
12418
+ organization_id: string;
12419
+ priority?: number;
12420
+ requires_evidence?: boolean;
12421
+ source_domain?: string | null;
12422
+ source_system?: string | null;
12423
+ target_schema?: string;
12424
+ target_table: string;
12425
+ updated_at?: string;
12426
+ };
12427
+ Update: {
12428
+ action?: string;
12429
+ ai_agent_key?: string | null;
12430
+ ai_agent_version?: string | null;
12431
+ created_at?: string;
12432
+ effective_from?: string | null;
12433
+ effective_until?: string | null;
12434
+ enabled?: boolean;
12435
+ entity_role?: string;
12436
+ id?: string;
12437
+ metadata?: Json;
12438
+ minimum_confidence?: number | null;
12439
+ mode?: string;
12440
+ organization_id?: string;
12441
+ priority?: number;
12442
+ requires_evidence?: boolean;
12443
+ source_domain?: string | null;
12444
+ source_system?: string | null;
12445
+ target_schema?: string;
12446
+ target_table?: string;
12447
+ updated_at?: string;
12448
+ };
12449
+ Relationships: [];
12450
+ };
12451
+ candidates: {
12452
+ Row: {
12453
+ created_at: string;
12454
+ id: string;
12455
+ is_recommended: boolean;
12456
+ match_method: string | null;
12457
+ match_score: number | null;
12458
+ rank: number | null;
12459
+ request_id: string;
12460
+ target_id: string | null;
12461
+ target_label: string;
12462
+ target_payload: Json;
12463
+ target_schema: string;
12464
+ target_table: string;
12465
+ };
12466
+ Insert: {
12467
+ created_at?: string;
12468
+ id?: string;
12469
+ is_recommended?: boolean;
12470
+ match_method?: string | null;
12471
+ match_score?: number | null;
12472
+ rank?: number | null;
12473
+ request_id: string;
12474
+ target_id?: string | null;
12475
+ target_label: string;
12476
+ target_payload?: Json;
12477
+ target_schema: string;
12478
+ target_table: string;
12479
+ };
12480
+ Update: {
12481
+ created_at?: string;
12482
+ id?: string;
12483
+ is_recommended?: boolean;
12484
+ match_method?: string | null;
12485
+ match_score?: number | null;
12486
+ rank?: number | null;
12487
+ request_id?: string;
12488
+ target_id?: string | null;
12489
+ target_label?: string;
12490
+ target_payload?: Json;
12491
+ target_schema?: string;
12492
+ target_table?: string;
12493
+ };
12494
+ Relationships: [
12495
+ {
12496
+ foreignKeyName: "candidates_request_id_fkey";
12497
+ columns: ["request_id"];
12498
+ isOneToOne: false;
12499
+ referencedRelation: "requests";
12500
+ referencedColumns: ["id"];
12501
+ }
12502
+ ];
12503
+ };
12504
+ decisions: {
12505
+ Row: {
12506
+ actor_user_id: string | null;
12507
+ ai_model_invocation_id: string | null;
12508
+ created_at: string;
12509
+ decision: string;
12510
+ decision_source: string;
12511
+ error_message: string | null;
12512
+ id: string;
12513
+ payload: Json;
12514
+ request_id: string;
12515
+ result: Json;
12516
+ target_id: string | null;
12517
+ target_schema: string | null;
12518
+ target_table: string | null;
12519
+ };
12520
+ Insert: {
12521
+ actor_user_id?: string | null;
12522
+ ai_model_invocation_id?: string | null;
12523
+ created_at?: string;
12524
+ decision: string;
12525
+ decision_source: string;
12526
+ error_message?: string | null;
12527
+ id?: string;
12528
+ payload?: Json;
12529
+ request_id: string;
12530
+ result?: Json;
12531
+ target_id?: string | null;
12532
+ target_schema?: string | null;
12533
+ target_table?: string | null;
12534
+ };
12535
+ Update: {
12536
+ actor_user_id?: string | null;
12537
+ ai_model_invocation_id?: string | null;
12538
+ created_at?: string;
12539
+ decision?: string;
12540
+ decision_source?: string;
12541
+ error_message?: string | null;
12542
+ id?: string;
12543
+ payload?: Json;
12544
+ request_id?: string;
12545
+ result?: Json;
12546
+ target_id?: string | null;
12547
+ target_schema?: string | null;
12548
+ target_table?: string | null;
12549
+ };
12550
+ Relationships: [
12551
+ {
12552
+ foreignKeyName: "decisions_request_id_fkey";
12553
+ columns: ["request_id"];
12554
+ isOneToOne: false;
12555
+ referencedRelation: "requests";
12556
+ referencedColumns: ["id"];
12557
+ }
12558
+ ];
12559
+ };
12560
+ request_sources: {
12561
+ Row: {
12562
+ created_at: string;
12563
+ evidence_refs: Json;
12564
+ id: string;
12565
+ metadata: Json;
12566
+ request_id: string;
12567
+ source_batch_id: string | null;
12568
+ source_candidate_id: string | null;
12569
+ source_domain: string | null;
12570
+ source_entity_resolution_id: string | null;
12571
+ source_file_id: string | null;
12572
+ source_finding_id: string | null;
12573
+ source_system: string;
12574
+ };
12575
+ Insert: {
12576
+ created_at?: string;
12577
+ evidence_refs?: Json;
12578
+ id?: string;
12579
+ metadata?: Json;
12580
+ request_id: string;
12581
+ source_batch_id?: string | null;
12582
+ source_candidate_id?: string | null;
12583
+ source_domain?: string | null;
12584
+ source_entity_resolution_id?: string | null;
12585
+ source_file_id?: string | null;
12586
+ source_finding_id?: string | null;
12587
+ source_system: string;
12588
+ };
12589
+ Update: {
12590
+ created_at?: string;
12591
+ evidence_refs?: Json;
12592
+ id?: string;
12593
+ metadata?: Json;
12594
+ request_id?: string;
12595
+ source_batch_id?: string | null;
12596
+ source_candidate_id?: string | null;
12597
+ source_domain?: string | null;
12598
+ source_entity_resolution_id?: string | null;
12599
+ source_file_id?: string | null;
12600
+ source_finding_id?: string | null;
12601
+ source_system?: string;
12602
+ };
12603
+ Relationships: [
12604
+ {
12605
+ foreignKeyName: "request_sources_request_id_fkey";
12606
+ columns: ["request_id"];
12607
+ isOneToOne: false;
12608
+ referencedRelation: "requests";
12609
+ referencedColumns: ["id"];
12610
+ }
12611
+ ];
12612
+ };
12613
+ requests: {
12614
+ Row: {
12615
+ ai_model_invocation_id: string | null;
12616
+ ai_policy_snapshot: Json | null;
12617
+ assigned_to: string | null;
12618
+ blocks_source_publish: boolean;
12619
+ confidence: number | null;
12620
+ created_at: string;
12621
+ created_by: string | null;
12622
+ display_value: string | null;
12623
+ entity_role: string;
12624
+ evidence_refs: Json;
12625
+ id: string;
12626
+ metadata: Json;
12627
+ normalized_value: string | null;
12628
+ organization_id: string;
12629
+ priority: string;
12630
+ recommended_action: string | null;
12631
+ recommended_payload: Json | null;
12632
+ recommended_target_ref: Json | null;
12633
+ requested_action: string;
12634
+ reviewed_at: string | null;
12635
+ reviewed_by: string | null;
12636
+ source_batch_id: string | null;
12637
+ source_candidate_id: string | null;
12638
+ source_domain: string | null;
12639
+ source_entity_resolution_id: string | null;
12640
+ source_file_id: string | null;
12641
+ source_finding_id: string | null;
12642
+ source_system: string;
12643
+ source_value: string;
12644
+ status: string;
12645
+ target_schema: string;
12646
+ target_table: string;
12647
+ updated_at: string;
12648
+ };
12649
+ Insert: {
12650
+ ai_model_invocation_id?: string | null;
12651
+ ai_policy_snapshot?: Json | null;
12652
+ assigned_to?: string | null;
12653
+ blocks_source_publish?: boolean;
12654
+ confidence?: number | null;
12655
+ created_at?: string;
12656
+ created_by?: string | null;
12657
+ display_value?: string | null;
12658
+ entity_role: string;
12659
+ evidence_refs?: Json;
12660
+ id?: string;
12661
+ metadata?: Json;
12662
+ normalized_value?: string | null;
12663
+ organization_id: string;
12664
+ priority?: string;
12665
+ recommended_action?: string | null;
12666
+ recommended_payload?: Json | null;
12667
+ recommended_target_ref?: Json | null;
12668
+ requested_action: string;
12669
+ reviewed_at?: string | null;
12670
+ reviewed_by?: string | null;
12671
+ source_batch_id?: string | null;
12672
+ source_candidate_id?: string | null;
12673
+ source_domain?: string | null;
12674
+ source_entity_resolution_id?: string | null;
12675
+ source_file_id?: string | null;
12676
+ source_finding_id?: string | null;
12677
+ source_system: string;
12678
+ source_value: string;
12679
+ status?: string;
12680
+ target_schema?: string;
12681
+ target_table: string;
12682
+ updated_at?: string;
12683
+ };
12684
+ Update: {
12685
+ ai_model_invocation_id?: string | null;
12686
+ ai_policy_snapshot?: Json | null;
12687
+ assigned_to?: string | null;
12688
+ blocks_source_publish?: boolean;
12689
+ confidence?: number | null;
12690
+ created_at?: string;
12691
+ created_by?: string | null;
12692
+ display_value?: string | null;
12693
+ entity_role?: string;
12694
+ evidence_refs?: Json;
12695
+ id?: string;
12696
+ metadata?: Json;
12697
+ normalized_value?: string | null;
12698
+ organization_id?: string;
12699
+ priority?: string;
12700
+ recommended_action?: string | null;
12701
+ recommended_payload?: Json | null;
12702
+ recommended_target_ref?: Json | null;
12703
+ requested_action?: string;
12704
+ reviewed_at?: string | null;
12705
+ reviewed_by?: string | null;
12706
+ source_batch_id?: string | null;
12707
+ source_candidate_id?: string | null;
12708
+ source_domain?: string | null;
12709
+ source_entity_resolution_id?: string | null;
12710
+ source_file_id?: string | null;
12711
+ source_finding_id?: string | null;
12712
+ source_system?: string;
12713
+ source_value?: string;
12714
+ status?: string;
12715
+ target_schema?: string;
12716
+ target_table?: string;
12717
+ updated_at?: string;
12718
+ };
12719
+ Relationships: [];
12720
+ };
12721
+ };
12722
+ Views: {
12723
+ [_ in never]: never;
12724
+ };
12725
+ Functions: {
12726
+ [_ in never]: never;
12727
+ };
12728
+ Enums: {
12729
+ [_ in never]: never;
12730
+ };
12731
+ CompositeTypes: {
12732
+ [_ in never]: never;
12733
+ };
12734
+ };
12347
12735
  external_sync: {
12348
12736
  Tables: {
12349
12737
  artist_core_links: {
@@ -19649,6 +20037,13 @@ export type Database = {
19649
20037
  };
19650
20038
  Returns: undefined;
19651
20039
  };
20040
+ relink_orphaned_resolver_editions: {
20041
+ Args: {
20042
+ p_dry_run?: boolean;
20043
+ p_organization_id: string;
20044
+ };
20045
+ Returns: Json;
20046
+ };
19652
20047
  resolve_group_against_series: {
19653
20048
  Args: {
19654
20049
  p_match_event_name?: string;
@@ -19906,6 +20301,74 @@ export type Database = {
19906
20301
  }
19907
20302
  ];
19908
20303
  };
20304
+ ad_spend_daily: {
20305
+ Row: {
20306
+ adset_or_adgroup_id: string;
20307
+ campaign_external_id: string;
20308
+ campaign_name: string | null;
20309
+ clicks: number | null;
20310
+ conversions: number | null;
20311
+ cpm_cents: number | null;
20312
+ ctr: number | null;
20313
+ event_edition_id: string | null;
20314
+ id: string;
20315
+ impressions: number | null;
20316
+ organization_id: string;
20317
+ platform: string;
20318
+ raw: Json | null;
20319
+ reach: number | null;
20320
+ spend_cents: number;
20321
+ spend_date: string;
20322
+ synced_at: string;
20323
+ };
20324
+ Insert: {
20325
+ adset_or_adgroup_id?: string;
20326
+ campaign_external_id?: string;
20327
+ campaign_name?: string | null;
20328
+ clicks?: number | null;
20329
+ conversions?: number | null;
20330
+ cpm_cents?: number | null;
20331
+ ctr?: number | null;
20332
+ event_edition_id?: string | null;
20333
+ id?: string;
20334
+ impressions?: number | null;
20335
+ organization_id: string;
20336
+ platform: string;
20337
+ raw?: Json | null;
20338
+ reach?: number | null;
20339
+ spend_cents?: number;
20340
+ spend_date: string;
20341
+ synced_at?: string;
20342
+ };
20343
+ Update: {
20344
+ adset_or_adgroup_id?: string;
20345
+ campaign_external_id?: string;
20346
+ campaign_name?: string | null;
20347
+ clicks?: number | null;
20348
+ conversions?: number | null;
20349
+ cpm_cents?: number | null;
20350
+ ctr?: number | null;
20351
+ event_edition_id?: string | null;
20352
+ id?: string;
20353
+ impressions?: number | null;
20354
+ organization_id?: string;
20355
+ platform?: string;
20356
+ raw?: Json | null;
20357
+ reach?: number | null;
20358
+ spend_cents?: number;
20359
+ spend_date?: string;
20360
+ synced_at?: string;
20361
+ };
20362
+ Relationships: [
20363
+ {
20364
+ foreignKeyName: "ad_spend_daily_event_edition_id_fkey";
20365
+ columns: ["event_edition_id"];
20366
+ isOneToOne: false;
20367
+ referencedRelation: "event_intelligence_projection";
20368
+ referencedColumns: ["event_edition_id"];
20369
+ }
20370
+ ];
20371
+ };
19909
20372
  artist_affinity_links: {
19910
20373
  Row: {
19911
20374
  affinity_score: number;
@@ -20986,6 +21449,24 @@ export type Database = {
20986
21449
  }
20987
21450
  ];
20988
21451
  };
21452
+ demo_orgs: {
21453
+ Row: {
21454
+ created_at: string;
21455
+ label: string | null;
21456
+ organization_id: string;
21457
+ };
21458
+ Insert: {
21459
+ created_at?: string;
21460
+ label?: string | null;
21461
+ organization_id: string;
21462
+ };
21463
+ Update: {
21464
+ created_at?: string;
21465
+ label?: string | null;
21466
+ organization_id?: string;
21467
+ };
21468
+ Relationships: [];
21469
+ };
20989
21470
  edition_sales_config: {
20990
21471
  Row: {
20991
21472
  announce_at: string | null;
@@ -21434,6 +21915,36 @@ export type Database = {
21434
21915
  }
21435
21916
  ];
21436
21917
  };
21918
+ oauth_states: {
21919
+ Row: {
21920
+ created_at: string;
21921
+ expires_at: string;
21922
+ organization_id: string;
21923
+ platform: string;
21924
+ redirect_to: string | null;
21925
+ state: string;
21926
+ user_id: string | null;
21927
+ };
21928
+ Insert: {
21929
+ created_at?: string;
21930
+ expires_at?: string;
21931
+ organization_id: string;
21932
+ platform: string;
21933
+ redirect_to?: string | null;
21934
+ state: string;
21935
+ user_id?: string | null;
21936
+ };
21937
+ Update: {
21938
+ created_at?: string;
21939
+ expires_at?: string;
21940
+ organization_id?: string;
21941
+ platform?: string;
21942
+ redirect_to?: string | null;
21943
+ state?: string;
21944
+ user_id?: string | null;
21945
+ };
21946
+ Relationships: [];
21947
+ };
21437
21948
  platform_connection_secrets: {
21438
21949
  Row: {
21439
21950
  access_token_ref: string;
@@ -22316,6 +22827,10 @@ export type Database = {
22316
22827
  };
22317
22828
  Returns: Json;
22318
22829
  };
22830
+ gc_oauth_states: {
22831
+ Args: never;
22832
+ Returns: number;
22833
+ };
22319
22834
  generate_marketing_calendar: {
22320
22835
  Args: {
22321
22836
  p_edition: string;
@@ -29530,6 +30045,9 @@ export declare const Constants: {
29530
30045
  readonly document_intake: {
29531
30046
  readonly Enums: {};
29532
30047
  };
30048
+ readonly entity_review: {
30049
+ readonly Enums: {};
30050
+ };
29533
30051
  readonly external_sync: {
29534
30052
  readonly Enums: {};
29535
30053
  };
@@ -739,6 +739,9 @@ export const Constants = {
739
739
  document_intake: {
740
740
  Enums: {},
741
741
  },
742
+ entity_review: {
743
+ Enums: {},
744
+ },
742
745
  external_sync: {
743
746
  Enums: {},
744
747
  },
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./app-context.js";
2
2
  export * from "./auth.js";
3
3
  export type * from "./db-enums.js";
4
4
  export * from "./document-intake.js";
5
+ export * from "./entity-review.js";
5
6
  export * from "./json.js";
6
7
  export * from "./rad-rpc.js";
7
8
  export * from "./schema-client.js";
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./app-context.js";
2
2
  export * from "./auth.js";
3
3
  export * from "./document-intake.js";
4
+ export * from "./entity-review.js";
4
5
  export * from "./json.js";
5
6
  export * from "./rad-rpc.js";
6
7
  export * from "./schema-client.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjromeoent/ein-supabase",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Shared Supabase types, app context, and contract helpers for EIN-connected apps.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -28,6 +28,10 @@
28
28
  "types": "./dist/document-intake.d.ts",
29
29
  "import": "./dist/document-intake.js"
30
30
  },
31
+ "./entity-review": {
32
+ "types": "./dist/entity-review.d.ts",
33
+ "import": "./dist/entity-review.js"
34
+ },
31
35
  "./generated/database.types": {
32
36
  "types": "./dist/generated/database.types.d.ts",
33
37
  "import": "./dist/generated/database.types.js"