From 7203272508501bb026f873f5dcf9e8091e310985 Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Wed, 19 Jun 2024 19:20:00 +0200 Subject: [PATCH 1/4] feat: add decimal type alias --- packages/clients/src/scw/custom-types.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/clients/src/scw/custom-types.ts b/packages/clients/src/scw/custom-types.ts index 34e79d060..9aabdafbd 100644 --- a/packages/clients/src/scw/custom-types.ts +++ b/packages/clients/src/scw/custom-types.ts @@ -67,3 +67,8 @@ export interface ScwFile { /** Content of the file in base64. */ content: string } + +/** A representation of a decimal value, such as 2.5. + * Comparable to language-native decimal formats, such as Java's BigDecimal or Python's decimal.Decimal. + * Lookup protobuf google.type.Decimal for details **/ +export type Decimal = string From f9bf16d64d8939f73aa1874256d603f8dab73a78 Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Thu, 20 Jun 2024 16:15:53 +0200 Subject: [PATCH 2/4] change to class --- packages/clients/src/scw/custom-types.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/clients/src/scw/custom-types.ts b/packages/clients/src/scw/custom-types.ts index 9aabdafbd..db6a20397 100644 --- a/packages/clients/src/scw/custom-types.ts +++ b/packages/clients/src/scw/custom-types.ts @@ -71,4 +71,13 @@ export interface ScwFile { /** A representation of a decimal value, such as 2.5. * Comparable to language-native decimal formats, such as Java's BigDecimal or Python's decimal.Decimal. * Lookup protobuf google.type.Decimal for details **/ -export type Decimal = string +export class Decimal { + str: string + constructor(v: string) { + this.str = v + } + + public toString = (): string => { + return this.str + } +} From 5171f7924cd7ea9a0425bf5aacbdb1988ca3e7f5 Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Thu, 20 Jun 2024 18:07:45 +0200 Subject: [PATCH 3/4] set field to private --- packages/clients/src/scw/custom-types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/clients/src/scw/custom-types.ts b/packages/clients/src/scw/custom-types.ts index db6a20397..842ed1797 100644 --- a/packages/clients/src/scw/custom-types.ts +++ b/packages/clients/src/scw/custom-types.ts @@ -72,7 +72,7 @@ export interface ScwFile { * Comparable to language-native decimal formats, such as Java's BigDecimal or Python's decimal.Decimal. * Lookup protobuf google.type.Decimal for details **/ export class Decimal { - str: string + private readonly str: string constructor(v: string) { this.str = v } From 30ea0359020460a0d71f301556fc71399bf138fa Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Fri, 21 Jun 2024 11:02:29 +0200 Subject: [PATCH 4/4] fix lint --- packages/clients/src/scw/custom-types.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/clients/src/scw/custom-types.ts b/packages/clients/src/scw/custom-types.ts index 842ed1797..8e5d16c8b 100644 --- a/packages/clients/src/scw/custom-types.ts +++ b/packages/clients/src/scw/custom-types.ts @@ -70,14 +70,13 @@ export interface ScwFile { /** A representation of a decimal value, such as 2.5. * Comparable to language-native decimal formats, such as Java's BigDecimal or Python's decimal.Decimal. - * Lookup protobuf google.type.Decimal for details **/ + * Lookup protobuf google.type.Decimal for details */ export class Decimal { private readonly str: string + constructor(v: string) { this.str = v } - public toString = (): string => { - return this.str - } + public toString = (): string => this.str }