1.0.0-beta.14 • Published 2 months ago
@jungle-commerce/sdk v1.0.0-beta.14
Jungle Commerce SDK
This is a set of libraries for integrating with the Jungle Platform with JavaScript/TypeScript.
Developing the SDK
To make changes, first modify/add graphql files in the operations/
folder. Then run:
npx gql-gen && npm i
or use the SDK - Update
task in VS Code.
This will introspect the GraphQL schema, and regenerate the SDK based on those defined operations. By default, it will retrieve the schema from your local platform instance.
Using the SDK
Getting Started
The preferred way to install the Jungle Commerce SDK for Node.js is to use npm:
npm install --save @jungle-commerce/sdk
Example (Using API Key)
import { sdkInit } from "@jungle-commerce/sdk"
const { sdk, sdkApiKey, sdkWsClient } = sdkInit()
sdkApiKey("SecretFromSomewhere") // NOTE: Replace this with your API key.
async function example(sdk: typeof sdk) {
// Query
const { product } = await sdk.product({ productId: "abc" })
// Mutation
if (!product) {
const { result } = await sdk.productCreate({ input: { barcode: "abc", name: "Alphabet" } })
if (result.ok) {
console.log("YAY!")
} else {
console.log("oh no!")
}
}
// Subscription
const { finished, unsubscribe } = sdk.onNow({
next: console.log,
})
const delay = (() => new Promise((resolve) => setTimeout(resolve, 10000)))()
await Promise.race([finished, delay]) // if no more msgs, or 10 seconds.
unsubscribe()
}
example(sdk)
1.0.0-beta.14
2 months ago
1.0.0-beta.13
9 months ago
1.0.0-beta.11
1 year ago
1.0.0-beta.12
1 year ago
1.0.0-beta.10
2 years ago
1.0.0-beta.9
2 years ago
1.0.0-beta.8
2 years ago
1.0.0-beta.7
2 years ago
1.0.0-beta.6
2 years ago
1.0.0-beta.5
2 years ago
1.0.0-beta.4
3 years ago
1.0.0-beta.3
3 years ago
1.0.0-beta.2
3 years ago
1.0.0-beta.1
3 years ago
1.0.0-beta.0
3 years ago