@vansite/ts-sharetribe-flex-sdk 3.0.12 → 3.1.0

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.
Files changed (59) hide show
  1. package/README.md +95 -122
  2. package/dist/endpoints/integrationApi/FileAttachments.d.ts +30 -0
  3. package/dist/endpoints/integrationApi/Files.d.ts +29 -0
  4. package/dist/endpoints/integrationApi/Messages.d.ts +33 -0
  5. package/dist/endpoints/integrationApi/Users.d.ts +17 -1
  6. package/dist/endpoints/integrationApi/index.d.ts +6 -0
  7. package/dist/endpoints/marketplace/FileDownloads.d.ts +32 -0
  8. package/dist/endpoints/marketplace/FileUploads.d.ts +34 -0
  9. package/dist/endpoints/marketplace/Files.d.ts +32 -0
  10. package/dist/endpoints/marketplace/OwnFileDownloads.d.ts +30 -0
  11. package/dist/endpoints/marketplace/OwnFiles.d.ts +49 -0
  12. package/dist/endpoints/marketplace/index.d.ts +10 -0
  13. package/dist/index.js +1 -1
  14. package/dist/index.js.LICENSE.txt +12 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +1 -1
  17. package/dist/index.mjs.LICENSE.txt +12 -0
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/index.umd.js +1 -1
  20. package/dist/index.umd.js.LICENSE.txt +12 -0
  21. package/dist/index.umd.js.map +1 -1
  22. package/dist/integrationSdk.d.ts +21 -0
  23. package/dist/sdk.d.ts +30 -0
  24. package/dist/types/endpoints/integrationApi/FileAttachments.d.ts +31 -0
  25. package/dist/types/endpoints/integrationApi/FileAttachments.d.ts.map +1 -0
  26. package/dist/types/endpoints/integrationApi/Files.d.ts +30 -0
  27. package/dist/types/endpoints/integrationApi/Files.d.ts.map +1 -0
  28. package/dist/types/endpoints/integrationApi/Messages.d.ts +34 -0
  29. package/dist/types/endpoints/integrationApi/Messages.d.ts.map +1 -0
  30. package/dist/types/endpoints/integrationApi/Users.d.ts +17 -1
  31. package/dist/types/endpoints/integrationApi/Users.d.ts.map +1 -1
  32. package/dist/types/endpoints/integrationApi/index.d.ts +6 -0
  33. package/dist/types/endpoints/integrationApi/index.d.ts.map +1 -1
  34. package/dist/types/endpoints/marketplace/FileDownloads.d.ts +33 -0
  35. package/dist/types/endpoints/marketplace/FileDownloads.d.ts.map +1 -0
  36. package/dist/types/endpoints/marketplace/FileUploads.d.ts +35 -0
  37. package/dist/types/endpoints/marketplace/FileUploads.d.ts.map +1 -0
  38. package/dist/types/endpoints/marketplace/Files.d.ts +33 -0
  39. package/dist/types/endpoints/marketplace/Files.d.ts.map +1 -0
  40. package/dist/types/endpoints/marketplace/OwnFileDownloads.d.ts +31 -0
  41. package/dist/types/endpoints/marketplace/OwnFileDownloads.d.ts.map +1 -0
  42. package/dist/types/endpoints/marketplace/OwnFiles.d.ts +50 -0
  43. package/dist/types/endpoints/marketplace/OwnFiles.d.ts.map +1 -0
  44. package/dist/types/endpoints/marketplace/index.d.ts +10 -0
  45. package/dist/types/endpoints/marketplace/index.d.ts.map +1 -1
  46. package/dist/types/integration/files.d.ts +66 -0
  47. package/dist/types/integrationSdk.d.ts +21 -0
  48. package/dist/types/integrationSdk.d.ts.map +1 -1
  49. package/dist/types/marketplace/files.d.ts +162 -0
  50. package/dist/types/marketplace/user.d.ts +11 -3
  51. package/dist/types/sdk.d.ts +30 -0
  52. package/dist/types/sdk.d.ts.map +1 -1
  53. package/dist/types/types/integration/files.d.ts +67 -0
  54. package/dist/types/types/integration/files.d.ts.map +1 -0
  55. package/dist/types/types/marketplace/files.d.ts +163 -0
  56. package/dist/types/types/marketplace/files.d.ts.map +1 -0
  57. package/dist/types/types/marketplace/user.d.ts +11 -3
  58. package/dist/types/types/marketplace/user.d.ts.map +1 -1
  59. package/package.json +1 -1
package/README.md CHANGED
@@ -1,191 +1,164 @@
1
1
  # @vansite/ts-sharetribe-flex-sdk
2
2
 
3
- ![TypeScript](https://img.shields.io/badge/TypeScript-4.x-blue)
3
+ [![npm version](https://img.shields.io/npm/v/@vansite/ts-sharetribe-flex-sdk)](https://www.npmjs.com/package/@vansite/ts-sharetribe-flex-sdk)
4
+ ![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue)
4
5
  ![MIT License](https://img.shields.io/badge/license-MIT-green)
5
- ![Version](https://img.shields.io/badge/version-3.0.11-blue)
6
6
 
7
- This is a **TypeScript SDK** for the [Sharetribe Flex API](https://www.sharetribe.com/api-reference/). It simplifies interaction with the API, providing a more user-friendly and intuitive interface for developers and reduces the size of the SDK.
7
+ A fully-typed **TypeScript SDK** for the [Sharetribe Flex API](https://www.sharetribe.com/api-reference/). It wraps both the **Marketplace API** and the **Integration API** in a single, lightweight package — with built-in token management, Transit serialization, and the same code path for Node.js and the browser.
8
8
 
9
9
  ## Features
10
10
 
11
- - **Unified SDK**: Combines both the Sharetribe SDK and Integration SDK in one package
12
- - **Cross-platform**: Works seamlessly in both Node.js and browser environments without additional configuration
13
- - **Fully typed**: Complete TypeScript definitions based on the official Sharetribe documentation
14
- - **Lightweight**: Optimized bundle size for better performance
15
- - **Developer-friendly**: Intuitive API design for easier integration
16
- - Built-in support for cookie handling and UUID generation
11
+ - **Two SDKs, one package** `SharetribeSdk` (client/marketplace) and `IntegrationSdk` (server/backend)
12
+ - **Cross-platform** identical code in Node.js and the browser, no loader needed
13
+ - **Fully typed** complete definitions generated from the official Sharetribe reference, including per-endpoint request params and `include`-aware response shapes
14
+ - **Complete API coverage** Marketplace, Integration, Authentication and Asset Delivery APIs, incl. the file-sharing endpoints
15
+ - **Built-in token management** pluggable token stores (memory, browser cookie, Express)
16
+ - **Transit-aware** transparent serialization of `UUID`, `Money`, `LatLng`, `BigDecimal`, …
17
+ - **Tree-shakeable** — ships ESM, CJS and a UMD browser bundle
17
18
 
18
19
  ## Installation
19
20
 
20
- **npm**
21
-
22
21
  ```bash
23
22
  npm install @vansite/ts-sharetribe-flex-sdk
23
+ # or: pnpm add … / yarn add …
24
24
  ```
25
25
 
26
- **yarn**
27
-
28
- ```bash
29
- yarn add @vansite/ts-sharetribe-flex-sdk
30
- ```
31
-
32
- ## Usage
33
-
34
- See also the migration section to see how things changed.
26
+ ## Quick Start
35
27
 
36
28
  ```typescript
37
- import {
38
- SharetribeSdk,
39
- IntegrationSdk,
40
- } from "@vansite/ts-sharetribe-flex-sdk";
29
+ import { SharetribeSdk, IntegrationSdk, sdkTypes } from "@vansite/ts-sharetribe-flex-sdk";
41
30
 
42
- // Regular SDK for client-side operations
43
- const sharetribeSdk = new SharetribeSdk({
44
- clientId: "your-client-id",
45
- });
31
+ const { UUID, Money, LatLng } = sdkTypes;
32
+
33
+ // --- Marketplace (client-side / browser) ---
34
+ const sdk = new SharetribeSdk({ clientId: "your-client-id" });
46
35
 
47
- sharetribeSdk.authInfo().then((response) => {
48
- console.log(response);
36
+ const { data } = await sdk.listings.query({
37
+ keywords: "yoga",
38
+ price: { gte: 1000, lte: 10000 }, // minor units (cents)
39
+ include: ["author", "images"],
49
40
  });
50
41
 
51
- // Integration SDK for server-side operations
42
+ // --- Integration (server-side only) ---
52
43
  const integrationSdk = new IntegrationSdk({
53
44
  clientId: "your-client-id",
54
- clientSecret: "your-client-secret",
45
+ clientSecret: "your-client-secret", // never expose in the browser
55
46
  });
56
47
 
57
- integrationSdk.users.show({ id: "user-id" }).then((response) => {
58
- console.log(response);
59
- });
48
+ await integrationSdk.users.show({ id: new UUID("user-id") });
60
49
  ```
61
50
 
62
- ## Migration
51
+ > **Money is in minor units** (e.g. cents). Always wrap typed values in `sdkTypes`
52
+ > (`UUID`, `Money`, `LatLng`, `LatLngBounds`, `BigDecimal`) so they serialize correctly.
63
53
 
64
- ### SDK Loader
54
+ ## API Coverage & Documentation
65
55
 
66
- The Sdk loader is not needed anymore, because there is no difference between the node and web sdk
56
+ Both APIs are covered end-to-end. See the per-area guides in [`docs/`](./docs):
67
57
 
68
- - Remove the sdkLoader file
69
- - Exchange all sdkTypes with the types from the new sdk
58
+ | Guide | Contents |
59
+ |-------|----------|
60
+ | [Getting Started](./docs/getting-started.md) | Setup, configuration, first requests |
61
+ | [Marketplace API](./docs/marketplace-api.md) | Listings, users, transactions, messages, reviews, **file sharing**, Stripe, … |
62
+ | [Integration API](./docs/integration-api.md) | Privileged listing/user/transaction ops, events, **files & attachments**, stock |
63
+ | [Authentication](./docs/authentication.md) | Token grants, login/logout, IdP, token exchange |
64
+ | [Token Stores](./docs/token-stores.md) | `MemoryStore`, `BrowserStore`, `ExpressStore` |
65
+ | [Transit Serialization](./docs/transit-serialization.md) | How SDK types map to Transit |
66
+ | [SDK Types](./docs/sdk-types.md) | `UUID`, `Money`, `LatLng`, `LatLngBounds`, `BigDecimal` |
67
+ | [Examples](./docs/examples.md) | End-to-end recipes |
70
68
 
71
- **before**
69
+ **Asset Delivery API** is exposed directly on the SDK: `sdk.assetByAlias`,
70
+ `sdk.assetsByAlias`, `sdk.assetByVersion`, `sdk.assetsByVersion`.
72
71
 
73
- ```javascript
74
- import { types as sdkTypes } from "./sdkLoader";
75
- const { Money } = sdkTypes;
76
- ```
72
+ ## Token Management
77
73
 
78
- **after:**
74
+ Tokens are persisted through a pluggable store (a `MemoryStore` is used by default):
79
75
 
80
- ```javascript
81
- import { sdkTypes } from "@vansite/ts-sharetribe-flex-sdk";
82
- const { Money } = sdkTypes;
83
- ```
76
+ ```typescript
77
+ import { SharetribeSdk, TokenStores } from "@vansite/ts-sharetribe-flex-sdk";
84
78
 
85
- ### Transit
79
+ // Express: store the refresh token in a secure, httpOnly cookie
80
+ const sdk = new SharetribeSdk({
81
+ clientId: "your-client-id",
82
+ tokenStore: new TokenStores.ExpressStore({ clientId: "your-client-id", req, res, secure: true, httpOnly: true }),
83
+ });
84
+ ```
86
85
 
87
- **before:**
86
+ | Store | Use case |
87
+ |-------|----------|
88
+ | `MemoryStore` | Default; scripts, tests, short-lived processes |
89
+ | `BrowserStore` | Single-page apps (browser cookies) |
90
+ | `ExpressStore` | Server apps; pair with `httpOnly: true` in production |
88
91
 
89
- ```javascript
90
- import { transit } from "./sdkLoader";
91
-
92
- const serialize = (data) => {
93
- return transit.write(data, {
94
- typeHandlers,
95
- verbose: config.sdk.transitVerbose,
96
- });
97
- };
98
-
99
- const deserialize = (str) => {
100
- return transit.read(str, { typeHandlers });
101
- };
102
- ```
92
+ ## Module Formats
103
93
 
104
- **after:**
94
+ Published in three formats (resolved automatically via the `exports` field):
105
95
 
106
- ```javascript
107
- import { transit } from "@vansite/ts-sharetribe-flex-sdk";
96
+ | Format | File | Entry |
97
+ |--------|------|-------|
98
+ | ES Module | `dist/index.mjs` | `import` |
99
+ | CommonJS | `dist/index.js` | `require` |
100
+ | UMD / Browser | `dist/index.umd.js` | global `TsSharetribeFlexSdk` |
108
101
 
109
- const serialize = (data) => {
110
- return transit.write(data, {
111
- typeHandlers,
112
- verbose: config.sdk.transitVerbose,
113
- });
114
- };
102
+ ## Migration from `sharetribe-flex-sdk`
115
103
 
116
- const deserialize = (str) => {
117
- return transit.read(str, { typeHandlers });
118
- };
119
- ```
104
+ <details>
105
+ <summary>SDK loader, Transit and token stores</summary>
120
106
 
121
- ### TokenStores
107
+ ### SDK Loader
122
108
 
123
- **before:**
109
+ The SDK loader is no longer needed — there is no difference between the Node and web builds.
124
110
 
125
111
  ```javascript
126
- const sharetribeSdk = require("sharetribe-flex-sdk");
127
- const store = sharetribeSdk.tokenStore.memoryStore();
112
+ // before
113
+ import { types as sdkTypes } from "./sdkLoader";
114
+ // after
115
+ import { sdkTypes } from "@vansite/ts-sharetribe-flex-sdk";
116
+ const { Money } = sdkTypes;
128
117
  ```
129
118
 
130
- **after:**
119
+ ### Transit
131
120
 
132
121
  ```javascript
133
- const { TokenStores } = require("@vansite/ts-sharetribe-flex-sdk");
134
- const store = new TokenStores.MemoryStore();
122
+ // before: import { transit } from "./sdkLoader";
123
+ // after:
124
+ import { transit } from "@vansite/ts-sharetribe-flex-sdk";
125
+
126
+ const serialize = (data) => transit.write(data, { typeHandlers, verbose: config.sdk.transitVerbose });
127
+ const deserialize = (str) => transit.read(str, { typeHandlers });
135
128
  ```
136
129
 
137
- or
130
+ ### Token Stores
138
131
 
139
132
  ```javascript
133
+ // before
134
+ const store = require("sharetribe-flex-sdk").tokenStore.memoryStore();
135
+ // after
140
136
  const { TokenStores } = require("@vansite/ts-sharetribe-flex-sdk");
141
- const cookieTokenStore = new TokenStores.ExpressStore({
142
- clientId: "client-id",
143
- req,
144
- secure: true,
145
- });
146
- ```
147
-
148
- ## Scripts
149
-
150
- **Build the project:**
151
-
152
- ```bash
153
- yarn build
137
+ const store = new TokenStores.MemoryStore();
154
138
  ```
155
139
 
156
- **Run tests:**
140
+ </details>
157
141
 
158
- ```bash
159
- yarn test
160
- ```
142
+ ## Development
161
143
 
162
- **Analyze the bundle size:**
144
+ This repo uses **pnpm**.
163
145
 
164
146
  ```bash
165
- yarn analyze
147
+ pnpm install
148
+ pnpm build # bundles (CJS/ESM/UMD) + type declarations
149
+ pnpm test # Jest test suite
150
+ pnpm analyze # bundle size analysis
166
151
  ```
167
152
 
168
153
  ## Contributing
169
154
 
170
- Contributions are welcome and appreciated! If you'd like to help improve this library, please feel free to:
171
-
172
- - Submit bug reports or feature requests through issues
173
- - Propose improvements through pull requests
174
- - Help expand test coverage
175
- - Improve documentation
176
-
177
- Please follow standard GitHub flow (fork, branch, pull request) for contributions.
155
+ Contributions are welcome! Please use the standard GitHub flow (fork branch pull request).
156
+ Bug reports, feature requests, expanded test coverage and documentation improvements are all appreciated.
178
157
 
179
158
  ## License
180
159
 
181
- This project is licensed under the MIT License. See the [LICENSE](LICENSE.txt) file for details.
160
+ MIT see [LICENSE](LICENSE.txt).
182
161
 
183
162
  ---
184
163
 
185
- ### Tags
186
-
187
- - Sharetribe Flex
188
- - TypeScript SDK
189
- - Node.js
190
- - Browser
191
- - API Integration
164
+ **Tags:** Sharetribe Flex · TypeScript SDK · Marketplace API · Integration API · Node.js · Browser
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview Client for querying file attachments in the Sharetribe
3
+ * Integration API.
4
+ *
5
+ * @see https://www.sharetribe.com/api-reference/integration.html#file-attachments
6
+ */
7
+ import type { AxiosResponse } from "axios";
8
+ import IntegrationApi from "./index";
9
+ import { FileAttachmentsQueryParameter, FileAttachmentsQueryResponse } from "../../types";
10
+ /**
11
+ * File Attachments API client (privileged)
12
+ */
13
+ declare class FileAttachments {
14
+ readonly authRequired = true;
15
+ private readonly axios;
16
+ private readonly endpoint;
17
+ private readonly headers;
18
+ constructor(api: IntegrationApi);
19
+ /**
20
+ * Query file attachments in the marketplace.
21
+ *
22
+ * @param {FileAttachmentsQueryParameter} params
23
+ * @returns {Promise<AxiosResponse<FileAttachmentsQueryResponse>>}
24
+ *
25
+ * @example
26
+ * const { data } = await sdk.fileAttachments.query({ transactionId: "tx-abc123" });
27
+ */
28
+ query(params: FileAttachmentsQueryParameter): Promise<AxiosResponse<FileAttachmentsQueryResponse>>;
29
+ }
30
+ export default FileAttachments;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @fileoverview Client for querying files in the Sharetribe Integration API.
3
+ *
4
+ * @see https://www.sharetribe.com/api-reference/integration.html#files
5
+ */
6
+ import type { AxiosResponse } from "axios";
7
+ import IntegrationApi from "./index";
8
+ import { FilesQueryParameter, FilesQueryResponse } from "../../types";
9
+ /**
10
+ * Files API client (privileged)
11
+ */
12
+ declare class Files {
13
+ readonly authRequired = true;
14
+ private readonly axios;
15
+ private readonly endpoint;
16
+ private readonly headers;
17
+ constructor(api: IntegrationApi);
18
+ /**
19
+ * Query files in the marketplace.
20
+ *
21
+ * @param {FilesQueryParameter} params
22
+ * @returns {Promise<AxiosResponse<FilesQueryResponse>>}
23
+ *
24
+ * @example
25
+ * const { data } = await sdk.files.query({ transactionId: "tx-abc123" });
26
+ */
27
+ query(params: FilesQueryParameter): Promise<AxiosResponse<FilesQueryResponse>>;
28
+ }
29
+ export default Files;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @fileoverview Client for querying messages in the Sharetribe Integration API.
3
+ *
4
+ * Read-only: lists messages within a transaction. Reuses the Marketplace
5
+ * message types since the resource shape is identical.
6
+ *
7
+ * @see https://www.sharetribe.com/api-reference/integration.html#messages
8
+ */
9
+ import type { AxiosResponse } from "axios";
10
+ import IntegrationApi from "./index";
11
+ import { MessagesQueryParameter, MessagesResponse } from "../../types";
12
+ /**
13
+ * Messages API client (privileged)
14
+ */
15
+ declare class Messages {
16
+ readonly authRequired = true;
17
+ private readonly axios;
18
+ private readonly endpoint;
19
+ private readonly headers;
20
+ constructor(api: IntegrationApi);
21
+ /**
22
+ * Query messages in a transaction.
23
+ *
24
+ * @template P
25
+ * @param {P & MessagesQueryParameter} params - Requires `transactionId`
26
+ * @returns {Promise<AxiosResponse<MessagesResponse<"query", P>>>}
27
+ *
28
+ * @example
29
+ * const { data } = await sdk.messages.query({ transactionId: "tx-abc123" });
30
+ */
31
+ query<P extends MessagesQueryParameter>(params: P): Promise<AxiosResponse<MessagesResponse<"query", P>>>;
32
+ }
33
+ export default Messages;
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import type { AxiosResponse } from "axios";
10
10
  import IntegrationApi from "./index";
11
- import { ExtraParameter, UsersApproveParameter, UsersQueryParameter, UsersResponse, UsersShowParameter, UsersUpdatePermissionsParameter, UsersUpdateProfileParameter } from "../../types";
11
+ import { ExtraParameter, UsersApproveParameter, UsersQueryParameter, UsersResponse, UsersShowParameter, UsersUpdatePermissionsParameter, UsersUpdateProfileParameter, UsersVerifyEmailParameter } from "../../types";
12
12
  /**
13
13
  * Users API client (privileged)
14
14
  */
@@ -70,5 +70,21 @@ declare class Users {
70
70
  * @returns {Promise<AxiosResponse<UsersResponse<"updatePermissions", P, EP>>>}
71
71
  */
72
72
  updatePermissions<P extends UsersUpdatePermissionsParameter, EP extends ExtraParameter | undefined = undefined>(params: P, extraParams?: EP): Promise<AxiosResponse<UsersResponse<"updatePermissions", P, EP>>>;
73
+ /**
74
+ * Verify a user's email address.
75
+ *
76
+ * `email` must match the user's current `email` or `pendingEmail`
77
+ * (case-insensitive).
78
+ *
79
+ * @template P
80
+ * @template EP
81
+ * @param {P & UsersVerifyEmailParameter} params - `id` and `email`
82
+ * @param {EP} [extraParams]
83
+ * @returns {Promise<AxiosResponse<UsersResponse<"verifyEmail", P, EP>>>}
84
+ *
85
+ * @example
86
+ * await sdk.users.verifyEmail({ id: "user-abc123", email: "john@example.com" });
87
+ */
88
+ verifyEmail<P extends UsersVerifyEmailParameter, EP extends ExtraParameter | undefined = undefined>(params: P, extraParams?: EP): Promise<AxiosResponse<UsersResponse<"verifyEmail", P, EP>>>;
73
89
  }
74
90
  export default Users;
@@ -23,9 +23,12 @@ import type { AxiosInstance } from "axios";
23
23
  import IntegrationSdk from "../../integrationSdk";
24
24
  import AvailabilityExceptions from "./AvailabilityExceptions";
25
25
  import Events from "./Events";
26
+ import FileAttachments from "./FileAttachments";
27
+ import Files from "./Files";
26
28
  import Images from "./Images";
27
29
  import Listings from "./Listings";
28
30
  import Marketplace from "./Marketplace";
31
+ import Messages from "./Messages";
29
32
  import Stock from "./Stock";
30
33
  import StockAdjustments from "./StockAdjustments";
31
34
  import StockReservations from "./StockReservations";
@@ -45,9 +48,12 @@ declare class IntegrationApi {
45
48
  readonly authRequired = true;
46
49
  readonly availabilityExceptions: AvailabilityExceptions;
47
50
  readonly events: Events;
51
+ readonly fileAttachments: FileAttachments;
52
+ readonly files: Files;
48
53
  readonly images: Images;
49
54
  readonly listings: Listings;
50
55
  readonly marketplace: Marketplace;
56
+ readonly messages: Messages;
51
57
  readonly stock: Stock;
52
58
  readonly stockAdjustments: StockAdjustments;
53
59
  readonly stockReservations: StockReservations;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @fileoverview Client for obtaining signed download URLs for shared files in
3
+ * the Sharetribe Marketplace API.
4
+ *
5
+ * Resolves a file attachment to a short-lived signed download URL.
6
+ *
7
+ * @see https://www.sharetribe.com/api-reference/marketplace.html#file-downloads
8
+ */
9
+ import type { AxiosResponse } from "axios";
10
+ import MarketplaceApi from "./index";
11
+ import { FileDownloadsCreateParameter, FileDownloadsCreateResponse } from "../../types";
12
+ /**
13
+ * File Downloads API client
14
+ */
15
+ declare class FileDownloads {
16
+ readonly authRequired = true;
17
+ private readonly axios;
18
+ private readonly endpoint;
19
+ private readonly headers;
20
+ constructor(api: MarketplaceApi);
21
+ /**
22
+ * Obtain a signed download URL for a file accessed via a file attachment.
23
+ *
24
+ * @param {FileDownloadsCreateParameter} params - Requires `fileAttachmentId`
25
+ * @returns {Promise<AxiosResponse<FileDownloadsCreateResponse>>}
26
+ *
27
+ * @example
28
+ * const { data } = await sdk.fileDownloads.create({ fileAttachmentId: "fa-abc123" });
29
+ */
30
+ create(params: FileDownloadsCreateParameter): Promise<AxiosResponse<FileDownloadsCreateResponse>>;
31
+ }
32
+ export default FileDownloads;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview Client for obtaining signed upload URLs in the Sharetribe
3
+ * Marketplace API.
4
+ *
5
+ * Returns a short-lived signed URL; the file bytes are then PUT directly to
6
+ * that URL (outside the Sharetribe API) using the returned headers.
7
+ *
8
+ * @see https://www.sharetribe.com/api-reference/marketplace.html#file-uploads
9
+ */
10
+ import type { AxiosResponse } from "axios";
11
+ import MarketplaceApi from "./index";
12
+ import { FileUploadsCreateParameter, FileUploadsCreateResponse } from "../../types";
13
+ /**
14
+ * File Uploads API client
15
+ */
16
+ declare class FileUploads {
17
+ readonly authRequired = true;
18
+ private readonly axios;
19
+ private readonly endpoint;
20
+ private readonly headers;
21
+ constructor(api: MarketplaceApi);
22
+ /**
23
+ * Obtain a signed URL to upload the bytes of an own file.
24
+ *
25
+ * @param {FileUploadsCreateParameter} params - Requires `fileId`
26
+ * @returns {Promise<AxiosResponse<FileUploadsCreateResponse>>}
27
+ *
28
+ * @example
29
+ * const { data } = await sdk.fileUploads.create({ fileId: "file-abc123" });
30
+ * // PUT the bytes to data.data.attributes.url with attributes.headers
31
+ */
32
+ create(params: FileUploadsCreateParameter): Promise<AxiosResponse<FileUploadsCreateResponse>>;
33
+ }
34
+ export default FileUploads;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @fileoverview Client for reading shared files in the Sharetribe Marketplace API.
3
+ *
4
+ * Files are accessed through a file attachment (e.g. an attachment shared in a
5
+ * transaction message), not by the file's own id.
6
+ *
7
+ * @see https://www.sharetribe.com/api-reference/marketplace.html#files
8
+ */
9
+ import type { AxiosResponse } from "axios";
10
+ import MarketplaceApi from "./index";
11
+ import { FilesShowParameter, FilesShowResponse } from "../../types";
12
+ /**
13
+ * Files API client
14
+ */
15
+ declare class Files {
16
+ readonly authRequired = true;
17
+ private readonly axios;
18
+ private readonly endpoint;
19
+ private readonly headers;
20
+ constructor(api: MarketplaceApi);
21
+ /**
22
+ * Fetch a file the current user can access via a file attachment.
23
+ *
24
+ * @param {FilesShowParameter} params - Requires `fileAttachmentId`
25
+ * @returns {Promise<AxiosResponse<FilesShowResponse>>}
26
+ *
27
+ * @example
28
+ * const { data } = await sdk.files.show({ fileAttachmentId: "fa-abc123" });
29
+ */
30
+ show(params: FilesShowParameter): Promise<AxiosResponse<FilesShowResponse>>;
31
+ }
32
+ export default Files;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview Client for obtaining signed download URLs for the current
3
+ * user's own files in the Sharetribe Marketplace API.
4
+ *
5
+ * @see https://www.sharetribe.com/api-reference/marketplace.html#own-file-downloads
6
+ */
7
+ import type { AxiosResponse } from "axios";
8
+ import MarketplaceApi from "./index";
9
+ import { OwnFileDownloadsCreateParameter, OwnFileDownloadsCreateResponse } from "../../types";
10
+ /**
11
+ * Own File Downloads API client
12
+ */
13
+ declare class OwnFileDownloads {
14
+ readonly authRequired = true;
15
+ private readonly axios;
16
+ private readonly endpoint;
17
+ private readonly headers;
18
+ constructor(api: MarketplaceApi);
19
+ /**
20
+ * Obtain a signed download URL for one of the current user's own files.
21
+ *
22
+ * @param {OwnFileDownloadsCreateParameter} params - Requires `fileId`
23
+ * @returns {Promise<AxiosResponse<OwnFileDownloadsCreateResponse>>}
24
+ *
25
+ * @example
26
+ * const { data } = await sdk.ownFileDownloads.create({ fileId: "file-abc123" });
27
+ */
28
+ create(params: OwnFileDownloadsCreateParameter): Promise<AxiosResponse<OwnFileDownloadsCreateResponse>>;
29
+ }
30
+ export default OwnFileDownloads;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @fileoverview Client for managing the current user's own files in the
3
+ * Sharetribe Marketplace API.
4
+ *
5
+ * Creating an own file only registers its metadata; the bytes are uploaded
6
+ * afterwards via `sdk.fileUploads.create`.
7
+ *
8
+ * @see https://www.sharetribe.com/api-reference/marketplace.html#own-files
9
+ */
10
+ import type { AxiosResponse } from "axios";
11
+ import MarketplaceApi from "./index";
12
+ import { ExtraParameter, OwnFilesCreateParameter, OwnFilesCreateResponse, OwnFilesShowParameter, OwnFilesShowResponse } from "../../types";
13
+ /**
14
+ * Own Files API client
15
+ */
16
+ declare class OwnFiles {
17
+ readonly authRequired = true;
18
+ private readonly axios;
19
+ private readonly endpoint;
20
+ private readonly headers;
21
+ constructor(api: MarketplaceApi);
22
+ /**
23
+ * Fetch one of the current user's own files by id.
24
+ *
25
+ * @param {OwnFilesShowParameter} params - Requires `id`
26
+ * @returns {Promise<AxiosResponse<OwnFilesShowResponse>>}
27
+ *
28
+ * @example
29
+ * const { data } = await sdk.ownFiles.show({ id: "file-abc123" });
30
+ */
31
+ show(params: OwnFilesShowParameter): Promise<AxiosResponse<OwnFilesShowResponse>>;
32
+ /**
33
+ * Register a new own file. Returns the file resource, after which the bytes
34
+ * are uploaded via `sdk.fileUploads.create({ fileId })`.
35
+ *
36
+ * @template EP
37
+ * @param {OwnFilesCreateParameter} params - `name`, `mimeType`, `size`
38
+ * @param {EP} [extraParams] - Optional extra parameters (e.g. `expand: true`)
39
+ * @returns {Promise<AxiosResponse<OwnFilesCreateResponse<EP>>>}
40
+ *
41
+ * @example
42
+ * const { data } = await sdk.ownFiles.create(
43
+ * { name: "invoice.pdf", mimeType: "application/pdf", size: 12345 },
44
+ * { expand: true }
45
+ * );
46
+ */
47
+ create<EP extends ExtraParameter | undefined = undefined>(params: OwnFilesCreateParameter, extraParams?: EP): Promise<AxiosResponse<OwnFilesCreateResponse<EP>>>;
48
+ }
49
+ export default OwnFiles;
@@ -24,10 +24,15 @@ import SharetribeSdk from "../../sdk";
24
24
  import AvailabilityExceptions from "./AvailabilityExceptions";
25
25
  import Bookings from "./Bookings";
26
26
  import CurrentUser from "./CurrentUser";
27
+ import FileDownloads from "./FileDownloads";
28
+ import FileUploads from "./FileUploads";
29
+ import Files from "./Files";
27
30
  import Images from "./Images";
28
31
  import Listings from "./Listings";
29
32
  import Marketplace from "./Marketplace";
30
33
  import Messages from "./Messages";
34
+ import OwnFileDownloads from "./OwnFileDownloads";
35
+ import OwnFiles from "./OwnFiles";
31
36
  import OwnListings from "./OwnListings";
32
37
  import PasswordReset from "./PasswordReset";
33
38
  import ProcessTransitions from "./ProcessTransitions";
@@ -58,10 +63,15 @@ declare class MarketplaceApi {
58
63
  readonly availabilityExceptions: AvailabilityExceptions;
59
64
  readonly bookings: Bookings;
60
65
  readonly currentUser: CurrentUser;
66
+ readonly fileDownloads: FileDownloads;
67
+ readonly fileUploads: FileUploads;
68
+ readonly files: Files;
61
69
  readonly images: Images;
62
70
  readonly listings: Listings;
63
71
  readonly marketplace: Marketplace;
64
72
  readonly messages: Messages;
73
+ readonly ownFileDownloads: OwnFileDownloads;
74
+ readonly ownFiles: OwnFiles;
65
75
  readonly ownListings: OwnListings;
66
76
  readonly passwordReset: PasswordReset;
67
77
  readonly processTransitions: ProcessTransitions;