Skip to content

Commit

Permalink
Merge branch 'staging' into sdk-113
Browse files Browse the repository at this point in the history
  • Loading branch information
thelissimus-work committed Feb 24, 2025
2 parents 84f53ec + 51d672d commit b40407d
Show file tree
Hide file tree
Showing 148 changed files with 8,530 additions and 4,530 deletions.
14 changes: 11 additions & 3 deletions .air.testing.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ testdata_dir = "testdata"

[build]
cmd = "go test -v ./..."
args = [] # Replace default args with test command
args = [] # Replace default args with test command
# Binary name after build (not used in this setup)
bin = ""
# Specify working directory if needed
full_bin = ""
# Timeout for the build process
delay = 2000 # in milliseconds
delay = 2000 # in milliseconds
kill_signal = "SIGINT"
# Patterns to watch
exclude_dir = ["tmp", "vendor", "testdata", "postgres-data", "static", "py-embed", "e2e"]
exclude_dir = [
"tmp",
"vendor",
"testdata",
"postgres-data",
"static",
"py-embed",
"e2e",
]
exclude_file = []
exclude_regex = []
exclude_unchanged = false
Expand Down
20 changes: 17 additions & 3 deletions .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,28 @@ args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main cmd/server/main.go"
delay = 1000
exclude_dir = ["tmp", "vendor", "testdata", "postgres-data", "static", "py-embed", "e2e"]
exclude_file = []
exclude_dir = [
"tmp",
"vendor",
"testdata",
"postgres-data",
"static",
"py-embed",
"e2e",
]
exclude_file = [
".air.toml",
".air.testing.toml",
"compose.yml",
"compose.dev.yml",
"compose.testing.yml",
]
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "html", "json", "js", "css"]
include_ext = ["go", "html", "json", "js", "css", "toml", "yml", "yaml"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Test Makefile targets
# running seeds twice to verify that they are idempotent
run: |
make migrate-up
make migrate up
make seed
make seed
make css
Expand Down Expand Up @@ -123,4 +123,4 @@ jobs:
- name: Test database migrate down
# e2e tests require database to have the seed data. We can only down the migrations after cypress.
run: |
make migrate-down
make migrate down
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ localdb:
clear-localdb:
rm -rf postgres-data/

# Apply database migrations (up)
migrate-up:
go run cmd/migrate/main.go up

# Downgrade database migrations (down)
migrate-down:
go run cmd/migrate/main.go down
migrate:
go run cmd/migrate/main.go $(filter-out $@,$(MAKECMDGOALS))

# Compile TailwindCSS (with watch)
css-watch:
Expand All @@ -74,9 +69,6 @@ release-local:
clean:
rm -rf $(TAILWIND_OUTPUT)

# Full setup
setup: deps localdb migrate-up css lint

## Linter targets
#.PHONY: build-iota-linter run-iota-linter clean-iota-linter

Expand All @@ -92,10 +84,18 @@ run-iota-linter:
clean-iota-linter:
rm -f bin/iotalinter

# Migration management targets
collect-migrations:
go run cmd/migrate/main.go collect

build-docker-base:
docker buildx build --push --platform linux/amd64,linux/arm64 -t iotauz/sdk:base-$v --target base .

build-docker-prod:
docker buildx build --push --platform linux/amd64,linux/arm64 -t iotauz/sdk:$v --target production .

.PHONY: default deps test test-watch localdb migrate-up migrate-down dev css-watch css lint release release-local clean setup build-iota-linter run-iota-linter clean-iota-linter
# Prevents make from treating the argument as an undefined target
%:
@:

.PHONY: default deps test test-watch localdb migrate migrate-down dev css-watch css lint release release-local clean setup build-iota-linter run-iota-linter clean-iota-linter collect-migrations
12 changes: 4 additions & 8 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
- [Discord Community](https://discord.gg/zKeTEZAQqF): Join our community for support and Q&A.
- [Contribution Guide](docs/CONTRIBUTING.MD): Learn how to contribute to the project.
- [Setup Demo](https://github.com/iota-uz/sdk-demo): Learn how to setup IOTA-SDK.
- [Figma Designs (Coming soon...)](https://www.figma.com/): Access and contribute to our open-source designs.
- [Demo stand](https://demo.iotaerp.com): Explore the SDK UI
- [Docker hub](https://hub.docker.com/r/iotauz/sdk) - Official Docker images
- [Roadmap (Coming soon...)](docs/): Explore our upcoming features and milestones.
- [Figma Designs (Coming soon...)](https://www.figma.com/): Access and contribute to our open-source designs.

## 🛠 Built With

Expand Down Expand Up @@ -59,17 +61,11 @@ various industries. Here's what's in the pipeline:
invoices and other essential business documents.
- **Documentation Website**: Launch a comprehensive docs website to streamline onboarding and provide detailed guidance
for developers and users.
- **Demo Stand**: Develop an interactive demo stand to showcase IOTA SDK’s capabilities for prospective users and
contributors.
- **Open Source Designs and Documentation**: Share Figma designs and other internal documentation to help the community
understand the vision and contribute more effectively.

---

## Official Docker images

[Docker hub](https://hub.docker.com/r/iotauz/sdk)

## 📄 Licence

Apache 2.0
Expand All @@ -78,7 +74,7 @@ Updated at Jan 6, 2025

## 🌟 Join Us

<img width="250" style="display: block" src="https://www.iota.uz/images/common/logotype.svg">
<img width="250" style="display: block" src="https://cdn.prod.website-files.com/660549b5ac888804e6582845/6606afddd43da2d659209149_logo.svg">

We welcome contributions to improve and expand IOTA SDK! Check out our [contributing guide](docs/CONTRIBUTING.MD) to get
started.
Expand Down
37 changes: 33 additions & 4 deletions cmd/seed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ package main

import (
"context"
"os"
"runtime/debug"
"time"

"github.com/iota-uz/iota-sdk/modules"
"github.com/iota-uz/iota-sdk/modules/bichat"
"github.com/iota-uz/iota-sdk/modules/core"
"github.com/iota-uz/iota-sdk/modules/core/domain/aggregates/user"
coreseed "github.com/iota-uz/iota-sdk/modules/core/seed"
"github.com/iota-uz/iota-sdk/modules/crm"
"github.com/iota-uz/iota-sdk/modules/finance"
"github.com/iota-uz/iota-sdk/modules/hrm"
"github.com/iota-uz/iota-sdk/modules/warehouse"
"github.com/iota-uz/iota-sdk/modules/website"
"github.com/iota-uz/iota-sdk/pkg/application"
"github.com/iota-uz/iota-sdk/pkg/composables"
"github.com/iota-uz/iota-sdk/pkg/configuration"
Expand All @@ -18,28 +24,51 @@ import (
"github.com/jackc/pgx/v5/pgxpool"
)

func main() {
func pgxPool() *pgxpool.Pool {
conf := configuration.Use()
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
pool, err := pgxpool.New(ctx, conf.DBOpts)
pool, err := pgxpool.New(ctx, conf.Database.Opts)
if err != nil {
panic(err)
}
app := application.New(pool, eventbus.NewEventPublisher())
return pool
}

func main() {
defer func() {
if r := recover(); r != nil {
configuration.Use().Unload()
debug.PrintStack()
os.Exit(1)
}
}()

conf := configuration.Use()
ctx := context.Background()
pool := pgxPool()
app := application.New(pool, eventbus.NewEventPublisher(conf.Logger()))
if err := modules.Load(app, modules.BuiltInModules...); err != nil {
panic(err)
}
app.RegisterNavItems(core.NavItems...)
app.RegisterNavItems(bichat.NavItems...)
app.RegisterNavItems(hrm.NavItems...)
app.RegisterNavItems(finance.NavItems...)
app.RegisterNavItems(warehouse.NavItems...)
app.RegisterNavItems(crm.NavItems...)
app.RegisterNavItems(website.NavItems...)
tx, err := pool.Begin(ctx)
if err != nil {
panic(err)
}
if err := app.Seed(composables.WithTx(context.Background(), tx)); err != nil {
seeder := application.NewSeeder()
seeder.Register(
coreseed.CreateCurrencies,
coreseed.CreatePermissions,
coreseed.UserSeedFunc("[email protected]", "TestPass123!", user.UILanguageEN),
)
if err := seeder.Seed(composables.WithTx(ctx, tx), app); err != nil {
panic(err)
}
if err := tx.Commit(ctx); err != nil {
Expand Down
27 changes: 15 additions & 12 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"log"
"os"
"runtime/debug"
"time"

internalassets "github.com/iota-uz/iota-sdk/internal/assets"
Expand All @@ -14,41 +15,42 @@ import (
"github.com/iota-uz/iota-sdk/modules/core/presentation/controllers"
"github.com/iota-uz/iota-sdk/modules/crm"
"github.com/iota-uz/iota-sdk/modules/finance"
"github.com/iota-uz/iota-sdk/modules/hrm"
"github.com/iota-uz/iota-sdk/modules/warehouse"
"github.com/iota-uz/iota-sdk/modules/website"
"github.com/iota-uz/iota-sdk/pkg/application"
"github.com/iota-uz/iota-sdk/pkg/configuration"
"github.com/iota-uz/iota-sdk/pkg/eventbus"
"github.com/iota-uz/iota-sdk/pkg/logging"

"github.com/jackc/pgx/v5/pgxpool"
_ "github.com/lib/pq"
)

func main() {
conf := configuration.Use()
logFile, logger, err := logging.FileLogger(conf.LogrusLogLevel())
if err != nil {
log.Fatalf("failed to create logger: %v", err)
}
defer func(logFile *os.File) {
if err := logFile.Close(); err != nil {
log.Fatalf("failed to close log file: %v", err)
defer func() {
if r := recover(); r != nil {
configuration.Use().Unload()
debug.PrintStack()
os.Exit(1)
}
}(logFile)
}()

conf := configuration.Use()
logger := conf.Logger()

ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
pool, err := pgxpool.New(ctx, conf.DBOpts)
pool, err := pgxpool.New(ctx, conf.Database.Opts)
if err != nil {
panic(err)
}
app := application.New(pool, eventbus.NewEventPublisher())
app := application.New(pool, eventbus.NewEventPublisher(logger))
if err := modules.Load(app, modules.BuiltInModules...); err != nil {
log.Fatalf("failed to load modules: %v", err)
}
app.RegisterNavItems(core.NavItems...)
app.RegisterNavItems(bichat.NavItems...)
app.RegisterNavItems(hrm.NavItems...)
app.RegisterNavItems(warehouse.NavItems...)
app.RegisterNavItems(finance.NavItems...)
app.RegisterNavItems(crm.NavItems...)
Expand All @@ -68,6 +70,7 @@ func main() {
if err != nil {
log.Fatalf("failed to create server: %v", err)
}
log.Printf("Listening on: %s\n", conf.Address())
if err := serverInstance.Start(conf.SocketAddress); err != nil {
log.Fatalf("failed to start server: %v", err)
}
Expand Down
63 changes: 60 additions & 3 deletions components/base/dialog/drawer.templ
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package dialog

import "fmt"
import (
"fmt"
icons "github.com/iota-uz/icons/phosphor"
)

type Direction int

Expand All @@ -19,16 +22,27 @@ var directions = map[Direction]string{
}

type DrawerProps struct {
ID string
Open bool
Direction Direction
Action string
Attrs templ.Attributes
Classes templ.CSSClasses
}

templ Drawer(props DrawerProps) {
{{
listener := fmt.Sprintf("@%s.window", props.Action)
attrs := templ.Attributes{
"x-data": templ.SafeScriptInline("dialog", props.Open),
listener: "toggle",
}
if props.ID != "" {
attrs["id"] = props.ID
}
}}
<div
x-data="dialog"
{ templ.Attributes{fmt.Sprintf("@%s.window", props.Action): "toggle"}... }
{ attrs... }
>
<dialog
x-bind="dialog"
Expand All @@ -46,3 +60,46 @@ templ Drawer(props DrawerProps) {
</dialog>
</div>
}

type StdDrawerProps struct {
ID string
Title string
Action string
Open bool
Attrs templ.Attributes
}

templ StdViewDrawer(props StdDrawerProps) {
@Drawer(DrawerProps{
ID: props.ID,
Direction: RTL,
Open: props.Open,
Action: props.Action,
Classes: templ.Classes("flex items-stretch"),
Attrs: props.Attrs,
}) {
<div class="bg-white w-3/4 md:w-2/3 ml-auto">
<form
method="dialog"
class="flex flex-col h-full"
>
<div
class={
"flex justify-between px-4 py-3",
"border-b border-primary",
}
>
<h3 class="font-medium">
{ props.Title }
</h3>
<div>
<button class="cursor-pointer">
@icons.XCircle(icons.Props{Size: "20"})
</button>
</div>
</div>
{ children... }
</form>
</div>
}
}
Loading

0 comments on commit b40407d

Please sign in to comment.