feat(typescript-client): add deleteS3File + optional workspace arg on S3 helpers (#9300)

* feat(typescript-client): add deleteS3File + optional workspace arg on S3 helpers

Customer-requested ergonomics for the TypeScript SDK:

- New `deleteS3File(s3object, workspace?)` wrapper around the existing
  `HelpersService.deleteS3File` (backend endpoint is already there). Saves
  callers from having to either hand-roll `denoS3LightClientSettings()` +
  AWS SDK calls, or wire up `HelpersService` directly.
- `denoS3LightClientSettings`, `loadS3File`, `loadS3FileStream`, `writeS3File`,
  and the new `deleteS3File` all gain an optional trailing `workspace?: string`
  parameter that falls back to the `WM_WORKSPACE` env var via `getWorkspace()`.
  Mirrors the calling convention customers already expect from helpers like
  `getVariable` / `runScript`.

`build.sh` and `build.jsr.sh` are updated to export `deleteS3File` from both
the NPM and JSR entry points.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore: regenerate system_prompts auto-generated for new S3 helpers

`python system_prompts/generate.py` after adding deleteS3File and the
optional workspace param to the existing S3 helpers, so the agent-facing
docs (CLI skills, TS SDK prompt, script skills) reflect the new signatures.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alexander Petric
2026-05-22 16:58:50 -04:00
committed by GitHub
parent e3fbc20c29
commit daab561ec0
11 changed files with 306 additions and 57 deletions
+92 -16
View File
@@ -605,9 +605,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -618,8 +619,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* \`\`\`
*
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -629,8 +632,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* \`\`\`
*
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -640,8 +645,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* \`\`\`
*
* @param workspace - Workspace to write to (defaults to the \`WM_WORKSPACE\` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* \`\`\`typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* \`\`\`
*
* @param s3object - S3 object identifying the file to delete (must have \`s3\` set)
* @param workspace - Workspace to delete from (defaults to the \`WM_WORKSPACE\` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
@@ -1296,9 +1315,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -1309,8 +1329,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* \`\`\`
*
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -1320,8 +1342,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* \`\`\`
*
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -1331,8 +1355,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* \`\`\`
*
* @param workspace - Workspace to write to (defaults to the \`WM_WORKSPACE\` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* \`\`\`typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* \`\`\`
*
* @param s3object - S3 object identifying the file to delete (must have \`s3\` set)
* @param workspace - Workspace to delete from (defaults to the \`WM_WORKSPACE\` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
@@ -2075,9 +2113,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -2088,8 +2127,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* \`\`\`
*
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -2099,8 +2140,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* \`\`\`
*
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -2110,8 +2153,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* \`\`\`
*
* @param workspace - Workspace to write to (defaults to the \`WM_WORKSPACE\` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* \`\`\`typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* \`\`\`
*
* @param s3object - S3 object identifying the file to delete (must have \`s3\` set)
* @param workspace - Workspace to delete from (defaults to the \`WM_WORKSPACE\` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
@@ -3277,9 +3334,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -3290,8 +3348,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* \`\`\`
*
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -3301,8 +3361,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* \`\`\`
*
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -3312,8 +3374,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* \`\`\`
*
* @param workspace - Workspace to write to (defaults to the \`WM_WORKSPACE\` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* \`\`\`typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* \`\`\`
*
* @param s3object - S3 object identifying the file to delete (must have \`s3\` set)
* @param workspace - Workspace to delete from (defaults to the \`WM_WORKSPACE\` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
+23 -4
View File
@@ -1165,9 +1165,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -1178,8 +1179,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* \`\`\`
*
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -1189,8 +1192,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* \`\`\`
*
* @param workspace - Workspace to read from (defaults to the \`WM_WORKSPACE\` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -1200,8 +1205,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* \`\`\`
*
* @param workspace - Workspace to write to (defaults to the \`WM_WORKSPACE\` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* \`\`\`typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* \`\`\`
*
* @param s3object - S3 object identifying the file to delete (must have \`s3\` set)
* @param workspace - Workspace to delete from (defaults to the \`WM_WORKSPACE\` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
+23 -4
View File
@@ -1641,9 +1641,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -1654,8 +1655,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -1665,8 +1668,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -1676,8 +1681,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* ```
*
* @param workspace - Workspace to write to (defaults to the `WM_WORKSPACE` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* ```typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* ```
*
* @param s3object - S3 object identifying the file to delete (must have `s3` set)
* @param workspace - Workspace to delete from (defaults to the `WM_WORKSPACE` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
@@ -236,9 +236,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -249,8 +250,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -260,8 +263,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -271,8 +276,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* ```
*
* @param workspace - Workspace to write to (defaults to the `WM_WORKSPACE` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* ```typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* ```
*
* @param s3object - S3 object identifying the file to delete (must have `s3` set)
* @param workspace - Workspace to delete from (defaults to the `WM_WORKSPACE` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
@@ -391,9 +391,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -404,8 +405,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -415,8 +418,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -426,8 +431,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* ```
*
* @param workspace - Workspace to write to (defaults to the `WM_WORKSPACE` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* ```typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* ```
*
* @param s3object - S3 object identifying the file to delete (must have `s3` set)
* @param workspace - Workspace to delete from (defaults to the `WM_WORKSPACE` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
@@ -389,9 +389,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -402,8 +403,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -413,8 +416,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -424,8 +429,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* ```
*
* @param workspace - Workspace to write to (defaults to the `WM_WORKSPACE` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* ```typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* ```
*
* @param s3object - S3 object identifying the file to delete (must have `s3` set)
* @param workspace - Workspace to delete from (defaults to the `WM_WORKSPACE` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
@@ -395,9 +395,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -408,8 +409,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -419,8 +422,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -430,8 +435,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* ```
*
* @param workspace - Workspace to write to (defaults to the `WM_WORKSPACE` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* ```typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* ```
*
* @param s3object - S3 object identifying the file to delete (must have `s3` set)
* @param workspace - Workspace to delete from (defaults to the `WM_WORKSPACE` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
@@ -355,9 +355,10 @@ async duckdbConnectionSettings(s3_resource_path: string | undefined): Promise<an
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
* @returns S3 client configuration settings
*/
async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>
async denoS3LightClientSettings(s3_resource_path: string | undefined, workspace: string | undefined = undefined): Promise<DenoS3LightClientSettings>
/**
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -368,8 +369,10 @@ async denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<D
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Uint8Array | undefined>
async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Uint8Array | undefined>
/**
* Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -379,8 +382,10 @@ async loadS3File(s3object: S3Object, s3ResourcePath: string | undefined = undefi
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined): Promise<Blob | undefined>
async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined = undefined, workspace: string | undefined = undefined): Promise<Blob | undefined>
/**
* Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
@@ -390,8 +395,22 @@ async loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined =
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* ```
*
* @param workspace - Workspace to write to (defaults to the `WM_WORKSPACE` env var)
*/
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined): Promise<S3Object>
async writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined = undefined, contentType: string | undefined = undefined, contentDisposition: string | undefined = undefined, workspace: string | undefined = undefined): Promise<S3Object>
/**
* Permanently delete a file from S3 by key.
*
* ```typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* ```
*
* @param s3object - S3 object identifying the file to delete (must have `s3` set)
* @param workspace - Workspace to delete from (defaults to the `WM_WORKSPACE` env var)
*/
async deleteS3File(s3object: S3Object, workspace: string | undefined = undefined): Promise<void>
/**
* Sign S3 objects to be used by anonymous users in public apps
+1 -1
View File
@@ -15,6 +15,6 @@ cp "${script_dirpath}/sqlUtils.ts" "${script_dirpath}/src/"
echo "" >> "${script_dirpath}/src/index.ts"
echo 'export type { DenoS3LightClientSettings } from "./s3Types";' >> "${script_dirpath}/src/index.ts"
echo "" >> "${script_dirpath}/src/index.ts"
echo 'export { type Base64, setClient, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, setProgress, getProgress, getState, getIdToken, denoS3LightClientSettings, loadS3FileStream, loadS3File, writeS3File, signS3Objects, signS3Object, getPresignedS3PublicUrls, getPresignedS3PublicUrl, task, runScript, runScriptAsync, runScriptByPath, runScriptByHash, runScriptByPathAsync, runScriptByHashAsync, runFlow, runFlowAsync, waitJob, getRootJobId, setFlowUserState, getFlowUserState, usernameToEmail, requestInteractiveSlackApproval, Sql, requestInteractiveTeamsApproval, appendToResultStream, streamResult, datatable, ducklake, type DatatableSqlTemplateFunction, type SqlTemplateFunction, type S3Object, type S3ObjectRecord, type S3ObjectURI } from "./client";' >> "${script_dirpath}/src/index.ts"
echo 'export { type Base64, setClient, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, setProgress, getProgress, getState, getIdToken, denoS3LightClientSettings, loadS3FileStream, loadS3File, writeS3File, deleteS3File, signS3Objects, signS3Object, getPresignedS3PublicUrls, getPresignedS3PublicUrl, task, runScript, runScriptAsync, runScriptByPath, runScriptByHash, runScriptByPathAsync, runScriptByHashAsync, runFlow, runFlowAsync, waitJob, getRootJobId, setFlowUserState, getFlowUserState, usernameToEmail, requestInteractiveSlackApproval, Sql, requestInteractiveTeamsApproval, appendToResultStream, streamResult, datatable, ducklake, type DatatableSqlTemplateFunction, type SqlTemplateFunction, type S3Object, type S3ObjectRecord, type S3ObjectURI } from "./client";' >> "${script_dirpath}/src/index.ts"
+3 -1
View File
@@ -40,7 +40,7 @@ cp "${script_dirpath}/sqlUtils.ts" "${script_dirpath}/src/"
echo "" >> "${script_dirpath}/src/index.ts"
echo 'export type { DenoS3LightClientSettings } from "./s3Types";' >> "${script_dirpath}/src/index.ts"
echo "" >> "${script_dirpath}/src/index.ts"
echo 'export { type Base64, setClient, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, setProgress, getProgress, getState, getIdToken, denoS3LightClientSettings, loadS3FileStream, loadS3File, writeS3File, signS3Objects, signS3Object, getPresignedS3PublicUrls, getPresignedS3PublicUrl, task, taskScript, taskFlow, workflow, step, sleep, parallel, waitForApproval, type TaskOptions, WorkflowCtx, _workflowCtx, setWorkflowCtx, StepSuspend, runScript, runScriptAsync, runScriptByPath, runScriptByHash, runScriptByPathAsync, runScriptByHashAsync, runFlow, runFlowAsync, waitJob, getRootJobId, setFlowUserState, getFlowUserState, usernameToEmail, requestInteractiveSlackApproval, type Sql, requestInteractiveTeamsApproval, appendToResultStream, streamResult, datatable, ducklake, type DatatableSqlTemplateFunction, type SqlTemplateFunction, type S3Object, type S3ObjectRecord, type S3ObjectURI, commitKafkaOffsets } from "./client";' >> "${script_dirpath}/src/index.ts"
echo 'export { type Base64, setClient, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, setProgress, getProgress, getState, getIdToken, denoS3LightClientSettings, loadS3FileStream, loadS3File, writeS3File, deleteS3File, signS3Objects, signS3Object, getPresignedS3PublicUrls, getPresignedS3PublicUrl, task, taskScript, taskFlow, workflow, step, sleep, parallel, waitForApproval, type TaskOptions, WorkflowCtx, _workflowCtx, setWorkflowCtx, StepSuspend, runScript, runScriptAsync, runScriptByPath, runScriptByHash, runScriptByPathAsync, runScriptByHashAsync, runFlow, runFlowAsync, waitJob, getRootJobId, setFlowUserState, getFlowUserState, usernameToEmail, requestInteractiveSlackApproval, type Sql, requestInteractiveTeamsApproval, appendToResultStream, streamResult, datatable, ducklake, type DatatableSqlTemplateFunction, type SqlTemplateFunction, type S3Object, type S3ObjectRecord, type S3ObjectURI, commitKafkaOffsets } from "./client";' >> "${script_dirpath}/src/index.ts"
# Build default export by combining client utilities + services
# This preserves backward compatibility for `import wmill from "windmill-client"`
@@ -63,6 +63,7 @@ import {
loadS3FileStream,
loadS3File,
writeS3File,
deleteS3File,
signS3Objects,
signS3Object,
getPresignedS3PublicUrls,
@@ -148,6 +149,7 @@ const wmill = {
loadS3FileStream,
loadS3File,
writeS3File,
deleteS3File,
signS3Objects,
signS3Object,
getPresignedS3PublicUrls,
+49 -11
View File
@@ -805,14 +805,15 @@ export async function databaseUrlFromResource(path: string): Promise<string> {
/**
* Get S3 client settings from a resource or workspace default
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
* @returns S3 client configuration settings
*/
export async function denoS3LightClientSettings(
s3_resource_path: string | undefined
s3_resource_path: string | undefined,
workspace: string | undefined = undefined
): Promise<DenoS3LightClientSettings> {
const workspace = getWorkspace();
const s3Resource = await HelpersService.s3ResourceInfo({
workspace: workspace,
workspace: workspace ?? getWorkspace(),
requestBody: {
s3_resource_path:
parseResourceSyntax(s3_resource_path) ?? s3_resource_path,
@@ -833,12 +834,19 @@ export async function denoS3LightClientSettings(
* const text = new TextDecoder().decode(fileContentStream)
* console.log(text);
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
export async function loadS3File(
s3object: S3Object,
s3ResourcePath: string | undefined = undefined
s3ResourcePath: string | undefined = undefined,
workspace: string | undefined = undefined
): Promise<Uint8Array | undefined> {
const fileContentBlob = await loadS3FileStream(s3object, s3ResourcePath);
const fileContentBlob = await loadS3FileStream(
s3object,
s3ResourcePath,
workspace
);
if (fileContentBlob === undefined) {
return undefined;
}
@@ -874,10 +882,13 @@ export async function loadS3File(
* // if the content is plain text, the blob can be read directly:
* console.log(await fileContentBlob.text());
* ```
*
* @param workspace - Workspace to read from (defaults to the `WM_WORKSPACE` env var)
*/
export async function loadS3FileStream(
s3object: S3Object,
s3ResourcePath: string | undefined = undefined
s3ResourcePath: string | undefined = undefined,
workspace: string | undefined = undefined
): Promise<Blob | undefined> {
let s3Obj = s3object && parseS3Object(s3object);
let params: Record<string, string> = {};
@@ -889,12 +900,11 @@ export async function loadS3FileStream(
params["storage"] = s3Obj.storage;
}
const queryParams = new URLSearchParams(params);
const w = workspace ?? getWorkspace();
// We use raw fetch here b/c OpenAPI generated client doesn't handle Blobs nicely
const response = await fetch(
`${
OpenAPI.BASE
}/w/${getWorkspace()}/job_helpers/download_s3_file?${queryParams}`,
`${OpenAPI.BASE}/w/${w}/job_helpers/download_s3_file?${queryParams}`,
{
method: "GET",
headers: {
@@ -922,13 +932,16 @@ export async function loadS3FileStream(
* const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
* console.log(fileContentAsUtf8Str)
* ```
*
* @param workspace - Workspace to write to (defaults to the `WM_WORKSPACE` env var)
*/
export async function writeS3File(
s3object: S3Object | undefined,
fileContent: string | Blob,
s3ResourcePath: string | undefined = undefined,
contentType: string | undefined = undefined,
contentDisposition: string | undefined = undefined
contentDisposition: string | undefined = undefined,
workspace: string | undefined = undefined
): Promise<S3Object> {
let fileContentBlob: Blob;
if (typeof fileContent === "string") {
@@ -942,7 +955,7 @@ export async function writeS3File(
let s3Obj = s3object && parseS3Object(s3object);
const response = await HelpersService.fileUpload({
workspace: getWorkspace(),
workspace: workspace ?? getWorkspace(),
fileKey: s3Obj?.s3,
fileExtension: undefined,
s3ResourcePath: s3ResourcePath,
@@ -957,6 +970,31 @@ export async function writeS3File(
};
}
/**
* Permanently delete a file from S3 by key.
*
* ```typescript
* await wmill.deleteS3File({ s3: "path/to/file.txt" })
* ```
*
* @param s3object - S3 object identifying the file to delete (must have `s3` set)
* @param workspace - Workspace to delete from (defaults to the `WM_WORKSPACE` env var)
*/
export async function deleteS3File(
s3object: S3Object,
workspace: string | undefined = undefined
): Promise<void> {
const s3Obj = parseS3Object(s3object);
if (!s3Obj.s3) {
throw new Error("deleteS3File: s3 key is required");
}
await HelpersService.deleteS3File({
workspace: workspace ?? getWorkspace(),
fileKey: s3Obj.s3,
storage: s3Obj.storage,
});
}
/**
* Sign S3 objects to be used by anonymous users in public apps
* @param s3objects s3 objects to sign