@darajs/core 1.0.2 → 1.1.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"use-component-registry.d.ts","sourceRoot":"","sources":["../../../js/shared/utils/use-component-registry.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE5D,UAAU,0BAA0B;IAChC,GAAG,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;CAC5D;AAED;;;GAGG;AACH,iBAAS,oBAAoB,CAAC,UAAU,SAAI,GAAG,0BAA0B,CAmCxE;AAED,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"use-component-registry.d.ts","sourceRoot":"","sources":["../../../js/shared/utils/use-component-registry.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE5D,UAAU,0BAA0B;IAChC,GAAG,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;CAC5D;AAED;;;GAGG;AACH,iBAAS,oBAAoB,CAAC,UAAU,SAAI,GAAG,0BAA0B,CA2CxE;AAED,eAAe,oBAAoB,CAAC"}
@@ -9,6 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  /* eslint-disable no-await-in-loop */
11
11
  import { useCallback, useContext } from 'react';
12
+ import { HTTP_METHOD, validateResponse } from '@darajs/ui-utils';
13
+ import { request } from '../../api';
14
+ import { handleAuthErrors } from '../../auth/auth';
15
+ import { useSessionToken } from '../../auth/auth-context';
12
16
  import { RegistriesCtx } from '../../shared/context';
13
17
  /**
14
18
  * The component registry pulls the full list of components from the backend and then returns a function that allows a
@@ -16,6 +20,7 @@ import { RegistriesCtx } from '../../shared/context';
16
20
  */
17
21
  function useComponentRegistry(maxRetries = 5) {
18
22
  const { componentRegistry: components, refetchComponents } = useContext(RegistriesCtx);
23
+ const token = useSessionToken();
19
24
  const get = useCallback((instance) => __awaiter(this, void 0, void 0, function* () {
20
25
  let component = null;
21
26
  let registry = Object.assign({}, components);
@@ -25,6 +30,12 @@ function useComponentRegistry(maxRetries = 5) {
25
30
  component = registry[instance.name];
26
31
  break;
27
32
  }
33
+ if (i === 0) {
34
+ const res = yield request(`/api/core/components?name=${instance.name}`, { method: HTTP_METHOD.GET }, token);
35
+ yield handleAuthErrors(res, true);
36
+ yield validateResponse(res, 'Failed to fetch the config for this app');
37
+ registry = yield res.json();
38
+ }
28
39
  else {
29
40
  // If component has not been found, it could be a nested py_component, so we refetch the registry
30
41
  // to see if the component might have been added to the registry in the meantime
@@ -1 +1 @@
1
- {"version":3,"file":"use-component-registry.js","sourceRoot":"","sources":["../../../js/shared/utils/use-component-registry.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,qCAAqC;AACrC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOjD;;;GAGG;AACH,SAAS,oBAAoB,CAAC,UAAU,GAAG,CAAC;IACxC,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAEvF,MAAM,GAAG,GAAG,WAAW,CACnB,CAAO,QAA2B,EAAsB,EAAE;QACtD,IAAI,SAAS,GAAc,IAAI,CAAC;QAChC,IAAI,QAAQ,qBAAQ,UAAU,CAAE,CAAC;QAEjC,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,OAAO,CAAC,GAAG,UAAU,EAAE;YACnB,IAAI,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACrC,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACpC,MAAM;aACT;iBAAM;gBACH,iGAAiG;gBACjG,gFAAgF;gBAChF,2FAA2F;gBAC3F,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;gBACzD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,iBAAiB,EAAE,CAAC;gBAC3C,QAAQ,GAAG,IAAI,CAAC;aACnB;YAED,CAAC,EAAE,CAAC;SACP;QAED,IAAI,CAAC,SAAS,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,CAAC,IAAI,+BAA+B,CAAC,CAAC;SACnG;QAED,OAAO,SAAS,CAAC;IACrB,CAAC,CAAA,EACD,CAAC,UAAU,CAAC,CACf,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,CAAC;AACnB,CAAC;AAED,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"use-component-registry.js","sourceRoot":"","sources":["../../../js/shared/utils/use-component-registry.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,qCAAqC;AACrC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOjD;;;GAGG;AACH,SAAS,oBAAoB,CAAC,UAAU,GAAG,CAAC;IACxC,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACvF,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,GAAG,GAA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B,CAAC;AAED,eAAe,oBAAoB,CAAC"}
@@ -56483,6 +56483,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
56483
56483
  }
56484
56484
  function useComponentRegistry(maxRetries = 5) {
56485
56485
  const { componentRegistry: components, refetchComponents } = React$2.useContext(registriesCtx);
56486
+ const token = useSessionToken();
56486
56487
  const get2 = React$2.useCallback(
56487
56488
  async (instance) => {
56488
56489
  let component = null;
@@ -56492,6 +56493,16 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
56492
56493
  if (registry && registry[instance.name]) {
56493
56494
  component = registry[instance.name];
56494
56495
  break;
56496
+ }
56497
+ if (i2 === 0) {
56498
+ const res = await request(
56499
+ `/api/core/components?name=${instance.name}`,
56500
+ { method: HTTP_METHOD.GET },
56501
+ token
56502
+ );
56503
+ await handleAuthErrors(res, true);
56504
+ await validateResponse(res, "Failed to fetch the config for this app");
56505
+ registry = await res.json();
56495
56506
  } else {
56496
56507
  await new Promise((resolve) => setTimeout(resolve, 500));
56497
56508
  const { data } = await refetchComponents();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darajs/core",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "description": "Dara Framework core",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -113,5 +113,5 @@
113
113
  "publishConfig": {
114
114
  "access": "public"
115
115
  },
116
- "gitHead": "0bb42050ea22d45b8a9d8f4cb9523bc66109195f"
116
+ "gitHead": "139a6b295a157b5a1348a790b1562922756ce889"
117
117
  }