Coder Social home page Coder Social logo

api-utils's Introduction

This repository is deprecated

This code is now located in our monorepo here

api-utils

npm (scoped) CircleCI semantic-release

Utility functions for the Reaction API.

How To Use

Note: Be sure you are using NPM 5+

First install in your project directory:

npm install @reactioncommerce/api-utils

Import API util functions in the file you wish to use them in

import functionName from "@reactioncommerce/api-utils/functionName.js";

Refer to package docs for a list of available functions.

Releases

This NPM package is published automatically on every push to the trunk branch. Be sure to use proper Git commit messages so that the version will be bumped properly and release notes can be automatically generated.

api-utils's People

Contributors

abednegotm avatar akarshit avatar aldeed avatar cboiangiu avatar delagroove avatar dependabot[bot] avatar dileepab avatar dineshdb avatar focusaurus avatar kieckhafer avatar loan-laux avatar mikemurray avatar mohannarayana avatar nevill avatar snyk-bot avatar spencern avatar trojanh avatar zenweasel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-utils's Issues

[Bug] - Searching for product with specific slug results in error while product slug exists

Issue Description

When searching for a product with the query catalogProductItem and using the value 8706401, it thinks it as a base64 string while it's the value of a valid product with slug.

Steps to Reproduce

  1. Create a product with 8706401 as slug
  2. Publish the product
  3. Use catalogProductItem query to find the product by slug (value of slugOrId is 8706401)

Possible Solution

I think there needs to be a check if the provided value of property slugOrId is a valid base64 string which contains the namespace. If not, it needs to check if the slug exists.

Version

Reaction Commerce API: 3.8
api-catalog: 1.0.1

Missing Currency PKR

lib/CurrencyDefinitions.js does not include PKR although it's defined in CountryDefinitions.js

PK: {
name: "Pakistan",
native: "Pakistan",
phone: "92",
continent: "AS",
capital: "Islamabad",
currency: "PKR",
languages: "en,ur"
},

Cannot import mockConext in tests from plugins like api-plugin-catalogs

Jest globals cannot be imported outside of the test env. Jest seems to be complaining that mockContext imports @jest/globals outside of the test env. mocContext.js is imported into a test in a plugin.

 FAIL  src/mutations/applyCustomPublisherTransforms.test.js
  โ— Test suite failed to run

    Do not import `@jest/globals` outside of the Jest test environment

      at Object.<anonymous> (node_modules/@jest/globals/build/index.js:23:7)
      at Object.<anonymous> (node_modules/@reactioncommerce/api-utils/lib/tests/mockContext.js:1:1)

Add method that accepts internal database ids as-is or an encoded opaque id

Summary

We've been in talks on whether the field _id and other encoded id fields in responses from the Reaction API should be prefixed and base64 encoded as opaque ids. We've decided to support both values in the response, and accept both as input for queries and mutations.

As part of the solution to this problem, we have to consider a method that can accept both the database id and the encoded opaque id.

Issue

Queries and mutations expect the ID to be the encoded opaque id.

Possible Solution

  • Create a method that will accept both the internal database id or the encoded opaque id as input.
  • Selectively decode the opaque ID or return the database id as-is

Considerations

  • It should be fast. This method will be used a lot and the additional check may be a performance hit.
  • There are no rules on what internal database ids can be. They may be generated by Random.id, or a Mongo object id or even generated from an external system.

Deprecation warnings in Node 16

When using Node 16 using this plugin gives you this warning for every plugin that uses it:

[DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module 

Deprecation warnings in Node 16

When using Node 16 using this plugin gives you this warning for every plugin that uses it:

[DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.