From e42351e1727d2b941054e6ca41712170bf98ac8f Mon Sep 17 00:00:00 2001 From: Madhukar Gaida <86058993+madhukar123456@users.noreply.github.com> Date: Tue, 27 Dec 2022 22:27:51 +0545 Subject: [PATCH 01/11] function: total static price --- packages/prices/.eslintrc.json | 26 + packages/prices/.gitignore | 3 + packages/prices/package.json | 52 ++ packages/prices/src/index.ts | 1 + packages/prices/src/prices.ts | 22 + packages/prices/test/prices.test.ts | 21 + packages/prices/tsconfig.json | 7 + pnpm-lock.yaml | 802 ++++++++++++++++++++++++---- 8 files changed, 838 insertions(+), 96 deletions(-) create mode 100644 packages/prices/.eslintrc.json create mode 100644 packages/prices/.gitignore create mode 100644 packages/prices/package.json create mode 100644 packages/prices/src/index.ts create mode 100644 packages/prices/src/prices.ts create mode 100644 packages/prices/test/prices.test.ts create mode 100644 packages/prices/tsconfig.json diff --git a/packages/prices/.eslintrc.json b/packages/prices/.eslintrc.json new file mode 100644 index 0000000..2fd7d57 --- /dev/null +++ b/packages/prices/.eslintrc.json @@ -0,0 +1,26 @@ +{ + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "prettier" + ], + "parserOptions": { + "ecmaVersion": 2020, + "sourceType": "module" + }, + "plugins": ["prettier", "@typescript-eslint"], + "rules": { + "eqeqeq": ["warn", "allow-null"], + "@typescript-eslint/no-unused-vars": [ + "error", + { + "ignoreRestSiblings": true, + "varsIgnorePattern": "^_", + "argsIgnorePattern": "^_" + } + ], + "no-var": "error", + "no-with": "warn", + "prefer-const": "error" + } +} diff --git a/packages/prices/.gitignore b/packages/prices/.gitignore new file mode 100644 index 0000000..fd771bc --- /dev/null +++ b/packages/prices/.gitignore @@ -0,0 +1,3 @@ +*.log +dist +node_modules \ No newline at end of file diff --git a/packages/prices/package.json b/packages/prices/package.json new file mode 100644 index 0000000..298cceb --- /dev/null +++ b/packages/prices/package.json @@ -0,0 +1,52 @@ +{ + "name": "@js-ligo/prices", + "version": "1.0.0", + "description": "", + "type": "module", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "exports": { + ".": "./dist/index.js" + }, + "files": [ + "dist" + ], + "scripts": { + "build:clean": "del dist", + "build:js": "swc src -d ./dist --config-file ../../.swcrc", + "build:types": "tsc --emitDeclarationOnly --skipLibCheck", + "build": "pnpm build:clean && pnpm build:types && pnpm build:js", + "test:it": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", + "lint": "eslint src/* test/* --fix", + "prepare": "pnpm build" + }, + "keywords": [], + "author": "", + "license": "MIT", + "dependencies": { + "@js-ligo/vocab": "workspace:^0.3.0" + }, + "jest": { + "extensionsToTreatAsEsm": [ + ".ts" + ], + "moduleNameMapper": { + "^(\\.{1,2}/.*)\\.js$": "$1" + }, + "transform": { + "^.+\\.(t|j)s$": [ + "@swc/jest", + { + "root": "../.." + } + ] + } + }, + "devDependencies": { + "@typescript-eslint/parser": "^4.9.1", + "eslint": "^6.0.0", + "jest-environment-node": "^29.0.3", + "node-fetch": "*", + "typescript": "^4.7.4" + } +} diff --git a/packages/prices/src/index.ts b/packages/prices/src/index.ts new file mode 100644 index 0000000..520ea5f --- /dev/null +++ b/packages/prices/src/index.ts @@ -0,0 +1 @@ +export * from "./prices"; \ No newline at end of file diff --git a/packages/prices/src/prices.ts b/packages/prices/src/prices.ts new file mode 100644 index 0000000..784511c --- /dev/null +++ b/packages/prices/src/prices.ts @@ -0,0 +1,22 @@ +import { PriceSpecification } from "@js-ligo/vocab"; + +export class Prices { + /** + * Find Total Price Static + */ + async findTotalStaticPrice(givenPrice: PriceSpecification) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const a = new Date(givenPrice.validThrough!); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const b = new Date(givenPrice.validFrom!); + return (await this._dateDiffInDays(a, b)) * givenPrice.price; + } + + private async _dateDiffInDays(a: Date, b: Date) { + const _MS_PER_DAY = 1000 * 60 * 60 * 24; + // Discard the time and time-zone information. + const utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate()); + const utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate()); + return Math.floor((utc2 - utc1) / _MS_PER_DAY); + } +} diff --git a/packages/prices/test/prices.test.ts b/packages/prices/test/prices.test.ts new file mode 100644 index 0000000..e165ccc --- /dev/null +++ b/packages/prices/test/prices.test.ts @@ -0,0 +1,21 @@ +import { PriceSpecification } from "@js-ligo/vocab"; +import { Prices } from "../src"; + +describe("prices", () => { + const givenPrice: PriceSpecification = { + price: 30, + priceCurrency: "USD", + validFrom: "2017-01-01", + validThrough: "2017-03-01", + }; + + describe("findTotalStaticPrice", () => { + test("total static price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.findTotalStaticPrice(givenPrice); + console.log(totalPrice); + expect(totalPrice).toBeDefined(); + expect(typeof totalPrice === "number").toBe(true); + }, 30000); + }); +}); diff --git a/packages/prices/tsconfig.json b/packages/prices/tsconfig.json new file mode 100644 index 0000000..34756dd --- /dev/null +++ b/packages/prices/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.build.json", + "compilerOptions": { + "outDir": "./dist" + }, + "include": ["src"] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9522fef..09d7280 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -42,7 +42,7 @@ importers: specifiers: '@ipld/car': ^4.1.5 '@ipld/dag-pb': ^2.1.18 - '@js-ligo/vocab': workspace:^0.2.1 + '@js-ligo/vocab': workspace:^0.3.0 '@stablelib/random': ^1.0.2 '@typescript-eslint/parser': ^4.9.1 dag-jose: ^2.0.1 @@ -70,7 +70,7 @@ importers: did-jwt: 6.8.0 dids: 3.4.0 eslint: 6.8.0 - ipfs-core: 0.16.0_x7fnwsarevril5ljymxhqdftba + ipfs-core: 0.16.0_6x5idpizl3qkvuzyh46d263eo4 ipfs-core-types: 0.12.0_undici@5.10.0 multiformats: 9.9.0 node-fetch: 2.6.7 @@ -91,7 +91,7 @@ importers: '@ethersproject/wallet': ^5.7.0 '@js-ligo/agreements': workspace:^0.2.1 '@js-ligo/interact': workspace:^0.2.1 - '@js-ligo/vocab': workspace:^0.2.1 + '@js-ligo/vocab': workspace:^0.3.0 '@lit-protocol/sdk-browser': ^1.1.228 '@lit-protocol/sdk-nodejs': ^1.1.228 '@peculiar/webcrypto': ^1.4.0 @@ -174,7 +174,7 @@ importers: did-jwt: 6.8.0 eslint: 6.8.0 eth-provider: 0.13.6 - ipfs: 0.64.2_odzcsdhh4pct4zkltozn235usi + ipfs: 0.64.2_pfoqomcgvehmtzydofkquizxzq ipfs-core-types: 0.12.0_undici@5.10.0 jest-environment-node: 29.0.3 node-fetch: 3.2.10 @@ -188,7 +188,7 @@ importers: specifiers: '@ipld/car': ^4.1.5 '@js-ligo/agreements': workspace:^0.2.1 - '@js-ligo/vocab': workspace:^0.2.1 + '@js-ligo/vocab': workspace:^0.3.0 '@stablelib/random': ^1.0.2 '@types/uuid': ^8.3.4 '@typescript-eslint/parser': ^4.9.1 @@ -227,8 +227,8 @@ importers: '@veramo/did-resolver': 4.1.1 '@veramo/key-manager': 4.1.1 '@veramo/kms-local': 4.1.1 - '@waku/core': 0.0.3_undici@5.10.0 - '@waku/interfaces': 0.0.2_undici@5.10.0 + '@waku/core': 0.0.3 + '@waku/interfaces': 0.0.2 dag-jose: 3.0.1 did-resolver: 4.0.1 dids: 3.4.0 @@ -237,7 +237,7 @@ importers: uuid: 9.0.0 devDependencies: '@typescript-eslint/parser': 4.33.0_ka3v2sz4nenxxmg4373y7syisy - '@waku/create': 0.0.3_undici@5.10.0 + '@waku/create': 0.0.3 did-jwt: 6.8.0 eslint: 6.8.0 jest-environment-node: 29.0.3 @@ -245,6 +245,23 @@ importers: node-fetch: 3.2.10 typescript: 4.8.3 + packages/prices: + specifiers: + '@js-ligo/vocab': workspace:^0.3.0 + '@typescript-eslint/parser': ^4.9.1 + eslint: ^6.0.0 + jest-environment-node: ^29.0.3 + node-fetch: '*' + typescript: ^4.7.4 + dependencies: + '@js-ligo/vocab': link:../vocab + devDependencies: + '@typescript-eslint/parser': 4.33.0_ka3v2sz4nenxxmg4373y7syisy + eslint: 6.8.0 + jest-environment-node: 29.0.3 + node-fetch: 3.2.10 + typescript: 4.8.3 + packages/vocab: specifiers: '@ipld/schema': ^4.1.2 @@ -761,12 +778,43 @@ packages: /@chainsafe/is-ip/2.0.1: resolution: {integrity: sha512-nqSJ8u2a1Rv9FYbyI8qpDhTYujaKEyLknNrTejLYoSWmdeg+2WB7R6BZqPZYfrJzDxVi3rl6ZQuoaEvpKRZWgQ==} + /@chainsafe/libp2p-gossipsub/4.1.1: + resolution: {integrity: sha512-W3z52uTVm48qvwTAcE+tz6ML2CPWA4ErmuL2aCWAW8S7ce6iH8anqo+xI9rcedyIOChWMWLLD4Gtaj4TMrWacw==} + engines: {npm: '>=8.7.0'} + dependencies: + '@libp2p/components': 2.1.0 + '@libp2p/crypto': 1.0.4 + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-keys': 1.0.3 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-pubsub': 2.1.0 + '@libp2p/interface-registrar': 2.0.3 + '@libp2p/interfaces': 3.0.3 + '@libp2p/logger': 2.0.1 + '@libp2p/peer-id': 1.1.15 + '@libp2p/peer-record': 4.0.3 + '@libp2p/pubsub': 3.1.2 + '@libp2p/topology': 3.0.0 + abortable-iterator: 4.0.2 + denque: 1.5.1 + err-code: 3.0.1 + it-length-prefixed: 8.0.2 + it-pipe: 2.0.4 + it-pushable: 3.1.0 + multiformats: 9.9.0 + protobufjs: 6.11.3 + uint8arraylist: 2.3.2 + uint8arrays: 3.1.0 + transitivePeerDependencies: + - supports-color + - undici + /@chainsafe/libp2p-gossipsub/4.1.1_undici@5.10.0: resolution: {integrity: sha512-W3z52uTVm48qvwTAcE+tz6ML2CPWA4ErmuL2aCWAW8S7ce6iH8anqo+xI9rcedyIOChWMWLLD4Gtaj4TMrWacw==} engines: {npm: '>=8.7.0'} dependencies: '@libp2p/components': 2.1.0_undici@5.10.0 - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-connection': 3.0.2_undici@5.10.0 '@libp2p/interface-keys': 1.0.3 '@libp2p/interface-peer-id': 1.0.6 @@ -796,7 +844,7 @@ packages: resolution: {integrity: sha512-mr1/CMTBIfraqTY4OWBdmJ2v+0+D89vbIp1nJTHz64oDPRgU0Ah8wb7K5hgs0erU8aYMkgMtbhXeouhJK3A7wA==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-connection-encrypter': 2.0.1 '@libp2p/interface-keys': 1.0.3 '@libp2p/interface-peer-id': 1.0.6 @@ -811,7 +859,7 @@ packages: it-pb-stream: 2.0.2 it-pipe: 2.0.4 it-stream-types: 1.0.4 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 uint8arraylist: 2.3.2 uint8arrays: 3.1.0 transitivePeerDependencies: @@ -1902,6 +1950,29 @@ packages: - supports-color - undici + /@libp2p/components/2.1.0: + resolution: {integrity: sha512-9xK1pauZiptaR0eJFn1LcOr/hwosU76IjPOqTkRVZVjSStIWmBl+Njrn4qK05Jizopf0cIUnpt/8A6YWjM4D7g==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-address-manager': 1.0.3 + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-connection-manager': 1.1.1 + '@libp2p/interface-content-routing': 1.0.2 + '@libp2p/interface-dht': 1.0.1 + '@libp2p/interface-metrics': 3.0.0 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-peer-routing': 1.0.1 + '@libp2p/interface-peer-store': 1.2.2 + '@libp2p/interface-pubsub': 2.1.0 + '@libp2p/interface-registrar': 2.0.3 + '@libp2p/interface-transport': 1.0.4 + '@libp2p/interfaces': 3.0.3 + err-code: 3.0.1 + interface-datastore: 7.0.0 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/components/2.1.0_undici@5.10.0: resolution: {integrity: sha512-9xK1pauZiptaR0eJFn1LcOr/hwosU76IjPOqTkRVZVjSStIWmBl+Njrn4qK05Jizopf0cIUnpt/8A6YWjM4D7g==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -1940,6 +2011,20 @@ packages: - undici dev: false + /@libp2p/connection/4.0.2: + resolution: {integrity: sha512-l/mvmcA7QkAC/0qRmTpuD5CeMaiy4DuKCsutaY3PpwJbMegTOjxuZh0uzk3z94d0wJBnhquVZ0e4Yqvd+QGlng==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interfaces': 3.0.3 + '@libp2p/logger': 2.0.1 + '@multiformats/multiaddr': 11.0.7 + err-code: 3.0.1 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/connection/4.0.2_undici@5.10.0: resolution: {integrity: sha512-l/mvmcA7QkAC/0qRmTpuD5CeMaiy4DuKCsutaY3PpwJbMegTOjxuZh0uzk3z94d0wJBnhquVZ0e4Yqvd+QGlng==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -1954,7 +2039,7 @@ packages: - supports-color - undici - /@libp2p/crypto/1.0.4_uint8arraylist@2.3.2: + /@libp2p/crypto/1.0.4: resolution: {integrity: sha512-3hHZvqi+vI8YoTHE+0u8nA5SYGPLZRLMvbgXQoAn0IyPjez66Taaxym/3p3Duf9QkFlvJu95nzpNzv0OdHs9Yw==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: @@ -1964,10 +2049,8 @@ packages: err-code: 3.0.1 multiformats: 9.9.0 node-forge: 1.3.1 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 uint8arrays: 3.1.0 - transitivePeerDependencies: - - uint8arraylist /@libp2p/delegated-content-routing/2.0.1_undici@5.10.0: resolution: {integrity: sha512-5J+i2yZsW1rddKQ07eiqHiqdcChK6dC8NghYOQGbizQI3QMixJvgTucEvES90Nh1bbf0swPHDkJmct6iLi+zlQ==} @@ -2015,7 +2098,7 @@ packages: '@libp2p/interface-pubsub': 2.1.0_undici@5.10.0 '@libp2p/logger': 2.0.1 '@libp2p/pubsub': 3.1.2_undici@5.10.0 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 uint8arraylist: 2.3.2 uint8arrays: 3.1.0 transitivePeerDependencies: @@ -2033,6 +2116,16 @@ packages: - undici dev: false + /@libp2p/interface-address-manager/1.0.3: + resolution: {integrity: sha512-/DNGUQEXA0Ks+EOp0IVv3TsWq1H+4ZlSnyBozzNGDmufz6wG+EvUDBbwIXieHR898bj4pHfmmogK+Vwz5s5Kdw==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interfaces': 3.0.3 + '@multiformats/multiaddr': 11.0.7 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-address-manager/1.0.3_undici@5.10.0: resolution: {integrity: sha512-/DNGUQEXA0Ks+EOp0IVv3TsWq1H+4ZlSnyBozzNGDmufz6wG+EvUDBbwIXieHR898bj4pHfmmogK+Vwz5s5Kdw==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2064,6 +2157,18 @@ packages: - undici dev: false + /@libp2p/interface-connection-manager/1.1.1: + resolution: {integrity: sha512-sPBHXNLqYCYl/fo4hdseRJm/Z9DWgPulegCKI5JUjaiqrcdmAHDOnIHIKWP0i+N+yNR3y7nUBWp5QT1pqpvK7Q==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interfaces': 3.0.3 + '@multiformats/multiaddr': 11.0.7 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-connection-manager/1.1.1_undici@5.10.0: resolution: {integrity: sha512-sPBHXNLqYCYl/fo4hdseRJm/Z9DWgPulegCKI5JUjaiqrcdmAHDOnIHIKWP0i+N+yNR3y7nUBWp5QT1pqpvK7Q==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2076,6 +2181,19 @@ packages: - supports-color - undici + /@libp2p/interface-connection/3.0.1: + resolution: {integrity: sha512-x+Ws74EhxvSym2fTQMP8/xpV3p8A3ar8yOq4dq/44HSvEMMKcuQvEq2jShVK0aXEpg1ce/KHY83FgY1zToFM2A==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interfaces': 3.0.3 + '@multiformats/multiaddr': 10.5.0 + it-stream-types: 1.0.4 + uint8arraylist: 2.3.2 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-connection/3.0.1_undici@5.10.0: resolution: {integrity: sha512-x+Ws74EhxvSym2fTQMP8/xpV3p8A3ar8yOq4dq/44HSvEMMKcuQvEq2jShVK0aXEpg1ce/KHY83FgY1zToFM2A==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2088,6 +2206,20 @@ packages: transitivePeerDependencies: - supports-color - undici + dev: false + + /@libp2p/interface-connection/3.0.2: + resolution: {integrity: sha512-38R2GQ6BCOtwMi5uWU5MLr+xfEpRmVK9gqOp7jNx+6T7TVn8ji4725XLXNfpzprbOrzZkqf2iER84s8+yX4pMA==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interfaces': 3.0.3 + '@multiformats/multiaddr': 11.0.7 + it-stream-types: 1.0.4 + uint8arraylist: 2.3.2 + transitivePeerDependencies: + - supports-color + - undici /@libp2p/interface-connection/3.0.2_undici@5.10.0: resolution: {integrity: sha512-38R2GQ6BCOtwMi5uWU5MLr+xfEpRmVK9gqOp7jNx+6T7TVn8ji4725XLXNfpzprbOrzZkqf2iER84s8+yX4pMA==} @@ -2102,6 +2234,17 @@ packages: - supports-color - undici + /@libp2p/interface-content-routing/1.0.2: + resolution: {integrity: sha512-Ue1X8XrZ4ymTMQk/GWom/EKfPB5Lu7zy33ohjSix26Da/HbBvkXBdnYGDj485vxSOZGZRqeBhh21nCVjD/yLyg==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-peer-info': 1.0.3 + '@libp2p/interfaces': 3.0.3 + multiformats: 9.9.0 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-content-routing/1.0.2_undici@5.10.0: resolution: {integrity: sha512-Ue1X8XrZ4ymTMQk/GWom/EKfPB5Lu7zy33ohjSix26Da/HbBvkXBdnYGDj485vxSOZGZRqeBhh21nCVjD/yLyg==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2113,6 +2256,19 @@ packages: - supports-color - undici + /@libp2p/interface-dht/1.0.1: + resolution: {integrity: sha512-EToxQznHUnD9frWoHwq8DUaOa7RZ2qoo6beb1aWdQrEJsEdUBi62FHh9qrLkrL+E4W3rkl2+WrhSP6/iHxZZwQ==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-peer-discovery': 1.0.1 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-peer-info': 1.0.3 + '@libp2p/interfaces': 3.0.3 + multiformats: 9.9.0 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-dht/1.0.1_undici@5.10.0: resolution: {integrity: sha512-EToxQznHUnD9frWoHwq8DUaOa7RZ2qoo6beb1aWdQrEJsEdUBi62FHh9qrLkrL+E4W3rkl2+WrhSP6/iHxZZwQ==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2143,6 +2299,16 @@ packages: '@libp2p/interface-peer-id': 1.0.6 it-stream-types: 1.0.4 + /@libp2p/interface-peer-discovery/1.0.1: + resolution: {integrity: sha512-ZqBhpX7fR3ROYQaGYV47YhyTJJzFDzyyEIsQ7NnDuG3KhcQb2PtocnN0sy1Ozm784M0oYveM/HjfuNxxcOwdYg==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-peer-info': 1.0.3 + '@libp2p/interfaces': 3.0.3 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-peer-discovery/1.0.1_undici@5.10.0: resolution: {integrity: sha512-ZqBhpX7fR3ROYQaGYV47YhyTJJzFDzyyEIsQ7NnDuG3KhcQb2PtocnN0sy1Ozm784M0oYveM/HjfuNxxcOwdYg==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2175,6 +2341,16 @@ packages: - supports-color - undici + /@libp2p/interface-peer-info/1.0.3: + resolution: {integrity: sha512-QKybxfp/NmDGDMkgf/CTt4fU03ajZnldHr9TYg5wMkJrnVaaHbhDTYBg5YWt+iOH1mgR89/dpKv/Na0ZE5sPIA==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-peer-id': 1.0.6 + '@multiformats/multiaddr': 11.0.7 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-peer-info/1.0.3_undici@5.10.0: resolution: {integrity: sha512-QKybxfp/NmDGDMkgf/CTt4fU03ajZnldHr9TYg5wMkJrnVaaHbhDTYBg5YWt+iOH1mgR89/dpKv/Na0ZE5sPIA==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2185,6 +2361,17 @@ packages: - supports-color - undici + /@libp2p/interface-peer-routing/1.0.1: + resolution: {integrity: sha512-MKx2g0mIUI6qNuLv3xApKXR2ZrO9CUTT9ZPL0gvRlhpFCXovEkdWJ1h8KnmkR7tGPxKHt2bsCCJ8gqUaFeNstA==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-peer-info': 1.0.3 + '@libp2p/interfaces': 3.0.3 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-peer-routing/1.0.1_undici@5.10.0: resolution: {integrity: sha512-MKx2g0mIUI6qNuLv3xApKXR2ZrO9CUTT9ZPL0gvRlhpFCXovEkdWJ1h8KnmkR7tGPxKHt2bsCCJ8gqUaFeNstA==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2210,6 +2397,19 @@ packages: - undici dev: false + /@libp2p/interface-peer-store/1.2.2: + resolution: {integrity: sha512-ZjE9AkDtjz4R+SppCgZ66oko7Z9pDsdFk1lbba0hTPA2i0uuWdTYep7bZ3RvKot0Q2UrWg8ySL/30pW+Wp70sA==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-peer-info': 1.0.3 + '@libp2p/interface-record': 2.0.1 + '@libp2p/interfaces': 3.0.3 + '@multiformats/multiaddr': 11.0.7 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-peer-store/1.2.2_undici@5.10.0: resolution: {integrity: sha512-ZjE9AkDtjz4R+SppCgZ66oko7Z9pDsdFk1lbba0hTPA2i0uuWdTYep7bZ3RvKot0Q2UrWg8ySL/30pW+Wp70sA==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2223,6 +2423,19 @@ packages: - supports-color - undici + /@libp2p/interface-pubsub/2.1.0: + resolution: {integrity: sha512-X+SIqzfeCO8ZDGrFTzH9EMwMf8ojW5nk20rxv3h1sCXEdfvyJCARZ51r9UlwJcnucnHqvFChfkbubAkrr3R4Cw==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interfaces': 3.0.3 + it-pushable: 3.1.0 + uint8arraylist: 2.3.2 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-pubsub/2.1.0_undici@5.10.0: resolution: {integrity: sha512-X+SIqzfeCO8ZDGrFTzH9EMwMf8ojW5nk20rxv3h1sCXEdfvyJCARZ51r9UlwJcnucnHqvFChfkbubAkrr3R4Cw==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2243,6 +2456,16 @@ packages: '@libp2p/interface-peer-id': 1.0.6 uint8arraylist: 2.3.2 + /@libp2p/interface-registrar/2.0.3: + resolution: {integrity: sha512-YA/A+o+166/+noXxMFXvZdg9soZSZX2EPOlUwnGXZWR7J5B2sxyP76QxHWXL5npsEMj7suP+Rjb/GJYGz7rDyg==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-peer-id': 1.0.6 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-registrar/2.0.3_undici@5.10.0: resolution: {integrity: sha512-YA/A+o+166/+noXxMFXvZdg9soZSZX2EPOlUwnGXZWR7J5B2sxyP76QxHWXL5npsEMj7suP+Rjb/GJYGz7rDyg==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2253,6 +2476,17 @@ packages: - supports-color - undici + /@libp2p/interface-stream-muxer/2.0.2: + resolution: {integrity: sha512-BcLsV8ZVr34G32u/w4pgSAgFju9CTuBB9OJwgX6ugasYf6LtJ0a3m5Kwddy79lvvM/gBvVv/McpCr4mPxP4WWg==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interfaces': 3.0.3 + it-stream-types: 1.0.4 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-stream-muxer/2.0.2_undici@5.10.0: resolution: {integrity: sha512-BcLsV8ZVr34G32u/w4pgSAgFju9CTuBB9OJwgX6ugasYf6LtJ0a3m5Kwddy79lvvM/gBvVv/McpCr4mPxP4WWg==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2276,6 +2510,18 @@ packages: - supports-color - undici + /@libp2p/interface-transport/1.0.4: + resolution: {integrity: sha512-MOkhtykUrrbgHC1CcAFe/6QTz/BEBbHfu5sf+go6dhBlHXeHI+AcV8Fic5zTZNz71E1SRi2UR+5TVi7ORPL57Q==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interfaces': 3.0.3 + '@multiformats/multiaddr': 11.0.7 + it-stream-types: 1.0.4 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/interface-transport/1.0.4_undici@5.10.0: resolution: {integrity: sha512-MOkhtykUrrbgHC1CcAFe/6QTz/BEBbHfu5sf+go6dhBlHXeHI+AcV8Fic5zTZNz71E1SRi2UR+5TVi7ORPL57Q==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2297,7 +2543,7 @@ packages: engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: '@libp2p/components': 2.1.0_undici@5.10.0 - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-address-manager': 1.0.3_undici@5.10.0 '@libp2p/interface-connection': 3.0.2_undici@5.10.0 '@libp2p/interface-connection-manager': 1.1.1_undici@5.10.0 @@ -2335,7 +2581,7 @@ packages: p-defer: 4.0.0 p-queue: 7.3.0 private-ip: 2.3.4 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 timeout-abort-controller: 3.0.0 uint8arraylist: 2.3.2 uint8arrays: 3.1.0 @@ -2374,6 +2620,30 @@ packages: - supports-color - undici + /@libp2p/mplex/5.2.3: + resolution: {integrity: sha512-FvFSpFXa4cfwxDTw1uHVr3sbab48R7kMj1Hu17n9MrQiH0OCrsfjuYsjAZAwmPWPnBV7Rpffpj8A7Y7DUhxZBQ==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/components': 2.1.0 + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-stream-muxer': 2.0.2 + '@libp2p/logger': 2.0.1 + '@libp2p/tracked-map': 2.0.2 + abortable-iterator: 4.0.2 + any-signal: 3.0.1 + err-code: 3.0.1 + it-pipe: 2.0.4 + it-pushable: 3.1.0 + it-stream-types: 1.0.4 + rate-limiter-flexible: 2.3.10 + uint8arraylist: 2.3.2 + uint8arrays: 3.1.0 + varint: 6.0.0 + transitivePeerDependencies: + - supports-color + - undici + dev: true + /@libp2p/mplex/5.2.3_undici@5.10.0: resolution: {integrity: sha512-FvFSpFXa4cfwxDTw1uHVr3sbab48R7kMj1Hu17n9MrQiH0OCrsfjuYsjAZAwmPWPnBV7Rpffpj8A7Y7DUhxZBQ==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2429,12 +2699,12 @@ packages: resolution: {integrity: sha512-x7lyPrfF4kkMj6az+h1sq5L6ifTvZt2exKi8yS6/Gi/hT8rfqXROdBDtanMjJivIFlzVKJyZdfW5f5RK9Av3iQ==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-keys': 1.0.3 '@libp2p/interface-peer-id': 1.0.6 '@libp2p/peer-id': 1.1.15 multiformats: 9.9.0 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 uint8arraylist: 2.3.2 uint8arrays: 3.1.0 @@ -2451,7 +2721,7 @@ packages: resolution: {integrity: sha512-r1arc73ADcLd9sESNy7bDHPAsv3JYvIV7kXjB13wQJAQ1oeu9e0I6f1MAIWt4ZukNAiRD8gdlrRvNG63AAZfOg==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-peer-id': 1.0.4 '@libp2p/interface-record': 2.0.1 '@libp2p/logger': 2.0.1 @@ -2466,7 +2736,7 @@ packages: it-map: 1.0.6 it-pipe: 2.0.4 multiformats: 9.9.0 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 uint8-varint: 1.0.3 uint8arraylist: 2.3.2 uint8arrays: 3.1.0 @@ -2476,11 +2746,39 @@ packages: - undici dev: false + /@libp2p/peer-record/4.0.3: + resolution: {integrity: sha512-0GqcZ2LU/RfIZk7SA2g9ZI8t+jh5p0lkmrhD4VefqhBkIc2fpAthUo+2O94gz9UpFn0LDJMqmgQgrKImL2VJTQ==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/crypto': 1.0.4 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-record': 2.0.1 + '@libp2p/logger': 2.0.1 + '@libp2p/peer-id': 1.1.15 + '@libp2p/utils': 3.0.2 + '@multiformats/multiaddr': 11.0.7 + err-code: 3.0.1 + interface-datastore: 7.0.0 + it-all: 1.0.6 + it-filter: 1.0.3 + it-foreach: 0.1.1 + it-map: 1.0.6 + it-pipe: 2.0.4 + multiformats: 9.9.0 + protons-runtime: 3.1.0 + uint8-varint: 1.0.3 + uint8arraylist: 2.3.2 + uint8arrays: 3.1.0 + varint: 6.0.0 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/peer-record/4.0.3_undici@5.10.0: resolution: {integrity: sha512-0GqcZ2LU/RfIZk7SA2g9ZI8t+jh5p0lkmrhD4VefqhBkIc2fpAthUo+2O94gz9UpFn0LDJMqmgQgrKImL2VJTQ==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-peer-id': 1.0.6 '@libp2p/interface-record': 2.0.1 '@libp2p/logger': 2.0.1 @@ -2495,7 +2793,7 @@ packages: it-map: 1.0.6 it-pipe: 2.0.4 multiformats: 9.9.0 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 uint8-varint: 1.0.3 uint8arraylist: 2.3.2 uint8arrays: 3.1.0 @@ -2527,7 +2825,7 @@ packages: it-pipe: 2.0.4 mortice: 3.0.1 multiformats: 9.9.0 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 uint8arraylist: 2.3.2 uint8arrays: 3.1.0 transitivePeerDependencies: @@ -2535,6 +2833,36 @@ packages: - undici dev: false + /@libp2p/peer-store/3.1.5: + resolution: {integrity: sha512-tChz3TqkQj1t0+yugWroeGhHbX+q7e1goVRJQbli4sZ1j5NEAQlxHpPq2yDOOCB5RVvX0oZ8b32999ILOJXbvA==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/components': 2.1.0 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-peer-info': 1.0.3 + '@libp2p/interface-peer-store': 1.2.2 + '@libp2p/interface-record': 2.0.1 + '@libp2p/interfaces': 3.0.3 + '@libp2p/logger': 2.0.1 + '@libp2p/peer-id': 1.1.15 + '@libp2p/peer-record': 4.0.3 + '@multiformats/multiaddr': 11.0.7 + err-code: 3.0.1 + interface-datastore: 7.0.0 + it-all: 1.0.6 + it-filter: 1.0.3 + it-foreach: 0.1.1 + it-map: 1.0.6 + it-pipe: 2.0.4 + mortice: 3.0.1 + multiformats: 9.9.0 + protons-runtime: 3.1.0 + uint8arraylist: 2.3.2 + uint8arrays: 3.1.0 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/peer-store/3.1.5_undici@5.10.0: resolution: {integrity: sha512-tChz3TqkQj1t0+yugWroeGhHbX+q7e1goVRJQbli4sZ1j5NEAQlxHpPq2yDOOCB5RVvX0oZ8b32999ILOJXbvA==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2558,7 +2886,36 @@ packages: it-pipe: 2.0.4 mortice: 3.0.1 multiformats: 9.9.0 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 + uint8arraylist: 2.3.2 + uint8arrays: 3.1.0 + transitivePeerDependencies: + - supports-color + - undici + + /@libp2p/pubsub/3.1.2: + resolution: {integrity: sha512-pCbz6JW9q10Ukw2f+gfMWzvKRdN3K3w04//JRfCOrGwRnkdHWA90k4FGEZ0j2caXK8Z0cnUGVD86UBX5uBAG7Q==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/components': 2.1.0 + '@libp2p/crypto': 1.0.4 + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-pubsub': 2.1.0 + '@libp2p/interface-registrar': 2.0.3 + '@libp2p/interfaces': 3.0.3 + '@libp2p/logger': 2.0.1 + '@libp2p/peer-collections': 2.0.0 + '@libp2p/peer-id': 1.1.15 + '@libp2p/topology': 3.0.0 + '@multiformats/multiaddr': 10.5.0 + abortable-iterator: 4.0.2 + err-code: 3.0.1 + it-length-prefixed: 8.0.2 + it-pipe: 2.0.4 + it-pushable: 3.1.0 + multiformats: 9.9.0 + p-queue: 7.3.0 uint8arraylist: 2.3.2 uint8arrays: 3.1.0 transitivePeerDependencies: @@ -2570,7 +2927,7 @@ packages: engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: '@libp2p/components': 2.1.0_undici@5.10.0 - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-connection': 3.0.2_undici@5.10.0 '@libp2p/interface-peer-id': 1.0.6 '@libp2p/interface-pubsub': 2.1.0_undici@5.10.0 @@ -2601,7 +2958,7 @@ packages: '@libp2p/interface-dht': 1.0.1_undici@5.10.0 err-code: 3.0.1 multiformats: 9.9.0 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 uint8arraylist: 2.3.2 uint8arrays: 3.1.0 transitivePeerDependencies: @@ -2626,6 +2983,20 @@ packages: - supports-color - undici + /@libp2p/topology/3.0.0: + resolution: {integrity: sha512-gQMkO1j7D/7A9MfL2mtLxr0StXzjqK0V554w7hk25E66Ly0wp1K7vPEfhE9rExLSaQqe9ir4nijhbA3rNnxZng==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-registrar': 2.0.3 + '@libp2p/logger': 2.0.1 + '@multiformats/multiaddr': 10.5.0 + err-code: 3.0.1 + it-all: 1.0.6 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/topology/3.0.0_undici@5.10.0: resolution: {integrity: sha512-gQMkO1j7D/7A9MfL2mtLxr0StXzjqK0V554w7hk25E66Ly0wp1K7vPEfhE9rExLSaQqe9ir4nijhbA3rNnxZng==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2666,6 +3037,25 @@ packages: - undici dev: false + /@libp2p/utils/3.0.2: + resolution: {integrity: sha512-/+mwCEd1o1sko3fYkVfy9pDT3Ks+KszR4Y3fb3M3/UCETDituvqZKHHM4wyTJsFlrFrohbtYlNvWhJ7Pej3X5g==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@achingbrain/ip-address': 8.1.0 + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-peer-store': 1.2.2 + '@libp2p/logger': 2.0.1 + '@multiformats/multiaddr': 11.0.7 + abortable-iterator: 4.0.2 + err-code: 3.0.1 + is-loopback-addr: 2.0.1 + it-stream-types: 1.0.4 + private-ip: 2.3.4 + uint8arraylist: 2.3.2 + transitivePeerDependencies: + - supports-color + - undici + /@libp2p/utils/3.0.2_undici@5.10.0: resolution: {integrity: sha512-/+mwCEd1o1sko3fYkVfy9pDT3Ks+KszR4Y3fb3M3/UCETDituvqZKHHM4wyTJsFlrFrohbtYlNvWhJ7Pej3X5g==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2745,6 +3135,31 @@ packages: - undici - utf-8-validate + /@libp2p/websockets/3.0.3: + resolution: {integrity: sha512-fGbXpbyJaToA3Opc/lyw3C2xGlhDiabwQeQE6bTNTCpCFsBwOq8DwE4J++lkxnvJzKu0D4oC1c7oQrQ+4oq1Fw==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-transport': 1.0.4 + '@libp2p/interfaces': 3.0.3 + '@libp2p/logger': 2.0.1 + '@libp2p/utils': 3.0.2 + '@multiformats/mafmt': 11.0.3 + '@multiformats/multiaddr': 10.5.0 + '@multiformats/multiaddr-to-uri': 9.0.1 + abortable-iterator: 4.0.2 + err-code: 3.0.1 + it-ws: 5.0.2 + p-defer: 4.0.0 + p-timeout: 6.0.0 + wherearewe: 2.0.1 + transitivePeerDependencies: + - bufferutil + - supports-color + - undici + - utf-8-validate + dev: true + /@libp2p/websockets/3.0.3_undici@5.10.0: resolution: {integrity: sha512-fGbXpbyJaToA3Opc/lyw3C2xGlhDiabwQeQE6bTNTCpCFsBwOq8DwE4J++lkxnvJzKu0D4oC1c7oQrQ+4oq1Fw==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2856,6 +3271,15 @@ packages: - supports-color - undici + /@multiformats/mafmt/11.0.3: + resolution: {integrity: sha512-DvCQeZJgaC4kE3BLqMuW3gQkNAW14Z7I+yMt30Ze+wkfHkWSp+bICcHGihhtgfzYCumHA/vHlJ9n54mrCcmnvQ==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@multiformats/multiaddr': 11.0.7 + transitivePeerDependencies: + - supports-color + - undici + /@multiformats/mafmt/11.0.3_undici@5.10.0: resolution: {integrity: sha512-DvCQeZJgaC4kE3BLqMuW3gQkNAW14Z7I+yMt30Ze+wkfHkWSp+bICcHGihhtgfzYCumHA/vHlJ9n54mrCcmnvQ==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2865,6 +3289,15 @@ packages: - supports-color - undici + /@multiformats/multiaddr-to-uri/9.0.1: + resolution: {integrity: sha512-kSyHZ2lKjoEzHu/TM4ZVwFj4AWV1B9qFBFJjYb/fK1NqrnrNb/M3uhoyckJvP7WZvpDsnEc7fUCpmPipDY6LMw==} + dependencies: + '@multiformats/multiaddr': 10.5.0 + transitivePeerDependencies: + - supports-color + - undici + dev: true + /@multiformats/multiaddr-to-uri/9.0.1_undici@5.10.0: resolution: {integrity: sha512-kSyHZ2lKjoEzHu/TM4ZVwFj4AWV1B9qFBFJjYb/fK1NqrnrNb/M3uhoyckJvP7WZvpDsnEc7fUCpmPipDY6LMw==} dependencies: @@ -2873,6 +3306,20 @@ packages: - supports-color - undici + /@multiformats/multiaddr/10.5.0: + resolution: {integrity: sha512-u4qHMyv25iAqCb9twJROoN1M8UDm8bureOCIzwz03fVhwJzV6DpgH1eFz9UAzDn7CpSShQ9SLS5MiC4hJjTfig==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + dns-over-http-resolver: 2.1.0 + err-code: 3.0.1 + is-ip: 5.0.0 + multiformats: 9.9.0 + uint8arrays: 3.1.0 + varint: 6.0.0 + transitivePeerDependencies: + - supports-color + - undici + /@multiformats/multiaddr/10.5.0_undici@5.10.0: resolution: {integrity: sha512-u4qHMyv25iAqCb9twJROoN1M8UDm8bureOCIzwz03fVhwJzV6DpgH1eFz9UAzDn7CpSShQ9SLS5MiC4hJjTfig==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -2887,6 +3334,20 @@ packages: - supports-color - undici + /@multiformats/multiaddr/11.0.7: + resolution: {integrity: sha512-rCqYS3Qz/dm4H/1Lvda11OBZf1tH8rst69GWK9jDy8AY+3n+NBBdErA/SRtdcRx6hPtQ8lAB5UhHlzIVbViv1Q==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@chainsafe/is-ip': 2.0.1 + dns-over-http-resolver: 2.1.0 + err-code: 3.0.1 + multiformats: 10.0.2 + uint8arrays: 4.0.2 + varint: 6.0.0 + transitivePeerDependencies: + - supports-color + - undici + /@multiformats/multiaddr/11.0.7_undici@5.10.0: resolution: {integrity: sha512-rCqYS3Qz/dm4H/1Lvda11OBZf1tH8rst69GWK9jDy8AY+3n+NBBdErA/SRtdcRx6hPtQ8lAB5UhHlzIVbViv1Q==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -3649,7 +4110,7 @@ packages: '@types/yargs-parser': 21.0.0 dev: true - /@typescript-eslint/eslint-plugin/4.33.0_xsxgdzylkyblyeozel5v5k6qf4: + /@typescript-eslint/eslint-plugin/4.33.0_qkm6m2dvh7633pj2jigehwm774: resolution: {integrity: sha512-aINiAxGVdOl1eJyVjaWn/YcVAq4Gi/Yo35qHGCnqbWVz61g39D0h23veY/MA0rFFGfxK7TySg2uwDeNv+JgVpg==} engines: {node: ^10.12.0 || >=12.0.0} peerDependencies: @@ -3660,11 +4121,11 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/experimental-utils': 4.33.0_ka3v2sz4nenxxmg4373y7syisy + '@typescript-eslint/experimental-utils': 4.33.0_dyxdave6dwjbccc5dgiifcmuza '@typescript-eslint/parser': 4.33.0_ka3v2sz4nenxxmg4373y7syisy '@typescript-eslint/scope-manager': 4.33.0 debug: 4.3.4 - eslint: 6.8.0 + eslint: 7.32.0 functional-red-black-tree: 1.0.1 ignore: 5.2.0 regexpp: 3.2.0 @@ -3700,7 +4161,7 @@ packages: - supports-color dev: true - /@typescript-eslint/experimental-utils/4.33.0_ka3v2sz4nenxxmg4373y7syisy: + /@typescript-eslint/experimental-utils/4.33.0_dyxdave6dwjbccc5dgiifcmuza: resolution: {integrity: sha512-zeQjOoES5JFjTnAhI5QY7ZviczMzDptls15GFsI6jyUOq0kOf9+WonkhtlIhh0RgHRnqj5gdNxW5j1EvAyYg6Q==} engines: {node: ^10.12.0 || >=12.0.0} peerDependencies: @@ -3710,9 +4171,9 @@ packages: '@typescript-eslint/scope-manager': 4.33.0 '@typescript-eslint/types': 4.33.0 '@typescript-eslint/typescript-estree': 4.33.0_typescript@4.8.3 - eslint: 6.8.0 + eslint: 7.32.0 eslint-scope: 5.1.1 - eslint-utils: 3.0.0_eslint@6.8.0 + eslint-utils: 3.0.0_eslint@7.32.0 transitivePeerDependencies: - supports-color - typescript @@ -4212,6 +4673,36 @@ packages: dependencies: uint8arrays: 4.0.2 + /@waku/core/0.0.3: + resolution: {integrity: sha512-w17LLkD0TJAI2tqFrpfUKDCAPIXCf1yagas6goqA/NiLc6lPIk03dziFbSVFhtnq92+5IVrKqHKm/RNBbTmn4Q==} + engines: {node: '>=16'} + dependencies: + '@chainsafe/libp2p-gossipsub': 4.1.1 + '@libp2p/interface-connection': 3.0.1 + '@libp2p/interface-peer-discovery': 1.0.1 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-peer-info': 1.0.3 + '@libp2p/interface-peer-store': 1.2.2 + '@libp2p/interface-pubsub': 2.1.0 + '@libp2p/interfaces': 3.0.3 + '@libp2p/peer-id': 1.1.15 + '@multiformats/multiaddr': 11.0.7 + '@waku/byte-utils': 0.0.2 + '@waku/interfaces': 0.0.2 + debug: 4.3.4 + it-all: 1.0.6 + it-length-prefixed: 8.0.2 + it-pipe: 2.0.4 + libp2p: 0.38.0 + p-event: 5.0.1 + protons-runtime: 3.1.0 + uint8arraylist: 2.3.2 + uint8arrays: 4.0.2 + uuid: 8.3.2 + transitivePeerDependencies: + - supports-color + - undici + /@waku/core/0.0.3_undici@5.10.0: resolution: {integrity: sha512-w17LLkD0TJAI2tqFrpfUKDCAPIXCf1yagas6goqA/NiLc6lPIk03dziFbSVFhtnq92+5IVrKqHKm/RNBbTmn4Q==} engines: {node: '>=16'} @@ -4234,13 +4725,31 @@ packages: it-pipe: 2.0.4 libp2p: 0.38.0_undici@5.10.0 p-event: 5.0.1 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 uint8arraylist: 2.3.2 uint8arrays: 4.0.2 uuid: 8.3.2 transitivePeerDependencies: - supports-color - undici + dev: false + + /@waku/create/0.0.3: + resolution: {integrity: sha512-T/kMMLi8nJCWS6NMFpePBI0LwUZ0fHPO1ydTsa7wx3lNMsB0HL/w1lacL1J82TAA//29nB1QtaJbpDO+NIp71A==} + engines: {node: '>=16'} + dependencies: + '@chainsafe/libp2p-noise': 8.0.1 + '@libp2p/interface-peer-discovery': 1.0.1 + '@libp2p/mplex': 5.2.3 + '@libp2p/websockets': 3.0.3 + '@waku/core': 0.0.3 + '@waku/interfaces': 0.0.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - undici + - utf-8-validate + dev: true /@waku/create/0.0.3_undici@5.10.0: resolution: {integrity: sha512-T/kMMLi8nJCWS6NMFpePBI0LwUZ0fHPO1ydTsa7wx3lNMsB0HL/w1lacL1J82TAA//29nB1QtaJbpDO+NIp71A==} @@ -4257,6 +4766,21 @@ packages: - supports-color - undici - utf-8-validate + dev: false + + /@waku/interfaces/0.0.2: + resolution: {integrity: sha512-mL0tJf2aqDfObC/moPUQ4YieEDPFRhZNmU4mraTHMqMn0+nGXFkeoOZNZfZAj1irYKqXxH/BQ0LkrMQmIOqplg==} + engines: {node: '>=16'} + dependencies: + '@chainsafe/libp2p-gossipsub': 4.1.1 + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-peer-store': 1.2.2 + '@multiformats/multiaddr': 11.0.7 + libp2p: 0.38.0 + transitivePeerDependencies: + - supports-color + - undici /@waku/interfaces/0.0.2_undici@5.10.0: resolution: {integrity: sha512-mL0tJf2aqDfObC/moPUQ4YieEDPFRhZNmU4mraTHMqMn0+nGXFkeoOZNZfZAj1irYKqXxH/BQ0LkrMQmIOqplg==} @@ -4271,6 +4795,7 @@ packages: transitivePeerDependencies: - supports-color - undici + dev: false /@walletconnect/browser-utils/1.8.0: resolution: {integrity: sha512-Wcqqx+wjxIo9fv6eBUFHPsW1y/bGWWRboni5dfD8PtOmrihrEpOCmvRJe4rfl7xgJW8Ea9UqKEaq0bIRLHlK4A==} @@ -5984,6 +6509,17 @@ packages: - supports-color dev: true + /dns-over-http-resolver/2.1.0: + resolution: {integrity: sha512-eb8RGy6k54JdD7Rjw8g65y1MyA4z3m3IIYh7uazkgZuKIdFn8gYt8dydMm3op+2UshDdk9EexrXcDluKNY/CDg==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + debug: 4.3.4 + native-fetch: 4.0.2 + receptacle: 1.3.2 + transitivePeerDependencies: + - supports-color + - undici + /dns-over-http-resolver/2.1.0_undici@5.10.0: resolution: {integrity: sha512-eb8RGy6k54JdD7Rjw8g65y1MyA4z3m3IIYh7uazkgZuKIdFn8gYt8dydMm3op+2UshDdk9EexrXcDluKNY/CDg==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -6302,7 +6838,7 @@ packages: eslint-plugin-react: ^7.21.5 dependencies: eslint: 7.32.0 - eslint-plugin-react: 7.31.8_eslint@6.8.0 + eslint-plugin-react: 7.31.8_eslint@7.32.0 /eslint-config-standard-with-typescript/21.0.1_yorietsc576znrnlzfzt5he4ia: resolution: {integrity: sha512-FeiMHljEJ346Y0I/HpAymNKdrgKEpHpcg/D93FvPHWfCzbT4QyUJba/0FwntZeGLXfUiWDSeKmdJD597d9wwiw==} @@ -6314,13 +6850,13 @@ packages: eslint-plugin-promise: ^4.2.1 || ^5.0.0 typescript: ^3.9 || ^4.0.0 dependencies: - '@typescript-eslint/eslint-plugin': 4.33.0_xsxgdzylkyblyeozel5v5k6qf4 + '@typescript-eslint/eslint-plugin': 4.33.0_qkm6m2dvh7633pj2jigehwm774 '@typescript-eslint/parser': 4.33.0_dyxdave6dwjbccc5dgiifcmuza eslint: 7.32.0 eslint-config-standard: 16.0.3_wnerebu6rbpsve3qx7qqwvcqtq - eslint-plugin-import: 2.26.0_inh3l5yejh4yosh34bfcghfssa - eslint-plugin-node: 11.1.0_eslint@6.8.0 - eslint-plugin-promise: 5.2.0_eslint@6.8.0 + eslint-plugin-import: 2.26.0_ffi3uiz42rv3jyhs6cr7p7qqry + eslint-plugin-node: 11.1.0_eslint@7.32.0 + eslint-plugin-promise: 5.2.0_eslint@7.32.0 typescript: 4.8.3 transitivePeerDependencies: - supports-color @@ -6334,9 +6870,9 @@ packages: eslint-plugin-promise: ^4.2.1 || ^5.0.0 dependencies: eslint: 7.32.0 - eslint-plugin-import: 2.26.0_inh3l5yejh4yosh34bfcghfssa - eslint-plugin-node: 11.1.0_eslint@6.8.0 - eslint-plugin-promise: 5.2.0_eslint@6.8.0 + eslint-plugin-import: 2.26.0_ffi3uiz42rv3jyhs6cr7p7qqry + eslint-plugin-node: 11.1.0_eslint@7.32.0 + eslint-plugin-promise: 5.2.0_eslint@7.32.0 /eslint-import-resolver-node/0.3.6: resolution: {integrity: sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==} @@ -6346,7 +6882,7 @@ packages: transitivePeerDependencies: - supports-color - /eslint-module-utils/2.7.4_dhxfb2hdoetm7nfvnwcu3amxdq: + /eslint-module-utils/2.7.4_d3sglxdl6hhgcbhsy3jaoc7rpu: resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==} engines: {node: '>=4'} peerDependencies: @@ -6369,22 +6905,22 @@ packages: dependencies: '@typescript-eslint/parser': 4.33.0_ka3v2sz4nenxxmg4373y7syisy debug: 3.2.7 - eslint: 6.8.0 + eslint: 7.32.0 eslint-import-resolver-node: 0.3.6 transitivePeerDependencies: - supports-color - /eslint-plugin-es/3.0.1_eslint@6.8.0: + /eslint-plugin-es/3.0.1_eslint@7.32.0: resolution: {integrity: sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=4.19.1' dependencies: - eslint: 6.8.0 + eslint: 7.32.0 eslint-utils: 2.1.0 regexpp: 3.2.0 - /eslint-plugin-import/2.26.0_inh3l5yejh4yosh34bfcghfssa: + /eslint-plugin-import/2.26.0_ffi3uiz42rv3jyhs6cr7p7qqry: resolution: {integrity: sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==} engines: {node: '>=4'} peerDependencies: @@ -6399,9 +6935,9 @@ packages: array.prototype.flat: 1.3.0 debug: 2.6.9 doctrine: 2.1.0 - eslint: 6.8.0 + eslint: 7.32.0 eslint-import-resolver-node: 0.3.6 - eslint-module-utils: 2.7.4_dhxfb2hdoetm7nfvnwcu3amxdq + eslint-module-utils: 2.7.4_d3sglxdl6hhgcbhsy3jaoc7rpu has: 1.0.3 is-core-module: 2.10.0 is-glob: 4.0.3 @@ -6436,14 +6972,14 @@ packages: - typescript dev: true - /eslint-plugin-node/11.1.0_eslint@6.8.0: + /eslint-plugin-node/11.1.0_eslint@7.32.0: resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=5.16.0' dependencies: - eslint: 6.8.0 - eslint-plugin-es: 3.0.1_eslint@6.8.0 + eslint: 7.32.0 + eslint-plugin-es: 3.0.1_eslint@7.32.0 eslint-utils: 2.1.0 ignore: 5.2.0 minimatch: 3.1.2 @@ -6467,15 +7003,15 @@ packages: prettier-linter-helpers: 1.0.0 dev: true - /eslint-plugin-promise/5.2.0_eslint@6.8.0: + /eslint-plugin-promise/5.2.0_eslint@7.32.0: resolution: {integrity: sha512-SftLb1pUG01QYq2A/hGAWfDRXqYD82zE7j7TopDOyNdU+7SvvoXREls/+PRTY17vUXzXnZA/zfnyKgRH6x4JJw==} engines: {node: ^10.12.0 || >=12.0.0} peerDependencies: eslint: ^7.0.0 dependencies: - eslint: 6.8.0 + eslint: 7.32.0 - /eslint-plugin-react/7.31.8_eslint@6.8.0: + /eslint-plugin-react/7.31.8_eslint@7.32.0: resolution: {integrity: sha512-5lBTZmgQmARLLSYiwI71tiGVTLUuqXantZM6vlSY39OaDSV0M7+32K5DnLkmFrwTe+Ksz0ffuLUC91RUviVZfw==} engines: {node: '>=4'} peerDependencies: @@ -6484,7 +7020,7 @@ packages: array-includes: 3.1.5 array.prototype.flatmap: 1.3.0 doctrine: 2.1.0 - eslint: 6.8.0 + eslint: 7.32.0 estraverse: 5.3.0 jsx-ast-utils: 3.3.3 minimatch: 3.1.2 @@ -6524,13 +7060,13 @@ packages: dependencies: eslint-visitor-keys: 1.3.0 - /eslint-utils/3.0.0_eslint@6.8.0: + /eslint-utils/3.0.0_eslint@7.32.0: resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} peerDependencies: eslint: '>=5' dependencies: - eslint: 6.8.0 + eslint: 7.32.0 eslint-visitor-keys: 2.1.0 /eslint-utils/3.0.0_eslint@8.23.1: @@ -7892,7 +8428,7 @@ packages: - supports-color dev: true - /ipfs-cli/0.14.2_odzcsdhh4pct4zkltozn235usi: + /ipfs-cli/0.14.2_pfoqomcgvehmtzydofkquizxzq: resolution: {integrity: sha512-SDVArmV5mWna2IorPH+O/2MAvQvlOzasRHxx2N5ylahykh8RzIGgP9v4hFtsSLTH+LYkp4JYJCpY3N+rkERu9w==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: @@ -7907,10 +8443,10 @@ packages: byteman: 1.3.5 execa: 6.1.0 get-folder-size: 4.0.0 - ipfs-core: 0.16.1_odzcsdhh4pct4zkltozn235usi + ipfs-core: 0.16.1_pfoqomcgvehmtzydofkquizxzq ipfs-core-types: 0.12.1_undici@5.10.0 ipfs-core-utils: 0.16.1_undici@5.10.0 - ipfs-daemon: 0.14.2_odzcsdhh4pct4zkltozn235usi + ipfs-daemon: 0.14.2_pfoqomcgvehmtzydofkquizxzq ipfs-http-client: 58.0.1_undici@5.10.0 ipfs-utils: 9.0.7 it-concat: 2.0.0 @@ -7932,7 +8468,6 @@ packages: - encoding - node-fetch - supports-color - - uint8arraylist - undici - utf-8-validate dev: true @@ -8175,7 +8710,7 @@ packages: - undici dev: true - /ipfs-core/0.16.0_x7fnwsarevril5ljymxhqdftba: + /ipfs-core/0.16.0_6x5idpizl3qkvuzyh46d263eo4: resolution: {integrity: sha512-k34ahuMoRTa7H1ynkQjCAOtCfr7XvyKn749MOg7/uEoMQL9nP2g220BiYlP4eGp51Iiq8gJYhw/MJLB3stl8cQ==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: @@ -8185,7 +8720,7 @@ packages: '@ipld/dag-json': 8.0.11 '@ipld/dag-pb': 2.1.18 '@libp2p/bootstrap': 2.0.0_undici@5.10.0 - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/delegated-content-routing': 2.0.1_undici@5.10.0 '@libp2p/delegated-peer-routing': 2.0.2_undici@5.10.0 '@libp2p/interface-dht': 1.0.1_undici@5.10.0 @@ -8226,7 +8761,7 @@ packages: ipfs-unixfs-exporter: 8.0.5 ipfs-unixfs-importer: 10.0.2 ipfs-utils: 9.0.7 - ipns: 2.0.3_lzmvheoxkch7tkanz3gw7v3pwy + ipns: 2.0.3_undici@5.10.0 is-domain-name: 1.0.1 is-ipfs: 6.0.2_node-fetch@2.6.7 it-drain: 1.0.5 @@ -8255,12 +8790,11 @@ packages: - encoding - node-fetch - supports-color - - uint8arraylist - undici - utf-8-validate dev: false - /ipfs-core/0.16.1_odzcsdhh4pct4zkltozn235usi: + /ipfs-core/0.16.1_pfoqomcgvehmtzydofkquizxzq: resolution: {integrity: sha512-z8L+1BhptxGs2cKA80BOm7kpcvc1Ql9goWHAEBLTx8kyIRgbg3/SRpFNquSBvX0kaUfcLiyRzaapU4j8EE80Ww==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: @@ -8270,7 +8804,7 @@ packages: '@ipld/dag-json': 8.0.11 '@ipld/dag-pb': 2.1.18 '@libp2p/bootstrap': 2.0.0_undici@5.10.0 - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/delegated-content-routing': 2.0.1_undici@5.10.0 '@libp2p/delegated-peer-routing': 2.0.2_undici@5.10.0 '@libp2p/interface-dht': 1.0.1_undici@5.10.0 @@ -8311,7 +8845,7 @@ packages: ipfs-unixfs-exporter: 8.0.6 ipfs-unixfs-importer: 10.0.2 ipfs-utils: 9.0.7 - ipns: 2.0.3_lzmvheoxkch7tkanz3gw7v3pwy + ipns: 2.0.3_undici@5.10.0 is-domain-name: 1.0.1 is-ipfs: 7.0.2_undici@5.10.0 it-drain: 1.0.5 @@ -8340,19 +8874,18 @@ packages: - encoding - node-fetch - supports-color - - uint8arraylist - undici - utf-8-validate dev: true - /ipfs-daemon/0.14.2_odzcsdhh4pct4zkltozn235usi: + /ipfs-daemon/0.14.2_pfoqomcgvehmtzydofkquizxzq: resolution: {integrity: sha512-shHPjTnCAFyOto4k0q8vdt093W89EHw5WaUcfPrqVh5iJ1sfNP6+AOlCxmE2CbTeMk1WBrTT3vprolAv+PG+2Q==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: '@libp2p/logger': 2.0.1 '@libp2p/webrtc-star': 3.0.1_undici@5.10.0 '@mapbox/node-pre-gyp': 1.0.10 - ipfs-core: 0.16.1_odzcsdhh4pct4zkltozn235usi + ipfs-core: 0.16.1_pfoqomcgvehmtzydofkquizxzq ipfs-core-types: 0.12.1_undici@5.10.0 ipfs-grpc-server: 0.10.1_undici@5.10.0 ipfs-http-gateway: 0.11.1_undici@5.10.0 @@ -8368,7 +8901,6 @@ packages: - encoding - node-fetch - supports-color - - uint8arraylist - undici - utf-8-validate dev: true @@ -8798,14 +9330,14 @@ packages: react-native-fetch-api: 2.0.0 stream-to-it: 0.2.4 - /ipfs/0.64.2_odzcsdhh4pct4zkltozn235usi: + /ipfs/0.64.2_pfoqomcgvehmtzydofkquizxzq: resolution: {integrity: sha512-k6iUBn4aEbrBM8+OcoadQ1YR40on/eyeLyyIhyWxf7rXlXqNFxzLDyI1vUJp4CXbvM9Vq22FLyxGioHgZ2aY2A==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} hasBin: true dependencies: '@libp2p/logger': 2.0.1 - ipfs-cli: 0.14.2_odzcsdhh4pct4zkltozn235usi - ipfs-core: 0.16.1_odzcsdhh4pct4zkltozn235usi + ipfs-cli: 0.14.2_pfoqomcgvehmtzydofkquizxzq + ipfs-core: 0.16.1_pfoqomcgvehmtzydofkquizxzq semver: 7.3.7 update-notifier: 6.0.2 transitivePeerDependencies: @@ -8813,7 +9345,6 @@ packages: - encoding - node-fetch - supports-color - - uint8arraylist - undici - utf-8-validate dev: true @@ -8835,11 +9366,11 @@ packages: transitivePeerDependencies: - supports-color - /ipns/2.0.3_lzmvheoxkch7tkanz3gw7v3pwy: + /ipns/2.0.3_undici@5.10.0: resolution: {integrity: sha512-B8cNrVo5JhEEoNsBxviIRu9KHu04jIbQxmq+yQtxPeGXBrgW5aEmy5hylPUOHkboU1eTfggu8Ule0FVfcSxrkw==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-dht': 1.0.1_undici@5.10.0 '@libp2p/interface-keys': 1.0.3 '@libp2p/interface-peer-id': 1.0.6 @@ -8849,12 +9380,11 @@ packages: err-code: 3.0.1 interface-datastore: 7.0.0 multiformats: 9.9.0 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 timestamp-nano: 1.0.0 uint8arrays: 3.1.0 transitivePeerDependencies: - supports-color - - uint8arraylist - undici /is-arguments/1.1.1: @@ -10193,6 +10723,82 @@ packages: protobufjs: 6.11.3 uint8arrays: 3.1.0 + /libp2p/0.38.0: + resolution: {integrity: sha512-Wi/ptR69M5LuOrH8hwno98Dg/YeaDXmsyN2cd3vx/yuaEdcgz1RPdGtxxpyVP6J63eZbH07MYTvQcQHH5VhTkA==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dependencies: + '@achingbrain/nat-port-mapper': 1.0.7 + '@libp2p/components': 2.1.0 + '@libp2p/connection': 4.0.2 + '@libp2p/crypto': 1.0.4 + '@libp2p/interface-address-manager': 1.0.3 + '@libp2p/interface-connection': 3.0.2 + '@libp2p/interface-connection-encrypter': 2.0.1 + '@libp2p/interface-content-routing': 1.0.2 + '@libp2p/interface-dht': 1.0.1 + '@libp2p/interface-metrics': 3.0.0 + '@libp2p/interface-peer-discovery': 1.0.1 + '@libp2p/interface-peer-id': 1.0.6 + '@libp2p/interface-peer-info': 1.0.3 + '@libp2p/interface-peer-routing': 1.0.1 + '@libp2p/interface-peer-store': 1.2.2 + '@libp2p/interface-pubsub': 2.1.0 + '@libp2p/interface-registrar': 2.0.3 + '@libp2p/interface-stream-muxer': 2.0.2 + '@libp2p/interface-transport': 1.0.4 + '@libp2p/interfaces': 3.0.3 + '@libp2p/logger': 2.0.1 + '@libp2p/multistream-select': 3.0.0 + '@libp2p/peer-collections': 2.0.0 + '@libp2p/peer-id': 1.1.15 + '@libp2p/peer-id-factory': 1.0.18 + '@libp2p/peer-record': 4.0.3 + '@libp2p/peer-store': 3.1.5 + '@libp2p/tracked-map': 2.0.2 + '@libp2p/utils': 3.0.2 + '@multiformats/mafmt': 11.0.3 + '@multiformats/multiaddr': 10.5.0 + abortable-iterator: 4.0.2 + any-signal: 3.0.1 + datastore-core: 8.0.1 + err-code: 3.0.1 + events: 3.3.0 + hashlru: 2.3.0 + interface-datastore: 7.0.0 + it-all: 1.0.6 + it-drain: 1.0.5 + it-filter: 1.0.3 + it-first: 1.0.7 + it-foreach: 0.1.1 + it-handshake: 4.1.2 + it-length-prefixed: 8.0.2 + it-map: 1.0.6 + it-merge: 1.0.4 + it-pair: 2.0.3 + it-pipe: 2.0.4 + it-sort: 1.0.1 + it-stream-types: 1.0.4 + merge-options: 3.0.4 + multiformats: 9.9.0 + mutable-proxy: 1.0.0 + node-forge: 1.3.1 + p-fifo: 1.0.0 + p-retry: 5.1.1 + p-settle: 5.1.0 + private-ip: 2.3.4 + protons-runtime: 3.1.0 + retimer: 3.0.0 + sanitize-filename: 1.6.3 + set-delayed-interval: 1.0.0 + timeout-abort-controller: 3.0.0 + uint8arraylist: 2.3.2 + uint8arrays: 3.1.0 + wherearewe: 2.0.1 + xsalsa20: 1.2.0 + transitivePeerDependencies: + - supports-color + - undici + /libp2p/0.38.0_undici@5.10.0: resolution: {integrity: sha512-Wi/ptR69M5LuOrH8hwno98Dg/YeaDXmsyN2cd3vx/yuaEdcgz1RPdGtxxpyVP6J63eZbH07MYTvQcQHH5VhTkA==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} @@ -10200,7 +10806,7 @@ packages: '@achingbrain/nat-port-mapper': 1.0.7 '@libp2p/components': 2.1.0_undici@5.10.0 '@libp2p/connection': 4.0.2_undici@5.10.0 - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-address-manager': 1.0.3_undici@5.10.0 '@libp2p/interface-connection': 3.0.2_undici@5.10.0 '@libp2p/interface-connection-encrypter': 2.0.1 @@ -10256,7 +10862,7 @@ packages: p-retry: 5.1.1 p-settle: 5.1.0 private-ip: 2.3.4 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 retimer: 3.0.0 sanitize-filename: 1.6.3 set-delayed-interval: 1.0.0 @@ -10268,6 +10874,7 @@ packages: transitivePeerDependencies: - supports-color - undici + dev: false /libp2p/0.39.1_undici@5.10.0: resolution: {integrity: sha512-3moZyOqn2297iJB4Ettz7G+PGscEdcaZCzXb6V5MjPwDy8Uv9YRH/D8lgx6FHqs5dKF3wM1SjQj91OYDNoNx2g==} @@ -10276,7 +10883,7 @@ packages: '@achingbrain/nat-port-mapper': 1.0.7 '@libp2p/components': 2.1.0_undici@5.10.0 '@libp2p/connection': 4.0.1_undici@5.10.0 - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-address-manager': 1.0.2_undici@5.10.0 '@libp2p/interface-connection': 3.0.1_undici@5.10.0 '@libp2p/interface-connection-encrypter': 2.0.1 @@ -10333,7 +10940,7 @@ packages: p-retry: 5.1.1 p-settle: 5.1.0 private-ip: 2.3.4 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 retimer: 3.0.0 sanitize-filename: 1.6.3 set-delayed-interval: 1.0.0 @@ -10354,7 +10961,7 @@ packages: '@achingbrain/nat-port-mapper': 1.0.7 '@libp2p/components': 2.1.0_undici@5.10.0 '@libp2p/connection': 4.0.2_undici@5.10.0 - '@libp2p/crypto': 1.0.4_uint8arraylist@2.3.2 + '@libp2p/crypto': 1.0.4 '@libp2p/interface-address-manager': 1.0.3_undici@5.10.0 '@libp2p/interface-connection': 3.0.2_undici@5.10.0 '@libp2p/interface-connection-encrypter': 2.0.1 @@ -10411,7 +11018,7 @@ packages: p-retry: 5.1.1 p-settle: 5.1.0 private-ip: 2.3.4 - protons-runtime: 3.1.0_uint8arraylist@2.3.2 + protons-runtime: 3.1.0 retimer: 3.0.0 sanitize-filename: 1.6.3 set-delayed-interval: 1.0.0 @@ -10935,6 +11542,11 @@ packages: node-fetch: 3.2.10 dev: true + /native-fetch/4.0.2: + resolution: {integrity: sha512-4QcVlKFtv2EYVS5MBgsGX5+NWKtbDbIECdUXDBGDMAZXq3Jkv9zf+y8iS7Ub8fEdga3GpYeazp9gauNqXHJOCg==} + peerDependencies: + undici: '*' + /native-fetch/4.0.2_undici@5.10.0: resolution: {integrity: sha512-4QcVlKFtv2EYVS5MBgsGX5+NWKtbDbIECdUXDBGDMAZXq3Jkv9zf+y8iS7Ub8fEdga3GpYeazp9gauNqXHJOCg==} peerDependencies: @@ -11726,11 +12338,9 @@ packages: '@types/node': 18.7.18 long: 5.2.0 - /protons-runtime/3.1.0_uint8arraylist@2.3.2: + /protons-runtime/3.1.0: resolution: {integrity: sha512-S1iSPQC0McdHKJRi0XcATBkWgwWPx46UDfrnshYDXBvGHSYqkFtn4MQ8Gatf67w7FzFtHivA+Hb0ZPq56upG8w==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} - peerDependencies: - uint8arraylist: ^2.3.2 dependencies: protobufjs: 7.1.1 uint8arraylist: 2.3.2 @@ -12910,15 +13520,15 @@ packages: peerDependencies: typescript: '>=3.8' dependencies: - '@typescript-eslint/eslint-plugin': 4.33.0_xsxgdzylkyblyeozel5v5k6qf4 + '@typescript-eslint/eslint-plugin': 4.33.0_qkm6m2dvh7633pj2jigehwm774 eslint: 7.32.0 eslint-config-standard: 16.0.3_wnerebu6rbpsve3qx7qqwvcqtq eslint-config-standard-jsx: 10.0.0_7agtesdk3vzm2mmitpawh5lvgq eslint-config-standard-with-typescript: 21.0.1_yorietsc576znrnlzfzt5he4ia - eslint-plugin-import: 2.26.0_inh3l5yejh4yosh34bfcghfssa - eslint-plugin-node: 11.1.0_eslint@6.8.0 - eslint-plugin-promise: 5.2.0_eslint@6.8.0 - eslint-plugin-react: 7.31.8_eslint@6.8.0 + eslint-plugin-import: 2.26.0_ffi3uiz42rv3jyhs6cr7p7qqry + eslint-plugin-node: 11.1.0_eslint@7.32.0 + eslint-plugin-promise: 5.2.0_eslint@7.32.0 + eslint-plugin-react: 7.31.8_eslint@7.32.0 get-stdin: 8.0.0 minimist: 1.2.6 pkg-conf: 3.1.0 From 632524e758559d073e7d4b85bbaa403d0f6de504 Mon Sep 17 00:00:00 2001 From: Madhukar Gaida <86058993+madhukar123456@users.noreply.github.com> Date: Wed, 28 Dec 2022 16:41:34 +0545 Subject: [PATCH 02/11] function: total dynamic price --- packages/prices/src/prices.ts | 9 +++++++++ packages/prices/test/prices.test.ts | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/packages/prices/src/prices.ts b/packages/prices/src/prices.ts index 784511c..c1d5504 100644 --- a/packages/prices/src/prices.ts +++ b/packages/prices/src/prices.ts @@ -1,5 +1,9 @@ import { PriceSpecification } from "@js-ligo/vocab"; +export interface DynamicPrice { + [key: string]: number; +} + export class Prices { /** * Find Total Price Static @@ -12,6 +16,11 @@ export class Prices { return (await this._dateDiffInDays(a, b)) * givenPrice.price; } + async findTotalDynamicPrice(givenPrice: DynamicPrice) { + const sum = Object.values(givenPrice).reduce((acc, val) => acc + val, 0); + return sum; + } + private async _dateDiffInDays(a: Date, b: Date) { const _MS_PER_DAY = 1000 * 60 * 60 * 24; // Discard the time and time-zone information. diff --git a/packages/prices/test/prices.test.ts b/packages/prices/test/prices.test.ts index e165ccc..818d5c2 100644 --- a/packages/prices/test/prices.test.ts +++ b/packages/prices/test/prices.test.ts @@ -1,5 +1,6 @@ import { PriceSpecification } from "@js-ligo/vocab"; import { Prices } from "../src"; +import { DynamicPrice } from "../src"; describe("prices", () => { const givenPrice: PriceSpecification = { @@ -8,6 +9,11 @@ describe("prices", () => { validFrom: "2017-01-01", validThrough: "2017-03-01", }; + const givenDynamicPrice: DynamicPrice = { + "2017-01-01": 200, + "2017-01-02": 300, + "2017-01-03": 250, + }; describe("findTotalStaticPrice", () => { test("total static price", async () => { @@ -18,4 +24,16 @@ describe("prices", () => { expect(typeof totalPrice === "number").toBe(true); }, 30000); }); + + describe("findTotalDynamicPrice", () => { + test("total dynamic price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.findTotalDynamicPrice( + givenDynamicPrice + ); + console.log(totalPrice); + expect(totalPrice).toBeDefined(); + expect(typeof totalPrice === "number").toBe(true); + }, 30000); + }); }); From f6ca4018c5a650ad7932cd1d8872fa479e8476de Mon Sep 17 00:00:00 2001 From: Madhukar Gaida <86058993+madhukar123456@users.noreply.github.com> Date: Sun, 1 Jan 2023 23:43:22 +0545 Subject: [PATCH 03/11] Total price calculation based on UnitCodes --- packages/prices/package.json | 2 +- packages/prices/src/prices.ts | 159 ++++++++++++++++++++++++++++++---- 2 files changed, 145 insertions(+), 16 deletions(-) diff --git a/packages/prices/package.json b/packages/prices/package.json index 298cceb..0bf67b7 100644 --- a/packages/prices/package.json +++ b/packages/prices/package.json @@ -16,7 +16,7 @@ "build:js": "swc src -d ./dist --config-file ../../.swcrc", "build:types": "tsc --emitDeclarationOnly --skipLibCheck", "build": "pnpm build:clean && pnpm build:types && pnpm build:js", - "test:it": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", + "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "lint": "eslint src/* test/* --fix", "prepare": "pnpm build" }, diff --git a/packages/prices/src/prices.ts b/packages/prices/src/prices.ts index c1d5504..51d9e36 100644 --- a/packages/prices/src/prices.ts +++ b/packages/prices/src/prices.ts @@ -1,24 +1,136 @@ +/* eslint-disable eqeqeq */ import { PriceSpecification } from "@js-ligo/vocab"; - -export interface DynamicPrice { - [key: string]: number; -} +import { LigoAgreementState } from "@js-ligo/vocab"; +import { RentalCarReservation } from "@js-ligo/vocab"; +import { Offer } from "@js-ligo/vocab"; export class Prices { /** - * Find Total Price Static - */ - async findTotalStaticPrice(givenPrice: PriceSpecification) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const a = new Date(givenPrice.validThrough!); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const b = new Date(givenPrice.validFrom!); - return (await this._dateDiffInDays(a, b)) * givenPrice.price; + * Find Total Price + // Case 1: Base Price per day + // Case 2: Base price per kilometer + // Case 3: Base price per day + X$ per kilometer over Y range + // Case 4: Base price per hour + // Case 5: Different price per day + // Case 6: Monthly Subscription of X$ + // Case 7: Discount for Y+ days + */ + async CalculateTotalPrice( + _priceSpecifications: Offer["priceSpecifications"], + _rentalCarReservation: RentalCarReservation, + _ligoAgreementState: LigoAgreementState + ) { + let sum = 0; + for (let i = 0; i < _priceSpecifications.length; i++) { + if (_priceSpecifications[i].referenceQuantity?.unitCode === "DAY") { + sum = + sum + + (await this._totalPriceDays( + _priceSpecifications[i], + _rentalCarReservation + )); + } else if ( + _priceSpecifications[i].referenceQuantity?.unitCode === "KMT" + ) { + const result = this._totalPriceKM( + _priceSpecifications[i], + _ligoAgreementState + ); + if (typeof result == "number") { + sum = sum + result; + } + } else if ( + _priceSpecifications[i].referenceQuantity?.unitCode === "HUR" + ) { + const result = this._totalPriceHour( + _priceSpecifications[i], + _rentalCarReservation + ); + if (typeof result == "number") { + sum = sum + result; + } + } else if ( + _priceSpecifications[i].referenceQuantity?.unitCode === "MON" + ) { + const result = this._totalMonthlySub(_priceSpecifications[i]); + if (typeof result == "number") { + sum = sum + result; + } + } + } + } + + private async _totalPriceDays( + PriceSpecification: PriceSpecification, + RentalCarReservation: RentalCarReservation + ) { + const a = new Date(RentalCarReservation.dropoffTime); + const b = new Date(RentalCarReservation.pickupTime); + // For discount maxValue + if (PriceSpecification.eligibleQuantity?.maxValue != null) { + return ( + PriceSpecification.eligibleQuantity?.maxValue * PriceSpecification.price + ); + } + // For discount minValue + if (PriceSpecification.eligibleQuantity?.minValue != null) { + return ( + ((await this._dateDiffInDays(a, b)) - + PriceSpecification.eligibleQuantity?.minValue) * + PriceSpecification.price + ); + } + // Normal days + return (await this._dateDiffInDays(a, b)) * PriceSpecification.price; + } + + private async _totalPriceKM( + PriceSpecification: PriceSpecification, + _ligoAgreementState: LigoAgreementState + ) { + if ( + _ligoAgreementState.startOdometer?.value != null && + _ligoAgreementState.endOdometer?.value != null + ) { + if (PriceSpecification.eligibleQuantity?.minValue != null) { + if ( + Math.abs( + _ligoAgreementState.endOdometer.value - + _ligoAgreementState.startOdometer.value + ) > PriceSpecification.eligibleQuantity?.minValue + ) + return ( + Math.abs( + _ligoAgreementState.endOdometer.value - + _ligoAgreementState.startOdometer.value - + PriceSpecification.eligibleQuantity?.minValue + ) * PriceSpecification.price + ); + } + return ( + Math.abs( + _ligoAgreementState.endOdometer.value - + _ligoAgreementState.startOdometer.value + ) * PriceSpecification.price + ); + } + return; + } + + private async _totalPriceHour( + PriceSpecification: PriceSpecification, + RentalCarReservation: RentalCarReservation + ) { + const a = new Date(RentalCarReservation.dropoffTime); + const b = new Date(RentalCarReservation.pickupTime); + return (await this._hourDiffInDays(a, b)) * PriceSpecification.price; } - async findTotalDynamicPrice(givenPrice: DynamicPrice) { - const sum = Object.values(givenPrice).reduce((acc, val) => acc + val, 0); - return sum; + private async _totalMonthlySub(PriceSpecification: PriceSpecification) { + if (PriceSpecification.billingIncrement != null) { + return PriceSpecification.price * PriceSpecification.billingIncrement; + } + return; } private async _dateDiffInDays(a: Date, b: Date) { @@ -28,4 +140,21 @@ export class Prices { const utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate()); return Math.floor((utc2 - utc1) / _MS_PER_DAY); } + + private async _hourDiffInDays(a: Date, b: Date) { + const _MS_PER_HOUR = 1000 * 60 * 60; + const utc1 = Date.UTC( + a.getFullYear(), + a.getMonth(), + a.getDate(), + a.getHours() + ); + const utc2 = Date.UTC( + b.getFullYear(), + b.getMonth(), + b.getDate(), + b.getHours() + ); + return Math.floor((utc2 - utc1) / _MS_PER_HOUR); + } } From bd6c74778ac7da73dcd4c2cd67afe3d461391fed Mon Sep 17 00:00:00 2001 From: Madhukar Gaida <86058993+madhukar123456@users.noreply.github.com> Date: Mon, 2 Jan 2023 21:41:43 +0545 Subject: [PATCH 04/11] Different price per day calculation --- packages/prices/src/prices.ts | 64 ++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/packages/prices/src/prices.ts b/packages/prices/src/prices.ts index 51d9e36..bb36a19 100644 --- a/packages/prices/src/prices.ts +++ b/packages/prices/src/prices.ts @@ -58,77 +58,93 @@ export class Prices { } } } + return sum; } private async _totalPriceDays( - PriceSpecification: PriceSpecification, - RentalCarReservation: RentalCarReservation + _priceSpecification: PriceSpecification, + _rentalCarReservation: RentalCarReservation ) { - const a = new Date(RentalCarReservation.dropoffTime); - const b = new Date(RentalCarReservation.pickupTime); + //Filter ValidFrom and ValidThrough + const validF = new Date( + _priceSpecification.validFrom + ? _priceSpecification.validFrom + : _rentalCarReservation.pickupTime + ); + const validT = new Date( + _priceSpecification.validThrough + ? _priceSpecification.validThrough + : _rentalCarReservation.dropoffTime + ); + const dropoffT = new Date(_rentalCarReservation.dropoffTime); + const pickupT = new Date(_rentalCarReservation.pickupTime); + const a = validF >= pickupT ? validF : pickupT; + const b = validT <= dropoffT ? validT : dropoffT; + // For discount maxValue - if (PriceSpecification.eligibleQuantity?.maxValue != null) { + if (_priceSpecification.eligibleQuantity?.maxValue != null) { return ( - PriceSpecification.eligibleQuantity?.maxValue * PriceSpecification.price + _priceSpecification.eligibleQuantity?.maxValue * + _priceSpecification.price ); } // For discount minValue - if (PriceSpecification.eligibleQuantity?.minValue != null) { + if (_priceSpecification.eligibleQuantity?.minValue != null) { return ( ((await this._dateDiffInDays(a, b)) - - PriceSpecification.eligibleQuantity?.minValue) * - PriceSpecification.price + _priceSpecification.eligibleQuantity?.minValue) * + _priceSpecification.price ); } // Normal days - return (await this._dateDiffInDays(a, b)) * PriceSpecification.price; + return (await this._dateDiffInDays(a, b)) * _priceSpecification.price; } private async _totalPriceKM( - PriceSpecification: PriceSpecification, + _priceSpecification: PriceSpecification, _ligoAgreementState: LigoAgreementState ) { if ( _ligoAgreementState.startOdometer?.value != null && _ligoAgreementState.endOdometer?.value != null ) { - if (PriceSpecification.eligibleQuantity?.minValue != null) { + if (_priceSpecification.eligibleQuantity?.minValue != null) { if ( Math.abs( _ligoAgreementState.endOdometer.value - _ligoAgreementState.startOdometer.value - ) > PriceSpecification.eligibleQuantity?.minValue + ) > _priceSpecification.eligibleQuantity?.minValue ) return ( Math.abs( _ligoAgreementState.endOdometer.value - _ligoAgreementState.startOdometer.value - - PriceSpecification.eligibleQuantity?.minValue - ) * PriceSpecification.price + _priceSpecification.eligibleQuantity?.minValue + ) * _priceSpecification.price ); } return ( Math.abs( _ligoAgreementState.endOdometer.value - _ligoAgreementState.startOdometer.value - ) * PriceSpecification.price + ) * _priceSpecification.price ); } return; } private async _totalPriceHour( - PriceSpecification: PriceSpecification, - RentalCarReservation: RentalCarReservation + _priceSpecification: PriceSpecification, + _rentalCarReservation: RentalCarReservation ) { - const a = new Date(RentalCarReservation.dropoffTime); - const b = new Date(RentalCarReservation.pickupTime); - return (await this._hourDiffInDays(a, b)) * PriceSpecification.price; + const a = new Date(_rentalCarReservation.dropoffTime); + const b = new Date(_rentalCarReservation.pickupTime); + return (await this._hourDiffInDays(a, b)) * _priceSpecification.price; } - private async _totalMonthlySub(PriceSpecification: PriceSpecification) { - if (PriceSpecification.billingIncrement != null) { - return PriceSpecification.price * PriceSpecification.billingIncrement; + private async _totalMonthlySub(_priceSpecification: PriceSpecification) { + if (_priceSpecification.billingIncrement != null) { + return _priceSpecification.price * _priceSpecification.billingIncrement; } return; } From b12a45b1c0ae8188f1da6a8fb4b31f0c9525d1d8 Mon Sep 17 00:00:00 2001 From: Madhukar Gaida <86058993+madhukar123456@users.noreply.github.com> Date: Mon, 2 Jan 2023 22:45:25 +0545 Subject: [PATCH 05/11] Test cases on total price calculation --- packages/prices/package.json | 1 + packages/prices/test/prices.test.ts | 262 ++++++++++++++++++++++++++-- pnpm-lock.yaml | 2 + 3 files changed, 247 insertions(+), 18 deletions(-) diff --git a/packages/prices/package.json b/packages/prices/package.json index 0bf67b7..14f4eac 100644 --- a/packages/prices/package.json +++ b/packages/prices/package.json @@ -46,6 +46,7 @@ "@typescript-eslint/parser": "^4.9.1", "eslint": "^6.0.0", "jest-environment-node": "^29.0.3", + "multiformats": "^9.9.0", "node-fetch": "*", "typescript": "^4.7.4" } diff --git a/packages/prices/test/prices.test.ts b/packages/prices/test/prices.test.ts index 818d5c2..3d4449a 100644 --- a/packages/prices/test/prices.test.ts +++ b/packages/prices/test/prices.test.ts @@ -1,35 +1,261 @@ -import { PriceSpecification } from "@js-ligo/vocab"; import { Prices } from "../src"; -import { DynamicPrice } from "../src"; +import { + LigoAgreementState, + Offer, + RentalCarReservation, +} from "@js-ligo/vocab"; +import { CID } from "multiformats/cid"; +import * as json from "multiformats/codecs/json"; +import { sha256 } from "multiformats/hashes/sha2"; + +const bytes = json.encode({ hello: "world" }); +const hash = await sha256.digest(bytes); +const cid = CID.create(1, json.code, hash); describe("prices", () => { - const givenPrice: PriceSpecification = { - price: 30, - priceCurrency: "USD", - validFrom: "2017-01-01", - validThrough: "2017-03-01", + /** + * Find Total Price + * + **/ + // Case 1: Base Price per day + const case1: Offer["priceSpecifications"] = [ + { + price: 25, + priceCurrency: "USD", + referenceQuantity: { + value: 1, + unitCode: "DAY", + }, + }, + ]; + // Case 2: Base price per kilometer + const case2: Offer["priceSpecifications"] = [ + { + price: 0.25, + priceCurrency: "USD", + referenceQuantity: { + value: 1, + unitCode: "KMT", + }, + }, + ]; + // Case 3: Base price per day + X$ per kilometer over Y range + const case3: Offer["priceSpecifications"] = [ + { + price: 25, + priceCurrency: "USD", + referenceQuantity: { + value: 1, + unitCode: "DAY", + }, + }, + { + price: 0.25, + priceCurrency: "USD", + eligibleQuantity: { + minValue: 1000, + unitCode: "KMT", + }, + referenceQuantity: { + value: 1, + unitCode: "KMT", + }, + }, + ]; + // Case 4: Base price per hour + const case4: Offer["priceSpecifications"] = [ + { + price: 5, + priceCurrency: "USD", + referenceQuantity: { + value: 1, + unitCode: "HUR", + }, + }, + ]; + // Case 5: Different price per day + const case5: Offer["priceSpecifications"] = [ + { + price: 25, + priceCurrency: "USD", + validFrom: "2022-07-01T00:00:00Z", + validThrough: "2022-07-10T00:00:00Z", + referenceQuantity: { + value: 1, + unitCode: "DAY", + }, + }, + { + price: 30, + priceCurrency: "USD", + validFrom: "2022-07-10T00:00:00Z", + referenceQuantity: { + value: 1, + unitCode: "DAY", + }, + }, + ]; + // Case 6: Monthly Subscription of X$ + const case6: Offer["priceSpecifications"] = [ + { + price: 1000, + priceCurrency: "USD", + billingIncrement: 1, + referenceQuantity: { + unitCode: "MON", + }, + }, + ]; + // Case 7: Discount for Y+ days + const case7: Offer["priceSpecifications"] = [ + { + price: 25, + priceCurrency: "USD", + eligibleQuantity: { + maxValue: 3, + unitCode: "DAY", + }, + referenceQuantity: { + value: 1, + unitCode: "DAY", + }, + }, + { + price: 20, + priceCurrency: "USD", + eligibleQuantity: { + minValue: 3, + unitCode: "DAY", + }, + referenceQuantity: { + value: 1, + unitCode: "DAY", + }, + }, + ]; + + const rentalCarReservation: RentalCarReservation = { + pickupTime: "2022-07-02T00:00:00Z", + dropoffTime: "2022-07-15T00:00:00Z", + bookingTime: "", + modifiedTime: "", + provider: "", + underName: "", + reservationFor: cid, + totalPrice: { + price: 20, + priceCurrency: "USD", + }, + dropoffLocation: { + address: "CA", + }, + pickupLocation: { + address: "CA", + }, }; - const givenDynamicPrice: DynamicPrice = { - "2017-01-01": 200, - "2017-01-02": 300, - "2017-01-03": 250, + + const ligoAgreementState: LigoAgreementState = { + startOdometer: { + value: 1000, + }, + endOdometer: { + value: 2000, + }, }; - describe("findTotalStaticPrice", () => { - test("total static price", async () => { + //Test Cases + + describe("Case 1: Base Price per day", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.CalculateTotalPrice( + case1, + rentalCarReservation, + ligoAgreementState + ); + console.log(totalPrice); + expect(totalPrice).toBeDefined(); + expect(typeof totalPrice === "number").toBe(true); + }, 30000); + }); + + describe("Case 2: Base price per kilometer", () => { + test("Total Price", async () => { const priceFinder = new Prices(); - const totalPrice = await priceFinder.findTotalStaticPrice(givenPrice); + const totalPrice = await priceFinder.CalculateTotalPrice( + case2, + rentalCarReservation, + ligoAgreementState + ); + console.log(totalPrice); + expect(totalPrice).toBeDefined(); + expect(typeof totalPrice === "number").toBe(true); + }, 30000); + }); + + describe("Case 3: Base price per day + X$ per kilometer over Y range", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.CalculateTotalPrice( + case3, + rentalCarReservation, + ligoAgreementState + ); + console.log(totalPrice); + expect(totalPrice).toBeDefined(); + expect(typeof totalPrice === "number").toBe(true); + }, 30000); + }); + + describe("Case 4: Base price per hour", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.CalculateTotalPrice( + case4, + rentalCarReservation, + ligoAgreementState + ); + console.log(totalPrice); + expect(totalPrice).toBeDefined(); + expect(typeof totalPrice === "number").toBe(true); + }, 30000); + }); + + describe("Case 5: Different price per day", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.CalculateTotalPrice( + case5, + rentalCarReservation, + ligoAgreementState + ); + console.log(totalPrice); + expect(totalPrice).toBeDefined(); + expect(typeof totalPrice === "number").toBe(true); + }, 30000); + }); + + describe("Case 6: Monthly Subscription of X$", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.CalculateTotalPrice( + case6, + rentalCarReservation, + ligoAgreementState + ); console.log(totalPrice); expect(totalPrice).toBeDefined(); expect(typeof totalPrice === "number").toBe(true); }, 30000); }); - describe("findTotalDynamicPrice", () => { - test("total dynamic price", async () => { + describe("Case 7: Discount for Y+ days", () => { + test("Total Price", async () => { const priceFinder = new Prices(); - const totalPrice = await priceFinder.findTotalDynamicPrice( - givenDynamicPrice + const totalPrice = await priceFinder.CalculateTotalPrice( + case7, + rentalCarReservation, + ligoAgreementState ); console.log(totalPrice); expect(totalPrice).toBeDefined(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 09d7280..503085e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -251,6 +251,7 @@ importers: '@typescript-eslint/parser': ^4.9.1 eslint: ^6.0.0 jest-environment-node: ^29.0.3 + multiformats: ^9.9.0 node-fetch: '*' typescript: ^4.7.4 dependencies: @@ -259,6 +260,7 @@ importers: '@typescript-eslint/parser': 4.33.0_ka3v2sz4nenxxmg4373y7syisy eslint: 6.8.0 jest-environment-node: 29.0.3 + multiformats: 9.9.0 node-fetch: 3.2.10 typescript: 4.8.3 From 32ba0c22a6fbd215f66fd7b1f51052b033d1503b Mon Sep 17 00:00:00 2001 From: Madhukar Gaida <86058993+madhukar123456@users.noreply.github.com> Date: Tue, 3 Jan 2023 09:48:09 +0545 Subject: [PATCH 06/11] PriceSpecification type and capitalization update --- packages/prices/src/prices.ts | 13 +++++++------ packages/prices/test/prices.test.ts | 30 ++++++++++++++--------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/packages/prices/src/prices.ts b/packages/prices/src/prices.ts index bb36a19..749f9d7 100644 --- a/packages/prices/src/prices.ts +++ b/packages/prices/src/prices.ts @@ -1,8 +1,9 @@ /* eslint-disable eqeqeq */ -import { PriceSpecification } from "@js-ligo/vocab"; -import { LigoAgreementState } from "@js-ligo/vocab"; -import { RentalCarReservation } from "@js-ligo/vocab"; -import { Offer } from "@js-ligo/vocab"; +import { + LigoAgreementState, + PriceSpecification, + RentalCarReservation, +} from "@js-ligo/vocab"; export class Prices { /** @@ -15,8 +16,8 @@ export class Prices { // Case 6: Monthly Subscription of X$ // Case 7: Discount for Y+ days */ - async CalculateTotalPrice( - _priceSpecifications: Offer["priceSpecifications"], + async calculateTotalPrice( + _priceSpecifications: PriceSpecification[], _rentalCarReservation: RentalCarReservation, _ligoAgreementState: LigoAgreementState ) { diff --git a/packages/prices/test/prices.test.ts b/packages/prices/test/prices.test.ts index 3d4449a..a41c36d 100644 --- a/packages/prices/test/prices.test.ts +++ b/packages/prices/test/prices.test.ts @@ -1,7 +1,7 @@ import { Prices } from "../src"; import { LigoAgreementState, - Offer, + PriceSpecification, RentalCarReservation, } from "@js-ligo/vocab"; import { CID } from "multiformats/cid"; @@ -18,7 +18,7 @@ describe("prices", () => { * **/ // Case 1: Base Price per day - const case1: Offer["priceSpecifications"] = [ + const case1: PriceSpecification[] = [ { price: 25, priceCurrency: "USD", @@ -29,7 +29,7 @@ describe("prices", () => { }, ]; // Case 2: Base price per kilometer - const case2: Offer["priceSpecifications"] = [ + const case2: PriceSpecification[] = [ { price: 0.25, priceCurrency: "USD", @@ -40,7 +40,7 @@ describe("prices", () => { }, ]; // Case 3: Base price per day + X$ per kilometer over Y range - const case3: Offer["priceSpecifications"] = [ + const case3: PriceSpecification[] = [ { price: 25, priceCurrency: "USD", @@ -63,7 +63,7 @@ describe("prices", () => { }, ]; // Case 4: Base price per hour - const case4: Offer["priceSpecifications"] = [ + const case4: PriceSpecification[] = [ { price: 5, priceCurrency: "USD", @@ -74,7 +74,7 @@ describe("prices", () => { }, ]; // Case 5: Different price per day - const case5: Offer["priceSpecifications"] = [ + const case5: PriceSpecification[] = [ { price: 25, priceCurrency: "USD", @@ -96,7 +96,7 @@ describe("prices", () => { }, ]; // Case 6: Monthly Subscription of X$ - const case6: Offer["priceSpecifications"] = [ + const case6: PriceSpecification[] = [ { price: 1000, priceCurrency: "USD", @@ -107,7 +107,7 @@ describe("prices", () => { }, ]; // Case 7: Discount for Y+ days - const case7: Offer["priceSpecifications"] = [ + const case7: PriceSpecification[] = [ { price: 25, priceCurrency: "USD", @@ -168,7 +168,7 @@ describe("prices", () => { describe("Case 1: Base Price per day", () => { test("Total Price", async () => { const priceFinder = new Prices(); - const totalPrice = await priceFinder.CalculateTotalPrice( + const totalPrice = await priceFinder.calculateTotalPrice( case1, rentalCarReservation, ligoAgreementState @@ -182,7 +182,7 @@ describe("prices", () => { describe("Case 2: Base price per kilometer", () => { test("Total Price", async () => { const priceFinder = new Prices(); - const totalPrice = await priceFinder.CalculateTotalPrice( + const totalPrice = await priceFinder.calculateTotalPrice( case2, rentalCarReservation, ligoAgreementState @@ -196,7 +196,7 @@ describe("prices", () => { describe("Case 3: Base price per day + X$ per kilometer over Y range", () => { test("Total Price", async () => { const priceFinder = new Prices(); - const totalPrice = await priceFinder.CalculateTotalPrice( + const totalPrice = await priceFinder.calculateTotalPrice( case3, rentalCarReservation, ligoAgreementState @@ -210,7 +210,7 @@ describe("prices", () => { describe("Case 4: Base price per hour", () => { test("Total Price", async () => { const priceFinder = new Prices(); - const totalPrice = await priceFinder.CalculateTotalPrice( + const totalPrice = await priceFinder.calculateTotalPrice( case4, rentalCarReservation, ligoAgreementState @@ -224,7 +224,7 @@ describe("prices", () => { describe("Case 5: Different price per day", () => { test("Total Price", async () => { const priceFinder = new Prices(); - const totalPrice = await priceFinder.CalculateTotalPrice( + const totalPrice = await priceFinder.calculateTotalPrice( case5, rentalCarReservation, ligoAgreementState @@ -238,7 +238,7 @@ describe("prices", () => { describe("Case 6: Monthly Subscription of X$", () => { test("Total Price", async () => { const priceFinder = new Prices(); - const totalPrice = await priceFinder.CalculateTotalPrice( + const totalPrice = await priceFinder.calculateTotalPrice( case6, rentalCarReservation, ligoAgreementState @@ -252,7 +252,7 @@ describe("prices", () => { describe("Case 7: Discount for Y+ days", () => { test("Total Price", async () => { const priceFinder = new Prices(); - const totalPrice = await priceFinder.CalculateTotalPrice( + const totalPrice = await priceFinder.calculateTotalPrice( case7, rentalCarReservation, ligoAgreementState From 9b8c884f301c0d82db2ce8373f4ce46a98e636a3 Mon Sep 17 00:00:00 2001 From: Madhukar Gaida <86058993+madhukar123456@users.noreply.github.com> Date: Wed, 18 Jan 2023 23:57:32 +0545 Subject: [PATCH 07/11] Prices function and tests correction updates --- packages/prices/src/prices.ts | 58 ++++++++++++++--------------- packages/prices/test/prices.test.ts | 32 ++++++++-------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/packages/prices/src/prices.ts b/packages/prices/src/prices.ts index 749f9d7..c5829a6 100644 --- a/packages/prices/src/prices.ts +++ b/packages/prices/src/prices.ts @@ -33,30 +33,25 @@ export class Prices { } else if ( _priceSpecifications[i].referenceQuantity?.unitCode === "KMT" ) { - const result = this._totalPriceKM( - _priceSpecifications[i], - _ligoAgreementState - ); - if (typeof result == "number") { - sum = sum + result; - } + sum = + sum + + (await this._totalPriceKM( + _priceSpecifications[i], + _ligoAgreementState + )); } else if ( _priceSpecifications[i].referenceQuantity?.unitCode === "HUR" ) { - const result = this._totalPriceHour( - _priceSpecifications[i], - _rentalCarReservation - ); - if (typeof result == "number") { - sum = sum + result; - } + sum = + sum + + (await this._totalPriceHour( + _priceSpecifications[i], + _rentalCarReservation + )); } else if ( _priceSpecifications[i].referenceQuantity?.unitCode === "MON" ) { - const result = this._totalMonthlySub(_priceSpecifications[i]); - if (typeof result == "number") { - sum = sum + result; - } + sum = sum + (await this._totalMonthlySub(_priceSpecifications[i])); } } return sum; @@ -115,7 +110,7 @@ export class Prices { _ligoAgreementState.endOdometer.value - _ligoAgreementState.startOdometer.value ) > _priceSpecification.eligibleQuantity?.minValue - ) + ) { return ( Math.abs( _ligoAgreementState.endOdometer.value - @@ -123,15 +118,17 @@ export class Prices { _priceSpecification.eligibleQuantity?.minValue ) * _priceSpecification.price ); + } } - return ( - Math.abs( - _ligoAgreementState.endOdometer.value - - _ligoAgreementState.startOdometer.value - ) * _priceSpecification.price - ); - } - return; + { + return ( + Math.abs( + _ligoAgreementState.endOdometer.value - + _ligoAgreementState.startOdometer.value + ) * _priceSpecification.price + ); + } + } else return 0; } private async _totalPriceHour( @@ -140,14 +137,17 @@ export class Prices { ) { const a = new Date(_rentalCarReservation.dropoffTime); const b = new Date(_rentalCarReservation.pickupTime); - return (await this._hourDiffInDays(a, b)) * _priceSpecification.price; + return ( + (await Math.abs(await this._hourDiffInDays(a, b))) * + _priceSpecification.price + ); } private async _totalMonthlySub(_priceSpecification: PriceSpecification) { if (_priceSpecification.billingIncrement != null) { return _priceSpecification.price * _priceSpecification.billingIncrement; } - return; + return 0; } private async _dateDiffInDays(a: Date, b: Date) { diff --git a/packages/prices/test/prices.test.ts b/packages/prices/test/prices.test.ts index a41c36d..d382c25 100644 --- a/packages/prices/test/prices.test.ts +++ b/packages/prices/test/prices.test.ts @@ -79,7 +79,7 @@ describe("prices", () => { price: 25, priceCurrency: "USD", validFrom: "2022-07-01T00:00:00Z", - validThrough: "2022-07-10T00:00:00Z", + validThrough: "2022-07-05T00:00:00Z", referenceQuantity: { value: 1, unitCode: "DAY", @@ -88,7 +88,7 @@ describe("prices", () => { { price: 30, priceCurrency: "USD", - validFrom: "2022-07-10T00:00:00Z", + validFrom: "2022-07-05T00:00:00Z", referenceQuantity: { value: 1, unitCode: "DAY", @@ -173,9 +173,9 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log(totalPrice); + console.log("case 1", totalPrice); expect(totalPrice).toBeDefined(); - expect(typeof totalPrice === "number").toBe(true); + expect(totalPrice === 325).toBe(true); }, 30000); }); @@ -187,9 +187,9 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log(totalPrice); + console.log("case 2", totalPrice); expect(totalPrice).toBeDefined(); - expect(typeof totalPrice === "number").toBe(true); + expect(totalPrice === 250).toBe(true); }, 30000); }); @@ -201,9 +201,9 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log(totalPrice); + console.log("case 3", totalPrice); expect(totalPrice).toBeDefined(); - expect(typeof totalPrice === "number").toBe(true); + expect(totalPrice === 575).toBe(true); }, 30000); }); @@ -215,9 +215,9 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log(totalPrice); + console.log("case 4", totalPrice); expect(totalPrice).toBeDefined(); - expect(typeof totalPrice === "number").toBe(true); + expect(totalPrice === 1560).toBe(true); }, 30000); }); @@ -229,9 +229,9 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log(totalPrice); + console.log("case 5", totalPrice); expect(totalPrice).toBeDefined(); - expect(typeof totalPrice === "number").toBe(true); + expect(totalPrice === 375).toBe(true); }, 30000); }); @@ -243,9 +243,9 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log(totalPrice); + console.log("case 6", totalPrice); expect(totalPrice).toBeDefined(); - expect(typeof totalPrice === "number").toBe(true); + expect(totalPrice === 1000).toBe(true); }, 30000); }); @@ -257,9 +257,9 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log(totalPrice); + console.log("case 7", totalPrice); expect(totalPrice).toBeDefined(); - expect(typeof totalPrice === "number").toBe(true); + expect(totalPrice === 275).toBe(true); }, 30000); }); }); From ac323396184415ffb255e97582d89ffb31342e94 Mon Sep 17 00:00:00 2001 From: Madhukar Gaida <86058993+madhukar123456@users.noreply.github.com> Date: Fri, 20 Jan 2023 07:17:24 +0545 Subject: [PATCH 08/11] Bug fix, add mile unitCode --- packages/prices/src/prices.ts | 12 +++++----- packages/prices/test/prices.test.ts | 34 ++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/packages/prices/src/prices.ts b/packages/prices/src/prices.ts index c5829a6..6a9e487 100644 --- a/packages/prices/src/prices.ts +++ b/packages/prices/src/prices.ts @@ -31,7 +31,8 @@ export class Prices { _rentalCarReservation )); } else if ( - _priceSpecifications[i].referenceQuantity?.unitCode === "KMT" + _priceSpecifications[i].referenceQuantity?.unitCode === "KMT" || + _priceSpecifications[i].referenceQuantity?.unitCode === "MIL" ) { sum = sum + @@ -109,13 +110,14 @@ export class Prices { Math.abs( _ligoAgreementState.endOdometer.value - _ligoAgreementState.startOdometer.value - ) > _priceSpecification.eligibleQuantity?.minValue + ) >= _priceSpecification.eligibleQuantity?.minValue ) { return ( Math.abs( - _ligoAgreementState.endOdometer.value - - _ligoAgreementState.startOdometer.value - - _priceSpecification.eligibleQuantity?.minValue + Math.abs( + _ligoAgreementState.endOdometer.value - + _ligoAgreementState.startOdometer.value + ) - _priceSpecification.eligibleQuantity?.minValue ) * _priceSpecification.price ); } diff --git a/packages/prices/test/prices.test.ts b/packages/prices/test/prices.test.ts index d382c25..8fd6e4a 100644 --- a/packages/prices/test/prices.test.ts +++ b/packages/prices/test/prices.test.ts @@ -95,8 +95,8 @@ describe("prices", () => { }, }, ]; - // Case 6: Monthly Subscription of X$ - const case6: PriceSpecification[] = [ + // Case 6.1: Monthly Subscription of X$ + const case6_1: PriceSpecification[] = [ { price: 1000, priceCurrency: "USD", @@ -106,6 +106,17 @@ describe("prices", () => { }, }, ]; + // Case 6.2: Monthly Subscription of X$ + const case6_2: PriceSpecification[] = [ + { + price: 1000, + priceCurrency: "USD", + billingIncrement: 5, + referenceQuantity: { + unitCode: "MON", + }, + }, + ]; // Case 7: Discount for Y+ days const case7: PriceSpecification[] = [ { @@ -203,7 +214,7 @@ describe("prices", () => { ); console.log("case 3", totalPrice); expect(totalPrice).toBeDefined(); - expect(totalPrice === 575).toBe(true); + expect(totalPrice === 325).toBe(true); }, 30000); }); @@ -235,11 +246,11 @@ describe("prices", () => { }, 30000); }); - describe("Case 6: Monthly Subscription of X$", () => { + describe("Case 6.1: Monthly Subscription of X$", () => { test("Total Price", async () => { const priceFinder = new Prices(); const totalPrice = await priceFinder.calculateTotalPrice( - case6, + case6_1, rentalCarReservation, ligoAgreementState ); @@ -248,6 +259,19 @@ describe("prices", () => { expect(totalPrice === 1000).toBe(true); }, 30000); }); + describe("Case 6.2: Monthly Subscription of X$ multiple months", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.calculateTotalPrice( + case6_2, + rentalCarReservation, + ligoAgreementState + ); + console.log("case 6", totalPrice); + expect(totalPrice).toBeDefined(); + expect(totalPrice === 5000).toBe(true); + }, 30000); + }); describe("Case 7: Discount for Y+ days", () => { test("Total Price", async () => { From b59f39d6ac3c0f6d342d6c2ce5145eb40455481c Mon Sep 17 00:00:00 2001 From: Madhukar Gaida <86058993+madhukar123456@users.noreply.github.com> Date: Fri, 20 Jan 2023 07:26:45 +0545 Subject: [PATCH 09/11] Statute mile unitCode --- packages/prices/src/prices.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/prices/src/prices.ts b/packages/prices/src/prices.ts index 6a9e487..a0340ba 100644 --- a/packages/prices/src/prices.ts +++ b/packages/prices/src/prices.ts @@ -32,7 +32,7 @@ export class Prices { )); } else if ( _priceSpecifications[i].referenceQuantity?.unitCode === "KMT" || - _priceSpecifications[i].referenceQuantity?.unitCode === "MIL" + _priceSpecifications[i].referenceQuantity?.unitCode === "SMI" ) { sum = sum + From c9106db0ac2fc23bedb0bba37561ccef2394d491 Mon Sep 17 00:00:00 2001 From: Madhukar Gaida <86058993+madhukar123456@users.noreply.github.com> Date: Mon, 23 Jan 2023 07:53:44 +0545 Subject: [PATCH 10/11] Prices test updates --- packages/prices/test/prices.test.ts | 146 +++++++++++++++++++++++++--- 1 file changed, 135 insertions(+), 11 deletions(-) diff --git a/packages/prices/test/prices.test.ts b/packages/prices/test/prices.test.ts index 8fd6e4a..4ab0ed8 100644 --- a/packages/prices/test/prices.test.ts +++ b/packages/prices/test/prices.test.ts @@ -39,7 +39,18 @@ describe("prices", () => { }, }, ]; - // Case 3: Base price per day + X$ per kilometer over Y range + // Case 2: Base price per mile + const case2_2: PriceSpecification[] = [ + { + price: 0.25, + priceCurrency: "USD", + referenceQuantity: { + value: 1, + unitCode: "SMI", + }, + }, + ]; + // Case 3.1 & 3.2: Base price per day + X$ per kilometer over Y range const case3: PriceSpecification[] = [ { price: 25, @@ -62,6 +73,30 @@ describe("prices", () => { }, }, ]; + + // Case 3.3: Base price per day + X$ per kilometer over Y range mileage greater than 0$ + const case3_3: PriceSpecification[] = [ + { + price: 25, + priceCurrency: "USD", + referenceQuantity: { + value: 1, + unitCode: "DAY", + }, + }, + { + price: 0.25, + priceCurrency: "USD", + eligibleQuantity: { + minValue: 500, + unitCode: "KMT", + }, + referenceQuantity: { + value: 1, + unitCode: "KMT", + }, + }, + ]; // Case 4: Base price per hour const case4: PriceSpecification[] = [ { @@ -165,6 +200,26 @@ describe("prices", () => { }, }; + const rentalCarReservation2: RentalCarReservation = { + pickupTime: "2022-07-02T00:00:00Z", + dropoffTime: "2022-09-15T00:00:00Z", + bookingTime: "", + modifiedTime: "", + provider: "", + underName: "", + reservationFor: cid, + totalPrice: { + price: 20, + priceCurrency: "USD", + }, + dropoffLocation: { + address: "CA", + }, + pickupLocation: { + address: "CA", + }, + }; + const ligoAgreementState: LigoAgreementState = { startOdometer: { value: 1000, @@ -190,7 +245,7 @@ describe("prices", () => { }, 30000); }); - describe("Case 2: Base price per kilometer", () => { + describe("Case 2.1 : Base price per kilometer", () => { test("Total Price", async () => { const priceFinder = new Prices(); const totalPrice = await priceFinder.calculateTotalPrice( @@ -198,13 +253,27 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log("case 2", totalPrice); + console.log("case 2.1", totalPrice); expect(totalPrice).toBeDefined(); expect(totalPrice === 250).toBe(true); }, 30000); }); - describe("Case 3: Base price per day + X$ per kilometer over Y range", () => { + describe("Case 2.2 : Base price per mile", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.calculateTotalPrice( + case2_2, + rentalCarReservation, + ligoAgreementState + ); + console.log("case 2.2", totalPrice); + expect(totalPrice).toBeDefined(); + expect(totalPrice === 250).toBe(true); + }, 30000); + }); + + describe("Case 3.1 : Base price per day + X$ per kilometer over Y range", () => { test("Total Price", async () => { const priceFinder = new Prices(); const totalPrice = await priceFinder.calculateTotalPrice( @@ -212,12 +281,40 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log("case 3", totalPrice); + console.log("case 3.1", totalPrice); expect(totalPrice).toBeDefined(); expect(totalPrice === 325).toBe(true); }, 30000); }); + describe("Case 3.2 : Base price per day + X$ per kilometer over Y range for multiple months", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.calculateTotalPrice( + case3, + rentalCarReservation2, + ligoAgreementState + ); + console.log("case 3.2", totalPrice); + expect(totalPrice).toBeDefined(); + expect(totalPrice === 1875).toBe(true); + }, 30000); + }); + + describe("Case 3.3 : Base price per day + X$ per kilometer over Y range mileage more than 0$", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.calculateTotalPrice( + case3_3, + rentalCarReservation, + ligoAgreementState + ); + console.log("case 3.3", totalPrice); + expect(totalPrice).toBeDefined(); + expect(totalPrice === 450).toBe(true); + }, 30000); + }); + describe("Case 4: Base price per hour", () => { test("Total Price", async () => { const priceFinder = new Prices(); @@ -232,7 +329,7 @@ describe("prices", () => { }, 30000); }); - describe("Case 5: Different price per day", () => { + describe("Case 5.1 : Different price per day", () => { test("Total Price", async () => { const priceFinder = new Prices(); const totalPrice = await priceFinder.calculateTotalPrice( @@ -240,12 +337,26 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log("case 5", totalPrice); + console.log("case 5.1", totalPrice); expect(totalPrice).toBeDefined(); expect(totalPrice === 375).toBe(true); }, 30000); }); + describe("Case 5.2 : Different price per day for multiple months", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.calculateTotalPrice( + case5, + rentalCarReservation2, + ligoAgreementState + ); + console.log("case 5.2", totalPrice); + expect(totalPrice).toBeDefined(); + expect(totalPrice === 2235).toBe(true); + }, 30000); + }); + describe("Case 6.1: Monthly Subscription of X$", () => { test("Total Price", async () => { const priceFinder = new Prices(); @@ -254,7 +365,7 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log("case 6", totalPrice); + console.log("case 6.1", totalPrice); expect(totalPrice).toBeDefined(); expect(totalPrice === 1000).toBe(true); }, 30000); @@ -267,13 +378,13 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log("case 6", totalPrice); + console.log("case 6.2", totalPrice); expect(totalPrice).toBeDefined(); expect(totalPrice === 5000).toBe(true); }, 30000); }); - describe("Case 7: Discount for Y+ days", () => { + describe("Case 7.1 : Discount for Y+ days", () => { test("Total Price", async () => { const priceFinder = new Prices(); const totalPrice = await priceFinder.calculateTotalPrice( @@ -281,9 +392,22 @@ describe("prices", () => { rentalCarReservation, ligoAgreementState ); - console.log("case 7", totalPrice); + console.log("case 7.1", totalPrice); expect(totalPrice).toBeDefined(); expect(totalPrice === 275).toBe(true); }, 30000); }); + describe("Case 7.2 : Discount for Y+ days for multiple months", () => { + test("Total Price", async () => { + const priceFinder = new Prices(); + const totalPrice = await priceFinder.calculateTotalPrice( + case7, + rentalCarReservation2, + ligoAgreementState + ); + console.log("case 7.2", totalPrice); + expect(totalPrice).toBeDefined(); + expect(totalPrice === 1515).toBe(true); + }, 30000); + }); }); From e90c569257fe5ca6990fd375da7e8026403a24a2 Mon Sep 17 00:00:00 2001 From: Madhukar Gaida Date: Thu, 23 Mar 2023 20:34:36 +0545 Subject: [PATCH 11/11] Add conversion for statute mile to kilometers. --- packages/prices/src/prices.ts | 48 +++++++++++++++++++++-------- packages/prices/test/prices.test.ts | 2 +- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/packages/prices/src/prices.ts b/packages/prices/src/prices.ts index a0340ba..b7b4eec 100644 --- a/packages/prices/src/prices.ts +++ b/packages/prices/src/prices.ts @@ -112,24 +112,48 @@ export class Prices { _ligoAgreementState.startOdometer.value ) >= _priceSpecification.eligibleQuantity?.minValue ) { + if (_priceSpecification.referenceQuantity?.unitCode == "SMI") { + return ( + Math.abs( + Math.abs( + _ligoAgreementState.endOdometer.value - + _ligoAgreementState.startOdometer.value + ) - _priceSpecification.eligibleQuantity?.minValue + ) * + 1.609344 * + _priceSpecification.price // 1 SMI = 1.609344 KMT + ); + } else { + return ( + Math.abs( + Math.abs( + _ligoAgreementState.endOdometer.value - + _ligoAgreementState.startOdometer.value + ) - _priceSpecification.eligibleQuantity?.minValue + ) * _priceSpecification.price + ); + } + } + } + { + if (_priceSpecification.referenceQuantity?.unitCode == "SMI") { return ( Math.abs( - Math.abs( - _ligoAgreementState.endOdometer.value - - _ligoAgreementState.startOdometer.value - ) - _priceSpecification.eligibleQuantity?.minValue + _ligoAgreementState.endOdometer.value - + _ligoAgreementState.startOdometer.value + ) * + 1.609344 * // 1 SMI = 1.609344 KMT + _priceSpecification.price + ); + } else { + return ( + Math.abs( + _ligoAgreementState.endOdometer.value - + _ligoAgreementState.startOdometer.value ) * _priceSpecification.price ); } } - { - return ( - Math.abs( - _ligoAgreementState.endOdometer.value - - _ligoAgreementState.startOdometer.value - ) * _priceSpecification.price - ); - } } else return 0; } diff --git a/packages/prices/test/prices.test.ts b/packages/prices/test/prices.test.ts index 4ab0ed8..878ca0f 100644 --- a/packages/prices/test/prices.test.ts +++ b/packages/prices/test/prices.test.ts @@ -269,7 +269,7 @@ describe("prices", () => { ); console.log("case 2.2", totalPrice); expect(totalPrice).toBeDefined(); - expect(totalPrice === 250).toBe(true); + expect(totalPrice === 402.336).toBe(true); }, 30000); });