Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,105 @@
|
||||
// Generated, do not edit. sha256:ec282b725055d62dd35348c8698b9fb220cb23c5aa15fc53463e42d07d187d42
|
||||
import { getPref } from '../data/preferences.js';
|
||||
import { ENUMS } from '../../shared/config.js';
|
||||
import { hasFeature } from '../license.mjs';
|
||||
|
||||
export const AI_DISABLED = 'ai_disabled';
|
||||
|
||||
export const AI_WRITE_DENIED = 'ai_write_denied';
|
||||
|
||||
export const AI_CONTROL_DENIED = 'ai_control_denied';
|
||||
|
||||
export const AI_UNLICENSED = 'ai_unlicensed';
|
||||
|
||||
export const AI_UNLICENSED_TEXT =
|
||||
'De AI-koppeling hoort bij de betaalde versie van AssetApp. De gratis versie laat de administratie '
|
||||
+ 'niet lezen of wijzigen via een AI-koppeling. Er is niets gelezen en niets gewijzigd; deze poging '
|
||||
+ 'staat wel in het activiteitenlogboek.';
|
||||
|
||||
export const AI_INACTIVE = 'ai_inactive';
|
||||
|
||||
export const AI_REFUSALS = Object.freeze([AI_UNLICENSED, AI_INACTIVE, AI_DISABLED, AI_WRITE_DENIED, AI_CONTROL_DENIED]);
|
||||
|
||||
export const AI_INACTIVE_TEXT =
|
||||
'De AI-koppeling van AssetApp staat uit. Er wordt niets gelezen, niets gewijzigd en niets getoond, '
|
||||
+ 'ook geen verbindingstest. De eigenaar van de app zet hem weer aan met de schuif "Actief" onder '
|
||||
+ 'Systeem, tabblad AI-activiteit. Deze poging staat wel in het activiteitenlogboek.';
|
||||
|
||||
export const AI_DISABLED_TEXT =
|
||||
'De AI-koppeling van AssetApp mag de administratie niet lezen. De koppeling zelf staat wel aan; '
|
||||
+ 'lezen is een aparte schuif die de eigenaar van de app zelf aanzet onder Systeem, tabblad '
|
||||
+ 'AI-activiteit. Er is niets gelezen en niets gewijzigd; deze poging staat wel in het '
|
||||
+ 'activiteitenlogboek.';
|
||||
|
||||
export function isAiEnabled() {
|
||||
try { return getPref('ai', 'allow_read') !== 0; }
|
||||
catch { return false; }
|
||||
}
|
||||
|
||||
export function isAiActive() {
|
||||
try { return getPref('ai', 'enabled') !== 0; }
|
||||
catch { return false; }
|
||||
}
|
||||
|
||||
export function assertAiEnabled() {
|
||||
if (isAiEnabled()) return;
|
||||
const e = new Error(AI_DISABLED_TEXT);
|
||||
e.code = AI_DISABLED;
|
||||
throw e;
|
||||
}
|
||||
|
||||
export const AI_WRITE_DENIED_TEXT =
|
||||
'De AI-koppeling van AssetApp mag niets wijzigen. Lezen kan wel; schrijven is een aparte instelling '
|
||||
+ 'die de eigenaar van de app zelf aanzet onder Systeem, tabblad AI-activiteit. Er is niets '
|
||||
+ 'gewijzigd; deze poging staat wel in het activiteitenlogboek.';
|
||||
|
||||
export function isAiWriteAllowed() {
|
||||
try { return getPref('ai', 'allow_write') === 1; }
|
||||
catch { return false; }
|
||||
}
|
||||
|
||||
export const AI_CONTROL_DENIED_TEXT =
|
||||
'De AI-koppeling van AssetApp mag de app niet besturen. Lezen kan wel; navigeren is een aparte '
|
||||
+ 'instelling die de eigenaar van de app zelf aanzet onder Systeem, tabblad AI-activiteit. Er is '
|
||||
+ 'niets gewijzigd; deze poging staat wel in het activiteitenlogboek.';
|
||||
|
||||
export function isAiControlAllowed() {
|
||||
try { return getPref('ai', 'allow_control') === 1; }
|
||||
catch { return false; }
|
||||
}
|
||||
|
||||
export function isAiRawAllowed() {
|
||||
try { return getPref('ai', 'allow_raw') === 1; }
|
||||
catch { return false; }
|
||||
}
|
||||
|
||||
function weigering(scope) {
|
||||
if (!hasFeature('ai')) return { code: AI_UNLICENSED, text: AI_UNLICENSED_TEXT };
|
||||
if (!isAiActive()) return { code: AI_INACTIVE, text: AI_INACTIVE_TEXT };
|
||||
if (scope === 'none') return null;
|
||||
if (scope === 'read') {
|
||||
return isAiEnabled() ? null : { code: AI_DISABLED, text: AI_DISABLED_TEXT };
|
||||
}
|
||||
if (scope === 'write') {
|
||||
return isAiWriteAllowed() ? null : { code: AI_WRITE_DENIED, text: AI_WRITE_DENIED_TEXT };
|
||||
}
|
||||
if (scope === 'control') {
|
||||
return isAiControlAllowed() ? null : { code: AI_CONTROL_DENIED, text: AI_CONTROL_DENIED_TEXT };
|
||||
}
|
||||
return {
|
||||
code: AI_DISABLED,
|
||||
text: `Onbekende scope '${scope}'; toegestaan is ${ENUMS.AI_SCOPE.join(', ')}.`,
|
||||
};
|
||||
}
|
||||
|
||||
export function assertScope(scope) {
|
||||
const w = weigering(scope);
|
||||
if (!w) return;
|
||||
const e = new Error(w.text);
|
||||
e.code = w.code;
|
||||
throw e;
|
||||
}
|
||||
|
||||
export function mayScope(scope) {
|
||||
return weigering(scope) === null;
|
||||
}
|
||||
Reference in new issue
Block a user