@ibiz-template/core 0.7.41-alpha.101 → 0.7.41-alpha.106

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 (137) hide show
  1. package/package.json +3 -2
  2. package/src/command/command-register.ts +121 -0
  3. package/src/command/command.ts +78 -0
  4. package/src/command/index.ts +8 -0
  5. package/src/command/utils/index.ts +2 -0
  6. package/src/command/utils/linked-list.ts +136 -0
  7. package/src/command/utils/util.ts +103 -0
  8. package/src/constant/core/core.ts +54 -0
  9. package/src/constant/emoji/emoji.ts +2929 -0
  10. package/src/constant/http-status-message/http-status-message.ts +18 -0
  11. package/src/constant/index.ts +4 -0
  12. package/src/constant/util/util.ts +3 -0
  13. package/src/context/index.ts +231 -0
  14. package/src/environment/environment.ts +64 -0
  15. package/src/error/http-error/entity-error.ts +29 -0
  16. package/src/error/http-error/http-error-factory.ts +24 -0
  17. package/src/error/http-error/http-error.ts +52 -0
  18. package/src/error/index.ts +7 -0
  19. package/src/error/model-error/model-error.ts +27 -0
  20. package/src/error/notice-error/notice-error.ts +16 -0
  21. package/src/error/runtime-error/runtime-error.ts +13 -0
  22. package/src/error/runtime-model-error/runtime-model-error.ts +27 -0
  23. package/src/ibizsys.ts +82 -0
  24. package/src/index.ts +14 -0
  25. package/src/install.ts +12 -0
  26. package/src/interface/api/chat-message/i-api-chat-message.ts +71 -0
  27. package/src/interface/api/chat-message/index.ts +1 -0
  28. package/src/interface/api/constant/index.ts +2 -0
  29. package/src/interface/api/constant/login-mode/login-mode.ts +25 -0
  30. package/src/interface/api/constant/menu-permission-mode/menu-permission-mode.ts +20 -0
  31. package/src/interface/api/environment/i-devtool-config.ts +56 -0
  32. package/src/interface/api/environment/i-environment.ts +523 -0
  33. package/src/interface/api/environment/index.ts +2 -0
  34. package/src/interface/api/global-param/i-api-context.ts +37 -0
  35. package/src/interface/api/global-param/i-global-param.ts +27 -0
  36. package/src/interface/api/global-param/index.ts +2 -0
  37. package/src/interface/api/ibizsys/i-api-ibizsys.ts +54 -0
  38. package/src/interface/api/ibizsys/i-app-data.ts +64 -0
  39. package/src/interface/api/ibizsys/i-org-data.ts +31 -0
  40. package/src/interface/api/ibizsys/index.ts +3 -0
  41. package/src/interface/api/index.ts +6 -0
  42. package/src/interface/api/utils/i-api-i18n.ts +56 -0
  43. package/src/interface/api/utils/index.ts +5 -0
  44. package/src/interface/api/utils/message-center/base/i-message-all.ts +8 -0
  45. package/src/interface/api/utils/message-center/base/i-message-base.ts +29 -0
  46. package/src/interface/api/utils/message-center/base/index.ts +2 -0
  47. package/src/interface/api/utils/message-center/command/add-in-changed/i-add-in-changed.ts +25 -0
  48. package/src/interface/api/utils/message-center/command/add-in-changed/i-command-add-in-changed.ts +16 -0
  49. package/src/interface/api/utils/message-center/command/async-action/i-command-async-action.ts +17 -0
  50. package/src/interface/api/utils/message-center/command/change/i-command-change.ts +8 -0
  51. package/src/interface/api/utils/message-center/command/create/i-command-create.ts +18 -0
  52. package/src/interface/api/utils/message-center/command/i-command-base.ts +23 -0
  53. package/src/interface/api/utils/message-center/command/i-message-command.ts +94 -0
  54. package/src/interface/api/utils/message-center/command/index.ts +20 -0
  55. package/src/interface/api/utils/message-center/command/internal-message/i-command-internal-message.ts +17 -0
  56. package/src/interface/api/utils/message-center/command/internal-message/i-internal-message.ts +132 -0
  57. package/src/interface/api/utils/message-center/command/mark-open-data/i-command-mark-open-data.ts +17 -0
  58. package/src/interface/api/utils/message-center/command/mark-open-data/i-mark-open-data.ts +47 -0
  59. package/src/interface/api/utils/message-center/command/remove/i-command-remove.ts +18 -0
  60. package/src/interface/api/utils/message-center/command/update/i-command-update.ts +18 -0
  61. package/src/interface/api/utils/message-center/common/i-app-data-entity.ts +16 -0
  62. package/src/interface/api/utils/message-center/common/i-message-center-event.ts +15 -0
  63. package/src/interface/api/utils/message-center/common/i-msg-meta-data.ts +13 -0
  64. package/src/interface/api/utils/message-center/common/i-portal-async-action.ts +144 -0
  65. package/src/interface/api/utils/message-center/common/i-portal-message.ts +84 -0
  66. package/src/interface/api/utils/message-center/common/index.ts +5 -0
  67. package/src/interface/api/utils/message-center/console/i-message-console.ts +17 -0
  68. package/src/interface/api/utils/message-center/error/i-message-error.ts +17 -0
  69. package/src/interface/api/utils/message-center/i-message-center.ts +53 -0
  70. package/src/interface/api/utils/message-center/index.ts +6 -0
  71. package/src/interface/api/utils/net/i-api-http-error.ts +43 -0
  72. package/src/interface/api/utils/net/i-api-net.ts +93 -0
  73. package/src/interface/api/utils/net/i-http-response.ts +67 -0
  74. package/src/interface/click-outside/click-outside.ts +51 -0
  75. package/src/interface/command/command/i-command-option.ts +47 -0
  76. package/src/interface/command/command/i-command.ts +68 -0
  77. package/src/interface/command/disposable/i-disposable.ts +12 -0
  78. package/src/interface/command/i-command-controller.ts +50 -0
  79. package/src/interface/command/index.ts +11 -0
  80. package/src/interface/context/index.ts +42 -0
  81. package/src/interface/error/index.ts +13 -0
  82. package/src/interface/i-chat-message/i-chat-message.ts +16 -0
  83. package/src/interface/ibizsys/i-ibizsys.ts +33 -0
  84. package/src/interface/ibizsys/index.ts +1 -0
  85. package/src/interface/index.ts +11 -0
  86. package/src/interface/utils/i-18n.ts +22 -0
  87. package/src/interface/utils/index.ts +1 -0
  88. package/src/locale/en/index.ts +30 -0
  89. package/src/locale/index.ts +2 -0
  90. package/src/locale/zh-CN/index.ts +28 -0
  91. package/src/params/params.ts +131 -0
  92. package/src/types.ts +26 -0
  93. package/src/utils/bit-mask/bit-mask.ts +87 -0
  94. package/src/utils/click-outside/click-outside.ts +108 -0
  95. package/src/utils/clone/clone.ts +38 -0
  96. package/src/utils/color/color.ts +84 -0
  97. package/src/utils/cookie-util/cookie-util.ts +192 -0
  98. package/src/utils/data-type/data-types.ts +93 -0
  99. package/src/utils/download-file/download-file.ts +110 -0
  100. package/src/utils/event/event.ts +69 -0
  101. package/src/utils/history-list/history-item.ts +41 -0
  102. package/src/utils/history-list/history-list.ts +137 -0
  103. package/src/utils/index.ts +24 -0
  104. package/src/utils/interceptor/core-interceptor.ts +127 -0
  105. package/src/utils/interceptor/index.ts +2 -0
  106. package/src/utils/interceptor/interceptor.ts +122 -0
  107. package/src/utils/logger/logger.ts +34 -0
  108. package/src/utils/message-center/base/message-all.ts +10 -0
  109. package/src/utils/message-center/base/message-base.ts +73 -0
  110. package/src/utils/message-center/command/add-in-changed/command-add-in-changed.ts +23 -0
  111. package/src/utils/message-center/command/async-action/command-async-action.ts +23 -0
  112. package/src/utils/message-center/command/change/command-change.ts +11 -0
  113. package/src/utils/message-center/command/command-base/command-base.ts +35 -0
  114. package/src/utils/message-center/command/create/command-create.ts +25 -0
  115. package/src/utils/message-center/command/internal-message/command-internal-message.ts +26 -0
  116. package/src/utils/message-center/command/mark-open-data/command-mark-open-data.ts +23 -0
  117. package/src/utils/message-center/command/message-command.ts +162 -0
  118. package/src/utils/message-center/command/remove/command-remove.ts +25 -0
  119. package/src/utils/message-center/command/update/command-update.ts +25 -0
  120. package/src/utils/message-center/console/message-console.ts +27 -0
  121. package/src/utils/message-center/error/message-error.ts +27 -0
  122. package/src/utils/message-center/index.ts +1 -0
  123. package/src/utils/message-center/message-center.ts +77 -0
  124. package/src/utils/namespace/namespace.ts +217 -0
  125. package/src/utils/net/http-response.ts +60 -0
  126. package/src/utils/net/net.ts +448 -0
  127. package/src/utils/recursive/find-recursive-child.ts +238 -0
  128. package/src/utils/string-util/string-util.ts +76 -0
  129. package/src/utils/style/remote-style.ts +17 -0
  130. package/src/utils/sync/await-timeout.ts +29 -0
  131. package/src/utils/sync/count-latch.ts +79 -0
  132. package/src/utils/sync/index.ts +2 -0
  133. package/src/utils/types/types.ts +24 -0
  134. package/src/utils/upload/select-file.ts +93 -0
  135. package/src/utils/upload/upload-file.ts +194 -0
  136. package/src/utils/url-helper/url-helper.ts +52 -0
  137. package/src/utils/util/util.ts +580 -0
@@ -0,0 +1,18 @@
1
+ // 请求状态码文本
2
+ export const HttpStatusMessageConst: Record<number, string> = {
3
+ 200: '服务器成功返回请求的数据。',
4
+ 201: '新建或修改数据成功。',
5
+ 202: '一个请求已经进入后台排队(异步任务)。',
6
+ 204: '删除数据成功。',
7
+ 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
8
+ 401: '用户没有权限(令牌、用户名、密码错误)。',
9
+ 403: '用户得到授权,但是访问是被禁止的。',
10
+ 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
11
+ 406: '请求的格式不可得。',
12
+ 410: '请求的资源被永久删除,且不会再得到的。',
13
+ 422: '当创建一个对象时,发生一个验证错误。',
14
+ 500: '服务器发生错误,请检查服务器。',
15
+ 502: '网关错误。',
16
+ 503: '服务不可用,服务器暂时过载或维护。',
17
+ 504: '网关超时。',
18
+ };
@@ -0,0 +1,4 @@
1
+ export { CoreConst } from './core/core';
2
+ export { NOOP } from './util/util';
3
+ export { EMOJILIST, EMOJIMAP } from './emoji/emoji';
4
+ export { HttpStatusMessageConst } from './http-status-message/http-status-message';
@@ -0,0 +1,3 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
2
+ // 无操作函数
3
+ export const NOOP = (): void => {};
@@ -0,0 +1,231 @@
1
+ /* eslint-disable default-param-last */
2
+ import { clone } from 'ramda';
3
+ import { IIBizContext } from '../interface';
4
+
5
+ /**
6
+ * @description 上下文处理类
7
+ * @export
8
+ * @class IBizContext
9
+ * @implements {IIBizContext}
10
+ */
11
+ export class IBizContext implements IIBizContext {
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ [key: string | symbol]: any;
14
+
15
+ /**
16
+ * @description 当前所归属的应用
17
+ * @type {string}
18
+ * @memberof IBizContext
19
+ */
20
+ declare srfappid: string;
21
+
22
+ /**
23
+ * @description 界面域标识,每个独立路由导航的视图生成
24
+ * @type {string}
25
+ * @memberof IBizContext
26
+ */
27
+ declare srfsessionid: string;
28
+
29
+ /**
30
+ * @description clone 后引用的上下文实例,需要在实例销毁时,同时销毁
31
+ * @protected
32
+ * @type {IBizContext[]}
33
+ * @memberof IBizContext
34
+ */
35
+ declare protected _associationContext: IBizContext[];
36
+
37
+ /**
38
+ * @description 修改的父上下文
39
+ * @protected
40
+ * @type {IData}
41
+ * @memberof IBizContext
42
+ */
43
+ declare protected _context: IData;
44
+
45
+ /**
46
+ * @description 父的上下文源对象
47
+ * @type {IContext}
48
+ * @memberof IBizContext
49
+ */
50
+ declare _parent?: IContext;
51
+
52
+ /**
53
+ * Creates an instance of IBizContext.
54
+ * @param {IData} [context={}] 自身的上下文
55
+ * @param {IContext} [parent] 父的上下文源对象
56
+ * @memberof IBizContext
57
+ */
58
+ private constructor(context: IData = {}, parent?: IContext) {
59
+ Object.defineProperty(this, '_associationContext', {
60
+ enumerable: false,
61
+ configurable: true,
62
+ value: [],
63
+ });
64
+
65
+ if (parent) {
66
+ this.initWithParent(parent);
67
+ }
68
+
69
+ // 合并给入上下文
70
+ Object.assign(this, context);
71
+ }
72
+
73
+ /**
74
+ * @description 初始化上下文,并关联父上下文
75
+ * @private
76
+ * @param {IContext} parent
77
+ * @memberof IBizContext
78
+ */
79
+ private initWithParent(parent: IContext): void {
80
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
81
+ const self = this;
82
+
83
+ // 定义私有变量,存放父上下文源对象
84
+ Object.defineProperty(this, '_parent', {
85
+ enumerable: false,
86
+ writable: true,
87
+ value: parent,
88
+ });
89
+
90
+ // 定义私有变量,用于存储对父已有上下文的修改。
91
+ Object.defineProperty(this, '_context', {
92
+ enumerable: false,
93
+ writable: true,
94
+ value: {},
95
+ });
96
+ // 监控父上下文参数,自身不存在时从父取
97
+ const properties: { [key: string]: PropertyDescriptor } = {};
98
+ const keys = Object.keys(parent);
99
+ keys.forEach(key => {
100
+ if (Object.prototype.hasOwnProperty.call(this, key)) {
101
+ // !已经定义的不重复定义,会报错
102
+ return;
103
+ }
104
+ properties[key] = {
105
+ enumerable: true,
106
+ configurable: true,
107
+ set(val: unknown): void {
108
+ if (val == null) {
109
+ self._context[key] = null;
110
+ } else {
111
+ self._context[key] = val;
112
+ }
113
+ },
114
+ get(): string {
115
+ if (self._context[key] !== undefined) {
116
+ return self._context[key];
117
+ }
118
+ if (self._parent) {
119
+ return self._parent[key];
120
+ }
121
+ return '';
122
+ },
123
+ };
124
+ });
125
+ Object.defineProperties(this, properties);
126
+ }
127
+
128
+ /**
129
+ * @description 返回自身独有的上下文,和父有差异的
130
+ * @returns {*} {IData}
131
+ * @memberof IBizContext
132
+ */
133
+ getOwnContext(): IData {
134
+ const result: IData = {};
135
+ Object.keys(this).forEach(key => {
136
+ // 父没有的,或者修改了父的上下文
137
+ // 父不存在则返回所有自身的属性
138
+ if (
139
+ !this._parent ||
140
+ !Object.prototype.hasOwnProperty.call(this._parent, key) ||
141
+ Object.prototype.hasOwnProperty.call(this._context, key)
142
+ ) {
143
+ result[key] = this[key];
144
+ }
145
+ });
146
+ return result;
147
+ }
148
+
149
+ /**
150
+ * @description 销毁当前上下文对象
151
+ * @memberof IBizContext
152
+ */
153
+ destroy(): void {
154
+ this._parent = undefined;
155
+ this._context = {};
156
+ this._associationContext.forEach(item => {
157
+ item.destroy();
158
+ });
159
+ }
160
+
161
+ /**
162
+ * @description 在非视图中,需要断开视图上下文联系时。只能使用 clone 创建新的局部上下文
163
+ * @returns {*} {IBizContext}
164
+ * @memberof IBizContext
165
+ */
166
+ clone(): IBizContext {
167
+ const newContext = new IBizContext(
168
+ clone(this.getOwnContext()),
169
+ this._parent,
170
+ );
171
+ this._associationContext.push(newContext);
172
+ return newContext;
173
+ }
174
+
175
+ /**
176
+ * @description 深度克隆,只返回现有数据
177
+ * @returns {*} {IData}
178
+ * @memberof IBizContext
179
+ */
180
+ deepClone(): IData {
181
+ const result: IData = {};
182
+ Object.keys(this).forEach(key => {
183
+ result[key] = this[key];
184
+ });
185
+ return result;
186
+ }
187
+
188
+ /**
189
+ * @description 在不改变对象引用的情况下,重置上下文,等效于重新实例化,但是引用不变
190
+ * @param {IData} [context={}]
191
+ * @param {IContext} [parent]
192
+ * @memberof IBizContext
193
+ */
194
+ reset(context: IData = {}, parent?: IContext): void {
195
+ // 清空_associationContext
196
+ this._associationContext.forEach(item => {
197
+ item.destroy();
198
+ });
199
+ // 置空parent相关属性
200
+ if (this._parent) {
201
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
202
+ this._parent = {} as any;
203
+ this._context = {};
204
+ }
205
+ // 删除自身的属性,define的删不掉,上面置空了就不管了
206
+ Object.keys(this).forEach(key => {
207
+ try {
208
+ delete this[key];
209
+ } catch (error) {
210
+ // 删不掉的不管了,上面已经变成uneducated了
211
+ }
212
+ });
213
+ if (parent) {
214
+ this.initWithParent(parent);
215
+ }
216
+ // 合并默认值
217
+ Object.assign(this, context);
218
+ }
219
+
220
+ /**
221
+ * @description 上下文只有在视图初始化时,调用 create 方法
222
+ * @static
223
+ * @param {IData} [context]
224
+ * @param {IContext} [parent]
225
+ * @returns {*} {IBizContext}
226
+ * @memberof IBizContext
227
+ */
228
+ static create(context?: IData, parent?: IContext): IBizContext {
229
+ return new IBizContext(context, parent);
230
+ }
231
+ }
@@ -0,0 +1,64 @@
1
+ import { IEnvironment, LoginMode, MenuPermissionMode } from '../interface';
2
+ // 默认环境变量配置
3
+ export const Environment: IEnvironment = {
4
+ dev: false,
5
+ hub: true,
6
+ enableMqtt: false,
7
+ mqttUrl: '/portal/mqtt/mqtt',
8
+ isEnableMultiLan: false,
9
+ anonymousUser: '',
10
+ anonymousPwd: '',
11
+ enableAnonymous: false,
12
+ accessStoreArea: 'COOKIE',
13
+ logLevel: 'ERROR',
14
+ baseUrl: '/api',
15
+ appId: '',
16
+ pluginBaseUrl: 'http://172.16.240.221',
17
+ isLocalModel: false,
18
+ remoteModelUrl: '/remotemodel',
19
+ assetsUrl: './assets',
20
+ dcSystem: '',
21
+ // {cat} 会替换模型 IApplication的getDefaultOSSCat 参数 如果没有会截取掉/{cat}
22
+ // getDefaultOSSCat 配置方法 系统应用-高级设置-自定义参数:DefaultOSSCat
23
+ // 配置示例 DefaultOSSCat=cat
24
+ downloadFileUrl: '/ibizutil/download/{cat}',
25
+ uploadFileUrl: '/ibizutil/upload/{cat}',
26
+ defaultOSSCat: '',
27
+ casLoginUrl: '',
28
+ loginMode: LoginMode.DEFAULT,
29
+ menuPermissionMode: MenuPermissionMode.MIXIN,
30
+ enablePermission: true,
31
+ routePlaceholder: '-',
32
+ enableWfAllHistory: false,
33
+ isMob: false,
34
+ isSaaSMode: true,
35
+ AppTitle: '',
36
+ AppLabel: '',
37
+ favicon: './favicon.ico',
38
+ enableTitle: true,
39
+ tokenHeader: '',
40
+ tokenPrefix: '',
41
+ customParams: {},
42
+ oauthOpenAccessId: '',
43
+ enableEncryption: false,
44
+ cookieDomain: '',
45
+ appLoadingTheme: 'DEFAULT',
46
+ environmentTag: 'development',
47
+ mobMenuShowMode: 'DEFAULT',
48
+ appVersion: '',
49
+ devtoolConfig: {
50
+ studioBaseUrl: 'https://open.ibizlab.cn/modeldesign/#/',
51
+ v9Mode: false,
52
+ defaultMode: 'close',
53
+ },
54
+ enableAI: true,
55
+ aMapSecurityJsCode: '',
56
+ aMapKey: '',
57
+ runContainer: 'DYNAENGINE',
58
+ mobWeChatAppId: '',
59
+ isPortalApp: false,
60
+ isEnableMobLoading: false,
61
+ mobLoadingCaption: '',
62
+ mobLoadingDescription: '',
63
+ mobLoadingBackground: '',
64
+ };
@@ -0,0 +1,29 @@
1
+ import { HttpError } from '../http-error/http-error';
2
+ import { detailMessage, InputError } from '../../interface';
3
+
4
+ /**
5
+ * @description 请求异常
6
+ * @export
7
+ * @class EntityError
8
+ * @extends {HttpError}
9
+ */
10
+ export class EntityError extends HttpError {
11
+ name: string = 'EntityError';
12
+
13
+ details: detailMessage[] = [];
14
+
15
+ constructor(err: InputError) {
16
+ super(err);
17
+ if (this.response) {
18
+ const { details = [] } = this.response.data;
19
+ this.details = details.map((detail: IData) => {
20
+ return {
21
+ name: detail.fieldname.toLowerCase(),
22
+ logicName: detail.fieldlogicname,
23
+ errorType: detail.fielderrortype,
24
+ errorInfo: detail.fielderrorinfo,
25
+ };
26
+ });
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,24 @@
1
+ import { AxiosError } from 'axios';
2
+ import { HttpError } from './http-error';
3
+ import { EntityError } from './entity-error';
4
+
5
+ /**
6
+ * @description 错误工厂
7
+ * @export
8
+ * @class HttpErrorFactory
9
+ */
10
+ export class HttpErrorFactory {
11
+ public static getInstance(error: AxiosError): HttpError {
12
+ const { response } = error;
13
+ if (!response || !response.data) {
14
+ return new HttpError(error);
15
+ }
16
+ const { type } = response.data as IData;
17
+ switch (type) {
18
+ case 'EntityException':
19
+ return new EntityError(error);
20
+ default:
21
+ return new HttpError(error);
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,52 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { IApiHttpError, InputError } from '../../interface';
3
+
4
+ /**
5
+ * @description 请求异常
6
+ * @export
7
+ * @class HttpError
8
+ * @extends {Error}
9
+ */
10
+ export class HttpError extends Error implements IApiHttpError {
11
+ name: string = 'HttpError';
12
+
13
+ message: string;
14
+
15
+ status: number;
16
+
17
+ // 错误标识
18
+ tag: string;
19
+
20
+ response?: AxiosResponse;
21
+
22
+ constructor(err: InputError) {
23
+ super('HttpError');
24
+ const res = err.response;
25
+ this.response = err.response;
26
+ this.tag = '';
27
+ if (res) {
28
+ if (res.data) {
29
+ const data = res.data as IData;
30
+ this.message = data.message;
31
+ if (!this.message && data.status === 404) {
32
+ this.message = ibiz.i18n.t('core.error.serviceResNotExist');
33
+ }
34
+ if (!this.message && data.status === 403) {
35
+ this.message = ibiz.i18n.t('core.error.serviceResNotPermission');
36
+ }
37
+ if (!this.message) {
38
+ this.message = ibiz.i18n.t('core.error.serviceException');
39
+ }
40
+ } else {
41
+ this.message = res.statusText;
42
+ }
43
+ if (!this.message) {
44
+ this.message = ibiz.i18n.t('core.error.networkAbnormality');
45
+ }
46
+ this.status = res.status;
47
+ } else {
48
+ this.message = err.message || '';
49
+ this.status = 500;
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,7 @@
1
+ export { HttpError } from './http-error/http-error';
2
+ export { ModelError } from './model-error/model-error';
3
+ export { RuntimeError } from './runtime-error/runtime-error';
4
+ export { RuntimeModelError } from './runtime-model-error/runtime-model-error';
5
+ export { NoticeError } from './notice-error/notice-error';
6
+ export { EntityError } from './http-error/entity-error';
7
+ export { HttpErrorFactory } from './http-error/http-error-factory';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @description 未支持的模型错误
3
+ * @export
4
+ * @class ModelError
5
+ * @extends {Error}
6
+ */
7
+ export class ModelError extends Error {
8
+ name: string = ibiz.i18n.t('core.error.unsupportedModels');
9
+
10
+ /**
11
+ * Creates an instance of ModelError.
12
+ * @param {IData} model 模板未支持的模型
13
+ * @param {string} [msg] 错误信息
14
+ * @memberof ModelError
15
+ */
16
+ constructor(
17
+ public model: IData,
18
+ msg?: string,
19
+ ) {
20
+ super(
21
+ ibiz.i18n.t('core.error.modelMsg', {
22
+ id: model.id,
23
+ msg: msg ? `: ${msg}` : '',
24
+ }),
25
+ );
26
+ }
27
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @description 纯输出通知信息的异常
3
+ * @export
4
+ * @class NoticeError
5
+ * @extends {Error}
6
+ */
7
+ export class NoticeError extends Error {
8
+ name: string = 'notice Error';
9
+
10
+ constructor(
11
+ public message: string,
12
+ public duration?: number,
13
+ ) {
14
+ super(message);
15
+ }
16
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @description 运行时错误
3
+ * @export
4
+ * @class RuntimeError
5
+ * @extends {Error}
6
+ */
7
+ export class RuntimeError extends Error {
8
+ name: string = 'Runtime Error';
9
+
10
+ constructor(public message: string) {
11
+ super(message);
12
+ }
13
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @description 模型配置缺失错误
3
+ * @export
4
+ * @class RuntimeModelError
5
+ * @extends {Error}
6
+ */
7
+ export class RuntimeModelError extends Error {
8
+ name: string = ibiz.i18n.t('core.error.modelConfigurationMissing');
9
+
10
+ /**
11
+ * Creates an instance of RuntimeModelError.
12
+ * @param {IData} model 丢失配置的模型
13
+ * @param {string} [msg] 缺失配置描述
14
+ * @memberof RuntimeModelError
15
+ */
16
+ constructor(
17
+ public model: IData,
18
+ msg?: string,
19
+ ) {
20
+ super(
21
+ ibiz.i18n.t('core.error.modelMsg', {
22
+ id: model.id,
23
+ msg: msg ? `: ${msg}` : '',
24
+ }),
25
+ );
26
+ }
27
+ }
package/src/ibizsys.ts ADDED
@@ -0,0 +1,82 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
3
+ import { Logger } from 'loglevel';
4
+ import { CommandController } from './command';
5
+ import { Environment } from './environment/environment';
6
+ import { I18n, IIBizsys, OrgData } from './interface';
7
+ import { MessageCenter, Net } from './utils';
8
+ import { logger } from './utils/logger/logger';
9
+
10
+ /**
11
+ * @description 全局对象
12
+ * @export
13
+ * @class IBizSys
14
+ * @implements {IIBizsys}
15
+ */
16
+ export class IBizSys implements IIBizsys {
17
+ /**
18
+ * @description 环境变量
19
+ * @memberof IBizSys
20
+ */
21
+ env = Environment;
22
+
23
+ /**
24
+ * @description 日志输出工具类
25
+ * @type {Logger}
26
+ * @memberof IBizSys
27
+ */
28
+ log: Logger = logger;
29
+
30
+ /**
31
+ * @description 网络请求工具类(发送默认请求)
32
+ * @type {Net}
33
+ * @memberof IBizSys
34
+ */
35
+ net: Net = new Net();
36
+
37
+ /**
38
+ * @description 指令工具类
39
+ * @type {CommandController}
40
+ * @memberof IBizSys
41
+ */
42
+ commands: CommandController = new CommandController();
43
+
44
+ /**
45
+ * @description 消息中心
46
+ * @type {MessageCenter}
47
+ * @memberof IBizSys
48
+ */
49
+ mc: MessageCenter = new MessageCenter();
50
+
51
+ /**
52
+ * @description 国际化工具类
53
+ * @type {I18n}
54
+ * @memberof IBizSys
55
+ */
56
+ i18n!: I18n;
57
+
58
+ /**
59
+ * @description 组织数据
60
+ * @type {OrgData}
61
+ * @memberof IBizSys
62
+ */
63
+ orgData?: OrgData;
64
+
65
+ /**
66
+ * @description 应用数据
67
+ * @type {IData}
68
+ * @memberof IBizSys
69
+ */
70
+ appData?: IData;
71
+
72
+ /**
73
+ * @description 注册全局扩展,用于替换预置能力
74
+ * @param {keyof IBizSys} key
75
+ * @param {*} value
76
+ * @memberof IBizSys
77
+ */
78
+ registerExtension(key: keyof IBizSys, value: any): void {
79
+ const self = this as IData;
80
+ self[key] = value;
81
+ }
82
+ }
package/src/index.ts ADDED
@@ -0,0 +1,14 @@
1
+ import './types';
2
+
3
+ export * from '@microsoft/fetch-event-source';
4
+ export * from './command';
5
+ export * from './constant';
6
+ export { IBizContext } from './context';
7
+ export { IBizParams } from './params/params';
8
+ export { Environment } from './environment/environment';
9
+ export * from './error';
10
+ export * from './interface';
11
+ export * from './utils';
12
+ export * from './locale';
13
+ export { IBizSys } from './ibizsys';
14
+ export { install } from './install';
package/src/install.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { IBizSys } from './ibizsys';
2
+
3
+ /**
4
+ * @description 初始化全局对象
5
+ * @export
6
+ */
7
+ export function install(): void {
8
+ if (window.ibiz) {
9
+ throw new Error(ibiz.i18n.t('core.noReInstall'));
10
+ }
11
+ window.ibiz = new IBizSys();
12
+ }