Code Monkey home page Code Monkey logo

prici's People

Contributors

davidmeirlevy avatar eladabramovich avatar himasnhu-at avatar madina0801 avatar rannn505 avatar yaelih avatar

Stargazers

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

Watchers

 avatar

prici's Issues

enhancement: improve NestJs support

Currently, when creating a new Prici SDK instance in a NestJs app the app does not know about
the SDK instance in any way. This means that the SDK does not work in tandem with the Nest runtime.
By abstracting the SDK instance in a custom module, the following could be achieved:

  • A simpler interface to work with.
  • Less setup work.
  • Less boilerplate code.
  • Adding support for projects that use @nestjs/config
    and possibly other Nest related packages in the future.
  • Passing default config options when instantiating
    the SDK in a central place and then using them all over the app.

chore: unit tests for sdk

  • test sdk exists together with all its methods.
  • test controller method.
  • test kafka usage of increment.

ability to exceed over a field limit value

scenario:

  1. the plan is limited to X items, but any additional item will cost more.
  2. state.isAllowed should be true in this case, but also have another property to mention the limit has reached (maybe state.hasReachedLimit).

feat: as a user with multiple account-plans, feature credits should be spread from all plans.

let's say there's a user with multiple plans:

  1. a monthly plan with 100 credits of some feature.
  2. a "credits" plan with no-renewal.

when the user uses the feature, the increment should first come from the monthly package, and only when it's over - it should use the credits plan first.

same as when the user has multiple renewal plans - when it comes to a first plan limit - the counter should increment the second plan, and so on.

chore: unit tests for middlewares

  • test "get express middleware" function exists, both in js and ts.
  • test that nest guard class exists, both in js and ts.
  • test express middleware operation.
  • test nest guard operation.

bug: nest guard has a type check problem with the SDK

when coding:

 @Post("todos")
    @UseGuards(new IsAllowedGuard({
        // @ts-ignore
        sdk: priciSdk,
        errorMessage: "User is out of quota",
        getAccountId: (_) => "demo-account",
        getFieldId: (_) => featureId
    }))
    createTodo(@Body() body: any) {
        return this.appService.createTodo(body);
    }

without the ts-ignore - this code will never pass the build.
the error is:

TS2739: Type PriciSdk is missing the following properties from type PriciSdk: #remult, #accountFields

those are js private properties, and it's literally the same class, so it's weird that it's not passing.

Add fields groups

Fields Groups should have a name and priority (for order).

a plan field should have a "group" property (optional) with a group id.

next issue to open after that PR will be merged:

getGroupState method - to validate an entire group.

Add documentation website

Use Nuxt docs or vitepress.

First content:

  • content from readme file.
  • content from node sdk readme file

feat request: get count usages between dates via api

Provide a count API for a basic property.
Get the count for specific dates of that property.

That way users will be able to call an API call and charge by usage.

Assumption a Plan is composed of many properties which might be charged differently and dervied from different plans. The point is to do so by not knowing the whole plan's complexity - just the property.

getFieldsStates - multiple

  1. ability to get the state of multiple fields at the same request - by mentioning field ids.
  2. ability to get all states of all account plan fields, including isAllowed calculated value.

feature: account plan usage logs entity

A user would like to know anything that happened between/until/after certain dates.
A usage log entity can achieve this goal.

The usage log entity should persist:

  • account id
  • tenant
  • field id (refer to the plan field)
  • created at (date)
  • usage: number
  • additional info (string, optional)

The usage log should be set asynchronously on every increment action.
The usage property should be equal to the incementAmount given to the method (even if the field kind is boolean or string).

We should have an optional property to the increment method to support the additional info property, that will be stored in the usage log.
The user would like to add additional information about the increment action to add some context to the usage).

re-set an account plan

  1. ability to reset the state to its original state.
  2. ability to reset the state to the plan(s) current initial state (if edited afterwords).
  3. ability to set new plans (replace) and reset the state to the current associated plan(s).

feature: a plan fields and plans can also have a reset mode

Currently, account plans have reset modes - monthly, yearly, and manually.

But sometimes, certain feature counters (for example - storage) shouldn't reset at the reset action.

this mission is to add a "resetMode" to the plan fields' entity and store it on the account plan state when its created.
the default is empty (undefined), so the reset mode of the field is the same as the account plan reset mode.

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.