Giter VIP home page Giter VIP logo

skucon-decomposer's Introduction

SKUcon-Decomposer

npm version PRs Welcome TypeScript

A simple npm package to decompose Android/iOS opinionated SKUs in my convetion/pattern, to allow information changes and additions to the SKUs easily and future-proofable.

In this pattern, each information in the SKU string isn't important, as it searchs for the key of the info to get its value. '_' separates the key from the value. '.' separates the key-value pair from another.

You can easily add a field you wish to the pattern, wrapping the decomposeSku() function and adding your fields (read index.ts to see how it's done there).

SKU full example: 'app_myapp.os_ios.id_license.id2_0.t_3m.loc_br.v_1'

export interface DescomposedSku {
  // App identifier. To make easier the identification of the SKU from other apps. Optional.
  app?: string;
  // Operational System.
  os: 'android' | 'ios';
  // The duration of the subscription if it's one (you may pass like '3m' for 3 months), or 'consumable' if it's one. It's the `t` field with a better name.
  duration: string | 'consumable';
  // The main identifier of the SKU.
  id: string;
  // An additional identifier for the "same" product. Useful to have multiple active subscriptions of the same product for different targets.
  id2?: string;
  // Locale. Lowercase [ISO 3166โ€“1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) or another pattern you may preffer. Useful for iOS specific pricing. Optional. Omitting it means default / international value.
  loc?: string;
  // The version of this SKU. Useful for deprecating an older one. A number.
  v: number;
  // The raw SKU you inputted. Useful for retrieving it after some filtrations.
  sku: string;
}

decomposeSku(sku: string): DescomposedSku

The function to decompose the SKU.

As it may throw errors for missing required fields or invalid values, you should wrap it in a try/catch block and at least console.error() the error to know what is wrong in your SKU in dev environment. You should even send this error to your backend so you can fix the SKU asap, decreasing the UX and gain losses.

IAPHUB recommended!

skucon-decomposer's People

Contributors

srbrahma avatar

Watchers

 avatar  avatar

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.