create-gramstax 0.1.0 → 0.1.2

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.
Files changed (36) hide show
  1. package/LICENSE +25 -25
  2. package/dist/src/index.cjs +0 -0
  3. package/dist/src/index.js +0 -0
  4. package/dist/src/templates/.env.example +14 -14
  5. package/dist/src/templates/.prettierrc +23 -23
  6. package/dist/src/templates/README.md +120 -120
  7. package/dist/src/templates/bunfig.toml +1 -1
  8. package/dist/src/templates/package.json +1 -1
  9. package/dist/src/templates/src/base/guard.ts +11 -11
  10. package/dist/src/templates/src/base/index.ts +4 -4
  11. package/dist/src/templates/src/base/page.ts +3 -3
  12. package/dist/src/templates/src/base/repository.ts +1 -1
  13. package/dist/src/templates/src/base/service.ts +1 -1
  14. package/dist/src/templates/src/core/bot.ts +23 -23
  15. package/dist/src/templates/src/core/ctx.ts +3 -3
  16. package/dist/src/templates/src/core/index.ts +2 -2
  17. package/dist/src/templates/src/db/index.ts +1 -1
  18. package/dist/src/templates/src/env.ts +5 -5
  19. package/dist/src/templates/src/guards/index.ts +1 -1
  20. package/dist/src/templates/src/guards/user.ts +19 -19
  21. package/dist/src/templates/src/index.ts +15 -15
  22. package/dist/src/templates/src/pages/general-error-input-notfound.ts +28 -28
  23. package/dist/src/templates/src/pages/general-error.ts +60 -60
  24. package/dist/src/templates/src/pages/help.ts +49 -49
  25. package/dist/src/templates/src/pages/start.ts +69 -69
  26. package/dist/src/templates/src/pages/username-notfound.ts +33 -33
  27. package/dist/src/templates/src/repositories/example.ts +3 -3
  28. package/dist/src/templates/src/repositories/index.ts +1 -1
  29. package/dist/src/templates/src/services/example.ts +3 -3
  30. package/dist/src/templates/src/services/index.ts +1 -1
  31. package/dist/src/templates/src/threads/index.ts +1 -1
  32. package/dist/src/templates/src/threads/main.ts +9 -9
  33. package/dist/src/templates/src/utils/index.ts +1 -1
  34. package/dist/src/templates/src/utils/log.ts +2 -2
  35. package/dist/src/templates/tsconfig.json +37 -37
  36. package/package.json +63 -63
@@ -1,60 +1,60 @@
1
- import { log } from "~/utils"
2
- import { PageBase } from "~/base"
3
- import { StartPage } from "./start"
4
-
5
- export class GeneralErrorPage extends PageBase {
6
- public kb() {
7
- return this.inlineKeyboard((kb, arr) => {
8
- return kb.text(arr[0]!, StartPage.data.callbackData())
9
- })
10
- }
11
-
12
- public async transition(constructorName: string, funcName: string, error: unknown, isUpdate = true) {
13
- log.errorMake(error, constructorName, funcName)
14
- await this.sessionClear()
15
-
16
- const kb = this.kb()
17
- if (isUpdate === true) {
18
- await this.edit(kb)
19
- } else {
20
- await this.reply(kb)
21
- }
22
- }
23
-
24
- public static template = /*jsx*/ `
25
- <base>
26
- <keyboard type="inline">.. Home</keyboard>
27
- <keyboard lang="en" type="inline">.. Home</keyboard>
28
- <keyboard lang="es" type="inline">.. Inicio</keyboard>
29
- <keyboard lang="id" type="inline">.. Beranda</keyboard>
30
-
31
- <message>
32
- <b>❌ Error</b>
33
-
34
- An unexpected error occurred.
35
- Please try again later.
36
- </message>
37
-
38
- <message lang="en">
39
- <b>❌ Error</b>
40
-
41
- An unexpected error occurred.
42
- Please try again later.
43
- </message>
44
-
45
- <message lang="it">
46
- <b>❌ Errore</b>
47
-
48
- Si è verificato un errore imprevisto.
49
- Riprova più tardi.
50
- </message>
51
-
52
- <message lang="id">
53
- <b>❌ Kesalahan</b>
54
-
55
- Terjadi kesalahan yang tidak diharapkan.
56
- Silakan coba lagi nanti.
57
- </message>
58
- </base>
59
- `
60
- }
1
+ import { log } from "~/utils"
2
+ import { PageBase } from "~/base"
3
+ import { StartPage } from "./start"
4
+
5
+ export class GeneralErrorPage extends PageBase {
6
+ public kb() {
7
+ return this.inlineKeyboard((kb, arr) => {
8
+ return kb.text(arr[0]!, StartPage.data.callbackData())
9
+ })
10
+ }
11
+
12
+ public async transition(constructorName: string, funcName: string, error: unknown, isUpdate = true) {
13
+ log.errorMake(error, constructorName, funcName)
14
+ await this.sessionClear()
15
+
16
+ const kb = this.kb()
17
+ if (isUpdate === true) {
18
+ await this.edit(kb)
19
+ } else {
20
+ await this.reply(kb)
21
+ }
22
+ }
23
+
24
+ public static template = /*jsx*/ `
25
+ <base>
26
+ <keyboard type="inline">.. Home</keyboard>
27
+ <keyboard lang="en" type="inline">.. Home</keyboard>
28
+ <keyboard lang="es" type="inline">.. Inicio</keyboard>
29
+ <keyboard lang="id" type="inline">.. Beranda</keyboard>
30
+
31
+ <message>
32
+ <b>❌ Error</b>
33
+
34
+ An unexpected error occurred.
35
+ Please try again later.
36
+ </message>
37
+
38
+ <message lang="en">
39
+ <b>❌ Error</b>
40
+
41
+ An unexpected error occurred.
42
+ Please try again later.
43
+ </message>
44
+
45
+ <message lang="it">
46
+ <b>❌ Errore</b>
47
+
48
+ Si è verificato un errore imprevisto.
49
+ Riprova più tardi.
50
+ </message>
51
+
52
+ <message lang="id">
53
+ <b>❌ Kesalahan</b>
54
+
55
+ Terjadi kesalahan yang tidak diharapkan.
56
+ Silakan coba lagi nanti.
57
+ </message>
58
+ </base>
59
+ `
60
+ }
@@ -1,49 +1,49 @@
1
- import { PageBase } from "~/base"
2
- import { StartPage } from "./start"
3
-
4
- export class HelpPage extends PageBase {
5
- public kb() {
6
- return this.inlineKeyboard((kb, arr) => {
7
- return kb.text(arr[0]!, StartPage.data.callbackData())
8
- })
9
- }
10
-
11
- public async internal(edit = true) {
12
- const kb = this.kb()
13
- if (edit) {
14
- await this.edit(kb)
15
- } else {
16
- await this.reply(kb)
17
- }
18
- }
19
-
20
- public async callback() {
21
- await this.internal(true)
22
- }
23
-
24
- public async text() {
25
- await this.internal(false)
26
- }
27
-
28
- public async textCommand() {
29
- await this.internal(false)
30
- }
31
-
32
- public async textCommandPayload() {
33
- await this.internal(false)
34
- }
35
-
36
- public static template = /*jsx*/ `
37
- <base>
38
- <keyboard type="inline">.. Back</keyboard>
39
- <keyboard lang="en" type="inline">.. Back</keyboard>
40
- <keyboard lang="it" type="inline">.. Ritorno</keyboard>
41
- <keyboard lang="id" type="inline">.. Kembali</keyboard>
42
-
43
- <message><b>Help message</b></message>
44
- <message lang="en"><b>Help message</b></message>
45
- <message lang="it"><b>Ordina aiuto</b></message>
46
- <message lang="id"><b>Pesan bantuan</b></message>
47
- </base>
48
- `
49
- }
1
+ import { PageBase } from "~/base"
2
+ import { StartPage } from "./start"
3
+
4
+ export class HelpPage extends PageBase {
5
+ public kb() {
6
+ return this.inlineKeyboard((kb, arr) => {
7
+ return kb.text(arr[0]!, StartPage.data.callbackData())
8
+ })
9
+ }
10
+
11
+ public async internal(edit = true) {
12
+ const kb = this.kb()
13
+ if (edit) {
14
+ await this.edit(kb)
15
+ } else {
16
+ await this.reply(kb)
17
+ }
18
+ }
19
+
20
+ public async callback() {
21
+ await this.internal(true)
22
+ }
23
+
24
+ public async text() {
25
+ await this.internal(false)
26
+ }
27
+
28
+ public async textCommand() {
29
+ await this.internal(false)
30
+ }
31
+
32
+ public async textCommandPayload() {
33
+ await this.internal(false)
34
+ }
35
+
36
+ public static template = /*jsx*/ `
37
+ <base>
38
+ <keyboard type="inline">.. Back</keyboard>
39
+ <keyboard lang="en" type="inline">.. Back</keyboard>
40
+ <keyboard lang="it" type="inline">.. Ritorno</keyboard>
41
+ <keyboard lang="id" type="inline">.. Kembali</keyboard>
42
+
43
+ <message><b>Help message</b></message>
44
+ <message lang="en"><b>Help message</b></message>
45
+ <message lang="it"><b>Ordina aiuto</b></message>
46
+ <message lang="id"><b>Pesan bantuan</b></message>
47
+ </base>
48
+ `
49
+ }
@@ -1,69 +1,69 @@
1
- import { HelpPage } from "./help"
2
- import { PageBase } from "~/base"
3
-
4
- export class StartPage extends PageBase {
5
- public kb() {
6
- return this.inlineKeyboard((kb, arr) => {
7
- return kb.text(arr[0]!, HelpPage.data.callbackData())
8
- })
9
- }
10
-
11
- public async internal(edit = true) {
12
- const kb = this.kb()
13
- const data = { userName: this.userName }
14
- if (edit) {
15
- await this.edit(kb, data)
16
- } else {
17
- await this.reply(kb, data)
18
- }
19
- }
20
-
21
- public async callback() {
22
- await this.internal(true)
23
- }
24
-
25
- public async text() {
26
- await this.internal(false)
27
- }
28
-
29
- public async textCommand() {
30
- await this.internal(false)
31
- }
32
-
33
- public async textCommandPayload() {
34
- await this.internal(false)
35
- }
36
-
37
- public static template = /*jsx*/ `
38
- <base>
39
- <keyboard type="inline">❓ Help</keyboard>
40
- <keyboard lang="en" type="inline">❓ Help</keyboard>
41
- <keyboard lang="it" type="inline">❓ Aiuto</keyboard>
42
- <keyboard lang="id" type="inline">❓ Bantuan</keyboard>
43
-
44
- <message>
45
- <b>Welcome to the bot {{userName}}</b>
46
-
47
- <b>❓ Help</b> - View help
48
- </message>
49
-
50
- <message lang="en">
51
- <b>Welcome to the bot {{userName}}</b>
52
-
53
- <b>❓ Help</b> - View help
54
- </message>
55
-
56
- <message lang="it">
57
- <b>Benvenuto nel Bot di {{userName}}</b>
58
-
59
- <b>❓ Aiuto</b> - Ottieni assistenza e informazioni
60
- </message>
61
-
62
- <message lang="id">
63
- <b>Selamat datang di bot {{userName}}</b>
64
-
65
- <b>❓ Bantuan</b> - Lihat bantuan
66
- </message>
67
- </base>
68
- `
69
- }
1
+ import { HelpPage } from "./help"
2
+ import { PageBase } from "~/base"
3
+
4
+ export class StartPage extends PageBase {
5
+ public kb() {
6
+ return this.inlineKeyboard((kb, arr) => {
7
+ return kb.text(arr[0]!, HelpPage.data.callbackData())
8
+ })
9
+ }
10
+
11
+ public async internal(edit = true) {
12
+ const kb = this.kb()
13
+ const data = { userName: this.userName }
14
+ if (edit) {
15
+ await this.edit(kb, data)
16
+ } else {
17
+ await this.reply(kb, data)
18
+ }
19
+ }
20
+
21
+ public async callback() {
22
+ await this.internal(true)
23
+ }
24
+
25
+ public async text() {
26
+ await this.internal(false)
27
+ }
28
+
29
+ public async textCommand() {
30
+ await this.internal(false)
31
+ }
32
+
33
+ public async textCommandPayload() {
34
+ await this.internal(false)
35
+ }
36
+
37
+ public static template = /*jsx*/ `
38
+ <base>
39
+ <keyboard type="inline">❓ Help</keyboard>
40
+ <keyboard lang="en" type="inline">❓ Help</keyboard>
41
+ <keyboard lang="it" type="inline">❓ Aiuto</keyboard>
42
+ <keyboard lang="id" type="inline">❓ Bantuan</keyboard>
43
+
44
+ <message>
45
+ <b>Welcome to the bot {{userName}}</b>
46
+
47
+ <b>❓ Help</b> - View help
48
+ </message>
49
+
50
+ <message lang="en">
51
+ <b>Welcome to the bot {{userName}}</b>
52
+
53
+ <b>❓ Help</b> - View help
54
+ </message>
55
+
56
+ <message lang="it">
57
+ <b>Benvenuto nel Bot di {{userName}}</b>
58
+
59
+ <b>❓ Aiuto</b> - Ottieni assistenza e informazioni
60
+ </message>
61
+
62
+ <message lang="id">
63
+ <b>Selamat datang di bot {{userName}}</b>
64
+
65
+ <b>❓ Bantuan</b> - Lihat bantuan
66
+ </message>
67
+ </base>
68
+ `
69
+ }
@@ -1,33 +1,33 @@
1
- import { HelpPage } from "./help"
2
- import { PageBase } from "~/base"
3
-
4
- export class UserNameNotFoundPage extends PageBase {
5
- public kb() {
6
- return this.inlineKeyboard((kb, arr) => {
7
- return kb.text(arr[0]!, HelpPage.data.callbackData())
8
- })
9
- }
10
-
11
- public async transition(edit = true) {
12
- const kb = this.kb()
13
- if (edit) {
14
- await this.edit(kb)
15
- } else {
16
- await this.reply(kb)
17
- }
18
- }
19
-
20
- public static template = /*jsx*/ `
21
- <base>
22
- <keyboard type="inline">.. Home</keyboard>
23
- <keyboard lang="en" type="inline">.. Home</keyboard>
24
- <keyboard lang="es" type="inline">.. Inicio</keyboard>
25
- <keyboard lang="id" type="inline">.. Beranda</keyboard>
26
-
27
- <message>Please set the username first before using the bot.</message>
28
- <message lang="en">Please set the username first before using the bot.</message>
29
- <message lang="it">Prima di utilizzare il bot, imposta prima il nome utente.</message>
30
- <message lang="id">Tolong set username dulu sebelum memakai bot</message>
31
- </base>
32
- `
33
- }
1
+ import { HelpPage } from "./help"
2
+ import { PageBase } from "~/base"
3
+
4
+ export class UserNameNotFoundPage extends PageBase {
5
+ public kb() {
6
+ return this.inlineKeyboard((kb, arr) => {
7
+ return kb.text(arr[0]!, HelpPage.data.callbackData())
8
+ })
9
+ }
10
+
11
+ public async transition(edit = true) {
12
+ const kb = this.kb()
13
+ if (edit) {
14
+ await this.edit(kb)
15
+ } else {
16
+ await this.reply(kb)
17
+ }
18
+ }
19
+
20
+ public static template = /*jsx*/ `
21
+ <base>
22
+ <keyboard type="inline">.. Home</keyboard>
23
+ <keyboard lang="en" type="inline">.. Home</keyboard>
24
+ <keyboard lang="es" type="inline">.. Inicio</keyboard>
25
+ <keyboard lang="id" type="inline">.. Beranda</keyboard>
26
+
27
+ <message>Please set the username first before using the bot.</message>
28
+ <message lang="en">Please set the username first before using the bot.</message>
29
+ <message lang="it">Prima di utilizzare il bot, imposta prima il nome utente.</message>
30
+ <message lang="id">Tolong set username dulu sebelum memakai bot</message>
31
+ </base>
32
+ `
33
+ }
@@ -1,3 +1,3 @@
1
- import { RepositoryBase } from "~/base"
2
-
3
- export class ExampleRepo extends RepositoryBase {}
1
+ import { RepositoryBase } from "~/base"
2
+
3
+ export class ExampleRepo extends RepositoryBase {}
@@ -1 +1 @@
1
- export * from "./example"
1
+ export * from "./example"
@@ -1,3 +1,3 @@
1
- import { ServiceBase } from "~/base/service"
2
-
3
- export class ExampleService extends ServiceBase {}
1
+ import { ServiceBase } from "~/base/service"
2
+
3
+ export class ExampleService extends ServiceBase {}
@@ -1 +1 @@
1
- export * from "./example"
1
+ export * from "./example"
@@ -1 +1 @@
1
- export * from "./main"
1
+ export * from "./main"
@@ -1,9 +1,9 @@
1
- import { isMainThread } from "bun"
2
-
3
- export class MainThread {
4
- constructor(wrapCode: () => any) {
5
- if (isMainThread === true) {
6
- wrapCode()
7
- }
8
- }
9
- }
1
+ import { isMainThread } from "bun"
2
+
3
+ export class MainThread {
4
+ constructor(wrapCode: () => any) {
5
+ if (isMainThread === true) {
6
+ wrapCode()
7
+ }
8
+ }
9
+ }
@@ -1 +1 @@
1
- export * from "./log"
1
+ export * from "./log"
@@ -1,2 +1,2 @@
1
- import { log } from "gramstax"
2
- export { log }
1
+ import { log } from "gramstax"
2
+ export { log }
@@ -1,38 +1,38 @@
1
- {
2
- "compilerOptions": {
3
- // Short relative path
4
- "baseUrl": ".",
5
- "paths": {
6
- "~/*": [
7
- "./src/*"
8
- ]
9
- },
10
- // Environment setup & latest features
11
- "lib": [
12
- "ESNext"
13
- ],
14
- "target": "ESNext",
15
- "module": "Preserve",
16
- "moduleDetection": "force",
17
- "types": [
18
- //{{types}}
19
- ],
20
- "jsx": "react-jsx",
21
- "allowJs": true,
22
- // Bundler mode
23
- "moduleResolution": "bundler",
24
- "allowImportingTsExtensions": true,
25
- "verbatimModuleSyntax": true,
26
- "noEmit": true,
27
- // Best practices
28
- "strict": true,
29
- "skipLibCheck": true,
30
- "noFallthroughCasesInSwitch": true,
31
- "noUncheckedIndexedAccess": true,
32
- // Some stricter flags (disabled by default)
33
- "noImplicitOverride": false,
34
- "noUnusedLocals": false,
35
- "noUnusedParameters": false,
36
- "noPropertyAccessFromIndexSignature": false,
37
- }
1
+ {
2
+ "compilerOptions": {
3
+ // Short relative path
4
+ "baseUrl": ".",
5
+ "paths": {
6
+ "~/*": [
7
+ "./src/*"
8
+ ]
9
+ },
10
+ // Environment setup & latest features
11
+ "lib": [
12
+ "ESNext"
13
+ ],
14
+ "target": "ESNext",
15
+ "module": "Preserve",
16
+ "moduleDetection": "force",
17
+ "types": [
18
+ //{{types}}
19
+ ],
20
+ "jsx": "react-jsx",
21
+ "allowJs": true,
22
+ // Bundler mode
23
+ "moduleResolution": "bundler",
24
+ "allowImportingTsExtensions": true,
25
+ "verbatimModuleSyntax": true,
26
+ "noEmit": true,
27
+ // Best practices
28
+ "strict": true,
29
+ "skipLibCheck": true,
30
+ "noFallthroughCasesInSwitch": true,
31
+ "noUncheckedIndexedAccess": true,
32
+ // Some stricter flags (disabled by default)
33
+ "noImplicitOverride": false,
34
+ "noUnusedLocals": false,
35
+ "noUnusedParameters": false,
36
+ "noPropertyAccessFromIndexSignature": false,
37
+ }
38
38
  }