Skip to content

Commit 24d5fa2

Browse files
committed
fix(files): regenerate v2 artifacts, pin the path flag in route tests, tighten resolver types
1 parent 2bc981a commit 24d5fa2

9 files changed

Lines changed: 55 additions & 30 deletions

File tree

‎apps/docs/content/docs/cli/files.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ sim files describe <fileId> [options]
102102

103103
| Argument | Required | Description |
104104
| --- | --- | --- |
105-
| `fileId` | Yes | File identifier, or the file’s VFS path: `files/<folder>/<name>`. |
105+
| `fileId` | Yes | File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id. |
106106

107107
</CommandTable>
108108

@@ -303,7 +303,7 @@ sim files rename <fileId> [options]
303303

304304
| Argument | Required | Description |
305305
| --- | --- | --- |
306-
| `fileId` | Yes | File identifier, or the file’s VFS path: `files/<folder>/<name>`. |
306+
| `fileId` | Yes | File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id. |
307307

308308
</CommandTable>
309309

@@ -613,7 +613,7 @@ sim files delete <fileId> [options]
613613

614614
| Argument | Required | Description |
615615
| --- | --- | --- |
616-
| `fileId` | Yes | File identifier, or the file’s VFS path: `files/<folder>/<name>`. |
616+
| `fileId` | Yes | File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id. |
617617

618618
</CommandTable>
619619

‎apps/docs/content/docs/cli/reference.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ sim files delete <fileId> [options]
11811181

11821182
| Argument | Required | Description |
11831183
| --- | --- | --- |
1184-
| `fileId` | Yes | File identifier, or the file’s VFS path: `files/<folder>/<name>`. |
1184+
| `fileId` | Yes | File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id. |
11851185

11861186
</CommandTable>
11871187

@@ -1426,7 +1426,7 @@ sim files describe <fileId> [options]
14261426

14271427
| Argument | Required | Description |
14281428
| --- | --- | --- |
1429-
| `fileId` | Yes | File identifier, or the file’s VFS path: `files/<folder>/<name>`. |
1429+
| `fileId` | Yes | File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id. |
14301430

14311431
</CommandTable>
14321432

@@ -1591,7 +1591,7 @@ sim files rename <fileId> [options]
15911591

15921592
| Argument | Required | Description |
15931593
| --- | --- | --- |
1594-
| `fileId` | Yes | File identifier, or the file’s VFS path: `files/<folder>/<name>`. |
1594+
| `fileId` | Yes | File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id. |
15951595

15961596
</CommandTable>
15971597

‎apps/docs/openapi-v2-files-audit.json‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,12 +2151,12 @@
21512151
"name": "fileId",
21522152
"in": "path",
21532153
"required": true,
2154-
"description": "File identifier, or the file’s VFS path: `files/<folder>/<name>`.",
2154+
"description": "File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id.",
21552155
"schema": {
21562156
"type": "string",
21572157
"minLength": 1,
21582158
"maxLength": 4096,
2159-
"description": "File identifier, or the file’s VFS path: `files/<folder>/<name>`."
2159+
"description": "File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id."
21602160
}
21612161
},
21622162
{
@@ -2237,12 +2237,12 @@
22372237
"name": "fileId",
22382238
"in": "path",
22392239
"required": true,
2240-
"description": "File identifier, or the file’s VFS path: `files/<folder>/<name>`.",
2240+
"description": "File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id.",
22412241
"schema": {
22422242
"type": "string",
22432243
"minLength": 1,
22442244
"maxLength": 4096,
2245-
"description": "File identifier, or the file’s VFS path: `files/<folder>/<name>`."
2245+
"description": "File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id."
22462246
}
22472247
}
22482248
],
@@ -2487,12 +2487,12 @@
24872487
"name": "fileId",
24882488
"in": "path",
24892489
"required": true,
2490-
"description": "File identifier, or the file’s VFS path: `files/<folder>/<name>`.",
2490+
"description": "File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id.",
24912491
"schema": {
24922492
"type": "string",
24932493
"minLength": 1,
24942494
"maxLength": 4096,
2495-
"description": "File identifier, or the file’s VFS path: `files/<folder>/<name>`."
2495+
"description": "File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id."
24962496
}
24972497
},
24982498
{

‎apps/sim/app/api/v2/files/[fileId]/metadata/route.test.ts‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ describe('GET /api/v2/files/[fileId]/metadata', () => {
113113
expect((await response.json()).error.code).toBe('NOT_FOUND')
114114
expect(readMetadata).toHaveBeenCalledWith(
115115
expect.objectContaining({
116-
input: { fileId: FILE_ID, assertedWorkspaceId: WORKSPACE_ID, includeDeleted: false },
116+
input: {
117+
fileId: FILE_ID,
118+
acceptVfsPath: true,
119+
assertedWorkspaceId: WORKSPACE_ID,
120+
includeDeleted: false,
121+
},
117122
})
118123
)
119124
})
@@ -127,7 +132,12 @@ describe('GET /api/v2/files/[fileId]/metadata', () => {
127132
expect((await response.json()).error.code).toBe('NOT_FOUND')
128133
expect(readMetadata).toHaveBeenCalledWith(
129134
expect.objectContaining({
130-
input: { fileId: FILE_ID, assertedWorkspaceId: WORKSPACE_ID, includeDeleted: false },
135+
input: {
136+
fileId: FILE_ID,
137+
acceptVfsPath: true,
138+
assertedWorkspaceId: WORKSPACE_ID,
139+
includeDeleted: false,
140+
},
131141
})
132142
)
133143
})
@@ -159,7 +169,12 @@ describe('GET /api/v2/files/[fileId]/metadata', () => {
159169
expect(readMetadata).toHaveBeenCalledWith(
160170
expect.objectContaining({
161171
principal: auth.principal,
162-
input: { fileId: FILE_ID, assertedWorkspaceId: WORKSPACE_ID, includeDeleted: true },
172+
input: {
173+
fileId: FILE_ID,
174+
acceptVfsPath: true,
175+
assertedWorkspaceId: WORKSPACE_ID,
176+
includeDeleted: true,
177+
},
163178
})
164179
)
165180
})

‎apps/sim/lib/workspace-files/application/delete-workspace-file.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import {
99
import { defineAuthorizedWorkspaceFileUseCase } from '@/lib/workspace-files/application/authorized-workspace-file-use-case'
1010
import {
1111
resolveActiveWorkspaceFileContext,
12-
type WorkspaceFileReferenceInput,
12+
type WorkspaceFileTargetInput,
1313
} from '@/lib/workspace-files/application/file-context'
1414
import { fileOperations } from '@/lib/workspace-files/application/operations'
1515

1616
const logger = createLogger('DeleteWorkspaceFile')
1717

18-
export type DeleteWorkspaceFileInput = WorkspaceFileReferenceInput
18+
export type DeleteWorkspaceFileInput = WorkspaceFileTargetInput
1919

2020
export interface DeleteWorkspaceFileResult {
2121
id: string

‎apps/sim/lib/workspace-files/application/file-context.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ownedFileKind } from '@/lib/workspace-files/owned-files'
1313
import { matchesFileOwner } from '@/lib/workspace-files/ownership'
1414

1515
/** How a use case names one workspace file: its id, or with `acceptVfsPath` its exact VFS path. */
16-
export interface WorkspaceFileReferenceInput {
16+
export interface WorkspaceFileTargetInput {
1717
fileId: string
1818
assertedWorkspaceId?: string
1919
/**
@@ -24,7 +24,7 @@ export interface WorkspaceFileReferenceInput {
2424
acceptVfsPath?: boolean
2525
}
2626

27-
export interface WorkspaceFileContextInput extends WorkspaceFileReferenceInput {
27+
export interface WorkspaceFileContextInput extends WorkspaceFileTargetInput {
2828
includeDeleted?: boolean
2929
/**
3030
* Admit a chat upload (`context = 'mothership'`) addressed by its own id. Only read
@@ -93,16 +93,17 @@ function requireWorkspaceFileContext<C extends ActiveWorkspaceFileContext>(
9393
*/
9494
async function resolveFileId(input: WorkspaceFileContextInput): Promise<string> {
9595
if (!input.acceptVfsPath || !isWorkspaceFileVfsPath(input.fileId)) return input.fileId
96-
const notFound = new OrchestrationError('not_found', 'File not found')
97-
if (input.assertedWorkspaceId === undefined) throw notFound
96+
if (input.assertedWorkspaceId === undefined) {
97+
throw new OrchestrationError('not_found', 'File not found')
98+
}
9899
const file = await resolveFileReference(
99100
{ entityType: 'workspace', entityId: input.assertedWorkspaceId },
100101
input.fileId
101102
).catch((error: unknown) => {
102103
if (error instanceof OrchestrationError && error.code === 'conflict') return null
103104
throw error
104105
})
105-
if (!file) throw notFound
106+
if (!file) throw new OrchestrationError('not_found', 'File not found')
106107
return file.id
107108
}
108109

@@ -122,7 +123,7 @@ export async function resolveActiveWorkspaceFileContext(
122123
}
123124

124125
export async function resolveWorkspaceFileLifecycleContext(
125-
input: Omit<WorkspaceFileContextInput, 'acceptVfsPath'>
126+
input: Pick<WorkspaceFileTargetInput, 'fileId' | 'assertedWorkspaceId'>
126127
): Promise<WorkspaceFileLifecycleContext> {
127128
return requireWorkspaceFileContext(
128129
await loadWorkspaceFileLifecycleContext(input.fileId),

‎apps/sim/lib/workspace-files/application/read-workspace-file-metadata.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import {
1313
import { defineAuthorizedWorkspaceFileUseCase } from '@/lib/workspace-files/application/authorized-workspace-file-use-case'
1414
import {
1515
resolveActiveWorkspaceFileContext,
16-
type WorkspaceFileReferenceInput,
16+
type WorkspaceFileTargetInput,
1717
} from '@/lib/workspace-files/application/file-context'
1818
import { fileOperations } from '@/lib/workspace-files/application/operations'
1919

20-
export interface ReadWorkspaceFileMetadataInput extends WorkspaceFileReferenceInput {
20+
export interface ReadWorkspaceFileMetadataInput extends WorkspaceFileTargetInput {
2121
/**
2222
* Opt into the archived lifecycle set. It relaxes only the `deleted_at` predicate on the
2323
* canonical row lookup — the workspace the file resolves to, the asserted-workspace check,

‎apps/sim/lib/workspace-files/application/rename-workspace-file.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import {
1010
import { defineAuthorizedWorkspaceFileUseCase } from '@/lib/workspace-files/application/authorized-workspace-file-use-case'
1111
import {
1212
resolveActiveWorkspaceFileContext,
13-
type WorkspaceFileReferenceInput,
13+
type WorkspaceFileTargetInput,
1414
} from '@/lib/workspace-files/application/file-context'
1515
import { fileOperations } from '@/lib/workspace-files/application/operations'
1616

1717
const logger = createLogger('RenameWorkspaceFile')
1818

19-
export interface RenameWorkspaceFileInput extends WorkspaceFileReferenceInput {
19+
export interface RenameWorkspaceFileInput extends WorkspaceFileTargetInput {
2020
name: string
2121
}
2222

‎packages/sim-cli/src/generated/v2-api.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17680,7 +17680,10 @@ export const V2_OPERATIONS = {
1768017680
method: 'DELETE',
1768117681
path: '/api/v2/files/[fileId]',
1768217682
pathParams: ['fileId'] as const,
17683-
pathParamDocs: { fileId: 'File identifier, or the file’s VFS path: `files/<folder>/<name>`.' },
17683+
pathParamDocs: {
17684+
fileId:
17685+
'File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id.',
17686+
},
1768417687
responseMode: 'json',
1768517688
summary: 'Delete file',
1768617689
query: {
@@ -18673,7 +18676,10 @@ export const V2_OPERATIONS = {
1867318676
method: 'GET',
1867418677
path: '/api/v2/files/[fileId]/metadata',
1867518678
pathParams: ['fileId'] as const,
18676-
pathParamDocs: { fileId: 'File identifier, or the file’s VFS path: `files/<folder>/<name>`.' },
18679+
pathParamDocs: {
18680+
fileId:
18681+
'File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id.',
18682+
},
1867718683
responseMode: 'json',
1867818684
summary: 'Get file metadata',
1867918685
query: {
@@ -22959,7 +22965,10 @@ export const V2_OPERATIONS = {
2295922965
method: 'PATCH',
2296022966
path: '/api/v2/files/[fileId]',
2296122967
pathParams: ['fileId'] as const,
22962-
pathParamDocs: { fileId: 'File identifier, or the file’s VFS path: `files/<folder>/<name>`.' },
22968+
pathParamDocs: {
22969+
fileId:
22970+
'File identifier, or the VFS path of a live file: `files/<folder>/<name>`. A path that names no single live file is not found; pass the id.',
22971+
},
2296322972
responseMode: 'json',
2296422973
summary: 'Rename file',
2296522974
body: {

0 commit comments

Comments
 (0)