alpha
Login
or
Join now
gwen.works
/
churros-notella
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
fix(ts): properly compile to js
author
Gwen Le Bihan
date
1 year ago
(Feb 5, 2025, 6:54 PM +0100)
commit
ee98ae86
ee98ae860e011093ce13821562a2dd09f97ac9e8
parent
846db224
846db224dd65a2b2f0c7489a63c0e7c541075b7d
+117
-66
13 changed files
Expand all
Collapse all
Unified
Split
Justfile
go.mod
go.sum
package.json
scripts
typing.go
tsconfig.json
typescript
configuration.js
constants.js
health.js
index.js
message.js
typescript-dist
index.js
index.js.map
-1
Justfile
Reviewed
···
35
35
36
36
gen_typescript:
37
37
go run scripts/typing.go
38
38
-
npm run tsc typescript/*
39
38
40
39
generate:
41
40
just updateschema
+1
go.mod
Reviewed
···
7
7
github.com/SherClockHolmes/webpush-go v1.4.0
8
8
github.com/caarlos0/env/v11 v11.3.1
9
9
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be
10
10
+
github.com/evanw/esbuild v0.24.2
10
11
github.com/gwennlbh/label-logger-go v0.1.5
11
12
github.com/invopop/jsonschema v0.13.0
12
13
github.com/joho/godotenv v1.5.1
+5
-2
go.sum
Reviewed
···
48
48
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
49
49
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
50
50
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
51
51
+
github.com/evanw/esbuild v0.24.2 h1:PQExybVBrjHjN6/JJiShRGIXh1hWVm6NepVnhZhrt0A=
52
52
+
github.com/evanw/esbuild v0.24.2/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48=
51
53
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
52
54
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
53
55
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
···
197
199
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
198
200
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
199
201
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
200
200
-
golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70=
201
201
-
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
202
202
+
golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE=
203
203
+
golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
202
204
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
203
205
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
204
206
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
···
216
218
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
217
219
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
218
220
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
221
221
+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
219
222
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
220
223
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
221
224
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+4
-4
package.json
Reviewed
···
39
39
},
40
40
"files": [
41
41
"README.md",
42
42
-
"typescript/*.ts",
43
43
-
"typescript/*.js"
42
42
+
"typescript-dist/*.js",
43
43
+
"typescript/*.ts"
44
44
],
45
45
"exports": {
46
46
".": {
47
47
-
"default": "./typescript/index.js",
48
48
-
"types": "./typescript/index.ts"
47
47
+
"types": "./typescript/index.ts",
48
48
+
"default": "./typescript-dist/index.js"
49
49
}
50
50
}
51
51
}
+53
scripts/typing.go
Reviewed
···
10
10
11
11
"git.inpt.fr/churros/notella"
12
12
"github.com/invopop/jsonschema"
13
13
+
14
14
+
esbuild "github.com/evanw/esbuild/pkg/api"
15
15
+
ll "github.com/gwennlbh/label-logger-go"
13
16
)
14
17
15
18
func main() {
19
19
+
ll.Log("Reflecting", "cyan", "structs")
16
20
reflector := new(jsonschema.Reflector)
17
21
if err := reflector.AddGoComments("git.inpt.fr/churros/notella", "./"); err != nil {
18
22
fmt.Printf("Error adding Go comments: %v\n", err)
19
23
}
20
24
25
25
+
ll.Log("Writing", "cyan", "typescript types")
21
26
writeTypescriptDefinition(reflector, "Message", ¬ella.Message{}, "typescript/message.ts")
22
27
writeTypescriptDefinition(reflector, "HealthResponse", ¬ella.HealthResponse{}, "typescript/health.ts")
23
28
reflector.FieldNameTag = "env"
24
29
writeTypescriptDefinition(reflector, "Configuration", ¬ella.Configuration{}, "typescript/configuration.ts")
25
30
26
31
// Also save useful constants
32
32
+
ll.Log("Writing", "cyan", "exported constants")
27
33
os.WriteFile("typescript/constants.ts", []byte(fmt.Sprintf("export const STREAM_NAME = '%s';\nexport const SUBJECT_NAME = '%s';\n", notella.StreamName, notella.SubjectName)), 0644)
28
34
29
35
// Write barrel
36
36
+
ll.Log("Writing", "cyan", "barrel file")
30
37
os.WriteFile("typescript/index.ts", []byte(strings.Join([]string{
31
38
"export * from './message.js';",
32
39
"export * from './configuration.js';",
33
40
"export * from './health.js';",
34
41
"export * from './constants.js';",
35
42
}, "\n")), 0644)
43
43
+
44
44
+
ll.Log("Transpiling", "cyan", "to JS using esbuild")
45
45
+
result := esbuild.Build(esbuild.BuildOptions{
46
46
+
EntryPoints: []string{"typescript/index.ts"},
47
47
+
Outdir: "typescript-dist/",
48
48
+
Bundle: true,
49
49
+
Sourcemap: esbuild.SourceMapLinked,
50
50
+
Format: esbuild.FormatESModule,
51
51
+
Platform: esbuild.PlatformNeutral,
52
52
+
})
53
53
+
54
54
+
for _, msg := range result.Warnings {
55
55
+
ll.Warn(formatEsbuildMessage(msg))
56
56
+
}
57
57
+
58
58
+
if len(result.Errors) > 0 {
59
59
+
for _, msg := range result.Errors {
60
60
+
ll.Error(formatEsbuildMessage(msg))
61
61
+
os.Exit(1)
62
62
+
}
63
63
+
} else {
64
64
+
for _, file := range result.OutputFiles {
65
65
+
err := os.WriteFile(file.Path, file.Contents, 0o677)
66
66
+
if err != nil {
67
67
+
ll.ErrorDisplay("could not write %s [%s]", err, file.Path, file.Hash)
68
68
+
os.Exit(1)
69
69
+
}
70
70
+
ll.Log("Wrote", "blue", "%s [dim][%s][reset]", file.Path, file.Hash)
71
71
+
}
72
72
+
ll.Log("Built", "green", "typescript library to [bold]typescript-dist/[reset]")
73
73
+
}
74
74
+
}
75
75
+
76
76
+
func formatEsbuildMessage(msg esbuild.Message) string {
77
77
+
notes := ""
78
78
+
for _, note := range msg.Notes {
79
79
+
notes += fmt.Sprintf("\nat %s: %s", formatEsbuildLocation(note.Location), note.Text)
80
80
+
}
81
81
+
return fmt.Sprintf("at %s: %s%s", formatEsbuildLocation(msg.Location), msg.Text, notes)
82
82
+
}
83
83
+
84
84
+
func formatEsbuildLocation(loc *esbuild.Location) string {
85
85
+
if loc == nil {
86
86
+
return ""
87
87
+
}
88
88
+
return fmt.Sprintf("[blue]%s:%d:%d[reset]", loc.File, loc.Line, loc.Column)
36
89
}
37
90
38
91
func writeTypescriptDefinition(reflector *jsonschema.Reflector, typename string, typ interface{}, filename string) {
+12
tsconfig.json
Reviewed
···
1
1
+
{
2
2
+
"compilerOptions": {
3
3
+
"target": "ESNext",
4
4
+
"module": "ESNext",
5
5
+
"moduleResolution": "Node",
6
6
+
"declaration": true,
7
7
+
"outDir": "typescript-dist",
8
8
+
"rootDir": "typescript",
9
9
+
"strict": true
10
10
+
},
11
11
+
"include": ["typescript"]
12
12
+
}
+35
typescript-dist/index.js
Reviewed
···
1
1
+
// typescript/message.ts
2
2
+
var Event = /* @__PURE__ */ ((Event2) => {
3
3
+
Event2["BookingPaid"] = "booking_paid";
4
4
+
Event2["ClearSchedule"] = "clear_schedule";
5
5
+
Event2["ClearScheduledJobs"] = "clear_scheduled_jobs";
6
6
+
Event2["ClearStoredSchedule"] = "clear_stored_schedule";
7
7
+
Event2["CommentReply"] = "comment_reply";
8
8
+
Event2["ContributionPaid"] = "contribution_paid";
9
9
+
Event2["Custom"] = "custom";
10
10
+
Event2["GodchildAccepted"] = "godchild_accepted";
11
11
+
Event2["GodchildRejected"] = "godchild_rejected";
12
12
+
Event2["GodchildRequest"] = "godchild_request";
13
13
+
Event2["LoginStuck"] = "login_stuck";
14
14
+
Event2["NewComment"] = "new_comment";
15
15
+
Event2["NewPost"] = "new_post";
16
16
+
Event2["PendingSignup"] = "pending_signup";
17
17
+
Event2["RestoreSchedule"] = "restore_schedule";
18
18
+
Event2["RestoreScheduleEager"] = "restore_schedule_eager";
19
19
+
Event2["SaveSchedule"] = "save_schedule";
20
20
+
Event2["ShotgunClosesSoon"] = "shotgun_closes_soon";
21
21
+
Event2["ShotgunOpensSoon"] = "shotgun_opens_soon";
22
22
+
Event2["ShowScheduledJobs"] = "show_scheduled_jobs";
23
23
+
Event2["Test"] = "test";
24
24
+
return Event2;
25
25
+
})(Event || {});
26
26
+
27
27
+
// typescript/constants.ts
28
28
+
var STREAM_NAME = "notella:stream";
29
29
+
var SUBJECT_NAME = "notella:notification";
30
30
+
export {
31
31
+
Event,
32
32
+
STREAM_NAME,
33
33
+
SUBJECT_NAME
34
34
+
};
35
35
+
//# sourceMappingURL=index.js.map
+7
typescript-dist/index.js.map
Reviewed
···
1
1
+
{
2
2
+
"version": 3,
3
3
+
"sources": ["../typescript/message.ts", "../typescript/constants.ts"],
4
4
+
"sourcesContent": ["export interface Message {\n /**\n * URL to go to when the action button is clicked\n */\n action: string;\n /**\n * Additional action buttons\n */\n actions?: Action[];\n /**\n * Notification body\n */\n body: string;\n /**\n * Type of event that triggered the notification\n */\n event: Event;\n /**\n * Unique ID for the notification scheduling request.\n */\n id: string;\n /**\n * URL to an image to display in the notification\n */\n image?: string;\n /**\n * Churros ID of the ressource (the ticket, the post, the comment, etc)\n * Used to determine to whom the notification should be sent\n * For godchild_request, this is not a user id, but a godparent request id.\n */\n object_id: string;\n /**\n * When to push the notification\n */\n send_at: Date;\n /**\n * Notification title\n */\n title: string;\n}\n\nexport interface Action {\n action: string;\n label: string;\n}\n\n/**\n * Type of event that triggered the notification\n */\nexport enum Event {\n BookingPaid = \"booking_paid\",\n ClearSchedule = \"clear_schedule\",\n ClearScheduledJobs = \"clear_scheduled_jobs\",\n ClearStoredSchedule = \"clear_stored_schedule\",\n CommentReply = \"comment_reply\",\n ContributionPaid = \"contribution_paid\",\n Custom = \"custom\",\n GodchildAccepted = \"godchild_accepted\",\n GodchildRejected = \"godchild_rejected\",\n GodchildRequest = \"godchild_request\",\n LoginStuck = \"login_stuck\",\n NewComment = \"new_comment\",\n NewPost = \"new_post\",\n PendingSignup = \"pending_signup\",\n RestoreSchedule = \"restore_schedule\",\n RestoreScheduleEager = \"restore_schedule_eager\",\n SaveSchedule = \"save_schedule\",\n ShotgunClosesSoon = \"shotgun_closes_soon\",\n ShotgunOpensSoon = \"shotgun_opens_soon\",\n ShowScheduledJobs = \"show_scheduled_jobs\",\n Test = \"test\",\n}\n", "export const STREAM_NAME = 'notella:stream';\nexport const SUBJECT_NAME = 'notella:notification';\n"],
5
5
+
"mappings": ";AAiDO,IAAK,QAAL,kBAAKA,WAAL;AACH,EAAAA,OAAA,iBAAc;AACd,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,wBAAqB;AACrB,EAAAA,OAAA,yBAAsB;AACtB,EAAAA,OAAA,kBAAe;AACf,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,YAAS;AACT,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,gBAAa;AACb,EAAAA,OAAA,gBAAa;AACb,EAAAA,OAAA,aAAU;AACV,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,0BAAuB;AACvB,EAAAA,OAAA,kBAAe;AACf,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,UAAO;AArBC,SAAAA;AAAA,GAAA;;;ACjDL,IAAM,cAAc;AACpB,IAAM,eAAe;",
6
6
+
"names": ["Event"]
7
7
+
}
-2
typescript/configuration.js
Reviewed
···
1
1
-
"use strict";
2
2
-
Object.defineProperty(exports, "__esModule", { value: true });
-5
typescript/constants.js
Reviewed
···
1
1
-
"use strict";
2
2
-
Object.defineProperty(exports, "__esModule", { value: true });
3
3
-
exports.SUBJECT_NAME = exports.STREAM_NAME = void 0;
4
4
-
exports.STREAM_NAME = 'notella:stream';
5
5
-
exports.SUBJECT_NAME = 'notella:notification';
-2
typescript/health.js
Reviewed
···
1
1
-
"use strict";
2
2
-
Object.defineProperty(exports, "__esModule", { value: true });
-20
typescript/index.js
Reviewed
···
1
1
-
"use strict";
2
2
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
-
if (k2 === undefined) k2 = k;
4
4
-
var desc = Object.getOwnPropertyDescriptor(m, k);
5
5
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
6
-
desc = { enumerable: true, get: function() { return m[k]; } };
7
7
-
}
8
8
-
Object.defineProperty(o, k2, desc);
9
9
-
}) : (function(o, m, k, k2) {
10
10
-
if (k2 === undefined) k2 = k;
11
11
-
o[k2] = m[k];
12
12
-
}));
13
13
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
-
};
16
16
-
Object.defineProperty(exports, "__esModule", { value: true });
17
17
-
__exportStar(require("./message.js"), exports);
18
18
-
__exportStar(require("./configuration.js"), exports);
19
19
-
__exportStar(require("./health.js"), exports);
20
20
-
__exportStar(require("./constants.js"), exports);
-30
typescript/message.js
Reviewed
···
1
1
-
"use strict";
2
2
-
Object.defineProperty(exports, "__esModule", { value: true });
3
3
-
exports.Event = void 0;
4
4
-
/**
5
5
-
* Type of event that triggered the notification
6
6
-
*/
7
7
-
var Event;
8
8
-
(function (Event) {
9
9
-
Event["BookingPaid"] = "booking_paid";
10
10
-
Event["ClearSchedule"] = "clear_schedule";
11
11
-
Event["ClearScheduledJobs"] = "clear_scheduled_jobs";
12
12
-
Event["ClearStoredSchedule"] = "clear_stored_schedule";
13
13
-
Event["CommentReply"] = "comment_reply";
14
14
-
Event["ContributionPaid"] = "contribution_paid";
15
15
-
Event["Custom"] = "custom";
16
16
-
Event["GodchildAccepted"] = "godchild_accepted";
17
17
-
Event["GodchildRejected"] = "godchild_rejected";
18
18
-
Event["GodchildRequest"] = "godchild_request";
19
19
-
Event["LoginStuck"] = "login_stuck";
20
20
-
Event["NewComment"] = "new_comment";
21
21
-
Event["NewPost"] = "new_post";
22
22
-
Event["PendingSignup"] = "pending_signup";
23
23
-
Event["RestoreSchedule"] = "restore_schedule";
24
24
-
Event["RestoreScheduleEager"] = "restore_schedule_eager";
25
25
-
Event["SaveSchedule"] = "save_schedule";
26
26
-
Event["ShotgunClosesSoon"] = "shotgun_closes_soon";
27
27
-
Event["ShotgunOpensSoon"] = "shotgun_opens_soon";
28
28
-
Event["ShowScheduledJobs"] = "show_scheduled_jobs";
29
29
-
Event["Test"] = "test";
30
30
-
})(Event || (exports.Event = Event = {}));