@simitgroup/simpleapp-generator 2.0.3-l-alpha → 2.0.3-m-alpha

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.
package/ReleaseNote.md CHANGED
@@ -1,3 +1,6 @@
1
+ [2.0.3m-alpha]
2
+ 1. Extract BridgeResourceAccessorBase for extensibility
3
+
1
4
  [2.0.3l-alpha]
2
5
  1. Remove docnoformat form and page templates
3
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "2.0.3l-alpha",
3
+ "version": "2.0.3m-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -34,11 +34,11 @@ import { MiniAppBridgeService } from "./bridge.service";
34
34
  const { pascalName, kebabName, hasMiniAppWhitelistedApi } = getMiniAppInfo(it.modules[i]);
35
35
  %>
36
36
  <% if(hasMiniAppWhitelistedApi) { %>
37
- import { MiniApp<%= pascalName %>BridgeService } from "../services/resources/<%= kebabName %>-bridge.service";
37
+ import { MiniApp<%= pascalName %>BridgeService } from "./resources/<%= kebabName %>-bridge.service";
38
38
  <% } %>
39
39
  <% } %>
40
40
 
41
- export class MiniAppBridgeResourceAccessor {
41
+ export class MiniAppBridgeResourceAccessorBase {
42
42
  protected bridge: MiniAppBridgeService;
43
43
  protected instances: Partial<MiniAppResourceMap> = {};
44
44
 
@@ -0,0 +1,10 @@
1
+ import { MiniAppBridgeResourceAccessorBase } from "./bridge-resource-accessor-base.service";
2
+
3
+ export class MiniAppBridgeResourceAccessor extends MiniAppBridgeResourceAccessorBase {
4
+ protected customInstances: Partial<{
5
+ }> = {};
6
+
7
+ constructor() {
8
+ super();
9
+ }
10
+ }
@@ -36,7 +36,7 @@ import { MiniAppResourceMap } from "../types/resource-mapper.type";
36
36
  <% } %>
37
37
  <% } %>
38
38
 
39
- export class MiniAppBridgeResourceAccessor {
39
+ export class MiniAppBridgeResourceAccessorBase {
40
40
  protected instances: Partial<MiniAppResourceMap> = {};
41
41
 
42
42
  protected miniAppCode: string = "";
@@ -0,0 +1,6 @@
1
+ import { MiniAppBridgeResourceAccessorBase } from "./bridge-resource-accessor-base.service";
2
+
3
+ export class MiniAppBridgeResourceAccessor extends MiniAppBridgeResourceAccessorBase {
4
+ protected customInstances: Partial<{
5
+ }> = {};
6
+ }
@@ -5,29 +5,25 @@
5
5
  * Author: --
6
6
  */
7
7
 
8
+ import { AxiosError } from "axios";
8
9
  import { SimpleAppDocumentType } from "~/types";
10
+ import { MINI_APP_BRIDGE_MESSAGES } from "../constants/common.constant";
11
+ import { MINI_APP_API_CUSTOM_RESOURCES } from "../constants/custom-resource.constant";
12
+ import { MINI_APP_API_RESOURCES } from "../constants/resource.constant";
9
13
  import {
10
14
  MiniAppBridgeMessageApi,
11
15
  MiniAppBridgeMessageNavigate,
12
16
  MiniAppBridgeMessageNavigateCurrentMiniApp,
13
17
  MiniAppBridgeMessageOpenOnScreenResourceForm,
14
18
  } from "../types/bridge.type";
15
- import { AxiosError } from "axios";
16
- import { MINI_APP_BRIDGE_MESSAGES } from "../constants/common.constant";
17
19
  import { MiniAppResourceMap } from "../types/resource-mapper.type";
18
20
  import { MiniAppBridgeResourceAccessor } from "./bridge-resource-accessor.service";
19
- import { MINI_APP_API_RESOURCES } from "../constants/resource.constant";
20
21
 
21
22
  export class MiniAppBridgeService extends MiniAppBridgeResourceAccessor {
22
23
  /**************************************** Bridge Handler ***************************************/
23
24
 
24
25
  handleBridgeNavigate(message: MiniAppBridgeMessageNavigate) {
25
- goTo(
26
- message.params.target,
27
- message.params.id,
28
- message.params.query,
29
- message.params.options,
30
- );
26
+ goTo(message.params.target, message.params.id, message.params.query, message.params.options);
31
27
  }
32
28
 
33
29
  handleBridgeNavigateCurrentMiniApp(
@@ -48,9 +44,7 @@ export class MiniAppBridgeService extends MiniAppBridgeResourceAccessor {
48
44
  goTo(targetUrl, undefined, message.params.query, message.params.options);
49
45
  }
50
46
 
51
- handleBridgeOpenOnScreenResourceForm(
52
- message: MiniAppBridgeMessageOpenOnScreenResourceForm,
53
- ) {
47
+ handleBridgeOpenOnScreenResourceForm(message: MiniAppBridgeMessageOpenOnScreenResourceForm) {
54
48
  if (message.params.resource.id) {
55
49
  onScreenEditDocument(
56
50
  message.params.resource.name as SimpleAppDocumentType,
@@ -108,10 +102,8 @@ export class MiniAppBridgeService extends MiniAppBridgeResourceAccessor {
108
102
  data: (err.response.data as any)?.data ?? "",
109
103
  error: (err.response.data as any)?.error ?? "",
110
104
  message: (err.response.data as any)?.message ?? "",
111
- statusCode:
112
- (err.response.data as any)?.statusCode ?? "",
113
- statusMessage:
114
- (err.response.data as any)?.statusMessage ?? "",
105
+ statusCode: (err.response.data as any)?.statusCode ?? "",
106
+ statusMessage: (err.response.data as any)?.statusMessage ?? "",
115
107
  }
116
108
  : {},
117
109
  status: err.response.status,
@@ -129,11 +121,11 @@ export class MiniAppBridgeService extends MiniAppBridgeResourceAccessor {
129
121
 
130
122
  private async handleBridgeCallApi(message: MiniAppBridgeMessageApi<any>) {
131
123
  const resourceName = message.params.resource.name;
132
-
133
124
  if (!MINI_APP_API_RESOURCES.includes(resourceName)) {
134
- throw new Error(`Unknown resource name: ${resourceName}`);
125
+ if (!MINI_APP_API_CUSTOM_RESOURCES.includes(resourceName)) {
126
+ throw new Error(`Unknown resource name: ${resourceName}`);
127
+ }
135
128
  }
136
-
137
129
  const bridge = this[resourceName as keyof MiniAppResourceMap];
138
130
  return await bridge.handleApi(message);
139
131
  }