create-gramstax 0.8.2 → 0.8.3

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.
@@ -35,7 +35,7 @@
35
35
  "lint:fix": "eslint . --fix"
36
36
  },
37
37
  "dependencies": {
38
- "gramstax": "^0.8.1",
38
+ "gramstax": "^0.8.2",
39
39
  "dayjs": "^1.11.13"
40
40
  },
41
41
  "peerDependencies": {
@@ -11,7 +11,7 @@ export class UserGuard extends GuardBase {
11
11
  async ensureUsername(edit: boolean) {
12
12
  try {
13
13
  if (!this.userName || this.userName.length == 0) {
14
- await new UserNameNotFoundPage(this).entryPoint(edit)
14
+ await new UserNameNotFoundPage(this).showEntryPoint(edit)
15
15
  return null
16
16
  }
17
17
  return {status: true}
@@ -37,8 +37,8 @@ export class GeneralStatusPage extends PageBase {
37
37
  this.constructorName = p?.constructor?.name
38
38
  }
39
39
 
40
- async error(funcName: string, error: any, edit = true) {
41
- await Alert.error(this, funcName, error, edit)
40
+ async error(...args: Parameters<typeof Alert.error> extends [any, ...infer R] ? R : []) {
41
+ await Alert.error(this, ...args)
42
42
  }
43
43
 
44
44
  async errorInputNotFound() {
@@ -1,8 +1,8 @@
1
1
  import {PageBase} from "~/base/page"
2
2
  import {StartPage} from "./start"
3
3
 
4
- class Perform {
5
- static async entryPoint(ctx: HelpPage, edit = true) {
4
+ class Main {
5
+ static async showEntryPoint(ctx: HelpPage, edit = true) {
6
6
  const kb = ctx.inlineKeyboardT([StartPage])
7
7
  if (edit) {
8
8
  await ctx.edit(kb)
@@ -14,11 +14,11 @@ class Perform {
14
14
 
15
15
  export class HelpPage extends PageBase {
16
16
  async handleCallbackData() {
17
- await Perform.entryPoint(this, true)
17
+ await Main.showEntryPoint(this, true)
18
18
  }
19
19
 
20
20
  async handleCommandText() {
21
- await Perform.entryPoint(this, false)
21
+ await Main.showEntryPoint(this, false)
22
22
  }
23
23
 
24
24
  static template = `
@@ -1,8 +1,8 @@
1
1
  import {PageBase} from "~/base/page"
2
2
  import {StartPage} from "./start"
3
3
 
4
- class Perform {
5
- static async entryPoint(ctx: RandomNumberPage, edit = true) {
4
+ class Main {
5
+ static async showEntryPoint(ctx: RandomNumberPage, edit = true) {
6
6
  const kb = ctx.inlineKeyboardT([this, StartPage])
7
7
  const da = {result: Math.random() * 10 ** 18}
8
8
  if (edit) {
@@ -15,15 +15,15 @@ class Perform {
15
15
 
16
16
  export class RandomNumberPage extends PageBase {
17
17
  async handleCallbackData() {
18
- await Perform.entryPoint(this, true)
18
+ await Main.showEntryPoint(this, true)
19
19
  }
20
20
 
21
21
  async handleCommandText() {
22
- await Perform.entryPoint(this, false)
22
+ await Main.showEntryPoint(this, false)
23
23
  }
24
24
 
25
25
  async entryPoint(edit = true) {
26
- await Perform.entryPoint(this, edit)
26
+ await Main.showEntryPoint(this, edit)
27
27
  }
28
28
 
29
29
  static template = `
@@ -3,8 +3,8 @@ import {PageBase} from "~/base/page"
3
3
  import {RandomNumberPage} from "./random-number"
4
4
  import {SumNumberPage} from "./sum-number"
5
5
 
6
- class Perform {
7
- static async entryPoint(ctx: StartPage, edit = true) {
6
+ class Main {
7
+ static async showEntryPoint(ctx: StartPage, edit = true) {
8
8
  await ctx.clearSession()
9
9
  const kb = ctx.inlineKeyboardT([RandomNumberPage, SumNumberPage, HelpPage], `2`)
10
10
  const da = {userName: ctx.userName}
@@ -18,15 +18,15 @@ class Perform {
18
18
 
19
19
  export class StartPage extends PageBase {
20
20
  async handleCallbackData() {
21
- await Perform.entryPoint(this, true)
21
+ await Main.showEntryPoint(this, true)
22
22
  }
23
23
 
24
24
  async handleCommandText() {
25
- await Perform.entryPoint(this, false)
25
+ await Main.showEntryPoint(this, false)
26
26
  }
27
27
 
28
28
  async entryPoint(edit = true) {
29
- await Perform.entryPoint(this, edit)
29
+ await Main.showEntryPoint(this, edit)
30
30
  }
31
31
 
32
32
  static template = `
@@ -4,7 +4,7 @@ import {StartPage} from "./start"
4
4
  class Base {
5
5
  static pleft: `pleft`
6
6
  static pright: `pright`
7
- static result: `result`
7
+ static success: `success`
8
8
  }
9
9
 
10
10
  class Helper {
@@ -17,8 +17,8 @@ class Helper {
17
17
  }
18
18
  }
19
19
 
20
- class Flow {
21
- static async step1Form(ctx: SumNumberPage, edit: boolean) {
20
+ class Main {
21
+ static async showStep1Form(ctx: SumNumberPage, edit: boolean) {
22
22
  await ctx.sessionFreeText({step: `left`})
23
23
  const bi = Base.pleft
24
24
  const kb = Helper.kb(ctx, bi)
@@ -30,15 +30,15 @@ class Flow {
30
30
  }
31
31
  }
32
32
 
33
- static async step1Answer(ctx: SumNumberPage, left: number) {
33
+ static async processStep1Answer(ctx: SumNumberPage, left: number) {
34
34
  if (!Number.isFinite(left)) {
35
- await Flow.step1Form(ctx, false)
35
+ await Main.showStep1Form(ctx, false)
36
36
  } else {
37
- await this.step2Form(ctx, left)
37
+ await this.showStep2Form(ctx, left)
38
38
  }
39
39
  }
40
40
 
41
- static async step2Form(ctx: SumNumberPage, left: number) {
41
+ static async showStep2Form(ctx: SumNumberPage, left: number) {
42
42
  await ctx.sessionFreeText({step: `right`, left})
43
43
  const bi = Base.pright
44
44
  const kb = Helper.kb(ctx, bi)
@@ -46,12 +46,12 @@ class Flow {
46
46
  await ctx.reply(kb, da, bi)
47
47
  }
48
48
 
49
- static async step2Answer(ctx: SumNumberPage, left: number, right: number) {
49
+ static async processStep2Answer(ctx: SumNumberPage, left: number, right: number) {
50
50
  if (!Number.isFinite(right)) {
51
- await Flow.step2Form(ctx, right)
51
+ await Main.showStep2Form(ctx, right)
52
52
  } else if (!Number.isFinite(right ?? NaN)) {
53
53
  await ctx.clearSession()
54
- await Flow.step1Form(ctx, false)
54
+ await Main.showStep1Form(ctx, false)
55
55
  } else {
56
56
  await Alert.success(ctx, left, right)
57
57
  }
@@ -61,7 +61,7 @@ class Flow {
61
61
  class Alert {
62
62
  static async success(ctx: SumNumberPage, left: number, right: number) {
63
63
  await ctx.clearSession()
64
- const bi = Base.result
64
+ const bi = Base.success
65
65
  const kb = Helper.kb(ctx, bi)
66
66
  const da = {result: left! + right}
67
67
  await ctx.reply(kb, da, bi)
@@ -70,11 +70,11 @@ class Alert {
70
70
 
71
71
  export class SumNumberPage extends PageBase {
72
72
  async handleCallbackData() {
73
- await Flow.step1Form(this, true)
73
+ await Main.showStep1Form(this, true)
74
74
  }
75
75
 
76
76
  async handleCommandText() {
77
- await Flow.step1Form(this, false)
77
+ await Main.showStep1Form(this, false)
78
78
  }
79
79
 
80
80
  async handleFreeText() {
@@ -85,9 +85,9 @@ export class SumNumberPage extends PageBase {
85
85
  const input = this.msgText?.trim()
86
86
  const value = input ? Number(input) : NaN
87
87
  if (step === `left`) {
88
- await Flow.step1Answer(this, value)
88
+ await Main.processStep1Answer(this, value)
89
89
  } else if (step === `right`) {
90
- await Flow.step2Answer(this, left!, value)
90
+ await Main.processStep2Answer(this, left!, value)
91
91
  }
92
92
  }
93
93
 
@@ -120,7 +120,7 @@ export class SumNumberPage extends PageBase {
120
120
  </message>
121
121
  </base>
122
122
 
123
- <base id="${Base.result}">
123
+ <base id="${Base.success}">
124
124
  ${this.kbk.home()}
125
125
  <message>
126
126
  <b>📚 Result Sum</b>
@@ -1,8 +1,8 @@
1
1
  import {HelpPage} from "./help"
2
2
  import {PageBase} from "~/base/page"
3
3
 
4
- class Perform {
5
- static async entryPoint(ctx: UserNameNotFoundPage, edit = true) {
4
+ class Main {
5
+ static async showEntryPoint(ctx: UserNameNotFoundPage, edit = true) {
6
6
  const kb = ctx.inlineKeyboardT([HelpPage])
7
7
  if (edit) {
8
8
  await ctx.edit(kb)
@@ -13,8 +13,8 @@ class Perform {
13
13
  }
14
14
 
15
15
  export class UserNameNotFoundPage extends PageBase {
16
- async entryPoint(edit = true) {
17
- await Perform.entryPoint(this, edit)
16
+ async showEntryPoint(edit = true) {
17
+ await Main.showEntryPoint(this, edit)
18
18
  }
19
19
 
20
20
  static template = `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-gramstax",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",