@zapier/zapier-sdk 0.107.2 → 0.108.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.108.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 47a61ba: `listConnections` and `waitForNewConnection` now:
8
+ - Raise a `ZapierValidationError` (`ZAPIER_VALIDATION_ERROR`) when a response or
9
+ connection row doesn't match the expected shape; previously the list path
10
+ did not validate rows. `waitForNewConnection` surfaces it on the first
11
+ malformed successful response — any number of pending responses may precede
12
+ it — rather than after exhausting its poll retries.
13
+ - Preserve error status codes and messages. Previously, some 4xx messages were
14
+ replaced with generic text and some 5xx responses were reported as generic
15
+ 502 errors.
16
+ - Match an `app` filter with an explicit version (e.g. `"github@1.2.3"`) even
17
+ when it can't be resolved through the manifest, instead of failing to match
18
+ anything.
19
+
20
+ `waitForNewConnection` now checks the most recently created connection.
21
+ Previously the row it checked was not the newest, so it could keep waiting past
22
+ a connection that had already been created, or settle on a different one.
23
+
24
+ `ApiClient.poll` now propagates a throw from a caller's `isPending` or
25
+ `resultExtractor` unchanged and stops polling, instead of retrying it three
26
+ times and rebranding it as a JSON parse failure. Return `true` from `isPending`
27
+ to keep polling; throw only to abandon the poll. An unreadable response body
28
+ still retries, now reported as "Poll response body was not valid JSON".
29
+ Consecutive HTTP error responses that exhaust polling retries now preserve
30
+ the upstream status code and are no longer counted and wrapped twice.
31
+
32
+ Output is unchanged for conforming responses.
33
+
34
+ ## 0.108.0
35
+
36
+ ### Minor Changes
37
+
38
+ - cd1cafb: Added nine experimental Virtual File System (VFS) methods to `@zapier/zapier-sdk/experimental` for reading and managing a user's stored files and directories: `readVfsFile`, `writeVfsFile`, `appendVfsFile`, `copyVfsFile`, `listVfsDirectory`, `createVfsDirectory`, `statVfsPath`, `deleteVfsPath`, and `moveVfsPath`.
39
+
40
+ Paths are absolute and must start with `/`. A missing path throws `ZapierResourceNotFoundError`; a policy denial throws `ZapierAuthenticationError`.
41
+
3
42
  ## 0.107.2
4
43
 
5
44
  ### Patch Changes
package/README.md CHANGED
@@ -105,6 +105,16 @@
105
105
  - [`resumeTriggerInbox`](#resumetriggerinbox)
106
106
  - [`updateTriggerInbox`](#updatetriggerinbox)
107
107
  - [`watchTriggerInbox`](#watchtriggerinbox)
108
+ - [Virtual File System (Experimental)](#virtual-file-system-experimental)
109
+ - [`appendVfsFile`](#appendvfsfile--experimental)
110
+ - [`copyVfsFile`](#copyvfsfile--experimental)
111
+ - [`createVfsDirectory`](#createvfsdirectory--experimental)
112
+ - [`deleteVfsPath`](#deletevfspath--experimental)
113
+ - [`listVfsDirectory`](#listvfsdirectory--experimental)
114
+ - [`moveVfsPath`](#movevfspath--experimental)
115
+ - [`readVfsFile`](#readvfsfile--experimental)
116
+ - [`statVfsPath`](#statvfspath--experimental)
117
+ - [`writeVfsFile`](#writevfsfile--experimental)
108
118
 
109
119
  ## Documentation
110
120
 
@@ -2844,7 +2854,7 @@ for await (const connection of zapier.listConnections().items()) {
2844
2854
 
2845
2855
  #### `waitForNewConnection`
2846
2856
 
2847
- Wait for a new connection to appear for the given app. Polls `/api/v0/connections` with server-side `ordering=-date` until the most recent matching row's `date` is at or after the started-at timestamp, then returns it. Pair with `get-connection-start-url` — that mints the URL the user opens, this waits for the resulting connection to land. Errors with a timeout after the configured timeout (default 5 min). Example (JS):
2857
+ Wait for a new connection to appear for the given app. Polls the connections list newest-first until the most recent matching row's `date` is at or after the started-at timestamp, then returns it. Pair with `get-connection-start-url` — that mints the URL the user opens, this waits for the resulting connection to land. Errors with a timeout after the configured timeout (default 5 min). Example (JS):
2848
2858
 
2849
2859
  ```ts
2850
2860
  const {
@@ -4248,3 +4258,312 @@ await zapier.watchTriggerInbox({
4248
4258
  },
4249
4259
  });
4250
4260
  ```
4261
+
4262
+ ### Virtual File System (Experimental)
4263
+
4264
+ > ℹ️ **Experimental.** Import from `"@zapier/zapier-sdk/experimental"` to use these methods. Methods and behavior may change.
4265
+
4266
+ #### `appendVfsFile` 🧪 _experimental_
4267
+
4268
+ Append content to a file in the Zapier Virtual File System (VFS). Creates the file if it doesn't exist; missing parent directories are created automatically. Safer than reading the file and rewriting it — appends server-side without a read/write round-trip. Paths are absolute (e.g. `/Mine/log.md`).
4269
+
4270
+ **Parameters:**
4271
+
4272
+ | Name | Type | Required | Default | Possible Values | Description |
4273
+ | ------------- | -------- | -------- | ------- | --------------- | ---------------------------------------------------------------------------------------------- |
4274
+ | `options` | `object` | ✅ | — | — | |
4275
+ | ​ ↳ `path` | `string` | ✅ | — | — | Absolute path of the file (must start with `/`). |
4276
+ | ​ ↳ `content` | `string` | ✅ | — | — | Content to append. Capped at 10 MB per call, and the resulting file must also fit under 10 MB. |
4277
+
4278
+ **Returns:** `Promise<VfsWriteResultItem>`
4279
+
4280
+ | Name | Type | Required | Possible Values | Description |
4281
+ | -------------- | -------- | -------- | -------------------- | -------------------------------------------------------------------- |
4282
+ | `data` | `object` | ✅ | — | |
4283
+ | ​ ↳ `path` | `string` | ✅ | — | Absolute path of the written file. |
4284
+ | ​ ↳ `version` | `number` | ✅ | — | Monotonic version stamped by the server on this write. |
4285
+ | ​ ↳ `action` | `string` | ✅ | `created`, `updated` | Whether the write created a new file or updated an existing one. |
4286
+ | ​ ↳ `warnings` | `array` | ❌ | — | Non-fatal issues the server surfaced alongside the successful write. |
4287
+
4288
+ **Example:**
4289
+
4290
+ ```typescript
4291
+ const { data: vfsWriteResult } = await zapier.appendVfsFile({
4292
+ path: "/Mine/notes.md",
4293
+ content: "example-content",
4294
+ });
4295
+ ```
4296
+
4297
+ #### `copyVfsFile` 🧪 _experimental_
4298
+
4299
+ Copy a file to a new path in the Zapier Virtual File System (VFS). Both `from` and `to` are absolute file paths (e.g. `/Mine/notes.md`), not directories.
4300
+
4301
+ **Parameters:**
4302
+
4303
+ | Name | Type | Required | Default | Possible Values | Description |
4304
+ | --------------------- | --------- | -------- | ------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
4305
+ | `options` | `object` | ✅ | — | — | |
4306
+ | ​ ↳ `from` | `string` | ✅ | — | — | Absolute path of the source file. |
4307
+ | ​ ↳ `to` | `string` | ✅ | — | — | Absolute path of the destination file. |
4308
+ | ​ ↳ `overwrite` | `boolean` | ❌ | — | — | When `true`, replace any existing file at `to`. Default `false` fails if `to` already exists. |
4309
+ | ​ ↳ `expectedVersion` | `number` | ❌ | — | — | Optional version pin for the destination. Requires `overwrite: true` and an existing file at `to`; the replace only succeeds if the destination's current version matches, otherwise the call fails. |
4310
+
4311
+ **Returns:** `Promise<VfsWriteResultItem>`
4312
+
4313
+ | Name | Type | Required | Possible Values | Description |
4314
+ | -------------- | -------- | -------- | -------------------- | -------------------------------------------------------------------- |
4315
+ | `data` | `object` | ✅ | — | |
4316
+ | ​ ↳ `path` | `string` | ✅ | — | Absolute path of the written file. |
4317
+ | ​ ↳ `version` | `number` | ✅ | — | Monotonic version stamped by the server on this write. |
4318
+ | ​ ↳ `action` | `string` | ✅ | `created`, `updated` | Whether the write created a new file or updated an existing one. |
4319
+ | ​ ↳ `warnings` | `array` | ❌ | — | Non-fatal issues the server surfaced alongside the successful write. |
4320
+
4321
+ **Example:**
4322
+
4323
+ ```typescript
4324
+ const { data: vfsWriteResult } = await zapier.copyVfsFile({
4325
+ from: "/Mine/notes.md",
4326
+ to: "/Mine/notes-copy.md",
4327
+ });
4328
+ ```
4329
+
4330
+ #### `createVfsDirectory` 🧪 _experimental_
4331
+
4332
+ Create a directory in the Zapier Virtual File System (VFS). Paths are absolute (e.g. `/Mine/notes`). Idempotent — safe to call on an existing directory.
4333
+
4334
+ **Parameters:**
4335
+
4336
+ | Name | Type | Required | Default | Possible Values | Description |
4337
+ | ---------- | -------- | -------- | ------- | --------------- | ----------------------------------------------------- |
4338
+ | `options` | `object` | ✅ | — | — | |
4339
+ | ​ ↳ `path` | `string` | ✅ | — | — | Absolute path of the directory (must start with `/`). |
4340
+
4341
+ **Returns:** `Promise<VfsMkdirResultItem>`
4342
+
4343
+ | Name | Type | Required | Possible Values | Description |
4344
+ | ------------ | -------- | -------- | -------------------- | ------------------------------------------------------------------------ |
4345
+ | `data` | `object` | ✅ | — | |
4346
+ | ​ ↳ `path` | `string` | ✅ | — | Absolute path of the created directory. |
4347
+ | ​ ↳ `action` | `string` | ✅ | `created`, `updated` | Whether the directory was newly created or already existed (idempotent). |
4348
+
4349
+ **Example:**
4350
+
4351
+ ```typescript
4352
+ const { data: vfsMkdirResult } = await zapier.createVfsDirectory({
4353
+ path: "/Mine/notes",
4354
+ });
4355
+ ```
4356
+
4357
+ #### `deleteVfsPath` 🧪 _experimental_
4358
+
4359
+ Delete a file or directory in the Zapier Virtual File System (VFS). Works on either; paths are absolute (e.g. `/Mine/notes.md`). Deletes are recoverable — contact Zapier support to restore an entry.
4360
+
4361
+ **Parameters:**
4362
+
4363
+ | Name | Type | Required | Default | Possible Values | Description |
4364
+ | ---------- | -------- | -------- | ------- | --------------- | ---------------------------------------------- |
4365
+ | `options` | `object` | ✅ | — | — | |
4366
+ | ​ ↳ `path` | `string` | ✅ | — | — | Absolute path to delete (must start with `/`). |
4367
+
4368
+ **Returns:** `Promise<VfsDeleteResultItem>`
4369
+
4370
+ | Name | Type | Required | Possible Values | Description |
4371
+ | ---------- | -------- | -------- | --------------- | -------------------------------------------------- |
4372
+ | `data` | `object` | ✅ | — | |
4373
+ | ​ ↳ `path` | `string` | ✅ | — | Absolute path that was removed from the live tree. |
4374
+
4375
+ **Example:**
4376
+
4377
+ ```typescript
4378
+ const result = await zapier.deleteVfsPath({
4379
+ path: "/Mine/notes.md",
4380
+ });
4381
+ ```
4382
+
4383
+ #### `listVfsDirectory` 🧪 _experimental_
4384
+
4385
+ List one page of a directory's contents in the Zapier Virtual File System (VFS). Paths are absolute (e.g. `/Mine`). Pass the previous page's `nextCursor` back in `cursor` to fetch the next page.
4386
+
4387
+ **Parameters:**
4388
+
4389
+ | Name | Type | Required | Default | Possible Values | Description |
4390
+ | -------------- | -------- | -------- | ------- | --------------- | ----------------------------------------------------- |
4391
+ | `options` | `object` | ✅ | — | — | |
4392
+ | ​ ↳ `path` | `string` | ✅ | — | — | Absolute path of the directory (must start with `/`). |
4393
+ | ​ ↳ `pageSize` | `number` | ❌ | — | — | Entries per page (default 50, max 500). |
4394
+ | ​ ↳ `maxItems` | `number` | ❌ | — | — | Maximum total entries to return across all pages. |
4395
+ | ​ ↳ `cursor` | `string` | ❌ | — | — | Cursor to resume from, as returned in `nextCursor`. |
4396
+
4397
+ **Returns:** `Promise<PaginatedResult<VfsDirectoryEntryItem>>`
4398
+
4399
+ | Name | Type | Required | Possible Values | Description |
4400
+ | ------------------ | ---------- | -------- | ----------------------------------------- | ---------------------------------------------------------------------- |
4401
+ | `data[]` | `object[]` | ✅ | — | |
4402
+ | ​ ↳ `type` | `string` | ✅ | `file`, `directory`, `shortcut`, `stream` | Kind of entry. `shortcut` points at a `target_*` sibling. |
4403
+ | ​ ↳ `name` | `string` | ✅ | — | Basename of the entry (the segment after the last `/`). |
4404
+ | ​ ↳ `path` | `string` | ✅ | — | Absolute path of the entry. |
4405
+ | ​ ↳ `size` | `number` | ❌ | — | Content size in bytes. Present for files; absent for directories. |
4406
+ | ​ ↳ `version` | `number` | ❌ | — | Monotonic version for the underlying file, when applicable. |
4407
+ | ​ ↳ `updated_at` | `string` | ❌ | — | ISO-8601 timestamp of the last modification. |
4408
+ | ​ ↳ `target_type` | `string` | ❌ | `file`, `directory`, `stream` | For `shortcut` entries: the kind of resource the shortcut points at. |
4409
+ | ​ ↳ `target_path` | `string` | ❌ | — | For `shortcut` entries: the absolute path the shortcut points at. |
4410
+ | ​ ↳ `accessible` | `boolean` | ❌ | — | Whether the caller can read the target. Only meaningful for shortcuts. |
4411
+ | ​ ↳ `content_type` | `string` | ❌ | — | MIME type of a file's content, when the server can determine one. |
4412
+ | `nextCursor` | `string` | ❌ | — | Cursor for the next page; omitted when there are no more pages |
4413
+
4414
+ **Example:**
4415
+
4416
+ ```typescript
4417
+ // Get first page and a cursor for the second page
4418
+ const { data: vfsDirectoryEntrys, nextCursor } = await zapier.listVfsDirectory({
4419
+ path: "/Mine",
4420
+ });
4421
+
4422
+ // Or iterate over all pages
4423
+ for await (const page of zapier
4424
+ .listVfsDirectory({
4425
+ path: "/Mine",
4426
+ })
4427
+ .pages()) {
4428
+ // Do something with each page
4429
+ }
4430
+
4431
+ // Or iterate over individual items across all pages
4432
+ for await (const vfsDirectoryEntry of zapier
4433
+ .listVfsDirectory({
4434
+ path: "/Mine",
4435
+ })
4436
+ .items()) {
4437
+ // Do something with each vfsDirectoryEntry
4438
+ }
4439
+ ```
4440
+
4441
+ #### `moveVfsPath` 🧪 _experimental_
4442
+
4443
+ Move (rename) a file or directory in the Zapier Virtual File System (VFS). Both `from` and `to` are absolute paths (e.g. `/Mine/notes.md`). Fails if an entry already exists at `to` — delete or rename it first.
4444
+
4445
+ **Parameters:**
4446
+
4447
+ | Name | Type | Required | Default | Possible Values | Description |
4448
+ | ---------- | -------- | -------- | ------- | --------------- | ---------------------------------- |
4449
+ | `options` | `object` | ✅ | — | — | |
4450
+ | ​ ↳ `from` | `string` | ✅ | — | — | Absolute path of the source entry. |
4451
+ | ​ ↳ `to` | `string` | ✅ | — | — | New absolute path for the entry. |
4452
+
4453
+ **Returns:** `Promise<VfsMoveResultItem>`
4454
+
4455
+ | Name | Type | Required | Possible Values | Description |
4456
+ | ---------- | -------- | -------- | --------------- | ------------------------------------------- |
4457
+ | `data` | `object` | ✅ | — | |
4458
+ | ​ ↳ `from` | `string` | ✅ | — | Absolute source path (before the move). |
4459
+ | ​ ↳ `to` | `string` | ✅ | — | Absolute destination path (after the move). |
4460
+
4461
+ **Example:**
4462
+
4463
+ ```typescript
4464
+ const { data: vfsMoveResult } = await zapier.moveVfsPath({
4465
+ from: "/Mine/notes.md",
4466
+ to: "/Mine/archive/notes.md",
4467
+ });
4468
+ ```
4469
+
4470
+ #### `readVfsFile` 🧪 _experimental_
4471
+
4472
+ Read a file from the Zapier Virtual File System (VFS), the file store behind your context repository. Paths are absolute, e.g. `/Mine/notes.md`. Returns the content as a UTF-8 string with its size, version, and last-modified time.
4473
+
4474
+ **Parameters:**
4475
+
4476
+ | Name | Type | Required | Default | Possible Values | Description |
4477
+ | -------------- | -------- | -------- | ------- | --------------- | ------------------------------------------------------------------------------------------------------------------ |
4478
+ | `options` | `object` | ✅ | — | — | |
4479
+ | ​ ↳ `path` | `string` | ✅ | — | — | Absolute path of the file to read (must start with `/`). |
4480
+ | ​ ↳ `maxBytes` | `number` | ❌ | — | — | Optional cap on returned content length, in bytes. Files are capped at 10 MB, so values above that have no effect. |
4481
+
4482
+ **Returns:** `Promise<VfsFileItem>`
4483
+
4484
+ | Name | Type | Required | Possible Values | Description |
4485
+ | -------------------- | -------- | -------- | --------------- | ----------------------------------------------------------------------- |
4486
+ | `data` | `object` | ✅ | — | |
4487
+ | ​ ↳ `type` | `string` | ✅ | `file` | Discriminator — always `file` for a file read. |
4488
+ | ​ ↳ `path` | `string` | ✅ | — | Absolute path of the file that was read. |
4489
+ | ​ ↳ `name` | `string` | ✅ | — | Basename of the file (the segment after the last `/`). |
4490
+ | ​ ↳ `content` | `string` | ✅ | — | File content as a UTF-8 string, truncated to `maxBytes` when requested. |
4491
+ | ​ ↳ `size` | `number` | ✅ | — | Total content size in bytes (independent of any `maxBytes` truncation). |
4492
+ | ​ ↳ `version` | `number` | ✅ | — | Monotonic version for the file at read time. |
4493
+ | ​ ↳ `updated_at` | `string` | ✅ | — | ISO-8601 timestamp of the last modification. |
4494
+ | ​ ↳ `canonical_path` | `string` | ❌ | — | Absolute path the server resolved after following any shortcut. |
4495
+
4496
+ **Example:**
4497
+
4498
+ ```typescript
4499
+ const { data: vfsFile } = await zapier.readVfsFile({
4500
+ path: "/Mine/notes.md",
4501
+ });
4502
+ ```
4503
+
4504
+ #### `statVfsPath` 🧪 _experimental_
4505
+
4506
+ Inspect metadata for any path (file, directory, shortcut, or stream) in the Zapier Virtual File System (VFS). Paths are absolute (e.g. `/Mine/notes.md`). Check the `type` field before reading fields that only exist for certain types.
4507
+
4508
+ **Parameters:**
4509
+
4510
+ | Name | Type | Required | Default | Possible Values | Description |
4511
+ | ---------- | -------- | -------- | ------- | --------------- | -------------------------------------------- |
4512
+ | `options` | `object` | ✅ | — | — | |
4513
+ | ​ ↳ `path` | `string` | ✅ | — | — | Absolute path to stat (must start with `/`). |
4514
+
4515
+ **Returns:** `Promise<VfsStatItem>`
4516
+
4517
+ | Name | Type | Required | Possible Values | Description |
4518
+ | ------------------ | --------- | -------- | ----------------------------------------- | ---------------------------------------------------------------------- |
4519
+ | `data` | `object` | ✅ | — | |
4520
+ | ​ ↳ `type` | `string` | ✅ | `file`, `directory`, `shortcut`, `stream` | Kind of entry. `shortcut` points at a `target_*` sibling. |
4521
+ | ​ ↳ `name` | `string` | ✅ | — | Basename of the entry (the segment after the last `/`). |
4522
+ | ​ ↳ `path` | `string` | ✅ | — | Absolute path of the entry. |
4523
+ | ​ ↳ `size` | `number` | ❌ | — | Content size in bytes. Present for files; absent for directories. |
4524
+ | ​ ↳ `version` | `number` | ❌ | — | Monotonic version for the underlying file, when applicable. |
4525
+ | ​ ↳ `updated_at` | `string` | ❌ | — | ISO-8601 timestamp of the last modification. |
4526
+ | ​ ↳ `target_type` | `string` | ❌ | `file`, `directory`, `stream` | For `shortcut` entries: the kind of resource the shortcut points at. |
4527
+ | ​ ↳ `target_path` | `string` | ❌ | — | For `shortcut` entries: the absolute path the shortcut points at. |
4528
+ | ​ ↳ `accessible` | `boolean` | ❌ | — | Whether the caller can read the target. Only meaningful for shortcuts. |
4529
+ | ​ ↳ `content_type` | `string` | ❌ | — | MIME type of a file's content, when the server can determine one. |
4530
+
4531
+ **Example:**
4532
+
4533
+ ```typescript
4534
+ const { data: vfsStat } = await zapier.statVfsPath({
4535
+ path: "/Mine/notes.md",
4536
+ });
4537
+ ```
4538
+
4539
+ #### `writeVfsFile` 🧪 _experimental_
4540
+
4541
+ Write (create or overwrite) a file in the Zapier Virtual File System (VFS). Paths are absolute (e.g. `/Mine/notes.md`); missing parent directories are created automatically.
4542
+
4543
+ **Parameters:**
4544
+
4545
+ | Name | Type | Required | Default | Possible Values | Description |
4546
+ | --------------------- | -------- | -------- | ------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
4547
+ | `options` | `object` | ✅ | — | — | |
4548
+ | ​ ↳ `path` | `string` | ✅ | — | — | Absolute path of the file (must start with `/`). |
4549
+ | ​ ↳ `content` | `string` | ✅ | — | — | New file contents. Capped at 10 MB per call. |
4550
+ | ​ ↳ `expectedVersion` | `number` | ❌ | — | — | Optional expected current version for optimistic concurrency. The write fails if the file's actual version differs. Pass `0` to assert the file does not exist yet (versions start at 1). |
4551
+
4552
+ **Returns:** `Promise<VfsWriteResultItem>`
4553
+
4554
+ | Name | Type | Required | Possible Values | Description |
4555
+ | -------------- | -------- | -------- | -------------------- | -------------------------------------------------------------------- |
4556
+ | `data` | `object` | ✅ | — | |
4557
+ | ​ ↳ `path` | `string` | ✅ | — | Absolute path of the written file. |
4558
+ | ​ ↳ `version` | `number` | ✅ | — | Monotonic version stamped by the server on this write. |
4559
+ | ​ ↳ `action` | `string` | ✅ | `created`, `updated` | Whether the write created a new file or updated an existing one. |
4560
+ | ​ ↳ `warnings` | `array` | ❌ | — | Non-fatal issues the server surfaced alongside the successful write. |
4561
+
4562
+ **Example:**
4563
+
4564
+ ```typescript
4565
+ const { data: vfsWriteResult } = await zapier.writeVfsFile({
4566
+ path: "/Mine/notes.md",
4567
+ content: "example-content",
4568
+ });
4569
+ ```