1.0.5 • Published 4 months ago
@vansite/ts-sharetribe-flex-sdk v1.0.5
@vansite/ts-sharetribe-flex-sdk
This is a TypeScript SDK for the Sharetribe Flex API. It simplifies interaction with the API, providing a more user-friendly and intuitive interface for developers and reduces the size of the SDK.
Features
- Unified SDK: Combines both the Sharetribe SDK and Integration SDK in one package
- Cross-platform: Works seamlessly in both Node.js and browser environments without additional configuration
- Fully typed: Complete TypeScript definitions based on the official Sharetribe documentation
- Lightweight: Optimized bundle size for better performance
- Developer-friendly: Intuitive API design for easier integration
- Built-in support for cookie handling and UUID generation
Installation
npm
npm install @vansite/ts-sharetribe-flex-sdk
yarn
yarn add @vansite/ts-sharetribe-flex-sdk
Usage
See also the migration section to see how things changed.
import {
SharetribeSdk,
SharetribeIntegrationSdk,
} from "@vansite/ts-sharetribe-flex-sdk";
// Regular SDK for client-side operations
const sharetribeSdk = new SharetribeSdk({
clientId: "your-client-id",
});
sharetribeSdk.authInfo().then((response) => {
console.log(response);
});
// Integration SDK for server-side operations
const integrationSdk = new SharetribeIntegrationSdk({
clientId: "your-client-id",
clientSecret: "your-client-secret",
});
integrationSdk.users.show({ id: "user-id" }).then((response) => {
console.log(response);
});
Migration
SDK Loader
The Sdk loader is not needed anymore, because there is no difference between the node and web sdk
- Remove the sdkLoader file
- Exchange all sdkTypes with the types from the new sdk
brefore
import { types as sdkTypes } from "./sdkLoader";
const { Money } = sdkTypes;
after:
import { sdkTypes } from "@vansite/ts-sharetribe-flex-sdk";
const { Money } = sdkTypes;
Transit
before:
import { transit } from "./sdkLoader";
const serialize = (data) => {
return transit.write(data, {
typeHandlers,
verbose: config.sdk.transitVerbose,
});
};
const deserialize = (str) => {
return transit.read(str, { typeHandlers });
};
after:
import { transit } from "@vansite/ts-sharetribe-flex-sdk";
const serialize = (data) => {
return transit.write(data, {
typeHandlers,
verbose: config.sdk.transitVerbose,
});
};
const deserialize = (str) => {
return transit.read(str, { typeHandlers });
};
TokenStores
before:
const sharetribeSdk = require("sharetribe-flex-sdk");
const store = sharetribeSdk.tokenStore.memoryStore();
after:
const { TokenStore } = require("@vansite/ts-sharetribe-flex-sdk");
const store = new TokenStore.MemoryStore();
or
const { TokenStore } = require("@vansite/ts-sharetribe-flex-sdk");
const cookieTokenStore = new TokenStore.ExpressStore({
clientId: "client-id",
req,
secure: true,
});
Scripts
Build the project:
yarn build
Run tests:
yarn test
Analyze the bundle size:
yarn analyze
Contributing
Contributions are welcome and appreciated! If you'd like to help improve this library, please feel free to:
- Submit bug reports or feature requests through issues
- Propose improvements through pull requests
- Help expand test coverage
- Improve documentation
Please follow standard GitHub flow (fork, branch, pull request) for contributions.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Tags
- Sharetribe Flex
- TypeScript SDK
- Node.js
- Browser
- API Integration