From b02d2ba479446de6f38fce1e25cec8564ef9010a Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 26 Apr 2025 19:47:00 -0400 Subject: chore(templ): fix go generate commands Signed-off-by: Xe Iaso --- cmd/_old/tcpinfodump/main.go | 35 + cmd/asbestos/html_templ.go | 56 +- cmd/asbestos/main.go | 2 +- cmd/aura/aura_templ.go | 16 +- cmd/aura/main.go | 2 +- cmd/hlang/hlang_templ.go | 48 +- cmd/hlang/http.go | 2 +- cmd/mi/services/glance/glance.go | 2 +- cmd/mi/services/glance/glance_templ.go | 2 +- cmd/mimi/modules/scheduling/scheduling.pb.go | 308 ++++++ cmd/mimi/modules/scheduling/scheduling.twirp.go | 1115 +++++++++++++++++++++ cmd/mimi/modules/scheduling/scheduling_grpc.pb.go | 121 +++ cmd/nomadicdemo/main.go | 2 +- cmd/nomadicdemo/main_templ.go | 2 +- cmd/stickers/main.go | 2 +- cmd/stickers/main_templ.go | 2 +- cmd/todayinmarch2020/html_templ.go | 31 +- cmd/todayinmarch2020/main.go | 2 +- cmd/within.website/html_templ.go | 56 +- cmd/within.website/main.go | 2 +- cmd/xedn/uplodr/pb/uplodr.pb.go | 190 +--- cmd/xedn/uplodr/pb/uplodr_grpc.pb.go | 27 +- 22 files changed, 1793 insertions(+), 232 deletions(-) create mode 100644 cmd/_old/tcpinfodump/main.go create mode 100644 cmd/mimi/modules/scheduling/scheduling.pb.go create mode 100644 cmd/mimi/modules/scheduling/scheduling.twirp.go create mode 100644 cmd/mimi/modules/scheduling/scheduling_grpc.pb.go (limited to 'cmd') diff --git a/cmd/_old/tcpinfodump/main.go b/cmd/_old/tcpinfodump/main.go new file mode 100644 index 0000000..59c4e31 --- /dev/null +++ b/cmd/_old/tcpinfodump/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "encoding/json" + "fmt" + "log" + "net" + + "github.com/mikioh/tcp" + "github.com/mikioh/tcpinfo" +) + +func main() { + c, err := net.Dial("tcp", "golang.org:80") + if err != nil { + log.Fatal(err) + } + defer c.Close() + + tc, err := tcp.NewConn(c) + if err != nil { + log.Fatal(err) + } + var o tcpinfo.Info + var b [256]byte + i, err := tc.Option(o.Level(), o.Name(), b[:]) + if err != nil { + log.Fatal(err) + } + txt, err := json.Marshal(i) + if err != nil { + log.Fatal(err) + } + fmt.Println(string(txt)) +} diff --git a/cmd/asbestos/html_templ.go b/cmd/asbestos/html_templ.go index 7ac5c03..b1a0818 100644 --- a/cmd/asbestos/html_templ.go +++ b/cmd/asbestos/html_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.793 +// templ: version: v0.3.857 package main //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -34,11 +34,11 @@ func NotFound() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

The URL you requested could not be found. Please check your URL and hang up to try your call again.

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "

The URL you requested could not be found. Please check your URL and hang up to try your call again.

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } @@ -63,11 +63,11 @@ func allClear() templ.Component { templ_7745c5c3_Var2 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Your data was not found in the dataset. No action is required on your part.

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "

Your data was not found in the dataset. No action is required on your part.

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } @@ -92,7 +92,7 @@ func Error(why string) templ.Component { templ_7745c5c3_Var3 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Oopsie whoopsie uwu we made a fucky-wucky! A widdle fucko boingo! The code monkeys at our headquarters are working VEWY HARD to fix this!

Reason: ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "

Oopsie whoopsie uwu we made a fucky-wucky! A widdle fucko boingo! The code monkeys at our headquarters are working VEWY HARD to fix this!

Reason: ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -105,11 +105,11 @@ func Error(why string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } @@ -134,11 +134,11 @@ func Index() templ.Component { templ_7745c5c3_Var5 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

TODO placeholder


") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "

TODO placeholder


") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } @@ -167,11 +167,11 @@ func headArea() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } @@ -196,7 +196,7 @@ func footer() templ.Component { templ_7745c5c3_Var7 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

A product of Techaro ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "

A product of Techaro ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -209,11 +209,11 @@ func footer() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(", the only ethical AI company

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, ", the only ethical AI company

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } @@ -248,7 +248,7 @@ func Layout(title string, body templ.Component) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } @@ -273,12 +273,12 @@ func searchPage(authorDID string, posts []Post) templ.Component { templ_7745c5c3_Var10 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "
Created atTextLink
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, post := range posts { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\">🔗") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Created atTextLink
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -291,7 +291,7 @@ func searchPage(authorDID string, posts []Post) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -304,7 +304,7 @@ func searchPage(authorDID string, posts []Post) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("🔗

Since your data is in this dataset, here's what you can do about it:

Compose an email to dmca@huggingface.co with the subject line DMCA Takedown Request and something like the following body (rephrase this in your own words):

Hello,

I am writing to you to inform you that my data is present in the dataset bluesky-community/one-million-bluesky-posts and I did not consent to it being included. I would like to request that you remove my data from the dataset.

You can identify my data by searching for the following DID in the author_did column: ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "

Since your data is in this dataset, here's what you can do about it:

Compose an email to dmca@huggingface.co with the subject line DMCA Takedown Request and something like the following body (rephrase this in your own words):

Hello,

I am writing to you to inform you that my data is present in the dataset bluesky-community/one-million-bluesky-posts and I did not consent to it being included. I would like to request that you remove my data from the dataset.

You can identify my data by searching for the following DID in the author_did column: ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -331,7 +331,7 @@ func searchPage(authorDID string, posts []Post) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Thank you for your attention and patience in this matter.

Sincerely,

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "


Thank you for your attention and patience in this matter.

Sincerely,

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -344,7 +344,7 @@ func searchPage(authorDID string, posts []Post) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(", ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, ", ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -357,7 +357,7 @@ func searchPage(authorDID string, posts []Post) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -370,7 +370,7 @@ func searchPage(authorDID string, posts []Post) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -392,11 +392,11 @@ func searchPage(authorDID string, posts []Post) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

For more information, please refer to the dataset page.

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "

For more information, please refer to the dataset page.

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } diff --git a/cmd/asbestos/main.go b/cmd/asbestos/main.go index 9ab1f8e..1f99589 100644 --- a/cmd/asbestos/main.go +++ b/cmd/asbestos/main.go @@ -15,7 +15,7 @@ import ( "within.website/x/xess" ) -//go:generate go run github.com/a-h/templ/cmd/templ@latest generate +//go:generate go tool templ generate var ( bind = flag.String("bind", ":8069", "http port to bind on") diff --git a/cmd/aura/aura_templ.go b/cmd/aura/aura_templ.go index 421d54b..174a3cc 100644 --- a/cmd/aura/aura_templ.go +++ b/cmd/aura/aura_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.3.857 package main //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -11,6 +11,9 @@ import templruntime "github.com/a-h/templ/runtime" func index() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { @@ -26,17 +29,20 @@ func index() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Archive

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "

Archive

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } func notFound() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { @@ -52,11 +58,11 @@ func notFound() templ.Component { templ_7745c5c3_Var2 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

The URL you requested could not be found. Please check your URL and hang up to try your call again.

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "

The URL you requested could not be found. Please check your URL and hang up to try your call again.

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } diff --git a/cmd/aura/main.go b/cmd/aura/main.go index 4f7a535..c364efd 100644 --- a/cmd/aura/main.go +++ b/cmd/aura/main.go @@ -27,7 +27,7 @@ import ( "within.website/x/xess" ) -//go:generate go run github.com/a-h/templ/cmd/templ@latest generate +//go:generate go tool templ generate var ( token = flag.String("token", "", "Token for authentication") diff --git a/cmd/hlang/hlang_templ.go b/cmd/hlang/hlang_templ.go index 2155e26..c704085 100644 --- a/cmd/hlang/hlang_templ.go +++ b/cmd/hlang/hlang_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.731 +// templ: version: v0.3.857 package main //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -11,6 +11,9 @@ import templruntime "github.com/a-h/templ/runtime" func navbar() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { @@ -26,17 +29,20 @@ func navbar() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("The h programming language - Docs - Playground - FAQ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "The h programming language - Docs - Playground - FAQ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } func footer() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { @@ -52,17 +58,20 @@ func footer() templ.Component { templ_7745c5c3_Var2 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

From Within

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "

From Within

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } func homePage() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { @@ -78,17 +87,20 @@ func homePage() templ.Component { templ_7745c5c3_Var3 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

A simple, fast, open-source, complete and safe language for developing modern software for the web


Example Program

h

Outputs:

h

Fast Compilation

h probably compiles hundreds of characters of source per second. I didn't really test how fast it is, but when I was testing it the speed was fast enough that I didn't care to profile it.


Safety

h is completely memory safe with no garbage collector or heap allocations. It does not allow memory leaks to happen, nor do any programs in h have the possibility to allocate memory.


Zero* Dependencies

h generates WebAssembly, so every binary produced by the compiler is completely dependency free save a single system call: h.h. This allows for modern, future-proof code that will work on all platforms.


Simple

h has a simple grammar that gzips to 117 bytes. Creating a runtime environment for h is so trivial just about anyone can do it.


Platform Support

h supports the following platforms:


International Out of the Box

h supports multiple written and spoken languages with true contextual awareness. It not only supports the Latin h as input, it also accepts the Lojbanic ' as well. This allows for full 100% internationalization into Lojban should your project needs require it.


Testimonials

Not convinced? Take the word of people we probably didn't pay for their opinion.


Open-Source

The h compiler and default runtime are open-source free software sent out into the Public Domain. You can use h for any purpose at all with no limitations or restrictions.


") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "

A simple, fast, open-source, complete and safe language for developing modern software for the web


Example Program

h

Outputs:

h

Fast Compilation

h probably compiles hundreds of characters of source per second. I didn't really test how fast it is, but when I was testing it the speed was fast enough that I didn't care to profile it.


Safety

h is completely memory safe with no garbage collector or heap allocations. It does not allow memory leaks to happen, nor do any programs in h have the possibility to allocate memory.


Zero* Dependencies

h generates WebAssembly, so every binary produced by the compiler is completely dependency free save a single system call: h.h. This allows for modern, future-proof code that will work on all platforms.


Simple

h has a simple grammar that gzips to 117 bytes. Creating a runtime environment for h is so trivial just about anyone can do it.


Platform Support

h supports the following platforms:


International Out of the Box

h supports multiple written and spoken languages with true contextual awareness. It not only supports the Latin h as input, it also accepts the Lojbanic ' as well. This allows for full 100% internationalization into Lojban should your project needs require it.


Testimonials

Not convinced? Take the word of people we probably didn't pay for their opinion.


Open-Source

The h compiler and default runtime are open-source free software sent out into the Public Domain. You can use h for any purpose at all with no limitations or restrictions.


") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } func docsPage() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { @@ -104,17 +116,20 @@ func docsPage() templ.Component { templ_7745c5c3_Var4 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Coming soon...


") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "

Coming soon...


") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } func faqPage() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { @@ -130,7 +145,7 @@ func faqPage() templ.Component { templ_7745c5c3_Var5 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

What are the instructions of h?

h supports the following instructions:

All valid h instructions must be separated by a space (\\0x20 or the spacebar on your computer). No other forms of whitespace are permitted. Any other characters will render your program gentoldra.

How do I install and use h?

With any computer running Go 1.11 or higher:

go get -u -v within.website/x/cmd/hlang
Usage is simple:
")
+		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "

What are the instructions of h?

h supports the following instructions:

  • h
  • '

All valid h instructions must be separated by a space (\\0x20 or the spacebar on your computer). No other forms of whitespace are permitted. Any other characters will render your program gentoldra.

How do I install and use h?

With any computer running Go 1.11 or higher:

go get -u -v within.website/x/cmd/hlang
Usage is simple:
")
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
@@ -143,17 +158,20 @@ func faqPage() templ.Component {
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

What version is h?

Version 1.0.1, this will hopefully be the only release.

What is the h koan?

And Jesus said unto the theologians, \"Who do you say that I am?\"

They replied: \"You are the eschatological manifestation of the ground of our being, the kerygma of which we find the ultimate meaning in our interpersonal relationships.\"

And Jesus said \"...What?\"

Some time passed and one of them spoke \"h\".

Jesus was enlightened.

Why?

That's a good question. The following blogposts may help you understand this more:

Who wrote h?

Within

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "

What version is h?

Version 1.0.1, this will hopefully be the only release.

What is the h koan?

And Jesus said unto the theologians, \"Who do you say that I am?\"

They replied: \"You are the eschatological manifestation of the ground of our being, the kerygma of which we find the ultimate meaning in our interpersonal relationships.\"

And Jesus said \"...What?\"

Some time passed and one of them spoke \"h\".

Jesus was enlightened.

Why?

That's a good question. The following blogposts may help you understand this more:

Who wrote h?

Within

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } func playgroundPage() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { @@ -169,10 +187,12 @@ func playgroundPage() templ.Component { templ_7745c5c3_Var7 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Unfortunately, Javascript is required to use this page, sorry.

Program

Output

AST

Execution time (nanoseconds):

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "

Unfortunately, Javascript is required to use this page, sorry.

Program

Output

AST

Execution time (nanoseconds):

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - return templ_7745c5c3_Err + return nil }) } + +var _ = templruntime.GeneratedTemplate diff --git a/cmd/hlang/http.go b/cmd/hlang/http.go index d581b03..a4858c1 100644 --- a/cmd/hlang/http.go +++ b/cmd/hlang/http.go @@ -16,7 +16,7 @@ import ( "within.website/x/xess" ) -//go:generate go run github.com/a-h/templ/cmd/templ@latest generate +//go:generate go tool templ generate var ( maxBytes = flag.Int64("max-playground-bytes", 75, "how many bytes of data should users be allowed to post to the playground?") diff --git a/cmd/mi/services/glance/glance.go b/cmd/mi/services/glance/glance.go index 1396b0b..9c02d61 100644 --- a/cmd/mi/services/glance/glance.go +++ b/cmd/mi/services/glance/glance.go @@ -8,7 +8,7 @@ import ( "within.website/x/cmd/mi/models" ) -//go:generate go run github.com/a-h/templ/cmd/templ@latest generate +//go:generate go tool templ generate func New(dao *models.DAO) *Glance { return &Glance{dao: dao} diff --git a/cmd/mi/services/glance/glance_templ.go b/cmd/mi/services/glance/glance_templ.go index 548ef89..26620ab 100644 --- a/cmd/mi/services/glance/glance_templ.go +++ b/cmd/mi/services/glance/glance_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.857 package glance //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/cmd/mimi/modules/scheduling/scheduling.pb.go b/cmd/mimi/modules/scheduling/scheduling.pb.go new file mode 100644 index 0000000..ece77b2 --- /dev/null +++ b/cmd/mimi/modules/scheduling/scheduling.pb.go @@ -0,0 +1,308 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: scheduling.proto + +package scheduling + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ConversationMember struct { + state protoimpl.MessageState `protogen:"open.v1"` + Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ConversationMember) Reset() { + *x = ConversationMember{} + mi := &file_scheduling_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ConversationMember) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConversationMember) ProtoMessage() {} + +func (x *ConversationMember) ProtoReflect() protoreflect.Message { + mi := &file_scheduling_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConversationMember.ProtoReflect.Descriptor instead. +func (*ConversationMember) Descriptor() ([]byte, []int) { + return file_scheduling_proto_rawDescGZIP(), []int{0} +} + +func (x *ConversationMember) GetRole() string { + if x != nil { + return x.Role + } + return "" +} + +func (x *ConversationMember) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ConversationMember) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +type ParseReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Month string `protobuf:"bytes,1,opt,name=month,proto3" json:"month,omitempty"` + ConversationMembers []*ConversationMember `protobuf:"bytes,2,rep,name=conversation_members,json=conversationMembers,proto3" json:"conversation_members,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + Date string `protobuf:"bytes,4,opt,name=date,proto3" json:"date,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ParseReq) Reset() { + *x = ParseReq{} + mi := &file_scheduling_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ParseReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ParseReq) ProtoMessage() {} + +func (x *ParseReq) ProtoReflect() protoreflect.Message { + mi := &file_scheduling_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ParseReq.ProtoReflect.Descriptor instead. +func (*ParseReq) Descriptor() ([]byte, []int) { + return file_scheduling_proto_rawDescGZIP(), []int{1} +} + +func (x *ParseReq) GetMonth() string { + if x != nil { + return x.Month + } + return "" +} + +func (x *ParseReq) GetConversationMembers() []*ConversationMember { + if x != nil { + return x.ConversationMembers + } + return nil +} + +func (x *ParseReq) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *ParseReq) GetDate() string { + if x != nil { + return x.Date + } + return "" +} + +type ParseResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + StartTime string `protobuf:"bytes,1,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` + Duration string `protobuf:"bytes,2,opt,name=duration,proto3" json:"duration,omitempty"` + Summary string `protobuf:"bytes,3,opt,name=summary,proto3" json:"summary,omitempty"` + Attendees []*ConversationMember `protobuf:"bytes,4,rep,name=attendees,proto3" json:"attendees,omitempty"` + Location string `protobuf:"bytes,5,opt,name=location,proto3" json:"location,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ParseResp) Reset() { + *x = ParseResp{} + mi := &file_scheduling_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ParseResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ParseResp) ProtoMessage() {} + +func (x *ParseResp) ProtoReflect() protoreflect.Message { + mi := &file_scheduling_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ParseResp.ProtoReflect.Descriptor instead. +func (*ParseResp) Descriptor() ([]byte, []int) { + return file_scheduling_proto_rawDescGZIP(), []int{2} +} + +func (x *ParseResp) GetStartTime() string { + if x != nil { + return x.StartTime + } + return "" +} + +func (x *ParseResp) GetDuration() string { + if x != nil { + return x.Duration + } + return "" +} + +func (x *ParseResp) GetSummary() string { + if x != nil { + return x.Summary + } + return "" +} + +func (x *ParseResp) GetAttendees() []*ConversationMember { + if x != nil { + return x.Attendees + } + return nil +} + +func (x *ParseResp) GetLocation() string { + if x != nil { + return x.Location + } + return "" +} + +var File_scheduling_proto protoreflect.FileDescriptor + +const file_scheduling_proto_rawDesc = "" + + "\n" + + "\x10scheduling.proto\x12 within.website.x.mimi.scheduling\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"R\n" + + "\x12ConversationMember\x12\x12\n" + + "\x04role\x18\x01 \x01(\tR\x04role\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12\x14\n" + + "\x05email\x18\x03 \x01(\tR\x05email\"\xb7\x01\n" + + "\bParseReq\x12\x14\n" + + "\x05month\x18\x01 \x01(\tR\x05month\x12g\n" + + "\x14conversation_members\x18\x02 \x03(\v24.within.website.x.mimi.scheduling.ConversationMemberR\x13conversationMembers\x12\x18\n" + + "\amessage\x18\x03 \x01(\tR\amessage\x12\x12\n" + + "\x04date\x18\x04 \x01(\tR\x04date\"\xd0\x01\n" + + "\tParseResp\x12\x1d\n" + + "\n" + + "start_time\x18\x01 \x01(\tR\tstartTime\x12\x1a\n" + + "\bduration\x18\x02 \x01(\tR\bduration\x12\x18\n" + + "\asummary\x18\x03 \x01(\tR\asummary\x12R\n" + + "\tattendees\x18\x04 \x03(\v24.within.website.x.mimi.scheduling.ConversationMemberR\tattendees\x12\x1a\n" + + "\blocation\x18\x05 \x01(\tR\blocation2s\n" + + "\n" + + "Scheduling\x12e\n" + + "\n" + + "ParseEmail\x12*.within.website.x.mimi.scheduling.ParseReq\x1a+.within.website.x.mimi.scheduling.ParseRespB.Z,within.website/x/cmd/mimi/modules/schedulingb\x06proto3" + +var ( + file_scheduling_proto_rawDescOnce sync.Once + file_scheduling_proto_rawDescData []byte +) + +func file_scheduling_proto_rawDescGZIP() []byte { + file_scheduling_proto_rawDescOnce.Do(func() { + file_scheduling_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_scheduling_proto_rawDesc), len(file_scheduling_proto_rawDesc))) + }) + return file_scheduling_proto_rawDescData +} + +var file_scheduling_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_scheduling_proto_goTypes = []any{ + (*ConversationMember)(nil), // 0: within.website.x.mimi.scheduling.ConversationMember + (*ParseReq)(nil), // 1: within.website.x.mimi.scheduling.ParseReq + (*ParseResp)(nil), // 2: within.website.x.mimi.scheduling.ParseResp +} +var file_scheduling_proto_depIdxs = []int32{ + 0, // 0: within.website.x.mimi.scheduling.ParseReq.conversation_members:type_name -> within.website.x.mimi.scheduling.ConversationMember + 0, // 1: within.website.x.mimi.scheduling.ParseResp.attendees:type_name -> within.website.x.mimi.scheduling.ConversationMember + 1, // 2: within.website.x.mimi.scheduling.Scheduling.ParseEmail:input_type -> within.website.x.mimi.scheduling.ParseReq + 2, // 3: within.website.x.mimi.scheduling.Scheduling.ParseEmail:output_type -> within.website.x.mimi.scheduling.ParseResp + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_scheduling_proto_init() } +func file_scheduling_proto_init() { + if File_scheduling_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_scheduling_proto_rawDesc), len(file_scheduling_proto_rawDesc)), + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_scheduling_proto_goTypes, + DependencyIndexes: file_scheduling_proto_depIdxs, + MessageInfos: file_scheduling_proto_msgTypes, + }.Build() + File_scheduling_proto = out.File + file_scheduling_proto_goTypes = nil + file_scheduling_proto_depIdxs = nil +} diff --git a/cmd/mimi/modules/scheduling/scheduling.twirp.go b/cmd/mimi/modules/scheduling/scheduling.twirp.go new file mode 100644 index 0000000..bbe329d --- /dev/null +++ b/cmd/mimi/modules/scheduling/scheduling.twirp.go @@ -0,0 +1,1115 @@ +// Code generated by protoc-gen-twirp v8.1.3, DO NOT EDIT. +// source: scheduling.proto + +package scheduling + +import context "context" +import fmt "fmt" +import http "net/http" +import io "io" +import json "encoding/json" +import strconv "strconv" +import strings "strings" + +import protojson "google.golang.org/protobuf/encoding/protojson" +import proto "google.golang.org/protobuf/proto" +import twirp "github.com/twitchtv/twirp" +import ctxsetters "github.com/twitchtv/twirp/ctxsetters" + +import bytes "bytes" +import errors "errors" +import path "path" +import url "net/url" + +// Version compatibility assertion. +// If the constant is not defined in the package, that likely means +// the package needs to be updated to work with this generated code. +// See https://twitchtv.github.io/twirp/docs/version_matrix.html +const _ = twirp.TwirpPackageMinVersion_8_1_0 + +// ==================== +// Scheduling Interface +// ==================== + +type Scheduling interface { + ParseEmail(context.Context, *ParseReq) (*ParseResp, error) +} + +// ========================== +// Scheduling Protobuf Client +// ========================== + +type schedulingProtobufClient struct { + client HTTPClient + urls [1]string + interceptor twirp.Interceptor + opts twirp.ClientOptions +} + +// NewSchedulingProtobufClient creates a Protobuf client that implements the Scheduling interface. +// It communicates using Protobuf and can be configured with a custom HTTPClient. +func NewSchedulingProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Scheduling { + if c, ok := client.(*http.Client); ok { + client = withoutRedirects(c) + } + + clientOpts := twirp.ClientOptions{} + for _, o := range opts { + o(&clientOpts) + } + + // Using ReadOpt allows backwards and forwards compatibility with new options in the future + literalURLs := false + _ = clientOpts.ReadOpt("literalURLs", &literalURLs) + var pathPrefix string + if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { + pathPrefix = "/twirp" // default prefix + } + + // Build method URLs: []/./ + serviceURL := sanitizeBaseURL(baseURL) + serviceURL += baseServicePath(pathPrefix, "within.website.x.mimi.scheduling", "Scheduling") + urls := [1]string{ + serviceURL + "ParseEmail", + } + + return &schedulingProtobufClient{ + client: client, + urls: urls, + interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), + opts: clientOpts, + } +} + +func (c *schedulingProtobufClient) ParseEmail(ctx context.Context, in *ParseReq) (*ParseResp, error) { + ctx = ctxsetters.WithPackageName(ctx, "within.website.x.mimi.scheduling") + ctx = ctxsetters.WithServiceName(ctx, "Scheduling") + ctx = ctxsetters.WithMethodName(ctx, "ParseEmail") + caller := c.callParseEmail + if c.interceptor != nil { + caller = func(ctx context.Context, req *ParseReq) (*ParseResp, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ParseReq) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ParseReq) when calling interceptor") + } + return c.callParseEmail(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ParseResp) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ParseResp) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *schedulingProtobufClient) callParseEmail(ctx context.Context, in *ParseReq) (*ParseResp, error) { + out := new(ParseResp) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +// ====================== +// Scheduling JSON Client +// ====================== + +type schedulingJSONClient struct { + client HTTPClient + urls [1]string + interceptor twirp.Interceptor + opts twirp.ClientOptions +} + +// NewSchedulingJSONClient creates a JSON client that implements the Scheduling interface. +// It communicates using JSON and can be configured with a custom HTTPClient. +func NewSchedulingJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Scheduling { + if c, ok := client.(*http.Client); ok { + client = withoutRedirects(c) + } + + clientOpts := twirp.ClientOptions{} + for _, o := range opts { + o(&clientOpts) + } + + // Using ReadOpt allows backwards and forwards compatibility with new options in the future + literalURLs := false + _ = clientOpts.ReadOpt("literalURLs", &literalURLs) + var pathPrefix string + if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { + pathPrefix = "/twirp" // default prefix + } + + // Build method URLs: []/./ + serviceURL := sanitizeBaseURL(baseURL) + serviceURL += baseServicePath(pathPrefix, "within.website.x.mimi.scheduling", "Scheduling") + urls := [1]string{ + serviceURL + "ParseEmail", + } + + return &schedulingJSONClient{ + client: client, + urls: urls, + interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), + opts: clientOpts, + } +} + +func (c *schedulingJSONClient) ParseEmail(ctx context.Context, in *ParseReq) (*ParseResp, error) { + ctx = ctxsetters.WithPackageName(ctx, "within.website.x.mimi.scheduling") + ctx = ctxsetters.WithServiceName(ctx, "Scheduling") + ctx = ctxsetters.WithMethodName(ctx, "ParseEmail") + caller := c.callParseEmail + if c.interceptor != nil { + caller = func(ctx context.Context, req *ParseReq) (*ParseResp, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ParseReq) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ParseReq) when calling interceptor") + } + return c.callParseEmail(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ParseResp) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ParseResp) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *schedulingJSONClient) callParseEmail(ctx context.Context, in *ParseReq) (*ParseResp, error) { + out := new(ParseResp) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +// ========================= +// Scheduling Server Handler +// ========================= + +type schedulingServer struct { + Scheduling + interceptor twirp.Interceptor + hooks *twirp.ServerHooks + pathPrefix string // prefix for routing + jsonSkipDefaults bool // do not include unpopulated fields (default values) in the response + jsonCamelCase bool // JSON fields are serialized as lowerCamelCase rather than keeping the original proto names +} + +// NewSchedulingServer builds a TwirpServer that can be used as an http.Handler to handle +// HTTP requests that are routed to the right method in the provided svc implementation. +// The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks). +func NewSchedulingServer(svc Scheduling, opts ...interface{}) TwirpServer { + serverOpts := newServerOpts(opts) + + // Using ReadOpt allows backwards and forwards compatibility with new options in the future + jsonSkipDefaults := false + _ = serverOpts.ReadOpt("jsonSkipDefaults", &jsonSkipDefaults) + jsonCamelCase := false + _ = serverOpts.ReadOpt("jsonCamelCase", &jsonCamelCase) + var pathPrefix string + if ok := serverOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { + pathPrefix = "/twirp" // default prefix + } + + return &schedulingServer{ + Scheduling: svc, + hooks: serverOpts.Hooks, + interceptor: twirp.ChainInterceptors(serverOpts.Interceptors...), + pathPrefix: pathPrefix, + jsonSkipDefaults: jsonSkipDefaults, + jsonCamelCase: jsonCamelCase, + } +} + +// writeError writes an HTTP response with a valid Twirp error format, and triggers hooks. +// If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err) +func (s *schedulingServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) { + writeError(ctx, resp, err, s.hooks) +} + +// handleRequestBodyError is used to handle error when the twirp server cannot read request +func (s *schedulingServer) handleRequestBodyError(ctx context.Context, resp http.ResponseWriter, msg string, err error) { + if context.Canceled == ctx.Err() { + s.writeError(ctx, resp, twirp.NewError(twirp.Canceled, "failed to read request: context canceled")) + return + } + if context.DeadlineExceeded == ctx.Err() { + s.writeError(ctx, resp, twirp.NewError(twirp.DeadlineExceeded, "failed to read request: deadline exceeded")) + return + } + s.writeError(ctx, resp, twirp.WrapError(malformedRequestError(msg), err)) +} + +// SchedulingPathPrefix is a convenience constant that may identify URL paths. +// Should be used with caution, it only matches routes generated by Twirp Go clients, +// with the default "/twirp" prefix and default CamelCase service and method names. +// More info: https://twitchtv.github.io/twirp/docs/routing.html +const SchedulingPathPrefix = "/twirp/within.website.x.mimi.scheduling.Scheduling/" + +func (s *schedulingServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { + ctx := req.Context() + ctx = ctxsetters.WithPackageName(ctx, "within.website.x.mimi.scheduling") + ctx = ctxsetters.WithServiceName(ctx, "Scheduling") + ctx = ctxsetters.WithResponseWriter(ctx, resp) + + var err error + ctx, err = callRequestReceived(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + if req.Method != "POST" { + msg := fmt.Sprintf("unsupported method %q (only POST is allowed)", req.Method) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } + + // Verify path format: []/./ + prefix, pkgService, method := parseTwirpPath(req.URL.Path) + if pkgService != "within.website.x.mimi.scheduling.Scheduling" { + msg := fmt.Sprintf("no handler for path %q", req.URL.Path) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } + if prefix != s.pathPrefix { + msg := fmt.Sprintf("invalid path prefix %q, expected %q, on path %q", prefix, s.pathPrefix, req.URL.Path) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } + + switch method { + case "ParseEmail": + s.serveParseEmail(ctx, resp, req) + return + default: + msg := fmt.Sprintf("no handler for path %q", req.URL.Path) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } +} + +func (s *schedulingServer) serveParseEmail(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveParseEmailJSON(ctx, resp, req) + case "application/protobuf": + s.serveParseEmailProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *schedulingServer) serveParseEmailJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ParseEmail") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(ParseReq) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.Scheduling.ParseEmail + if s.interceptor != nil { + handler = func(ctx context.Context, req *ParseReq) (*ParseResp, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ParseReq) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ParseReq) when calling interceptor") + } + return s.Scheduling.ParseEmail(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ParseResp) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ParseResp) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ParseResp + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ParseResp and nil error while calling ParseEmail. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *schedulingServer) serveParseEmailProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ParseEmail") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(ParseReq) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.Scheduling.ParseEmail + if s.interceptor != nil { + handler = func(ctx context.Context, req *ParseReq) (*ParseResp, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := r