@vansite/ts-sharetribe-flex-sdk 3.0.12 → 3.1.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/README.md +105 -121
- package/dist/endpoints/integrationApi/FileAttachments.d.ts +30 -0
- package/dist/endpoints/integrationApi/Files.d.ts +29 -0
- package/dist/endpoints/integrationApi/Messages.d.ts +33 -0
- package/dist/endpoints/integrationApi/Users.d.ts +17 -1
- package/dist/endpoints/integrationApi/index.d.ts +6 -0
- package/dist/endpoints/marketplace/FileDownloads.d.ts +32 -0
- package/dist/endpoints/marketplace/FileUploads.d.ts +34 -0
- package/dist/endpoints/marketplace/Files.d.ts +32 -0
- package/dist/endpoints/marketplace/OwnFileDownloads.d.ts +30 -0
- package/dist/endpoints/marketplace/OwnFiles.d.ts +49 -0
- package/dist/endpoints/marketplace/index.d.ts +10 -0
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +12 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.LICENSE.txt +12 -0
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.LICENSE.txt +12 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/integrationSdk.d.ts +21 -0
- package/dist/sdk.d.ts +30 -0
- package/dist/types/endpoints/integrationApi/FileAttachments.d.ts +31 -0
- package/dist/types/endpoints/integrationApi/FileAttachments.d.ts.map +1 -0
- package/dist/types/endpoints/integrationApi/Files.d.ts +30 -0
- package/dist/types/endpoints/integrationApi/Files.d.ts.map +1 -0
- package/dist/types/endpoints/integrationApi/Messages.d.ts +34 -0
- package/dist/types/endpoints/integrationApi/Messages.d.ts.map +1 -0
- package/dist/types/endpoints/integrationApi/Users.d.ts +17 -1
- package/dist/types/endpoints/integrationApi/Users.d.ts.map +1 -1
- package/dist/types/endpoints/integrationApi/index.d.ts +6 -0
- package/dist/types/endpoints/integrationApi/index.d.ts.map +1 -1
- package/dist/types/endpoints/marketplace/FileDownloads.d.ts +33 -0
- package/dist/types/endpoints/marketplace/FileDownloads.d.ts.map +1 -0
- package/dist/types/endpoints/marketplace/FileUploads.d.ts +35 -0
- package/dist/types/endpoints/marketplace/FileUploads.d.ts.map +1 -0
- package/dist/types/endpoints/marketplace/Files.d.ts +33 -0
- package/dist/types/endpoints/marketplace/Files.d.ts.map +1 -0
- package/dist/types/endpoints/marketplace/OwnFileDownloads.d.ts +31 -0
- package/dist/types/endpoints/marketplace/OwnFileDownloads.d.ts.map +1 -0
- package/dist/types/endpoints/marketplace/OwnFiles.d.ts +50 -0
- package/dist/types/endpoints/marketplace/OwnFiles.d.ts.map +1 -0
- package/dist/types/endpoints/marketplace/index.d.ts +10 -0
- package/dist/types/endpoints/marketplace/index.d.ts.map +1 -1
- package/dist/types/integration/files.d.ts +66 -0
- package/dist/types/integrationSdk.d.ts +21 -0
- package/dist/types/integrationSdk.d.ts.map +1 -1
- package/dist/types/marketplace/files.d.ts +162 -0
- package/dist/types/marketplace/user.d.ts +11 -3
- package/dist/types/sdk.d.ts +30 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/types/integration/files.d.ts +67 -0
- package/dist/types/types/integration/files.d.ts.map +1 -0
- package/dist/types/types/marketplace/files.d.ts +163 -0
- package/dist/types/types/marketplace/files.d.ts.map +1 -0
- package/dist/types/types/marketplace/user.d.ts +11 -3
- package/dist/types/types/marketplace/user.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,191 +1,175 @@
|
|
|
1
1
|
# @vansite/ts-sharetribe-flex-sdk
|
|
2
2
|
|
|
3
|
-
](https://www.npmjs.com/package/@vansite/ts-sharetribe-flex-sdk)
|
|
4
|
+

|
|
4
5
|

|
|
5
|
-

|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
- **
|
|
12
|
-
- **Cross-platform
|
|
13
|
-
- **Fully typed
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
48
|
-
|
|
36
|
+
const { data } = await sdk.listings.query({
|
|
37
|
+
keywords: "yoga",
|
|
38
|
+
price: "1000,10000", // range "min,max" in minor units (cents)
|
|
39
|
+
include: ["author", "images"],
|
|
49
40
|
});
|
|
50
41
|
|
|
51
|
-
// Integration
|
|
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" })
|
|
58
|
-
console.log(response);
|
|
59
|
-
});
|
|
48
|
+
await integrationSdk.users.show({ id: new UUID("user-id") });
|
|
60
49
|
```
|
|
61
50
|
|
|
62
|
-
|
|
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
|
-
|
|
54
|
+
## API Coverage & Documentation
|
|
65
55
|
|
|
66
|
-
|
|
56
|
+
Both APIs are covered end-to-end. See the per-area guides in [`docs/`](./docs):
|
|
67
57
|
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
**
|
|
69
|
+
**Asset Delivery API** is exposed directly on the SDK: `sdk.assetByAlias`,
|
|
70
|
+
`sdk.assetsByAlias`, `sdk.assetByVersion`, `sdk.assetsByVersion`.
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
import { types as sdkTypes } from "./sdkLoader";
|
|
75
|
-
const { Money } = sdkTypes;
|
|
76
|
-
```
|
|
72
|
+
## Token Management
|
|
77
73
|
|
|
78
|
-
|
|
74
|
+
Tokens are persisted through a pluggable store (a `MemoryStore` is used by default):
|
|
79
75
|
|
|
80
|
-
```
|
|
81
|
-
import {
|
|
82
|
-
|
|
76
|
+
```typescript
|
|
77
|
+
import { SharetribeSdk, TokenStores } from "@vansite/ts-sharetribe-flex-sdk";
|
|
78
|
+
|
|
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
|
+
});
|
|
83
84
|
```
|
|
84
85
|
|
|
85
|
-
|
|
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 |
|
|
86
91
|
|
|
87
|
-
|
|
92
|
+
## Module Formats
|
|
88
93
|
|
|
89
|
-
|
|
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
|
-
```
|
|
94
|
+
Published in three formats (resolved automatically via the `exports` field):
|
|
103
95
|
|
|
104
|
-
|
|
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` |
|
|
105
101
|
|
|
106
|
-
|
|
107
|
-
import { transit } from "@vansite/ts-sharetribe-flex-sdk";
|
|
102
|
+
## Changelog
|
|
108
103
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
verbose: config.sdk.transitVerbose,
|
|
113
|
-
});
|
|
114
|
-
};
|
|
104
|
+
### 3.1.1
|
|
105
|
+
- Docs: fixed the `listings.query` price filter example — it's a range string `"min,max"` in minor units, not a `{ gte, lte }` object
|
|
106
|
+
- Docs: list **yarn** and **npm** alongside pnpm for the dev commands
|
|
115
107
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
### 3.1.0
|
|
109
|
+
- Marketplace file-sharing endpoints: `files`, `fileUploads`, `fileDownloads`, `ownFiles`, `ownFileDownloads`
|
|
110
|
+
- Integration query endpoints: `messages`, `files`, `fileAttachments`
|
|
111
|
+
- `integrationSdk.users.verifyEmail`
|
|
120
112
|
|
|
121
|
-
|
|
113
|
+
## Migration from `sharetribe-flex-sdk`
|
|
122
114
|
|
|
123
|
-
|
|
115
|
+
<details>
|
|
116
|
+
<summary>SDK loader, Transit and token stores</summary>
|
|
124
117
|
|
|
125
|
-
|
|
126
|
-
const sharetribeSdk = require("sharetribe-flex-sdk");
|
|
127
|
-
const store = sharetribeSdk.tokenStore.memoryStore();
|
|
128
|
-
```
|
|
118
|
+
### SDK Loader
|
|
129
119
|
|
|
130
|
-
|
|
120
|
+
The SDK loader is no longer needed — there is no difference between the Node and web builds.
|
|
131
121
|
|
|
132
122
|
```javascript
|
|
133
|
-
|
|
134
|
-
|
|
123
|
+
// before
|
|
124
|
+
import { types as sdkTypes } from "./sdkLoader";
|
|
125
|
+
// after
|
|
126
|
+
import { sdkTypes } from "@vansite/ts-sharetribe-flex-sdk";
|
|
127
|
+
const { Money } = sdkTypes;
|
|
135
128
|
```
|
|
136
129
|
|
|
137
|
-
|
|
130
|
+
### Transit
|
|
138
131
|
|
|
139
132
|
```javascript
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
req,
|
|
144
|
-
secure: true,
|
|
145
|
-
});
|
|
146
|
-
```
|
|
133
|
+
// before: import { transit } from "./sdkLoader";
|
|
134
|
+
// after:
|
|
135
|
+
import { transit } from "@vansite/ts-sharetribe-flex-sdk";
|
|
147
136
|
|
|
148
|
-
|
|
137
|
+
const serialize = (data) => transit.write(data, { typeHandlers, verbose: config.sdk.transitVerbose });
|
|
138
|
+
const deserialize = (str) => transit.read(str, { typeHandlers });
|
|
139
|
+
```
|
|
149
140
|
|
|
150
|
-
|
|
141
|
+
### Token Stores
|
|
151
142
|
|
|
152
|
-
```
|
|
153
|
-
|
|
143
|
+
```javascript
|
|
144
|
+
// before
|
|
145
|
+
const store = require("sharetribe-flex-sdk").tokenStore.memoryStore();
|
|
146
|
+
// after
|
|
147
|
+
const { TokenStores } = require("@vansite/ts-sharetribe-flex-sdk");
|
|
148
|
+
const store = new TokenStores.MemoryStore();
|
|
154
149
|
```
|
|
155
150
|
|
|
156
|
-
|
|
151
|
+
</details>
|
|
157
152
|
|
|
158
|
-
|
|
159
|
-
yarn test
|
|
160
|
-
```
|
|
153
|
+
## Development
|
|
161
154
|
|
|
162
|
-
**
|
|
155
|
+
Works with **pnpm**, **yarn** or **npm**:
|
|
163
156
|
|
|
164
157
|
```bash
|
|
165
|
-
yarn
|
|
158
|
+
pnpm install # yarn install | npm install
|
|
159
|
+
pnpm build # yarn build | npm run build — bundles (CJS/ESM/UMD) + types
|
|
160
|
+
pnpm test # yarn test | npm test — Jest test suite
|
|
161
|
+
pnpm analyze # yarn analyze | npm run analyze — bundle size analysis
|
|
166
162
|
```
|
|
167
163
|
|
|
168
164
|
## Contributing
|
|
169
165
|
|
|
170
|
-
Contributions are welcome
|
|
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.
|
|
166
|
+
Contributions are welcome! Please use the standard GitHub flow (fork → branch → pull request).
|
|
167
|
+
Bug reports, feature requests, expanded test coverage and documentation improvements are all appreciated.
|
|
178
168
|
|
|
179
169
|
## License
|
|
180
170
|
|
|
181
|
-
|
|
171
|
+
MIT — see [LICENSE](LICENSE.txt).
|
|
182
172
|
|
|
183
173
|
---
|
|
184
174
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
- Sharetribe Flex
|
|
188
|
-
- TypeScript SDK
|
|
189
|
-
- Node.js
|
|
190
|
-
- Browser
|
|
191
|
-
- API Integration
|
|
175
|
+
**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;
|