Skip to content

Commit 6aba825

Browse files
committed
Merge branch 'staging' into sdk-213
2 parents 6e1f790 + 8f320a1 commit 6aba825

File tree

144 files changed

+5710
-3289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+5710
-3289
lines changed

Diff for: .github/workflows/test.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
fi
115115
done
116116
echo "All SQL files are properly formatted"
117-
117+
118118
- name: Check templ files formatting
119119
run: |
120120
# Run templ fmt on the whole project
@@ -126,7 +126,7 @@ jobs:
126126
exit 1
127127
fi
128128
echo "All templ files are properly formatted"
129-
129+
130130
- name: Check Go files formatting
131131
run: |
132132
# Run go fmt on the whole project
@@ -139,12 +139,13 @@ jobs:
139139
fi
140140
echo "All Go files are properly formatted"
141141
142-
- name: Run go vet && tests
142+
- name: Run lint and vet
143143
run: |
144-
make generate
145-
git diff --exit-code
146144
go vet ./...
147-
go test -v ./...
145+
make lint
146+
147+
- name: Run tests
148+
run: go test -v ./...
148149

149150
- name: Cypress run
150151
uses: cypress-io/github-action@v6

Diff for: .golangci.yml

+4-14
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@ run:
44

55
issues:
66
exclude-use-default: false
7-
exclude-rules:
8-
- linters:
9-
- exhaustruct
10-
path: .*
11-
- linters:
12-
- exhaustruct
13-
path-except: ^modules/[^/]+/infrastructure/persistence/[^/]*mappers\.go
14-
- linters:
15-
- exhaustruct
16-
path-except: ^modules/[^/]+/domain/[^/]+/[^/]+/[^/]+\.go
17-
187
exclude-files:
198
- pkg/graphql/graphql.go
209
exclude-dirs:
@@ -54,7 +43,6 @@ linters:
5443
- errchkjson
5544
- errname
5645
- exhaustive
57-
- exhaustruct
5846
- fatcontext
5947
- forbidigo
6048
# - gci
@@ -64,7 +52,7 @@ linters:
6452
- gochecksumtype
6553
# - gocognit
6654
# - goconst
67-
- gocyclo
55+
# - gocyclo
6856
# - godot
6957
- gofmt
7058
# - gofumpt
@@ -82,7 +70,7 @@ linters:
8270
# - intrange
8371
# - lll
8472
- loggercheck
85-
- maintidx
73+
# - maintidx
8674
- makezero
8775
- mirror
8876
- misspell
@@ -127,5 +115,7 @@ linters-settings:
127115
exclude-dirs:
128116
- apex
129117
- test
118+
- node_modules
119+
- e2e
130120
- .vscode
131121
check-zero-byte-files: true

Diff for: CLAUDE.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
## Overview
44
The project follows DDD principles. DO NOT COMMENT EXECESSIVELY. Instead, write clear and concise code that is self-explanatory.
55

6+
## Tool use
7+
- DO NOT USE `sed` for file manipulation
8+
69
## Build/Lint/Test Commands
710
- After changes to css or .templ files: `make generate && make css`
811
- After changes to Go code: `go vet ./...`
912
- Run all tests: `make test` or `go test -v ./...`
1013
- Run single test: `go test -v ./path/to/package -run TestName`
1114
- Run specific subtest: `go test -v ./path/to/package -run TestName/SubtestName`
12-
- JSON linting: `make build-iota-linter && make run-iota-linter`
15+
- Linting translation files: `make run-iota-linter`
1316
- Apply migrations: `make migrate up`
1417

1518
## Code Style Guidelines
19+
- Use `go fmt` for formatting. Do not indent code manually.
1620
- Use Go v1.23.2 and follow standard Go idioms
1721
- File organization: group related functionality in modules/ or pkg/ directories
1822
- Naming: use camelCase for variables, PascalCase for exported functions/types

Diff for: Makefile

+2-9
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,9 @@ release-local:
7878
clean:
7979
rm -rf $(TAILWIND_OUTPUT)
8080

81-
## Linter targets
82-
#.PHONY: build-iota-linter run-iota-linter clean-iota-linter
83-
84-
# Build the JSON linter
85-
build-iota-linter:
86-
go build -o bin/iotalinter tools/iotalinter.go
87-
8881
# Run the JSON linter
8982
run-iota-linter:
90-
./bin/iotalinter ./...
83+
go build -o bin/iotalinter tools/iotalinter.go && ./bin/iotalinter ./...
9184

9285
# Clean built binaries
9386
clean-iota-linter:
@@ -103,4 +96,4 @@ build-docker-prod:
10396
%:
10497
@:
10598

106-
.PHONY: default deps test test-watch localdb clear-localdb reset-localdb migrate-up migrate-down dev css-watch css lint release release-local clean setup build-iota-linter run-iota-linter clean-iota-linter collect-migrations docs seed
99+
.PHONY: default deps test test-watch localdb clear-localdb reset-localdb migrate-up migrate-down dev css-watch css lint release release-local clean setup run-iota-linter clean-iota-linter collect-migrations docs seed

Diff for: cmd/collect-logs/main.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bufio"
55
"bytes"
6+
"context"
67
"encoding/json"
78
"fmt"
89
"io"
@@ -99,15 +100,19 @@ func (c *LogCollector) Process() {
99100
fileInfo, err := file.Stat()
100101
if err != nil {
101102
log.Printf("Failed to get file info: %v. Retrying in 5 seconds...", err)
102-
file.Close()
103+
if err := file.Close(); err != nil {
104+
log.Printf("Failed to close file: %v", err)
105+
}
103106
time.Sleep(5 * time.Second)
104107
continue
105108
}
106109

107110
offset := fileInfo.Size()
108111
if _, err := file.Seek(offset, 0); err != nil {
109112
log.Printf("Failed to seek to end of file: %v. Retrying in 5 seconds...", err)
110-
file.Close()
113+
if err := file.Close(); err != nil {
114+
log.Printf("Failed to close file: %v", err)
115+
}
111116
time.Sleep(5 * time.Second)
112117
continue
113118
}
@@ -205,7 +210,9 @@ func (c *LogCollector) Process() {
205210

206211
processBatch()
207212

208-
file.Close()
213+
if err := file.Close(); err != nil {
214+
log.Printf("Failed to close file: %v", err)
215+
}
209216

210217
log.Printf("Reopening log file in 5 seconds...")
211218
time.Sleep(5 * time.Second)
@@ -287,7 +294,7 @@ func (c *LogCollector) SendBatch(client *http.Client, batch []map[string]interfa
287294
return fmt.Errorf("failed to marshal Loki payload: %w", err)
288295
}
289296

290-
req, err := http.NewRequest("POST", c.LokiURL, bytes.NewBuffer(buf))
297+
req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, c.LokiURL, bytes.NewBuffer(buf))
291298
if err != nil {
292299
return fmt.Errorf("failed to create HTTP request: %w", err)
293300
}
@@ -297,7 +304,11 @@ func (c *LogCollector) SendBatch(client *http.Client, batch []map[string]interfa
297304
if err != nil {
298305
return fmt.Errorf("failed to send data to Loki: %w", err)
299306
}
300-
defer resp.Body.Close()
307+
defer func() {
308+
if err := resp.Body.Close(); err != nil {
309+
log.Printf("Failed to close response body: %v", err)
310+
}
311+
}()
301312

302313
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
303314
respBody, err := io.ReadAll(resp.Body)

Diff for: cmd/document/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"flag"
55
"fmt"
6+
"log"
67
"os"
78
"strings"
89

@@ -34,5 +35,5 @@ func main() {
3435
os.Exit(1)
3536
}
3637

37-
fmt.Printf("Documentation generated successfully at %s\n", *outputPath)
38+
log.Printf("Documentation generated successfully at %s", *outputPath)
3839
}

Diff for: components/base/dropdown.templ

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ type DropdownItemProps struct {
77
templ DropdownItem(props DropdownItemProps) {
88
<li>
99
if len(props.Href) > 0 {
10-
<a href={ templ.SafeURL(props.Href) } class="block p-2 duration-200 hover:bg-surface-400 rounded-md">
10+
<a
11+
href={ templ.SafeURL(props.Href) }
12+
class="block p-2 duration-200 hover:bg-surface-400 rounded-md"
13+
>
1114
{ children... }
1215
</a>
1316
} else {

Diff for: components/scaffold/filters/filters.go

+13
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ func MultiSelect() Option {
1919
}
2020
}
2121

22+
func WithOptions(options ...OptionItem) Option {
23+
return func(t *TableFilter) {
24+
t.options = options
25+
}
26+
}
27+
28+
func Opt(value, label string) OptionItem {
29+
return OptionItem{
30+
Value: value,
31+
Label: label,
32+
}
33+
}
34+
2235
type OptionItem struct {
2336
Value string
2437
Label string

Diff for: components/scaffold/filters/filters.templ

+113-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package filters
22

3-
import "github.com/iota-uz/iota-sdk/components/base"
3+
import (
4+
icons "github.com/iota-uz/icons/phosphor"
5+
"github.com/iota-uz/iota-sdk/components/base"
6+
"github.com/iota-uz/iota-sdk/components/base/input"
7+
)
48

59
type TableFilter struct {
610
Name string
@@ -20,26 +24,121 @@ func NewFilter(name string, opts ...Option) *TableFilter {
2024
return f
2125
}
2226

23-
func (t *TableFilter) AddOpt(key, label string) *TableFilter {
24-
t.options = append(t.options, OptionItem{
25-
Value: key,
26-
Label: label,
27-
})
27+
func (t *TableFilter) Add(opts ...OptionItem) *TableFilter {
28+
t.options = append(t.options, opts...)
2829
return t
2930
}
3031

32+
type DropdownProps struct {
33+
Label string
34+
Name string
35+
}
36+
37+
templ Dropdown(props DropdownProps) {
38+
<div
39+
x-data="{
40+
open: false,
41+
selected: [],
42+
toggleValue(val) {
43+
const index = this.selected.indexOf(val);
44+
if (index === -1) {
45+
this.selected.push(val);
46+
} else {
47+
this.selected.splice(index, 1);
48+
}
49+
}
50+
}"
51+
class="relative w-32"
52+
>
53+
<!-- Trigger -->
54+
<div class="flex">
55+
<!-- Clear Button -->
56+
<button
57+
x-show="selected.length"
58+
class={
59+
"flex items-center justify-center cursor-pointer",
60+
"border border-gray-500 rounded-md rounded-r-none px-2",
61+
}
62+
>
63+
@icons.X(icons.Props{
64+
Size: "16",
65+
Attributes: templ.Attributes{
66+
"@click": "selected = []",
67+
},
68+
})
69+
</button>
70+
<!-- Dropdown Button -->
71+
<button
72+
@click="open = !open"
73+
type="button"
74+
class={
75+
"w-full border border-gray-500 rounded-md shadow-sm cursor-pointer",
76+
"flex items-center justify-between px-4 py-2",
77+
}
78+
:class="selected.length ? 'rounded-l-none border-l-0' : ''"
79+
>
80+
<span class="text-gray-700 font-medium">
81+
{ props.Label }
82+
</span>
83+
@icons.CaretDown(icons.Props{
84+
Class: "text-gray-700 duration-200",
85+
Attributes: templ.Attributes{
86+
":class": "open ? 'rotate-180' : ''",
87+
},
88+
Size: "16",
89+
})
90+
</button>
91+
</div>
92+
<!-- Dropdown Items -->
93+
<ul
94+
x-show="open"
95+
@click.away="open = false"
96+
x-transition
97+
class="absolute z-20 mt-2 w-full bg-white border border-gray-200 rounded-md shadow-lg max-h-80 overflow-y-auto"
98+
>
99+
{ children... }
100+
</ul>
101+
</div>
102+
}
103+
104+
type DropdownItemProps struct {
105+
Class templ.CSSClasses
106+
Label string
107+
Value string
108+
Name string
109+
}
110+
111+
templ DropdownItem(props DropdownItemProps) {
112+
<li
113+
class={
114+
"hover:bg-gray-100 p-2",
115+
props.Class.String(),
116+
}
117+
>
118+
@input.Checkbox(&input.CheckboxProps{
119+
Label: props.Label,
120+
Attrs: templ.Attributes{
121+
"value": props.Value,
122+
"name": props.Name,
123+
"@change": "toggleValue($event.target.value)",
124+
":checked": "selected.includes('" + props.Value + "')",
125+
},
126+
})
127+
</li>
128+
}
129+
31130
templ (t *TableFilter) Component() {
32131
if t.multiple {
33-
@base.Combobox(base.ComboboxProps{
34-
Label: "",
35-
Placeholder: t.placeholder,
36-
Name: t.Name,
37-
Multiple: true,
132+
@Dropdown(DropdownProps{
133+
Label: t.placeholder,
134+
Name: t.Name,
38135
}) {
39136
for _, opt := range t.options {
40-
<option value={ opt.Value }>
41-
{ opt.Label }
42-
</option>
137+
@DropdownItem(DropdownItemProps{
138+
Label: opt.Label,
139+
Value: opt.Value,
140+
Name: t.Name,
141+
})
43142
}
44143
}
45144
} else {

0 commit comments

Comments
 (0)