11import { toError } from '@sim/utils/errors'
2- import { collectUserFileKeys } from '@/lib/core/utils/user-file '
2+ import { recordMaterializedAccessKeys } from '@/lib/execution/payloads/access-keys '
33import {
44 isLargeArrayManifest ,
55 LARGE_ARRAY_MANIFEST_MARKER ,
66 materializeLargeArrayManifest ,
77} from '@/lib/execution/payloads/large-array-manifest'
8- import { collectLargeValueKeys } from '@/lib/execution/payloads/large-execution-value'
98import { isLargeValueRef , LARGE_VALUE_REF_MARKER } from '@/lib/execution/payloads/large-value-ref'
109import { MAX_DURABLE_LARGE_VALUE_BYTES } from '@/lib/execution/payloads/materialization.server'
1110import { materializeLargeValueRef } from '@/lib/execution/payloads/store'
1211import { REFERENCE } from '@/executor/constants'
1312import type { ExecutionContext } from '@/executor/types'
1413import type { VariableResolver } from '@/executor/variables/resolver'
1514
16- function recordMaterializedKeys ( ctx : ExecutionContext , value : unknown ) : void {
17- const largeValueKeys = collectLargeValueKeys ( value )
18- if ( largeValueKeys . length > 0 ) {
19- ctx . largeValueKeys ??= [ ]
20- const existingKeys = new Set ( ctx . largeValueKeys )
21- for ( const key of largeValueKeys ) {
22- if ( ! existingKeys . has ( key ) ) {
23- existingKeys . add ( key )
24- ctx . largeValueKeys . push ( key )
25- }
26- }
27- }
28-
29- const fileKeys = collectUserFileKeys ( value )
30- if ( fileKeys . length > 0 ) {
31- ctx . fileKeys ??= [ ]
32- const existingKeys = new Set ( ctx . fileKeys )
33- for ( const key of fileKeys ) {
34- if ( ! existingKeys . has ( key ) ) {
35- existingKeys . add ( key )
36- ctx . fileKeys . push ( key )
37- }
38- }
39- }
40- }
41-
4215async function normalizeCollectionValue ( ctx : ExecutionContext , value : unknown ) : Promise < any [ ] > {
4316 if ( Array . isArray ( value ) ) {
4417 return value
@@ -56,7 +29,7 @@ async function normalizeCollectionValue(ctx: ExecutionContext, value: unknown):
5629 userId : ctx . userId ,
5730 maxBytes : MAX_DURABLE_LARGE_VALUE_BYTES ,
5831 } )
59- recordMaterializedKeys ( ctx , materialized )
32+ recordMaterializedAccessKeys ( ctx , materialized )
6033 return materialized
6134 }
6235
@@ -75,7 +48,7 @@ async function normalizeCollectionValue(ctx: ExecutionContext, value: unknown):
7548 if ( materialized === undefined ) {
7649 throw new Error ( 'Large execution value is unavailable.' )
7750 }
78- recordMaterializedKeys ( ctx , materialized )
51+ recordMaterializedAccessKeys ( ctx , materialized )
7952 return normalizeCollectionValue ( ctx , materialized )
8053 }
8154
0 commit comments