@ianua/ianus-dataverse-react-fluentui8 1.0.9 → 1.0.10
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.js +56 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -432,7 +432,7 @@ var dialogContentProps2 = {
|
|
|
432
432
|
type: import_react2.DialogType.largeHeader,
|
|
433
433
|
title: "Debug"
|
|
434
434
|
};
|
|
435
|
-
var DebugDialog = ({ publisherId, productId, dataProvider, offlineDataProvider, onDismiss }) => {
|
|
435
|
+
var DebugDialog = ({ publisherId, productId, environmentType, environmentIdentifier, dataProvider, offlineDataProvider, onDismiss }) => {
|
|
436
436
|
const [licenseState, licenseDispatch] = useLicenseContext();
|
|
437
437
|
const licenseColumns = [
|
|
438
438
|
{ key: "id", name: "Id", fieldName: "ian_licenseid", minWidth: 100, maxWidth: 200, isResizable: true },
|
|
@@ -460,7 +460,7 @@ var DebugDialog = ({ publisherId, productId, dataProvider, offlineDataProvider,
|
|
|
460
460
|
dialogContentProps: dialogContentProps2,
|
|
461
461
|
modalProps: modalProps2
|
|
462
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(
|
|
463
|
+
/* @__PURE__ */ React3.createElement("p", null, /* @__PURE__ */ React3.createElement(import_react2.Text, null, /* @__PURE__ */ React3.createElement("b", null, "Current environment type:"), " ", environmentType), /* @__PURE__ */ React3.createElement(import_react2.Text, null, /* @__PURE__ */ React3.createElement("b", null, "Current environment identifier:"), " ", environmentIdentifier), /* @__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
464
|
import_react2.DetailsList,
|
|
465
465
|
{
|
|
466
466
|
items: mapRecordsToItems(dataProvider),
|
|
@@ -510,17 +510,6 @@ var acquireLicenses = (publisherId, productId, dataProvider) => __async(null, nu
|
|
|
510
510
|
throw new Error(`The 'dataProvider' prop must be either of type ComponentFramework.WebApi or ComponentFramework.PropertyTypes.Dataset. You passed '${typeof dataProvider}'.`);
|
|
511
511
|
}
|
|
512
512
|
});
|
|
513
|
-
var updateResultIfDefined = (result, onLicenseValidated) => {
|
|
514
|
-
if (onLicenseValidated) {
|
|
515
|
-
try {
|
|
516
|
-
onLicenseValidated(result);
|
|
517
|
-
} catch (e) {
|
|
518
|
-
if (e && e instanceof Error) {
|
|
519
|
-
console.error(`Error while calling onLicenseValidated: '${e.message}'`);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
513
|
var fetchOrganizationIdFromWebApi = (webApi) => __async(null, null, function* () {
|
|
525
514
|
const results = yield webApi.retrieveMultipleRecords("organization", "?$top=1&$select=organizationid");
|
|
526
515
|
if (!results.entities.length) {
|
|
@@ -532,6 +521,17 @@ var fetchOrganizationIdFromWebApi = (webApi) => __async(null, null, function* ()
|
|
|
532
521
|
var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environmentIdentifier, dataProvider, offlineDataProvider, usagePermission, onLicenseValidated, children }) => {
|
|
533
522
|
var _a, _b, _c, _d, _e;
|
|
534
523
|
const [licenseState, licenseDispatch] = useLicenseContext();
|
|
524
|
+
const onLicenseValidatedRef = React4.useRef(onLicenseValidated);
|
|
525
|
+
React4.useEffect(() => {
|
|
526
|
+
onLicenseValidatedRef.current = onLicenseValidated;
|
|
527
|
+
}, [onLicenseValidated]);
|
|
528
|
+
const publicKeysRef = React4.useRef(publicKeys);
|
|
529
|
+
React4.useEffect(() => {
|
|
530
|
+
if (JSON.stringify(publicKeys) !== JSON.stringify(publicKeysRef.current)) {
|
|
531
|
+
publicKeysRef.current = publicKeys;
|
|
532
|
+
}
|
|
533
|
+
}, [publicKeys]);
|
|
534
|
+
const resolvedEnvironmentIdentifierRef = React4.useRef(null);
|
|
535
535
|
const runValidation = React4.useCallback(() => __async(null, null, function* () {
|
|
536
536
|
try {
|
|
537
537
|
if (!productId) {
|
|
@@ -541,7 +541,7 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
|
|
|
541
541
|
reason: "No productId found, pass a productId as prop!"
|
|
542
542
|
};
|
|
543
543
|
}
|
|
544
|
-
if (!
|
|
544
|
+
if (!publicKeysRef.current || !publicKeysRef.current.length) {
|
|
545
545
|
return {
|
|
546
546
|
isValid: false,
|
|
547
547
|
isTerminalError: true,
|
|
@@ -566,8 +566,17 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
|
|
|
566
566
|
};
|
|
567
567
|
}
|
|
568
568
|
const licenseRecord = licenses[0];
|
|
569
|
-
|
|
570
|
-
|
|
569
|
+
if (resolvedEnvironmentIdentifierRef.current === null) {
|
|
570
|
+
resolvedEnvironmentIdentifierRef.current = isWebApi(environmentIdentifier) ? yield fetchOrganizationIdFromWebApi(environmentIdentifier) : environmentIdentifier;
|
|
571
|
+
}
|
|
572
|
+
if (!resolvedEnvironmentIdentifierRef.current) {
|
|
573
|
+
return {
|
|
574
|
+
isValid: false,
|
|
575
|
+
isTerminalError: true,
|
|
576
|
+
reason: `Failed to determine current environment identifier!`
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
const validationResult = yield validateLicense(publisherId, productId, environmentType, resolvedEnvironmentIdentifierRef.current, publicKeysRef.current, licenseRecord.ian_key);
|
|
571
580
|
return __spreadProps(__spreadValues({}, validationResult), {
|
|
572
581
|
licenseId: licenseRecord.ian_licenseid,
|
|
573
582
|
licenseKey: licenseRecord.ian_key
|
|
@@ -579,12 +588,20 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
|
|
|
579
588
|
reason: e == null ? void 0 : e.message
|
|
580
589
|
};
|
|
581
590
|
}
|
|
582
|
-
}), [dataProvider, environmentIdentifier, environmentType, offlineDataProvider, productId,
|
|
591
|
+
}), [dataProvider, environmentIdentifier, environmentType, offlineDataProvider, productId, publisherId]);
|
|
583
592
|
const initLicenseValidation = React4.useCallback(() => __async(null, null, function* () {
|
|
584
593
|
const result = yield runValidation();
|
|
585
594
|
licenseDispatch({ type: "setLicense", payload: result });
|
|
586
|
-
|
|
587
|
-
|
|
595
|
+
if (onLicenseValidatedRef.current) {
|
|
596
|
+
try {
|
|
597
|
+
onLicenseValidatedRef.current(result);
|
|
598
|
+
} catch (e) {
|
|
599
|
+
if (e && e instanceof Error) {
|
|
600
|
+
console.error(`Error while calling onLicenseValidated: '${e.message}'`);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}), [licenseDispatch, runValidation]);
|
|
588
605
|
const onSettingsFinally = React4.useCallback(() => {
|
|
589
606
|
licenseDispatch({ type: "setLicenseDialogVisible", payload: false });
|
|
590
607
|
initLicenseValidation();
|
|
@@ -637,7 +654,15 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
|
|
|
637
654
|
reason: "Your user is not enabled for using this product"
|
|
638
655
|
};
|
|
639
656
|
licenseDispatch({ type: "setLicense", payload: result });
|
|
640
|
-
|
|
657
|
+
if (onLicenseValidatedRef.current) {
|
|
658
|
+
try {
|
|
659
|
+
onLicenseValidatedRef.current(result);
|
|
660
|
+
} catch (e) {
|
|
661
|
+
if (e && e instanceof Error) {
|
|
662
|
+
console.error(`Error while calling onLicenseValidated: '${e.message}'`);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
641
666
|
} else if (!isDataset(dataProvider) || !dataProvider.error && !dataProvider.loading && dataProvider.paging.totalResultCount >= 0 || offlineDataProvider != null && !offlineDataProvider.error && !offlineDataProvider.loading && offlineDataProvider.paging.totalResultCount >= 0) {
|
|
642
667
|
initLicenseValidation();
|
|
643
668
|
} else if (dataProvider.error) {
|
|
@@ -647,10 +672,18 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
|
|
|
647
672
|
reason: `Dataset error: ${dataProvider.errorMessage}`
|
|
648
673
|
};
|
|
649
674
|
licenseDispatch({ type: "setLicense", payload: result });
|
|
650
|
-
|
|
675
|
+
if (onLicenseValidatedRef.current) {
|
|
676
|
+
try {
|
|
677
|
+
onLicenseValidatedRef.current(result);
|
|
678
|
+
} catch (e) {
|
|
679
|
+
if (e && e instanceof Error) {
|
|
680
|
+
console.error(`Error while calling onLicenseValidated: '${e.message}'`);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
651
684
|
}
|
|
652
|
-
}, [dataProvider, dataProviderState, dataProviderSignature, initLicenseValidation, licenseDispatch, usagePermission,
|
|
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(
|
|
685
|
+
}, [dataProvider, dataProviderState, dataProviderSignature, initLicenseValidation, licenseDispatch, usagePermission, offlineDataProvider, offlineDataProviderState, offlineDataProviderSignature]);
|
|
686
|
+
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, environmentType, environmentIdentifier: resolvedEnvironmentIdentifierRef.current || "", 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(
|
|
654
687
|
import_MessageBar.MessageBar,
|
|
655
688
|
{
|
|
656
689
|
messageBarType: import_MessageBar.MessageBarType.error,
|
package/package.json
CHANGED