-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump msw from 1.3.2 to 2.0.8 #398
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7fa7bc2
Bump msw from 1.3.2 to 2.0.8
dependabot[bot] a5bd77e
Migrate to Vitest
9282f99
Brought promjs
ad0488d
Fix test after migration to msw
fc2caab
Merge branch 'main' into dependabot/npm_and_yarn/msw-2.0.8
4d6147b
Deduplicate dependencies
a1321d0
Arrange types
5bc0625
Simplify promjs imports
c1d0044
put directives on top
e12f16d
ignore no spaces comment rule
1845e64
Reference vitest globals from setup instead
454ecc4
Change module resolutions
9f0e86f
Use correct import on testing library plugin
8aef2d9
update dependencies
af6085b
prettier fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Labels, Metric, MetricValue } from './types'; | ||
import { findExistingMetric } from './utils'; | ||
|
||
export abstract class Collector<Value extends MetricValue> { | ||
private readonly data: Metric<Value>[]; | ||
|
||
constructor() { | ||
this.data = []; | ||
} | ||
|
||
get(labels?: Labels): Metric<Value> | undefined { | ||
return findExistingMetric<Value>(labels, this.data); | ||
} | ||
|
||
set(value: Value, labels?: Labels): this { | ||
const existing = findExistingMetric(labels, this.data); | ||
if (existing) { | ||
existing.value = value; | ||
} else { | ||
this.data.push({ | ||
labels, | ||
value, | ||
}); | ||
} | ||
|
||
return this; | ||
} | ||
|
||
collect(labels?: Labels): Metric<Value>[] { | ||
if (!labels) { | ||
return this.data; | ||
} | ||
return this.data.filter((item) => { | ||
if (!item.labels) { | ||
return false; | ||
} | ||
const entries = Object.entries(labels); | ||
for (let i = 0; i < entries.length; i += 1) { | ||
const [label, value] = entries[i]; | ||
if (item.labels[label] !== value) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}); | ||
} | ||
|
||
resetAll(): this { | ||
for (let i = 0; i < this.data.length; i += 1) { | ||
this.reset(this.data[i].labels); | ||
} | ||
|
||
return this; | ||
} | ||
|
||
abstract reset(labels?: Labels): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Collector } from './collector'; | ||
import { CounterValue, Labels } from './types'; | ||
|
||
export class Counter extends Collector<CounterValue> { | ||
inc(labels?: Labels): this { | ||
this.add(1, labels); | ||
return this; | ||
} | ||
|
||
add(amount: number, labels?: Labels): this { | ||
if (amount < 0) { | ||
throw new Error( | ||
`Expected increment amount to be greater than -1. Received: ${amount}`, | ||
); | ||
} | ||
const metric = this.get(labels); | ||
this.set(metric ? metric.value + amount : amount, labels); | ||
|
||
return this; | ||
} | ||
|
||
reset(labels?: Labels): void { | ||
this.set(0, labels); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Counter } from './counter'; | ||
import { Labels } from './types'; | ||
|
||
export class Gauge extends Counter { | ||
dec(labels?: Labels): this { | ||
const metric = this.get(labels); | ||
this.set(metric ? metric.value - 1 : 0, labels); | ||
return this; | ||
} | ||
|
||
sub(amount: number, labels?: Labels): this { | ||
const metric = this.get(labels); | ||
this.set(metric ? metric.value - amount : 0, labels); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a change of the public UI. This section is used for changes in existing functionality when following https://keepachangelog.com/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
promjs
is not a dependency anymore, somehow it affects to the consumers, what do you think a different approach: