1.0.11 ā€¢ Published 1 year ago

@jeeny/jeeny-js-sdk v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

The jeeny-js-sdk package provides an intuitive and typesafe way to interact with the Jeeny API.

šŸ  Jeeny.com

What is Jeeny?

Jeeny is a warehouse management system and enterprise resource planning API. It is a headless system for procurement, inventory, standard operating procedures, manufacturing, and fulfillment. Without replacing your current systems you can extend, enhance, and embed in order to create the customizations your teams need.

Table of contents

Why use this?

The Jeeny JavaScript/TypeScript SDK provides a few advantages over rolling your own API layer.

  1. Autocomplete - a self-documenting API that provides tree-like access to the API, showcasing all available queries and mutations in your IDE
  2. Validation - see errors in your code before compiling with validation that always matches our latest spec
  3. Inline documentation - view property and record documentation in your IDE
  4. Up-to-date - always have access to the latest features

Installation

yarn add @jeeny/jeeny-js-sdk
npm install @jeeny/jeeny-js-sdk

Authentication

When you first import the Jeeny class you will need to authenticate with your companyId and API key.

You can get your free API key from the Jeeny Hub under the Headless menu.

Import

import { Jeeny } from "@jeeny/jeeny-js-sdk";

const jeeny = new Jeeny({
  apiKey: TOKEN,
  companyId: COMPANY_ID,
});

Adding default user information

You can set a default user string to send to Jeeny. This default user string will be added to records in places like createdBy, updatedBy, etc.

import { Jeeny } from "@jeeny/jeeny-js-sdk";

const jeeny = new Jeeny({
  apiKey: TOKEN,
  companyId: COMPANY_ID,
  user: "oracle_application"
});

Setting the user

At any point in time you can change the user string that is sent to Jeeny. This can be useful if are going to authenticate users before they can access your application. For the best experience, you should match your userIds with users created in the Jeeny system and pass a Jeeny userId. This lets the Jeeny system add more information to records and provide better indexing and querying.

You can create users in the Jeeny Hub.

jeeny.setUser("test-user");

Usage

This SDK was built in TypeScript (but works great with JavaScript too). It is fully typed and meant to be self-documenting. This means that autocomplete will provide all available query and mutation options to you. Properties will have inline documentation that matches our GraphQL introspection. Validation is built-in so that you can't pass incorrect objects to endpoints.

It's a wrapper around the Jeeny API and so our official API documentation can provide further insight into using this SDK. You can also see a complete API reference in a single page if that's easier for you.

import { Jeeny } from "@jeeny/jeeny-js-sdk";

const newItem = await jeeny.items.createItem({
  data: {
    status: "active",
    name: "Wooden block",
    partNumber: "ABC-123",
  },
});

const id = newItem.createItem?.id ?? "";

console.log(`Created a new item with id ${newItem.createItem?.id}`);

const existingItem = await jeeny.items.getItem({ id });

console.log("Existing item", existingItem.getItem);

Available queries and mutations

The following top level record types are available. The links below will take you to the official API documentation that will display all available queries and mutations for that specific record type.

RecordRecord associations
jeeny.appsApp
jeeny.arrivalsArrival, ArrivalDetails, ArrivalRelease, ArrivalDelivery, ArrivalLineItem, ArrivalReleaseLineItem, ArrivalDeliveryLineItem
jeeny.bidsBidRequest, Bid, BidRequestLineItem, BidLineItem
jeeny.companiesCompany
jeeny.companyUsersCompanyUser
jeeny.departuresDeparture, DeparturePickList, DeparturePick, DepartureLineItem, DeparturePickListLineItem, DeparturePickLineItem
jeeny.devicesDevice
jeeny.dynamicContainersDynamicContainer
jeeny.eventsEvent
jeeny.facilitiesFacility, FacilityDetails
jeeny.facilityItemsFacilityItem
jeeny.instructionsInstructionTemplate, InstructionExecution, InstructionSubject
jeeny.inventoryAreasStorageInventoryArea
jeeny.inventoryRecordsInventoryRecord, InventoryLog
jeeny.itemsItem, ItemDetails
jeeny.itemGroupsItemGroup
jeeny.kiosksKiosk
jeeny.kitsKitTemplate, KitTemplatePart, KitTemplatePartOption, KitTemplateTree, KitTemplateBomEntry
jeeny.operatorsOperator, SafeOperator
jeeny.productsProduct
jeeny.staticItemLocationsItemStorageInventoryAreaLocation, ItemStorageInventoryAreaRule
jeeny.storageInventoriesStorageInventory
jeeny.storageLocationsStorageInventoryAreaLocation, StorageInventoryAreaLocationPayload
jeeny.suppliersSupplier
jeeny.supplierItemsSupplierItem
jeeny.teamsTeam

Error handling

Errors can easily be caught and acted upon. The error message will tell you what went wrong - typically it is a validation issue from incorrect user input.

  const newItem = await jeeny.items
    .createItem({
      data: {
        status: "active",
        name: "Wooden block",
        partNumber: "ABC-123",
      },
    })
    .catch((e) => {
      console.log(e.response.errors);
    });

or

try {
  const newItem = await jeeny.items
    .createItem({
      data: {
        status: "active",
        name: "Wooden block",
        partNumber: "ABC-123",
      },
    })
} catch (e) {
  console.log(e.response.errors);
}

The errors object looks like this and can hold multiple errors:

 [
  {
    message: 'Variable "$data" got invalid value { status: "active", partNumber: "ABC-123" }; Field "name" of required type "String!" was not provided.',
    extensions: { code: 'BAD_USER_INPUT', exception: [Object] }
  }
]

React SDK

If you're building a UI in React we have a great SDK that lets the API fade into the background. Table, form, and action components are provided (fully typed and validated). Check it out here.

Author

šŸ‘¤ Jeeny

šŸ¤ Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ā­ļø if this project helped you!

šŸ“ License

Copyright Ā© 2023 Jeeny. This project is MIT licensed.


This README was generated with ā¤ļø by readme-md-generator

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

0.0.4

1 year ago