@@ -2,7 +2,6 @@ import { z } from "zod";
22import { zod } from "../util/zod" ;
33import {
44 stateUpdateTable ,
5- stateEventTable ,
65 Action ,
76 UpdateCommand ,
87 Command ,
@@ -11,10 +10,6 @@ import {
1110 stateCountTable ,
1211} from "./state.sql" ;
1312
14- import {
15- stateEventTable as pg_stateEventTable ,
16- stateUpdateTable as pg_stateUpdateTable ,
17- } from "./state.pg" ;
1813import {
1914 createTransaction ,
2015 createTransactionEffect ,
@@ -36,7 +31,7 @@ import { Replicache } from "../replicache";
3631import { app , stage } from "../app/app.sql" ;
3732import { bus } from "sst/aws/bus" ;
3833import { Resource as SSTResource } from "sst" ;
39- import { map , mapValues , pipe , unique } from "remeda" ;
34+ import { map , pipe , unique } from "remeda" ;
4035import { Enrichers } from "../app/resource" ;
4136import { queue } from "../util/queue" ;
4237import { DateTime } from "luxon" ;
@@ -47,7 +42,6 @@ import {
4742import { runTable } from "../run/run.sql" ;
4843import { objectFlatten } from "../util/object" ;
4944import { logger } from "../util/log" ;
50- import { postgres } from "../drizzle/postgres" ;
5145import { disposable } from "../util/disposable" ;
5246
5347export module State {
@@ -215,30 +209,6 @@ export module State {
215209 } ;
216210 }
217211
218- export function serializeEvent (
219- input : typeof stateEventTable . $inferSelect ,
220- ) : ResourceEvent {
221- return {
222- id : input . id ,
223- type : input . type ,
224- time : {
225- created : input . timeCreated . toISOString ( ) ,
226- updated : input . timeUpdated . toISOString ( ) ,
227- deleted : input . timeDeleted ?. toISOString ( ) ,
228- stateCreated : input . timeStateCreated ?. toISOString ( ) ,
229- stateModified : input . timeStateModified ?. toISOString ( ) ,
230- } ,
231- stageID : input . stageID ,
232- custom : input . custom ,
233- updateID : input . updateID ,
234- urn : input . urn ,
235- inputs : input . inputs ,
236- parent : input . parent || undefined ,
237- outputs : input . outputs ,
238- action : input . action ,
239- } ;
240- }
241-
242212 export function serializeResource (
243213 input : typeof stateResourceTable . $inferSelect ,
244214 ) : Resource {
@@ -378,7 +348,6 @@ export module State {
378348 previousState . resources . map ( ( r : any ) => [ r . urn , r ] ) ,
379349 ) ;
380350
381- const eventInserts = [ ] as ( typeof stateEventTable . $inferInsert ) [ ] ;
382351 const resourceDeletes = [ ] as string [ ] ;
383352 const counts = { } as Record < string , number > ;
384353 console . log ( {
@@ -423,44 +392,11 @@ export module State {
423392
424393 delete inputs [ "__provider" ] ;
425394 delete outputs [ "__provider" ] ;
426-
427- eventInserts . push ( {
428- stageID : input . config . stageID ,
429- updateID : updateID ,
430- id : createId ( ) ,
431- timeStateModified : resource . modified
432- ? new Date ( resource . modified )
433- : null ,
434- timeStateCreated : resource . created
435- ? new Date ( resource . created )
436- : null ,
437- workspaceID : useWorkspace ( ) ,
438- type : resource . type ,
439- urn : resource . urn ,
440- custom : resource . custom ,
441- inputs : inputs ,
442- outputs : outputs ,
443- parent : resource . parent ,
444- action : action ,
445- } ) ;
446395 }
447396 }
448397 for ( const urn of Object . keys ( previousResources ) ) {
449398 const resource = previousResources [ urn ] ;
450399 counts [ "deleted" ] = ( counts [ "deleted" ] || 0 ) + 1 ;
451- eventInserts . push ( {
452- stageID : input . config . stageID ,
453- updateID,
454- action : "deleted" ,
455- id : createId ( ) ,
456- workspaceID : useWorkspace ( ) ,
457- type : resource . type ,
458- urn : resource . urn ,
459- custom : resource . custom ,
460- inputs : { } ,
461- outputs : { } ,
462- parent : resource . parent ,
463- } ) ;
464400 resourceDeletes . push ( resource . urn ) ;
465401 }
466402 await createTransaction (
@@ -480,8 +416,6 @@ export module State {
480416 eq ( stateUpdateTable . id , updateID ) ,
481417 ) ,
482418 ) ;
483- if ( eventInserts . length )
484- await tx . insert ( stateEventTable ) . ignore ( ) . values ( eventInserts ) ;
485419 if ( resourceDeletes . length )
486420 await tx
487421 . delete ( stateResourceTable )
0 commit comments