procode-lowcode-core 1.0.6 → 1.0.7

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/dist/index.esm.js CHANGED
@@ -4,7 +4,7 @@ import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
4
4
  import { useSelector, useDispatch, useStore, Provider } from 'react-redux';
5
5
  import axios from 'axios';
6
6
  import { createSlice, configureStore } from '@reduxjs/toolkit';
7
- import { call, select, put, all, fork, takeEvery } from 'redux-saga/effects';
7
+ import { delay, call, select, put, all, fork, takeEvery } from 'redux-saga/effects';
8
8
  import createSagaMiddleware from 'redux-saga';
9
9
 
10
10
  /******************************************************************************
@@ -71,6 +71,8 @@ const eventServiceType = {
71
71
  UI_SCHEMA_ACTION: "UI_SCHEMA_ACTION",
72
72
  UISCHEMA: "UISCHEMA",
73
73
  DATASTATE: "DATASTATE",
74
+ REQUEST_START: "REQUEST_START",
75
+ REQUEST_END: "REQUEST_END",
74
76
  };
75
77
  const parentRoute = ":parentslug/*";
76
78
  const childRoute = "section/:childslug/*";
@@ -258,8 +260,8 @@ class CoreAdapterProvider {
258
260
  enumerable: true,
259
261
  configurable: true,
260
262
  writable: true,
261
- value: (id, eventService) => {
262
- const { getSerializedModelData, getDeserializedModelData, getSupportiveFilters, getDeserializedSupportiveData, getDefaultViewModel, getSerializedRequestParam, getCustomAdapterMethod, } = this.getScreenAdapter(id);
263
+ value: (id, eventService, params) => {
264
+ const { getSerializedModelData, getDeserializedModelData, getSupportiveFilters, getDeserializedSupportiveData, getDefaultViewModel, getSerializedRequestParam, getCustomAdapterMethod, } = this.getScreenAdapter(id, params);
263
265
  eventService === null || eventService === void 0 ? void 0 : eventService.subscribe(AdapterType.GET_DEFAULT_VIEW_MODEL, getDefaultViewModel);
264
266
  eventService === null || eventService === void 0 ? void 0 : eventService.subscribe(AdapterType.GET_SERIALIZED_MODEL, getSerializedModelData);
265
267
  eventService === null || eventService === void 0 ? void 0 : eventService.subscribe(AdapterType.GET_DESERIALIZED_MODEL, getDeserializedModelData);
@@ -273,15 +275,17 @@ class CoreAdapterProvider {
273
275
  enumerable: true,
274
276
  configurable: true,
275
277
  writable: true,
276
- value: (id) => {
277
- var _a, _b, _c, _d, _e, _f;
278
- const adapter = window.getAdapter(id);
279
- const getSerializedModelData = (_a = adapter === null || adapter === void 0 ? void 0 : adapter.serializedModelData) !== null && _a !== void 0 ? _a : dummyFunc;
280
- const getDeserializedSupportiveData = (_b = adapter === null || adapter === void 0 ? void 0 : adapter.deserializedSupportiveData) !== null && _b !== void 0 ? _b : dummyFunc;
281
- const getDeserializedModelData = (_c = adapter === null || adapter === void 0 ? void 0 : adapter.deserializedModelData) !== null && _c !== void 0 ? _c : dummyFunc;
282
- const getSupportiveFilters = (_d = adapter === null || adapter === void 0 ? void 0 : adapter.supportiveFilters) !== null && _d !== void 0 ? _d : dummyFunc;
283
- const getDefaultViewModel = (_e = adapter === null || adapter === void 0 ? void 0 : adapter.defaultViewModel) !== null && _e !== void 0 ? _e : dummyFunc;
284
- const getSerializedRequestParam = (_f = adapter === null || adapter === void 0 ? void 0 : adapter.serializedRequestParam) !== null && _f !== void 0 ? _f : dummyFunc;
278
+ value: (id, params) => {
279
+ var _a, _b, _c, _d, _e, _f, _g, _h;
280
+ const { appCode } = params;
281
+ const atapterNamespace = "getAdapter" + ((_b = (_a = env.applicationCode) !== null && _a !== void 0 ? _a : appCode) !== null && _b !== void 0 ? _b : "");
282
+ const adapter = window[atapterNamespace](id);
283
+ const getSerializedModelData = (_c = adapter === null || adapter === void 0 ? void 0 : adapter.serializedModelData) !== null && _c !== void 0 ? _c : dummyFunc;
284
+ const getDeserializedSupportiveData = (_d = adapter === null || adapter === void 0 ? void 0 : adapter.deserializedSupportiveData) !== null && _d !== void 0 ? _d : dummyFunc;
285
+ const getDeserializedModelData = (_e = adapter === null || adapter === void 0 ? void 0 : adapter.deserializedModelData) !== null && _e !== void 0 ? _e : dummyFunc;
286
+ const getSupportiveFilters = (_f = adapter === null || adapter === void 0 ? void 0 : adapter.supportiveFilters) !== null && _f !== void 0 ? _f : dummyFunc;
287
+ const getDefaultViewModel = (_g = adapter === null || adapter === void 0 ? void 0 : adapter.defaultViewModel) !== null && _g !== void 0 ? _g : dummyFunc;
288
+ const getSerializedRequestParam = (_h = adapter === null || adapter === void 0 ? void 0 : adapter.serializedRequestParam) !== null && _h !== void 0 ? _h : dummyFunc;
285
289
  const getCustomAdapterMethod = (methodName) => {
286
290
  var _a;
287
291
  return (_a = adapter[methodName]) !== null && _a !== void 0 ? _a : null;
@@ -1009,12 +1013,12 @@ const coreResponseFormatter = (data, status) => {
1009
1013
  };
1010
1014
 
1011
1015
  const axiosInstance = axios.create();
1012
- const getSchemaBySlugService = (slug) => __awaiter(void 0, void 0, void 0, function* () {
1013
- var _a, _b, _c, _d, _e;
1016
+ const getSchemaBySlugService = (slug, appCode) => __awaiter(void 0, void 0, void 0, function* () {
1017
+ var _a, _b, _c, _d, _e, _f;
1014
1018
  try {
1015
- const res = yield axiosInstance.get(`${env.toolSchemaFetchUrl}?applicationCode=${env.applicationCode}&slug=${slug}&status=${env.projectEnviroment}`);
1016
- if (((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.responseCode) == 200 && ((_c = (_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.metadata)) {
1017
- return JSON.parse((_e = (_d = res === null || res === void 0 ? void 0 : res.data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.metadata);
1019
+ const res = yield axiosInstance.get(`${env.toolSchemaFetchUrl}?applicationCode=${(_a = env.applicationCode) !== null && _a !== void 0 ? _a : appCode}&slug=${slug}&status=${env.projectEnviroment}`);
1020
+ if (((_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.responseCode) == 200 && ((_d = (_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.metadata)) {
1021
+ return JSON.parse((_f = (_e = res === null || res === void 0 ? void 0 : res.data) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.metadata);
1018
1022
  }
1019
1023
  }
1020
1024
  catch (error) {
@@ -19338,6 +19342,13 @@ const setupStoreAction = (dispatch, eventService, store) => {
19338
19342
  Object.entries(actions).forEach(([eventType, action]) => {
19339
19343
  eventService === null || eventService === void 0 ? void 0 : eventService.subscribe(eventType, () => action);
19340
19344
  });
19345
+ // Register loader handlers for external services
19346
+ eventService === null || eventService === void 0 ? void 0 : eventService.subscribe(eventServiceType.REQUEST_START, () => () => {
19347
+ dispatch(commonDataActions.updatePendingRequests(LoadingStatus.INPROCESS));
19348
+ });
19349
+ eventService === null || eventService === void 0 ? void 0 : eventService.subscribe(eventServiceType.REQUEST_END, () => () => {
19350
+ dispatch(commonDataActions.updatePendingRequests(LoadingStatus.COMPLETE));
19351
+ });
19341
19352
  };
19342
19353
 
19343
19354
  const setVisibility = (uiElement, isVisible) => {
@@ -19683,7 +19694,7 @@ const ScreenInitializer = (props) => {
19683
19694
  const setupScreenAdapter = useCallback(() => {
19684
19695
  var _a, _b;
19685
19696
  (_a = AppDependenceyProvider.getInstance()
19686
- .getAdapterProvider()) === null || _a === void 0 ? void 0 : _a.setUpScreenAdapter((_b = props.uiMetaData) === null || _b === void 0 ? void 0 : _b.screenId, props.eventService);
19697
+ .getAdapterProvider()) === null || _a === void 0 ? void 0 : _a.setUpScreenAdapter((_b = props.uiMetaData) === null || _b === void 0 ? void 0 : _b.screenId, props.eventService, params);
19687
19698
  }, [(_a = props.uiMetaData) === null || _a === void 0 ? void 0 : _a.screenId]);
19688
19699
  const initializeScreen = () => __awaiter(void 0, void 0, void 0, function* () {
19689
19700
  setupStoreAction(dispatch, props.eventService, store);
@@ -19770,6 +19781,7 @@ function* dispatchModifiedState({ existUIState, modifiedUIState, put, }) {
19770
19781
  function* handleViewModelChange({ select, call, put }) {
19771
19782
  const appState = yield select((state) => state.app);
19772
19783
  const uiSchemaState = yield select((state) => state.metaData);
19784
+ yield delay(100);
19773
19785
  const modifiedState = applyUIEffectProcessor(_.cloneDeep(uiSchemaState.uiSchema), _.cloneDeep(appState.viewModel));
19774
19786
  yield call(dispatchModifiedState, {
19775
19787
  existUIState: {
@@ -19882,12 +19894,12 @@ const DocumentElement = ({ NotificationElement, LoaderElement }) => {
19882
19894
  };
19883
19895
 
19884
19896
  const getLoadedSchema = (store, slug) => store.commonData.loadedSchema[slug];
19885
- const loader = ({ commonStore, slug, appRouterProps }) => __awaiter(void 0, void 0, void 0, function* () {
19897
+ const loader = ({ commonStore, slug, appRouterProps, params }) => __awaiter(void 0, void 0, void 0, function* () {
19886
19898
  var _a;
19887
19899
  if (slug) {
19888
19900
  let schema = getLoadedSchema(commonStore.getState(), slug);
19889
19901
  if (!schema) {
19890
- schema = yield ((_a = appRouterProps.schemaReaderProvider) === null || _a === void 0 ? void 0 : _a.getScreenSchema(slug));
19902
+ schema = yield ((_a = appRouterProps.schemaReaderProvider) === null || _a === void 0 ? void 0 : _a.getScreenSchema(slug, params.appCode));
19891
19903
  commonStore.dispatch(commonDataActions.updateLoadedSchema({
19892
19904
  slug,
19893
19905
  schema,
@@ -19910,10 +19922,10 @@ const RouterElement = ({ NotificationElement, PageNotFoundElement, }) => {
19910
19922
 
19911
19923
  const AppRouter = (appRouterProps) => {
19912
19924
  var _a;
19913
- const loadSchema = (slug) => __awaiter(void 0, void 0, void 0, function* () { return yield loader({ commonStore, appRouterProps, slug }); });
19914
- const documentLoader = () => __awaiter(void 0, void 0, void 0, function* () {
19915
- const headerSchema = yield loadSchema(env.headerSlug);
19916
- const footerSchema = yield loadSchema(env.footerSlug);
19925
+ const loadSchema = (slug, params) => __awaiter(void 0, void 0, void 0, function* () { return yield loader({ commonStore, appRouterProps, slug, params }); });
19926
+ const documentLoader = ({ params }) => __awaiter(void 0, void 0, void 0, function* () {
19927
+ const headerSchema = yield loadSchema(env.headerSlug, params);
19928
+ const footerSchema = yield loadSchema(env.footerSlug, params);
19917
19929
  return { headerSchema, footerSchema };
19918
19930
  });
19919
19931
  const createCustomRouteElements = (routes) => {
@@ -19921,7 +19933,7 @@ const AppRouter = (appRouterProps) => {
19921
19933
  path: route.path,
19922
19934
  element: (jsx(RouterElement, { NotificationElement: appRouterProps.NotificationElement, PageNotFoundElement: appRouterProps.PageNotFoundElement }, route.path)),
19923
19935
  errorElement: appRouterProps.ErrorElement,
19924
- loader: ({ params }) => __awaiter(void 0, void 0, void 0, function* () { return yield loadSchema(getSlug(params, "custom", route.customSlug)); }),
19936
+ loader: ({ params }) => __awaiter(void 0, void 0, void 0, function* () { return yield loadSchema(getSlug(params, "custom", route.customSlug), params); }),
19925
19937
  children: route.children ? createCustomRouteElements(route.children) : [],
19926
19938
  }));
19927
19939
  };
@@ -19932,7 +19944,7 @@ const AppRouter = (appRouterProps) => {
19932
19944
  path: childRoute,
19933
19945
  element: (jsx(RouterElement, { NotificationElement: appRouterProps.NotificationElement, PageNotFoundElement: appRouterProps.PageNotFoundElement }, "childRouterElement")),
19934
19946
  errorElement: appRouterProps.ErrorElement,
19935
- loader: ({ params }) => __awaiter(void 0, void 0, void 0, function* () { return yield loadSchema(getSlug(params, "child")); }),
19947
+ loader: ({ params }) => __awaiter(void 0, void 0, void 0, function* () { return yield loadSchema(getSlug(params, "child"), params); }),
19936
19948
  children: ((_a = appRouterProps.customRoute) === null || _a === void 0 ? void 0 : _a.childNestedRoutes)
19937
19949
  ? createCustomRouteElements((_b = appRouterProps.customRoute) === null || _b === void 0 ? void 0 : _b.childNestedRoutes)
19938
19950
  : [],
@@ -19949,7 +19961,7 @@ const AppRouter = (appRouterProps) => {
19949
19961
  path: parentRoute,
19950
19962
  element: (jsx(RouterElement, { NotificationElement: appRouterProps.NotificationElement, PageNotFoundElement: appRouterProps.PageNotFoundElement }, "parentRouterElement")),
19951
19963
  errorElement: appRouterProps.ErrorElement,
19952
- loader: ({ params }) => __awaiter(void 0, void 0, void 0, function* () { return yield loadSchema(getSlug(params, "parent")); }),
19964
+ loader: ({ params }) => __awaiter(void 0, void 0, void 0, function* () { return yield loadSchema(getSlug(params, "parent"), params); }),
19953
19965
  children: createChildRoutes(),
19954
19966
  },
19955
19967
  ...(((_a = appRouterProps.customRoute) === null || _a === void 0 ? void 0 : _a.parentSimblingRoutes)
@@ -20130,13 +20142,27 @@ class ScreenSchema {
20130
20142
 
20131
20143
  class CoreSchemaReaderProvider {
20132
20144
  constructor() {
20145
+ Object.defineProperty(this, "schemaCache", {
20146
+ enumerable: true,
20147
+ configurable: true,
20148
+ writable: true,
20149
+ value: new Map()
20150
+ });
20133
20151
  Object.defineProperty(this, "getScreenSchema", {
20134
20152
  enumerable: true,
20135
20153
  configurable: true,
20136
20154
  writable: true,
20137
- value: (slug) => __awaiter(this, void 0, void 0, function* () {
20155
+ value: (slug, appCode) => __awaiter(this, void 0, void 0, function* () {
20156
+ // Check if schema exists in cache
20157
+ if (this.schemaCache.has(slug)) {
20158
+ const cachedData = this.schemaCache.get(slug);
20159
+ return new ScreenSchema(cachedData);
20160
+ }
20161
+ // Fetch from service if not in cache
20138
20162
  const getSchemaBySlugService = AppDependenceyProvider.getInstance().getSchemaBySlugService();
20139
- const schemaData = yield getSchemaBySlugService(slug);
20163
+ const schemaData = yield getSchemaBySlugService(slug, appCode);
20164
+ // Store in cache
20165
+ this.schemaCache.set(slug, schemaData);
20140
20166
  return schemaData ? new ScreenSchema(schemaData) : null;
20141
20167
  })
20142
20168
  });