@rivascva/dt-idl 1.1.42 → 1.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.githooks/pre-commit-config.yaml +7 -0
- package/.github/workflows/publish.yaml +1 -1
- package/.golangci.yaml +8 -0
- package/Makefile +6 -0
- package/README.md +10 -2
- package/dist/index.d.ts +4 -2
- package/go/utils/fetch/fetch.go +47 -0
- package/go/utils/logger/logger.go +59 -0
- package/go/utils/url/url.go +26 -0
- package/go.mod +3 -0
- package/mise.toml +2 -0
- package/package.json +1 -1
- package/ts/types/types.ts +3 -1
|
@@ -6,6 +6,13 @@ repos:
|
|
|
6
6
|
name: check newlines
|
|
7
7
|
- id: check-yaml
|
|
8
8
|
name: check yaml
|
|
9
|
+
- repo: https://github.com/dnephin/pre-commit-golang
|
|
10
|
+
rev: v0.5.1
|
|
11
|
+
hooks:
|
|
12
|
+
- id: golangci-lint
|
|
13
|
+
name: golangci-lint
|
|
14
|
+
- id: go-mod-tidy
|
|
15
|
+
name: go mod tidy
|
|
9
16
|
- repo: local
|
|
10
17
|
hooks:
|
|
11
18
|
- id: gen-services
|
package/.golangci.yaml
ADDED
package/Makefile
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
pre-commit-install:
|
|
2
2
|
pre-commit install --hook-type pre-commit --config .githooks/pre-commit-config.yaml
|
|
3
3
|
pre-commit install --hook-type pre-push --config .githooks/pre-push-config.yaml
|
|
4
|
+
|
|
5
|
+
lint:
|
|
6
|
+
golangci-lint run ./...
|
|
7
|
+
|
|
8
|
+
format:
|
|
9
|
+
golangci-lint run ./... --fix
|
package/README.md
CHANGED
|
@@ -44,7 +44,15 @@ mise install
|
|
|
44
44
|
make pre-commit-install
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
### 4. Install `
|
|
47
|
+
### 4. Install `go` modules
|
|
48
|
+
|
|
49
|
+
- Use `go` to install codebase modules
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
go mod tidy
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 5. Install `node` modules
|
|
48
56
|
|
|
49
57
|
- Install all `node` modules
|
|
50
58
|
|
|
@@ -60,4 +68,4 @@ npm install
|
|
|
60
68
|
|
|
61
69
|
### Deployments
|
|
62
70
|
|
|
63
|
-
Any merge to `main` with changes to the `ts/*` directory will trigger an automatic deployment to `npm`
|
|
71
|
+
Any merge to `main` with changes to the `ts/*` and `go/*` directory will trigger an automatic deployment to `npm`
|
package/dist/index.d.ts
CHANGED
|
@@ -1432,7 +1432,9 @@ type User = UserServiceSchemas['User'];
|
|
|
1432
1432
|
type AddUserPayload = UserServiceSchemas['AddUserPayload'];
|
|
1433
1433
|
type UpdateUserPayload = UserServiceSchemas['UpdateUserPayload'];
|
|
1434
1434
|
type UserServiceError = UserServiceSchemas['Error'];
|
|
1435
|
-
type AssetServiceError = AssetServiceSchemas['Error'];
|
|
1436
1435
|
type ImageType = AssetServiceSchemas['ImageType'];
|
|
1436
|
+
type UploadImagePayload = AssetServiceSchemas['UploadImagePayload'];
|
|
1437
|
+
type DeleteImagePayload = AssetServiceSchemas['DeleteImagePayload'];
|
|
1438
|
+
type AssetServiceError = AssetServiceSchemas['Error'];
|
|
1437
1439
|
|
|
1438
|
-
export { type AddOrderPayload, type AddUserPayload, type AssetServiceError, type FullQuote, type Holding, type ImageType, type MarketServiceError, type NewsArticle, type Order, type OrderType, type Portfolio, type PortfolioType, type SimpleQuote, type StockHistoryEntry, type StockHistoryTimeframe, type StockNewsArticle, type TradeServiceError, type UpdateUserPayload, type User, type UserServiceError, createAssetServiceClient, createMarketServiceClient, createTradeServiceClient, createUserServiceClient, isAssetServiceError, isMarketServiceError, isTradeServiceError, isUserServiceError };
|
|
1440
|
+
export { type AddOrderPayload, type AddUserPayload, type AssetServiceError, type DeleteImagePayload, type FullQuote, type Holding, type ImageType, type MarketServiceError, type NewsArticle, type Order, type OrderType, type Portfolio, type PortfolioType, type SimpleQuote, type StockHistoryEntry, type StockHistoryTimeframe, type StockNewsArticle, type TradeServiceError, type UpdateUserPayload, type UploadImagePayload, type User, type UserServiceError, createAssetServiceClient, createMarketServiceClient, createTradeServiceClient, createUserServiceClient, isAssetServiceError, isMarketServiceError, isTradeServiceError, isUserServiceError };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
package fetch
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"io"
|
|
6
|
+
"net/http"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
type response struct {
|
|
10
|
+
StatusCode int
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Makes a GET request to the given url.
|
|
14
|
+
//
|
|
15
|
+
// Parses the JSON-encoded response and stores the result into v.
|
|
16
|
+
func Get(url string, v any) (*response, error) {
|
|
17
|
+
// make the GET request
|
|
18
|
+
resp, err := http.Get(url)
|
|
19
|
+
if err != nil {
|
|
20
|
+
return nil, err
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// read the body from the response
|
|
24
|
+
content, err := io.ReadAll(resp.Body)
|
|
25
|
+
if err != nil {
|
|
26
|
+
return nil, err
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// unmarshal the body content
|
|
30
|
+
err = json.Unmarshal(content, v)
|
|
31
|
+
if err != nil {
|
|
32
|
+
return nil, err
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// build the custom fetch response
|
|
36
|
+
response := response{
|
|
37
|
+
StatusCode: resp.StatusCode,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// close the body content
|
|
41
|
+
err = resp.Body.Close()
|
|
42
|
+
if err != nil {
|
|
43
|
+
return nil, err
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return &response, nil
|
|
47
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
package logger
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"log"
|
|
6
|
+
"os"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
type loggerInterface interface {
|
|
10
|
+
// Prints an info log message.
|
|
11
|
+
Info(v ...any)
|
|
12
|
+
// Prints a warning log message.
|
|
13
|
+
Warn(v ...any)
|
|
14
|
+
// Prints an error log message.
|
|
15
|
+
Error(v ...any)
|
|
16
|
+
// Prints an error log message and exits the program.
|
|
17
|
+
Fatal(v ...any)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type logger struct {
|
|
21
|
+
prefix string
|
|
22
|
+
info *log.Logger
|
|
23
|
+
warn *log.Logger
|
|
24
|
+
error *log.Logger
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// A shared singleton log.
|
|
28
|
+
var Log = New()
|
|
29
|
+
|
|
30
|
+
// Creates a new logger.
|
|
31
|
+
func New() loggerInterface {
|
|
32
|
+
return NewWithPrefix("")
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Creates a new logger with a custom prefix.
|
|
36
|
+
func NewWithPrefix(prefix string) loggerInterface {
|
|
37
|
+
return &logger{
|
|
38
|
+
prefix: prefix,
|
|
39
|
+
info: log.New(os.Stdout, "[INFO] ", log.LstdFlags),
|
|
40
|
+
warn: log.New(os.Stdout, "[WARN] ", log.LstdFlags),
|
|
41
|
+
error: log.New(os.Stdout, "[ERROR] ", log.LstdFlags),
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
func (l *logger) Info(v ...any) {
|
|
46
|
+
l.info.Println(l.prefix, fmt.Sprint(v...))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
func (l *logger) Warn(v ...any) {
|
|
50
|
+
l.warn.Println(l.prefix, fmt.Sprint(v...))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func (l *logger) Error(v ...any) {
|
|
54
|
+
l.error.Println(l.prefix, fmt.Sprint(v...))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
func (l *logger) Fatal(v ...any) {
|
|
58
|
+
l.error.Fatal(l.prefix, fmt.Sprint(v...))
|
|
59
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package url
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"net/url"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// Builds a url string from the given base and path.
|
|
9
|
+
//
|
|
10
|
+
// Encodes any given query parameters into the url.
|
|
11
|
+
func Build(base string, path string, params map[string]any) (string, error) {
|
|
12
|
+
// parse the combined base and path
|
|
13
|
+
url, err := url.Parse(base + path)
|
|
14
|
+
if err != nil {
|
|
15
|
+
return "", fmt.Errorf("unable to parse the url: %w", err)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// add the query parameters
|
|
19
|
+
query := url.Query()
|
|
20
|
+
for key, value := range params {
|
|
21
|
+
query.Add(key, fmt.Sprintf("%v", value))
|
|
22
|
+
}
|
|
23
|
+
url.RawQuery = query.Encode()
|
|
24
|
+
|
|
25
|
+
return url.String(), nil
|
|
26
|
+
}
|
package/go.mod
ADDED
package/mise.toml
CHANGED
package/package.json
CHANGED
package/ts/types/types.ts
CHANGED
|
@@ -33,5 +33,7 @@ export type UpdateUserPayload = UserServiceSchemas['UpdateUserPayload'];
|
|
|
33
33
|
export type UserServiceError = UserServiceSchemas['Error'];
|
|
34
34
|
|
|
35
35
|
// Asset Service Types
|
|
36
|
-
export type AssetServiceError = AssetServiceSchemas['Error'];
|
|
37
36
|
export type ImageType = AssetServiceSchemas['ImageType'];
|
|
37
|
+
export type UploadImagePayload = AssetServiceSchemas['UploadImagePayload'];
|
|
38
|
+
export type DeleteImagePayload = AssetServiceSchemas['DeleteImagePayload'];
|
|
39
|
+
export type AssetServiceError = AssetServiceSchemas['Error'];
|