Files
simstudioai--sim/apps/sim/lib/execution/payloads/large-execution-value.test.ts
T
wehub-resource-sync d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

73 lines
2.1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
LARGE_ARRAY_MANIFEST_MARKER,
LARGE_ARRAY_MANIFEST_VERSION,
type LargeArrayManifest,
} from '@/lib/execution/payloads/large-array-manifest-metadata'
import {
collectLargeValueExecutionIds,
collectLargeValueKeys,
} from '@/lib/execution/payloads/large-execution-value'
import {
LARGE_VALUE_REF_MARKER,
LARGE_VALUE_REF_VERSION,
type LargeValueRef,
} from '@/lib/execution/payloads/large-value-ref'
function largeValueRef(id: string, executionId: string): LargeValueRef {
return {
[LARGE_VALUE_REF_MARKER]: true,
version: LARGE_VALUE_REF_VERSION,
id,
kind: 'object',
size: 10,
key: `execution/workspace-1/workflow-1/${executionId}/large-value-${id}.json`,
executionId,
}
}
function largeArrayManifest(executionId: string): LargeArrayManifest {
const ref = largeValueRef('lv_MNOPQRSTUVWX', executionId)
return {
[LARGE_ARRAY_MANIFEST_MARKER]: true,
version: LARGE_ARRAY_MANIFEST_VERSION,
kind: 'array',
totalCount: 1,
chunkCount: 1,
byteSize: ref.size,
chunks: [{ ref, count: 1, byteSize: ref.size }],
preview: [],
}
}
describe('collectLargeValueExecutionIds', () => {
it('collects deduplicated execution IDs from nested refs and manifests', () => {
const executionIds = collectLargeValueExecutionIds({
blockStates: {
upstream: {
output: {
directRef: largeValueRef('lv_ABCDEFGHIJKL', 'execution-a'),
inheritedManifest: largeArrayManifest('execution-b'),
duplicateRef: largeValueRef('lv_NOPQRSTUVWXY', 'execution-a'),
},
},
},
})
expect(executionIds).toEqual(['execution-a', 'execution-b'])
})
it('collects deduplicated storage keys from nested refs and manifests', () => {
const keys = collectLargeValueKeys({
directRef: largeValueRef('lv_ABCDEFGHIJKL', 'execution-a'),
manifest: largeArrayManifest('execution-b'),
})
expect(keys).toEqual([
'execution/workspace-1/workflow-1/execution-a/large-value-lv_ABCDEFGHIJKL.json',
'execution/workspace-1/workflow-1/execution-b/large-value-lv_MNOPQRSTUVWX.json',
])
})
})