@fctc/interface-logic 2.4.4 → 2.4.6

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.
@@ -0,0 +1,8 @@
1
+ interface BaseModelInit {
2
+ name: string;
3
+ view: Record<string, any>;
4
+ actContext?: Record<string, any>;
5
+ fields?: any;
6
+ }
7
+
8
+ export type { BaseModelInit as B };
@@ -0,0 +1,8 @@
1
+ interface BaseModelInit {
2
+ name: string;
3
+ view: Record<string, any>;
4
+ actContext?: Record<string, any>;
5
+ fields?: any;
6
+ }
7
+
8
+ export type { BaseModelInit as B };
package/dist/hooks.d.mts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { L as LoginCredentialBody, d as SocialTokenBody, F as ForgotPasswordBody, u as updatePasswordBody, V as ViewData, C as ContextApi, c as GetSelectionType, f as GetViewParams } from './view-type-xxw9OeSR.mjs';
3
+ import { B as BaseModelInit } from './base-model-type-DD8uZnDP.mjs';
4
+ import { BaseModel } from './models.mjs';
3
5
 
4
6
  declare const useForgotPassword: () => _tanstack_react_query.UseMutationResult<any, Error, string, unknown>;
5
7
 
@@ -173,24 +175,6 @@ declare const useGetListMyBankAccount: ({ domain, spectification, model, }: {
173
175
  model: string;
174
176
  }) => _tanstack_react_query.UseQueryResult<any, Error>;
175
177
 
176
- interface BaseModelInit {
177
- name: string;
178
- view: Record<string, any>;
179
- actContext?: Record<string, any>;
180
- fields?: any;
181
- }
182
-
183
- declare class BaseModel {
184
- name: string;
185
- view: Record<string, any>;
186
- fields?: any;
187
- constructor(init: BaseModelInit);
188
- private getSpecificationByFields;
189
- getTreeProps(): Record<string, any>;
190
- getTreeFields(): Record<string, any>[];
191
- getSpecification(): Record<string, any>;
192
- }
193
-
194
178
  declare const useModel: () => {
195
179
  initModel: (modelData: BaseModelInit) => BaseModel;
196
180
  };
package/dist/hooks.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { L as LoginCredentialBody, d as SocialTokenBody, F as ForgotPasswordBody, u as updatePasswordBody, V as ViewData, C as ContextApi, c as GetSelectionType, f as GetViewParams } from './view-type-xxw9OeSR.js';
3
+ import { B as BaseModelInit } from './base-model-type-DD8uZnDP.js';
4
+ import { BaseModel } from './models.js';
3
5
 
4
6
  declare const useForgotPassword: () => _tanstack_react_query.UseMutationResult<any, Error, string, unknown>;
5
7
 
@@ -173,24 +175,6 @@ declare const useGetListMyBankAccount: ({ domain, spectification, model, }: {
173
175
  model: string;
174
176
  }) => _tanstack_react_query.UseQueryResult<any, Error>;
175
177
 
176
- interface BaseModelInit {
177
- name: string;
178
- view: Record<string, any>;
179
- actContext?: Record<string, any>;
180
- fields?: any;
181
- }
182
-
183
- declare class BaseModel {
184
- name: string;
185
- view: Record<string, any>;
186
- fields?: any;
187
- constructor(init: BaseModelInit);
188
- private getSpecificationByFields;
189
- getTreeProps(): Record<string, any>;
190
- getTreeFields(): Record<string, any>[];
191
- getSpecification(): Record<string, any>;
192
- }
193
-
194
178
  declare const useModel: () => {
195
179
  initModel: (modelData: BaseModelInit) => BaseModel;
196
180
  };
package/dist/hooks.js CHANGED
@@ -5288,14 +5288,13 @@ var BaseModel = class {
5288
5288
  return specification;
5289
5289
  }
5290
5290
  };
5291
- var base_model_default = BaseModel;
5292
5291
 
5293
5292
  // src/hooks/model/use-model.ts
5294
5293
  var useModel = () => {
5295
5294
  const initModel = (modelData) => {
5296
5295
  switch (modelData?.name) {
5297
5296
  default:
5298
- return new base_model_default(modelData);
5297
+ return new BaseModel(modelData);
5299
5298
  }
5300
5299
  };
5301
5300
  return {
package/dist/hooks.mjs CHANGED
@@ -5184,14 +5184,13 @@ var BaseModel = class {
5184
5184
  return specification;
5185
5185
  }
5186
5186
  };
5187
- var base_model_default = BaseModel;
5188
5187
 
5189
5188
  // src/hooks/model/use-model.ts
5190
5189
  var useModel = () => {
5191
5190
  const initModel = (modelData) => {
5192
5191
  switch (modelData?.name) {
5193
5192
  default:
5194
- return new base_model_default(modelData);
5193
+ return new BaseModel(modelData);
5195
5194
  }
5196
5195
  };
5197
5196
  return {
@@ -0,0 +1,14 @@
1
+ import { B as BaseModelInit } from './base-model-type-DD8uZnDP.mjs';
2
+
3
+ declare class BaseModel {
4
+ name: string;
5
+ view: Record<string, any>;
6
+ fields?: any;
7
+ constructor(init: BaseModelInit);
8
+ private getSpecificationByFields;
9
+ getTreeProps(): Record<string, any>;
10
+ getTreeFields(): Record<string, any>[];
11
+ getSpecification(): Record<string, any>;
12
+ }
13
+
14
+ export { BaseModel };
@@ -0,0 +1,14 @@
1
+ import { B as BaseModelInit } from './base-model-type-DD8uZnDP.js';
2
+
3
+ declare class BaseModel {
4
+ name: string;
5
+ view: Record<string, any>;
6
+ fields?: any;
7
+ constructor(init: BaseModelInit);
8
+ private getSpecificationByFields;
9
+ getTreeProps(): Record<string, any>;
10
+ getTreeFields(): Record<string, any>[];
11
+ getSpecification(): Record<string, any>;
12
+ }
13
+
14
+ export { BaseModel };
package/dist/models.js ADDED
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/models.ts
21
+ var models_exports = {};
22
+ __export(models_exports, {
23
+ BaseModel: () => BaseModel
24
+ });
25
+ module.exports = __toCommonJS(models_exports);
26
+
27
+ // src/constants/widget/widget-avatar-constant.ts
28
+ var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
29
+ WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
30
+ WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
31
+ return WIDGETAVATAR2;
32
+ })(WIDGETAVATAR || {});
33
+
34
+ // src/models/base-model/index.ts
35
+ var BaseModel = class {
36
+ name;
37
+ view;
38
+ fields;
39
+ constructor(init) {
40
+ this.name = init.name;
41
+ this.view = init.view;
42
+ this.fields = init.fields;
43
+ }
44
+ getSpecificationByFields({
45
+ fields = [],
46
+ specification = {},
47
+ modelsData,
48
+ model,
49
+ modelRoot
50
+ }) {
51
+ if (Array.isArray(fields)) {
52
+ let spec = { ...specification };
53
+ fields.forEach((field) => {
54
+ if (!field?.type_co || field?.name && field?.type_co === "field" /* FIELD */) {
55
+ if (modelsData?.[model]?.[field?.name]) {
56
+ if (modelsData?.[model]?.[field?.name]?.type === "one2many" /* ONE2MANY */ || modelsData?.[model]?.[field?.name]?.type === "many2many" /* MANY2MANY */) {
57
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
58
+ const modelRelation = modelsData?.[relation];
59
+ if (modelRelation) {
60
+ spec[field?.name] = {
61
+ fields: {}
62
+ };
63
+ if (modelRoot && modelRoot === relation) {
64
+ spec[field?.name].fields = { id: {} };
65
+ } else {
66
+ spec[field?.name].fields = this.getSpecificationByFields({
67
+ fields: Object.values(modelRelation),
68
+ specification: {},
69
+ modelsData,
70
+ model: relation,
71
+ modelRoot: model
72
+ });
73
+ }
74
+ } else {
75
+ spec[field?.name] = {
76
+ fields: {
77
+ id: {},
78
+ display_name: {},
79
+ ...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
80
+ }
81
+ };
82
+ }
83
+ } else if (modelsData?.[model]?.[field?.name]?.type === "many2one" /* MANY2ONE */) {
84
+ spec[field?.name] = {
85
+ fields: {
86
+ id: {},
87
+ display_name: {},
88
+ ...WIDGETAVATAR[field?.widget] ? { image_256: {} } : {},
89
+ ...field?.name === "currency_id" && fields?.find((item) => item?.widget === "monetary") ? { symbol: {} } : {},
90
+ ...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
91
+ }
92
+ };
93
+ } else {
94
+ spec[field?.name] = {};
95
+ }
96
+ }
97
+ } else if (field?.type_co === "group" /* GROUP */ || field?.type_co === "div" /* DIV */ || field?.type_co === "span" /* SPAN */) {
98
+ const specGroup = this.getSpecificationByFields({
99
+ fields: field?.fields,
100
+ specification: spec,
101
+ modelsData,
102
+ model
103
+ });
104
+ spec = { ...spec, ...specGroup };
105
+ } else if (field?.type_co === "tree" /* TREE */ || field?.type_co === "list" /* LIST */) {
106
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
107
+ const specTreee = this.getSpecificationByFields({
108
+ fields: field?.fields,
109
+ specification: {},
110
+ modelsData,
111
+ model: relation,
112
+ modelRoot: model
113
+ });
114
+ spec = { ...spec, [field?.name]: { fields: specTreee } };
115
+ }
116
+ });
117
+ return spec;
118
+ } else {
119
+ console.warn("fields is not array");
120
+ }
121
+ }
122
+ getTreeProps() {
123
+ const props = this.view?.views?.list || {};
124
+ return props;
125
+ }
126
+ getTreeFields() {
127
+ const fields = this.view?.views?.list?.fields || [];
128
+ return fields;
129
+ }
130
+ getSpecification() {
131
+ const specInit = {};
132
+ const modelData = this.view?.models || {};
133
+ const specification = this.getSpecificationByFields({
134
+ fields: this.fields,
135
+ specification: specInit,
136
+ modelsData: modelData,
137
+ model: this.name,
138
+ modelRoot: ""
139
+ });
140
+ return specification;
141
+ }
142
+ };
143
+ // Annotate the CommonJS export names for ESM import in node:
144
+ 0 && (module.exports = {
145
+ BaseModel
146
+ });
@@ -0,0 +1,119 @@
1
+ // src/constants/widget/widget-avatar-constant.ts
2
+ var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
3
+ WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
4
+ WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
5
+ return WIDGETAVATAR2;
6
+ })(WIDGETAVATAR || {});
7
+
8
+ // src/models/base-model/index.ts
9
+ var BaseModel = class {
10
+ name;
11
+ view;
12
+ fields;
13
+ constructor(init) {
14
+ this.name = init.name;
15
+ this.view = init.view;
16
+ this.fields = init.fields;
17
+ }
18
+ getSpecificationByFields({
19
+ fields = [],
20
+ specification = {},
21
+ modelsData,
22
+ model,
23
+ modelRoot
24
+ }) {
25
+ if (Array.isArray(fields)) {
26
+ let spec = { ...specification };
27
+ fields.forEach((field) => {
28
+ if (!field?.type_co || field?.name && field?.type_co === "field" /* FIELD */) {
29
+ if (modelsData?.[model]?.[field?.name]) {
30
+ if (modelsData?.[model]?.[field?.name]?.type === "one2many" /* ONE2MANY */ || modelsData?.[model]?.[field?.name]?.type === "many2many" /* MANY2MANY */) {
31
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
32
+ const modelRelation = modelsData?.[relation];
33
+ if (modelRelation) {
34
+ spec[field?.name] = {
35
+ fields: {}
36
+ };
37
+ if (modelRoot && modelRoot === relation) {
38
+ spec[field?.name].fields = { id: {} };
39
+ } else {
40
+ spec[field?.name].fields = this.getSpecificationByFields({
41
+ fields: Object.values(modelRelation),
42
+ specification: {},
43
+ modelsData,
44
+ model: relation,
45
+ modelRoot: model
46
+ });
47
+ }
48
+ } else {
49
+ spec[field?.name] = {
50
+ fields: {
51
+ id: {},
52
+ display_name: {},
53
+ ...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
54
+ }
55
+ };
56
+ }
57
+ } else if (modelsData?.[model]?.[field?.name]?.type === "many2one" /* MANY2ONE */) {
58
+ spec[field?.name] = {
59
+ fields: {
60
+ id: {},
61
+ display_name: {},
62
+ ...WIDGETAVATAR[field?.widget] ? { image_256: {} } : {},
63
+ ...field?.name === "currency_id" && fields?.find((item) => item?.widget === "monetary") ? { symbol: {} } : {},
64
+ ...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
65
+ }
66
+ };
67
+ } else {
68
+ spec[field?.name] = {};
69
+ }
70
+ }
71
+ } else if (field?.type_co === "group" /* GROUP */ || field?.type_co === "div" /* DIV */ || field?.type_co === "span" /* SPAN */) {
72
+ const specGroup = this.getSpecificationByFields({
73
+ fields: field?.fields,
74
+ specification: spec,
75
+ modelsData,
76
+ model
77
+ });
78
+ spec = { ...spec, ...specGroup };
79
+ } else if (field?.type_co === "tree" /* TREE */ || field?.type_co === "list" /* LIST */) {
80
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
81
+ const specTreee = this.getSpecificationByFields({
82
+ fields: field?.fields,
83
+ specification: {},
84
+ modelsData,
85
+ model: relation,
86
+ modelRoot: model
87
+ });
88
+ spec = { ...spec, [field?.name]: { fields: specTreee } };
89
+ }
90
+ });
91
+ return spec;
92
+ } else {
93
+ console.warn("fields is not array");
94
+ }
95
+ }
96
+ getTreeProps() {
97
+ const props = this.view?.views?.list || {};
98
+ return props;
99
+ }
100
+ getTreeFields() {
101
+ const fields = this.view?.views?.list?.fields || [];
102
+ return fields;
103
+ }
104
+ getSpecification() {
105
+ const specInit = {};
106
+ const modelData = this.view?.models || {};
107
+ const specification = this.getSpecificationByFields({
108
+ fields: this.fields,
109
+ specification: specInit,
110
+ modelsData: modelData,
111
+ model: this.name,
112
+ modelRoot: ""
113
+ });
114
+ return specification;
115
+ }
116
+ };
117
+ export {
118
+ BaseModel
119
+ };
@@ -3,6 +3,8 @@ import { L as LocalStorageUtilsType, S as SessionStorageUtilsType } from './sess
3
3
  import { useForgotPassword, useForgotPasswordSSO, useGetProvider, useIsValidToken, useLoginCredential, useLoginSocial, useResetPassword, useResetPasswordSSO, useUpdatePassword, useLogout, useGetAccessByCode, useValidateActionToken, useGetCompanyInfo, useGetCurrentCompany, useGetListCompany, useExecuteImport, useExportExcel, useGetFieldExport, useGetFileExcel, useParsePreview, useUploadFileExcel, useUploadIdFile, useChangeStatus, useDeleteComment, useGetComment, useGetFormView, useGetImage, useSendComment, useUploadImage, useDelete, useGetAll, useGetConversionRate, useGetCurrency, useGetDetail, useGetFieldOnChange, useGetListMyBankAccount, useModel, useOdooDataTransform, useOnChangeForm, useSave, useGetProfile, useGetUser, useSwitchLocale, useButton, useDuplicateRecord, useGet2FAMethods, useGetActionDetail, useGetCalendar, useGetGroups, useGetListData, useGetMenu, useGetPrintReport, useGetProGressBar, useGetResequence, useGetSelection, useGetView, useLoadAction, useLoadMessage, usePrint, useRemoveRow, useRunAction, useSignInSSO, useVerify2FA, useGrantAccess, useRemoveTotpSetup, useRequestSetupTotp, useSettingsWebRead2fa, useVerifyTotp, useUploadFile } from './hooks.mjs';
4
4
  import '@tanstack/react-query';
5
5
  import './view-type-xxw9OeSR.mjs';
6
+ import './base-model-type-DD8uZnDP.mjs';
7
+ import './models.mjs';
6
8
 
7
9
  declare const MainProvider: ({ children }: {
8
10
  children: ReactNode;
@@ -3,6 +3,8 @@ import { L as LocalStorageUtilsType, S as SessionStorageUtilsType } from './sess
3
3
  import { useForgotPassword, useForgotPasswordSSO, useGetProvider, useIsValidToken, useLoginCredential, useLoginSocial, useResetPassword, useResetPasswordSSO, useUpdatePassword, useLogout, useGetAccessByCode, useValidateActionToken, useGetCompanyInfo, useGetCurrentCompany, useGetListCompany, useExecuteImport, useExportExcel, useGetFieldExport, useGetFileExcel, useParsePreview, useUploadFileExcel, useUploadIdFile, useChangeStatus, useDeleteComment, useGetComment, useGetFormView, useGetImage, useSendComment, useUploadImage, useDelete, useGetAll, useGetConversionRate, useGetCurrency, useGetDetail, useGetFieldOnChange, useGetListMyBankAccount, useModel, useOdooDataTransform, useOnChangeForm, useSave, useGetProfile, useGetUser, useSwitchLocale, useButton, useDuplicateRecord, useGet2FAMethods, useGetActionDetail, useGetCalendar, useGetGroups, useGetListData, useGetMenu, useGetPrintReport, useGetProGressBar, useGetResequence, useGetSelection, useGetView, useLoadAction, useLoadMessage, usePrint, useRemoveRow, useRunAction, useSignInSSO, useVerify2FA, useGrantAccess, useRemoveTotpSetup, useRequestSetupTotp, useSettingsWebRead2fa, useVerifyTotp, useUploadFile } from './hooks.js';
4
4
  import '@tanstack/react-query';
5
5
  import './view-type-xxw9OeSR.js';
6
+ import './base-model-type-DD8uZnDP.js';
7
+ import './models.js';
6
8
 
7
9
  declare const MainProvider: ({ children }: {
8
10
  children: ReactNode;
package/dist/provider.js CHANGED
@@ -5654,14 +5654,13 @@ var BaseModel = class {
5654
5654
  return specification;
5655
5655
  }
5656
5656
  };
5657
- var base_model_default = BaseModel;
5658
5657
 
5659
5658
  // src/hooks/model/use-model.ts
5660
5659
  var useModel = () => {
5661
5660
  const initModel = (modelData) => {
5662
5661
  switch (modelData?.name) {
5663
5662
  default:
5664
- return new base_model_default(modelData);
5663
+ return new BaseModel(modelData);
5665
5664
  }
5666
5665
  };
5667
5666
  return {
package/dist/provider.mjs CHANGED
@@ -5611,14 +5611,13 @@ var BaseModel = class {
5611
5611
  return specification;
5612
5612
  }
5613
5613
  };
5614
- var base_model_default = BaseModel;
5615
5614
 
5616
5615
  // src/hooks/model/use-model.ts
5617
5616
  var useModel = () => {
5618
5617
  const initModel = (modelData) => {
5619
5618
  switch (modelData?.name) {
5620
5619
  default:
5621
- return new base_model_default(modelData);
5620
+ return new BaseModel(modelData);
5622
5621
  }
5623
5622
  };
5624
5623
  return {
package/dist/types.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { C as ContextApi, D as DeleteParams, F as ForgotPasswordBody, G as GetAllParams, a as GetDetailParams, b as GetListParams, c as GetSelectionType, f as GetViewParams, L as LoginCredentialBody, O as OnChangeParams, R as ResetPasswordRequest, S as SaveParams, d as SocialTokenBody, e as Specification, U as UpdatePasswordRequest, g as View, V as ViewData, u as updatePasswordBody } from './view-type-xxw9OeSR.mjs';
2
+ export { B as BaseModelInit } from './base-model-type-DD8uZnDP.mjs';
2
3
 
3
4
  interface Config {
4
5
  baseUrl: string;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { C as ContextApi, D as DeleteParams, F as ForgotPasswordBody, G as GetAllParams, a as GetDetailParams, b as GetListParams, c as GetSelectionType, f as GetViewParams, L as LoginCredentialBody, O as OnChangeParams, R as ResetPasswordRequest, S as SaveParams, d as SocialTokenBody, e as Specification, U as UpdatePasswordRequest, g as View, V as ViewData, u as updatePasswordBody } from './view-type-xxw9OeSR.js';
2
+ export { B as BaseModelInit } from './base-model-type-DD8uZnDP.js';
2
3
 
3
4
  interface Config {
4
5
  baseUrl: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fctc/interface-logic",
3
- "version": "2.4.4",
3
+ "version": "2.4.6",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -54,6 +54,11 @@
54
54
  "types": "./dist/types.d.ts",
55
55
  "import": "./dist/types.mjs",
56
56
  "require": "./dist/types.cjs"
57
+ },
58
+ "./models": {
59
+ "types": "./dist/models.d.ts",
60
+ "import": "./dist/models.mjs",
61
+ "require": "./dist/models.cjs"
57
62
  }
58
63
  },
59
64
  "files": [