@ianua/ianus-dataverse-react-fluentui8 1.0.8 → 1.0.9

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.d.ts CHANGED
@@ -110,10 +110,14 @@ type Action = {
110
110
  } | {
111
111
  type: "setLicenseDialogVisible";
112
112
  payload: boolean;
113
+ } | {
114
+ type: "setDebugDialogVisible";
115
+ payload: boolean;
113
116
  };
114
117
  type IanusLicenseStateProps = {
115
118
  license?: DataverseLicenseValidationResult;
116
119
  licenseDialogVisible?: boolean;
120
+ debugDialogVisible?: boolean;
117
121
  };
118
122
  type IanusLicenseDispatch = (action: Action) => void;
119
123
  declare const IanusLicenseDispatch: React.Context<IanusLicenseDispatch | undefined>;
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ __export(index_exports, {
84
84
  module.exports = __toCommonJS(index_exports);
85
85
 
86
86
  // src/IanusGuard.tsx
87
- var React3 = __toESM(require("react"));
87
+ var React4 = __toESM(require("react"));
88
88
  var import_MessageBar = require("@fluentui/react/lib/MessageBar");
89
89
  var import_Button = require("@fluentui/react/lib/Button");
90
90
  var import_Spinner = require("@fluentui/react/lib/Spinner");
@@ -242,6 +242,9 @@ function stateReducer(state, action) {
242
242
  case "setLicenseDialogVisible": {
243
243
  return __spreadProps(__spreadValues({}, state), { licenseDialogVisible: action.payload });
244
244
  }
245
+ case "setDebugDialogVisible": {
246
+ return __spreadProps(__spreadValues({}, state), { debugDialogVisible: action.payload });
247
+ }
245
248
  }
246
249
  }
247
250
  var IanusLicenseState = React.createContext(void 0);
@@ -409,6 +412,77 @@ var LicenseDialog = ({ publisherId, productId, dataProvider, offlineDataProvider
409
412
  );
410
413
  };
411
414
 
415
+ // src/DebugDialog.tsx
416
+ var React3 = __toESM(require("react"));
417
+ var import_react2 = require("@fluentui/react");
418
+ var modalProps2 = {
419
+ isBlocking: false,
420
+ styles: {
421
+ main: {
422
+ width: "80vw !important",
423
+ maxWidth: "80vw !important",
424
+ height: "auto",
425
+ maxHeight: "90vh",
426
+ overflowY: "auto",
427
+ overflowX: "auto"
428
+ }
429
+ }
430
+ };
431
+ var dialogContentProps2 = {
432
+ type: import_react2.DialogType.largeHeader,
433
+ title: "Debug"
434
+ };
435
+ var DebugDialog = ({ publisherId, productId, dataProvider, offlineDataProvider, onDismiss }) => {
436
+ const [licenseState, licenseDispatch] = useLicenseContext();
437
+ const licenseColumns = [
438
+ { key: "id", name: "Id", fieldName: "ian_licenseid", minWidth: 100, maxWidth: 200, isResizable: true },
439
+ { key: "name", name: "Name", fieldName: "ian_name", minWidth: 100, maxWidth: 200, isResizable: true },
440
+ { key: "identifier", name: "Identifier", fieldName: "ian_identifier", minWidth: 100, maxWidth: 200, isResizable: true },
441
+ { key: "key", name: "Key", fieldName: "ian_key", minWidth: 100, maxWidth: 200, isResizable: true }
442
+ ];
443
+ const mapRecordsToItems = React3.useCallback(
444
+ (dataset) => dataset.sortedRecordIds.map((id) => {
445
+ const record = dataset.records[id];
446
+ return {
447
+ ian_licenseid: record.getRecordId(),
448
+ ian_name: record.getValue("ian_name"),
449
+ ian_identifier: record.getValue("ian_identifier"),
450
+ ian_key: record.getValue("ian_key")
451
+ };
452
+ }),
453
+ []
454
+ );
455
+ return /* @__PURE__ */ React3.createElement(
456
+ import_react2.Dialog,
457
+ {
458
+ hidden: !(licenseState == null ? void 0 : licenseState.debugDialogVisible),
459
+ onDismiss,
460
+ dialogContentProps: dialogContentProps2,
461
+ modalProps: modalProps2
462
+ },
463
+ /* @__PURE__ */ React3.createElement("p", null, /* @__PURE__ */ React3.createElement(import_react2.Text, null, /* @__PURE__ */ React3.createElement("b", null, "Target license identifier:"), " ", publisherId, "_", productId), /* @__PURE__ */ React3.createElement("br", null), /* @__PURE__ */ React3.createElement("br", null), isDataset(dataProvider) && /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(import_react2.Text, null, /* @__PURE__ */ React3.createElement("b", null, "Licenses in data provider:"), " ", dataProvider.sortedRecordIds.length), /* @__PURE__ */ React3.createElement("br", null), /* @__PURE__ */ React3.createElement(
464
+ import_react2.DetailsList,
465
+ {
466
+ items: mapRecordsToItems(dataProvider),
467
+ columns: licenseColumns,
468
+ setKey: "dataProviderList",
469
+ layoutMode: import_react2.DetailsListLayoutMode.fixedColumns,
470
+ selectionMode: 0
471
+ }
472
+ ), /* @__PURE__ */ React3.createElement("br", null)), offlineDataProvider && isDataset(offlineDataProvider) && /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(import_react2.Text, null, /* @__PURE__ */ React3.createElement("b", null, "Licenses in offline data provider:"), " ", offlineDataProvider.sortedRecordIds.length), /* @__PURE__ */ React3.createElement("br", null), /* @__PURE__ */ React3.createElement(
473
+ import_react2.DetailsList,
474
+ {
475
+ items: mapRecordsToItems(offlineDataProvider),
476
+ columns: licenseColumns,
477
+ setKey: "offlineDataProviderList",
478
+ layoutMode: import_react2.DetailsListLayoutMode.fixedColumns,
479
+ selectionMode: 0
480
+ }
481
+ ), /* @__PURE__ */ React3.createElement("br", null))),
482
+ /* @__PURE__ */ React3.createElement(import_react2.DialogFooter, null, /* @__PURE__ */ React3.createElement(import_react2.PrimaryButton, { onClick: onDismiss, text: "Close" }))
483
+ );
484
+ };
485
+
412
486
  // src/IanusGuard.tsx
413
487
  var isWebApi = (dataProvider) => {
414
488
  return (dataProvider == null ? void 0 : dataProvider.retrieveMultipleRecords) !== void 0;
@@ -456,13 +530,9 @@ var fetchOrganizationIdFromWebApi = (webApi) => __async(null, null, function* ()
456
530
  return organization.organizationid;
457
531
  });
458
532
  var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environmentIdentifier, dataProvider, offlineDataProvider, usagePermission, onLicenseValidated, children }) => {
459
- var _a, _b, _c, _d;
533
+ var _a, _b, _c, _d, _e;
460
534
  const [licenseState, licenseDispatch] = useLicenseContext();
461
- const onSettingsFinally = () => {
462
- licenseDispatch({ type: "setLicenseDialogVisible", payload: false });
463
- initLicenseValidation();
464
- };
465
- const runValidation = React3.useCallback(() => __async(null, null, function* () {
535
+ const runValidation = React4.useCallback(() => __async(null, null, function* () {
466
536
  try {
467
537
  if (!productId) {
468
538
  return {
@@ -510,15 +580,22 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
510
580
  };
511
581
  }
512
582
  }), [dataProvider, environmentIdentifier, environmentType, offlineDataProvider, productId, publicKeys, publisherId]);
513
- const initLicenseValidation = React3.useCallback(() => __async(null, null, function* () {
583
+ const initLicenseValidation = React4.useCallback(() => __async(null, null, function* () {
514
584
  const result = yield runValidation();
515
585
  licenseDispatch({ type: "setLicense", payload: result });
516
586
  updateResultIfDefined(result, onLicenseValidated);
517
587
  }), [licenseDispatch, onLicenseValidated, runValidation]);
588
+ const onSettingsFinally = React4.useCallback(() => {
589
+ licenseDispatch({ type: "setLicenseDialogVisible", payload: false });
590
+ initLicenseValidation();
591
+ }, [initLicenseValidation, licenseDispatch]);
592
+ const onDebugFinally = React4.useCallback(() => {
593
+ licenseDispatch({ type: "setDebugDialogVisible", payload: false });
594
+ }, [licenseDispatch]);
518
595
  const dataTotalResultCount = isDataset(dataProvider) ? dataProvider.paging.totalResultCount : void 0;
519
596
  const dataIsLoading = isDataset(dataProvider) ? dataProvider.loading : void 0;
520
597
  const dataHasError = isDataset(dataProvider) ? dataProvider.error : void 0;
521
- const dataProviderState = React3.useMemo(() => {
598
+ const dataProviderState = React4.useMemo(() => {
522
599
  if (!isDataset(dataProvider)) {
523
600
  return "webapi";
524
601
  } else {
@@ -528,26 +605,26 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
528
605
  const offlineDataTotalResultCount = offlineDataProvider != null ? offlineDataProvider.paging.totalResultCount : void 0;
529
606
  const offlineDataIsLoading = offlineDataProvider != null ? offlineDataProvider.loading : void 0;
530
607
  const offlineDataHasError = offlineDataProvider != null ? offlineDataProvider.error : void 0;
531
- const offlineDataProviderState = React3.useMemo(() => {
608
+ const offlineDataProviderState = React4.useMemo(() => {
532
609
  if (offlineDataProvider == null) {
533
610
  return "unused";
534
611
  } else {
535
612
  return `dataset-${offlineDataTotalResultCount}-${offlineDataIsLoading}-${offlineDataHasError}`;
536
613
  }
537
614
  }, [offlineDataHasError, offlineDataIsLoading, offlineDataProvider, offlineDataTotalResultCount]);
538
- const dataProviderSignature = React3.useMemo(() => {
615
+ const dataProviderSignature = React4.useMemo(() => {
539
616
  if (isDataset(dataProvider) && dataProvider.records) {
540
617
  return Object.values(dataProvider.records).map((r) => `${r.getRecordId()}-${r.getValue("ian_identifier")}-${r.getValue("ian_key")}`).join("|");
541
618
  }
542
619
  return "";
543
620
  }, [dataProvider]);
544
- const offlineDataProviderSignature = React3.useMemo(() => {
621
+ const offlineDataProviderSignature = React4.useMemo(() => {
545
622
  if (offlineDataProvider && offlineDataProvider.records) {
546
623
  return Object.values(offlineDataProvider.records).map((r) => `${r.getRecordId()}-${r.getValue("ian_identifier")}-${r.getValue("ian_key")}`).join("|");
547
624
  }
548
625
  return "";
549
626
  }, [offlineDataProvider]);
550
- React3.useEffect(() => {
627
+ React4.useEffect(() => {
551
628
  console.log(`Starting license evaluation at ${(/* @__PURE__ */ new Date()).toISOString()}`);
552
629
  console.log(`DataProvider state: ${dataProviderState}`);
553
630
  console.log(`DataProvider signature: ${dataProviderSignature}`);
@@ -573,7 +650,7 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
573
650
  updateResultIfDefined(result, onLicenseValidated);
574
651
  }
575
652
  }, [dataProvider, dataProviderState, dataProviderSignature, initLicenseValidation, licenseDispatch, usagePermission, onLicenseValidated, offlineDataProvider, offlineDataProviderState, offlineDataProviderSignature]);
576
- return ((_a = licenseState.license) == null ? void 0 : _a.isValid) ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, licenseState.licenseDialogVisible && /* @__PURE__ */ React3.createElement(LicenseDialog, { publisherId, productId, dataProvider, offlineDataProvider, onSubmit: onSettingsFinally, onCancel: onSettingsFinally }), children) : /* @__PURE__ */ React3.createElement("div", { style: { display: "flex", width: "100%", height: "100%", flex: "1" } }, licenseState.licenseDialogVisible && /* @__PURE__ */ React3.createElement(LicenseDialog, { publisherId, productId, dataProvider, offlineDataProvider, onSubmit: onSettingsFinally, onCancel: onSettingsFinally }), /* @__PURE__ */ React3.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", flex: 1 } }, ((_b = licenseState.license) == null ? void 0 : _b.isValid) === false && /* @__PURE__ */ React3.createElement(
653
+ return ((_a = licenseState.license) == null ? void 0 : _a.isValid) ? /* @__PURE__ */ React4.createElement(React4.Fragment, null, licenseState.licenseDialogVisible && /* @__PURE__ */ React4.createElement(LicenseDialog, { publisherId, productId, dataProvider, offlineDataProvider, onSubmit: onSettingsFinally, onCancel: onSettingsFinally }), children) : /* @__PURE__ */ React4.createElement("div", { style: { display: "flex", width: "100%", height: "100%", flex: "1" } }, licenseState.licenseDialogVisible && /* @__PURE__ */ React4.createElement(LicenseDialog, { publisherId, productId, dataProvider, offlineDataProvider, onSubmit: onSettingsFinally, onCancel: onSettingsFinally }), licenseState.debugDialogVisible && /* @__PURE__ */ React4.createElement(DebugDialog, { publisherId, productId, dataProvider, offlineDataProvider, onDismiss: onDebugFinally }), /* @__PURE__ */ React4.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", flex: 1 } }, ((_b = licenseState.license) == null ? void 0 : _b.isValid) === false && /* @__PURE__ */ React4.createElement(
577
654
  import_MessageBar.MessageBar,
578
655
  {
579
656
  messageBarType: import_MessageBar.MessageBarType.error,
@@ -583,17 +660,17 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
583
660
  licenseDispatch({ type: "setLicense", payload: void 0 });
584
661
  initLicenseValidation();
585
662
  },
586
- actions: /* @__PURE__ */ React3.createElement("div", null, !((_c = licenseState.license) == null ? void 0 : _c.isTerminalError) && /* @__PURE__ */ React3.createElement(import_Button.MessageBarButton, { onClick: () => licenseDispatch({ type: "setLicenseDialogVisible", payload: true }) }, "Set License"))
663
+ actions: /* @__PURE__ */ React4.createElement("div", null, !((_c = licenseState.license) == null ? void 0 : _c.isTerminalError) && /* @__PURE__ */ React4.createElement(import_Button.MessageBarButton, { onClick: () => licenseDispatch({ type: "setLicenseDialogVisible", payload: true }) }, "Set License"), !((_d = licenseState.license) == null ? void 0 : _d.isTerminalError) && /* @__PURE__ */ React4.createElement(import_Button.MessageBarButton, { onClick: () => licenseDispatch({ type: "setDebugDialogVisible", payload: true }) }, "Debug"))
587
664
  },
588
665
  "An error occured, please try again. Error information: ",
589
- (_d = licenseState.license) == null ? void 0 : _d.reason
590
- ), !licenseState.license && /* @__PURE__ */ React3.createElement(import_Spinner.Spinner, { styles: { root: { width: "auto" } }, label: "Loading..." })));
666
+ (_e = licenseState.license) == null ? void 0 : _e.reason
667
+ ), !licenseState.license && /* @__PURE__ */ React4.createElement(import_Spinner.Spinner, { styles: { root: { width: "auto" } }, label: "Loading..." })));
591
668
  };
592
669
 
593
670
  // src/IanusProvider.tsx
594
- var React4 = __toESM(require("react"));
671
+ var React5 = __toESM(require("react"));
595
672
  var IanusProvider = (props) => {
596
- return /* @__PURE__ */ React4.createElement(IanusLicenseStateProvider, null, /* @__PURE__ */ React4.createElement(IanusGuard, __spreadValues({}, props)));
673
+ return /* @__PURE__ */ React5.createElement(IanusLicenseStateProvider, null, /* @__PURE__ */ React5.createElement(IanusGuard, __spreadValues({}, props)));
597
674
  };
598
675
 
599
676
  // ../../../../ianus-core/GuidTools.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ianua/ianus-dataverse-react-fluentui8",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Client-side validation for Ianus Guard licenses in Dataverse using react and FluentUi v8",
5
5
  "scripts": {
6
6
  "build": "tsup"