@rogatio/cli 5.20.1 → 6.0.0
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/editor/index.js +114 -152
- package/dist/node/index.js +551 -282
- package/package.json +1 -1
package/dist/editor/index.js
CHANGED
|
@@ -3,7 +3,6 @@ var LIMITS = Object.freeze({
|
|
|
3
3
|
maxGroups: 64,
|
|
4
4
|
maxRulesPerGroup: 256,
|
|
5
5
|
maxRulesPerProject: 4096,
|
|
6
|
-
maxOriginsPerScope: 32,
|
|
7
6
|
maxIdLength: 64,
|
|
8
7
|
maxLabelLength: 100,
|
|
9
8
|
maxDescriptionLength: 1e3,
|
|
@@ -485,8 +484,12 @@ function createAIAssistPanel(_container, _editor, onApply, onClose, onSend) {
|
|
|
485
484
|
detail.innerHTML = `<span style="color:#666;">${label}:</span> ${value}`;
|
|
486
485
|
ruleDetails.appendChild(detail);
|
|
487
486
|
};
|
|
488
|
-
|
|
489
|
-
|
|
487
|
+
if (rule.source) {
|
|
488
|
+
addDetail(
|
|
489
|
+
"Source",
|
|
490
|
+
`${rule.source.key} / ${rule.source.operator}: ${rule.source.value}`
|
|
491
|
+
);
|
|
492
|
+
}
|
|
490
493
|
if (rule.resourceTypes?.length)
|
|
491
494
|
addDetail("Types", rule.resourceTypes.join(", "));
|
|
492
495
|
if (rule.priority !== void 0)
|
|
@@ -1126,7 +1129,8 @@ function createRedirectRuleType() {
|
|
|
1126
1129
|
validate(rule, rulePath) {
|
|
1127
1130
|
const redirect = rule.redirect;
|
|
1128
1131
|
const destination = redirect !== null && typeof redirect === "object" && typeof redirect.destination === "string" ? redirect.destination : "";
|
|
1129
|
-
const
|
|
1132
|
+
const source = rule.source;
|
|
1133
|
+
const urlRegex = source !== null && typeof source === "object" && source.key === "url" && typeof source.value === "string" ? source.value : "";
|
|
1130
1134
|
const issues = validateRedirectDestination(destination, urlRegex);
|
|
1131
1135
|
return issues.map((issue) => ({
|
|
1132
1136
|
code: `schema.${issue.code}`,
|
|
@@ -1691,8 +1695,7 @@ var HTTP_METHODS2 = [
|
|
|
1691
1695
|
var COMMON_RULE_FIELDS = /* @__PURE__ */ new Set([
|
|
1692
1696
|
"id",
|
|
1693
1697
|
"name",
|
|
1694
|
-
"
|
|
1695
|
-
"origins",
|
|
1698
|
+
"source",
|
|
1696
1699
|
"resourceTypes",
|
|
1697
1700
|
"priority",
|
|
1698
1701
|
"method",
|
|
@@ -2125,6 +2128,7 @@ var EditorControllerImpl = class {
|
|
|
2125
2128
|
aiAssistPanel = null;
|
|
2126
2129
|
aiAssistInFlight = false;
|
|
2127
2130
|
aiRepairTargets = [];
|
|
2131
|
+
migrationNoticesDismissed = false;
|
|
2128
2132
|
constructor(options, initial, extensions) {
|
|
2129
2133
|
this.root = options.root;
|
|
2130
2134
|
this.document = options.root.ownerDocument;
|
|
@@ -2442,31 +2446,8 @@ var EditorControllerImpl = class {
|
|
|
2442
2446
|
if (groupId && ruleId) this.copyRule(groupId, ruleId);
|
|
2443
2447
|
return;
|
|
2444
2448
|
}
|
|
2445
|
-
if (command === "
|
|
2446
|
-
|
|
2447
|
-
if (groupId) this.addGroupOrigin(groupId);
|
|
2448
|
-
return;
|
|
2449
|
-
}
|
|
2450
|
-
if (command === "remove-group-origin") {
|
|
2451
|
-
const groupId = element.dataset.groupId;
|
|
2452
|
-
const index = Number(element.dataset.index);
|
|
2453
|
-
if (groupId && Number.isSafeInteger(index))
|
|
2454
|
-
this.removeGroupOrigin(groupId, index);
|
|
2455
|
-
return;
|
|
2456
|
-
}
|
|
2457
|
-
if (command === "add-rule-origin") {
|
|
2458
|
-
const groupId = element.dataset.groupId;
|
|
2459
|
-
const ruleId = element.dataset.ruleId;
|
|
2460
|
-
if (groupId && ruleId) this.addRuleOrigin(groupId, ruleId);
|
|
2461
|
-
return;
|
|
2462
|
-
}
|
|
2463
|
-
if (command === "remove-rule-origin") {
|
|
2464
|
-
const groupId = element.dataset.groupId;
|
|
2465
|
-
const ruleId = element.dataset.ruleId;
|
|
2466
|
-
const index = Number(element.dataset.index);
|
|
2467
|
-
if (groupId && ruleId && Number.isSafeInteger(index)) {
|
|
2468
|
-
this.removeRuleOrigin(groupId, ruleId, index);
|
|
2469
|
-
}
|
|
2449
|
+
if (command === "dismiss-migration-notices") {
|
|
2450
|
+
void this.dismissMigrationNotices();
|
|
2470
2451
|
return;
|
|
2471
2452
|
}
|
|
2472
2453
|
if (command === "convert-url") {
|
|
@@ -2723,7 +2704,6 @@ var EditorControllerImpl = class {
|
|
|
2723
2704
|
this.draft.groups.push({
|
|
2724
2705
|
id: groupId,
|
|
2725
2706
|
name: "New group",
|
|
2726
|
-
origins: [],
|
|
2727
2707
|
rules: []
|
|
2728
2708
|
});
|
|
2729
2709
|
this.markChanged();
|
|
@@ -2740,8 +2720,7 @@ var EditorControllerImpl = class {
|
|
|
2740
2720
|
group.rules.push({
|
|
2741
2721
|
id: ruleId,
|
|
2742
2722
|
name: "New rule",
|
|
2743
|
-
|
|
2744
|
-
origins: [],
|
|
2723
|
+
source: { key: "url", operator: "regex", value: "" },
|
|
2745
2724
|
resourceTypes: ["main_frame"],
|
|
2746
2725
|
priority: 100
|
|
2747
2726
|
});
|
|
@@ -2983,7 +2962,6 @@ var EditorControllerImpl = class {
|
|
|
2983
2962
|
this.draft.groups.push({
|
|
2984
2963
|
id: groupId,
|
|
2985
2964
|
name: "AI Group",
|
|
2986
|
-
origins: [],
|
|
2987
2965
|
rules: []
|
|
2988
2966
|
});
|
|
2989
2967
|
group = this.groupById(groupId);
|
|
@@ -3005,8 +2983,11 @@ var EditorControllerImpl = class {
|
|
|
3005
2983
|
const rule = {
|
|
3006
2984
|
id: ruleId,
|
|
3007
2985
|
name: ruleProposal.name,
|
|
3008
|
-
|
|
3009
|
-
|
|
2986
|
+
source: {
|
|
2987
|
+
key: ruleProposal.source.key,
|
|
2988
|
+
operator: "regex",
|
|
2989
|
+
value: ruleProposal.source.value
|
|
2990
|
+
},
|
|
3010
2991
|
resourceTypes: ruleProposal.resourceTypes ? [...ruleProposal.resourceTypes] : ["main_frame"],
|
|
3011
2992
|
priority: ruleProposal.priority ?? 100
|
|
3012
2993
|
};
|
|
@@ -3128,48 +3109,17 @@ var EditorControllerImpl = class {
|
|
|
3128
3109
|
}
|
|
3129
3110
|
return { proposal: chunk.proposal };
|
|
3130
3111
|
}
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
this.groupIndex(groupId),
|
|
3139
|
-
"origins",
|
|
3140
|
-
group.origins.length - 1
|
|
3141
|
-
);
|
|
3142
|
-
this.render();
|
|
3143
|
-
}
|
|
3144
|
-
removeGroupOrigin(groupId, index) {
|
|
3145
|
-
const group = this.groupById(groupId);
|
|
3146
|
-
if (!group || this.saving || index < 0 || index >= group.origins.length)
|
|
3147
|
-
return;
|
|
3148
|
-
group.origins.splice(index, 1);
|
|
3149
|
-
this.markChanged();
|
|
3150
|
-
this.render();
|
|
3151
|
-
}
|
|
3152
|
-
addRuleOrigin(groupId, ruleId) {
|
|
3153
|
-
const rule = this.ruleById(groupId, ruleId);
|
|
3154
|
-
if (!rule || this.saving) return;
|
|
3155
|
-
rule.origins.push("");
|
|
3156
|
-
this.markChanged();
|
|
3157
|
-
this.focusRequest = pointer(
|
|
3158
|
-
"groups",
|
|
3159
|
-
this.groupIndex(groupId),
|
|
3160
|
-
"rules",
|
|
3161
|
-
this.ruleIndex(this.groupById(groupId), ruleId),
|
|
3162
|
-
"origins",
|
|
3163
|
-
rule.origins.length - 1
|
|
3164
|
-
);
|
|
3165
|
-
this.render();
|
|
3166
|
-
}
|
|
3167
|
-
removeRuleOrigin(groupId, ruleId, index) {
|
|
3168
|
-
const rule = this.ruleById(groupId, ruleId);
|
|
3169
|
-
if (!rule || this.saving || index < 0 || index >= rule.origins.length)
|
|
3112
|
+
async dismissMigrationNotices() {
|
|
3113
|
+
if (this.saving || this.migrationNoticesDismissed) return;
|
|
3114
|
+
try {
|
|
3115
|
+
await this.options.onDismissMigrationNotices?.();
|
|
3116
|
+
} catch {
|
|
3117
|
+
this.statusMessage = "Could not dismiss migration notices.";
|
|
3118
|
+
this.render();
|
|
3170
3119
|
return;
|
|
3171
|
-
|
|
3172
|
-
this.
|
|
3120
|
+
}
|
|
3121
|
+
this.migrationNoticesDismissed = true;
|
|
3122
|
+
this.statusMessage = "Migration notices dismissed.";
|
|
3173
3123
|
this.render();
|
|
3174
3124
|
}
|
|
3175
3125
|
convertUrl(groupId, ruleId) {
|
|
@@ -3186,7 +3136,7 @@ var EditorControllerImpl = class {
|
|
|
3186
3136
|
"rules",
|
|
3187
3137
|
this.ruleIndex(this.groupById(groupId), ruleId)
|
|
3188
3138
|
);
|
|
3189
|
-
const path = `${rulePath}/
|
|
3139
|
+
const path = `${rulePath}/source/value`;
|
|
3190
3140
|
if (!result.ok) {
|
|
3191
3141
|
this.conversionDiagnostics.set(
|
|
3192
3142
|
ruleId,
|
|
@@ -3202,6 +3152,12 @@ var EditorControllerImpl = class {
|
|
|
3202
3152
|
this.render();
|
|
3203
3153
|
return;
|
|
3204
3154
|
}
|
|
3155
|
+
if (setValueAtPath(this.draft, `${rulePath}/source/key`, "url")) {
|
|
3156
|
+
this.markChanged();
|
|
3157
|
+
}
|
|
3158
|
+
if (setValueAtPath(this.draft, `${rulePath}/source/operator`, "regex")) {
|
|
3159
|
+
this.markChanged();
|
|
3160
|
+
}
|
|
3205
3161
|
if (setValueAtPath(this.draft, path, result.source)) this.markChanged();
|
|
3206
3162
|
this.statusMessage = "Exact URL regular expression created.";
|
|
3207
3163
|
this.focusRequest = path;
|
|
@@ -3306,8 +3262,7 @@ var EditorControllerImpl = class {
|
|
|
3306
3262
|
ruleHeader.append(ruleName, ruleBadge);
|
|
3307
3263
|
ruleDiv.append(ruleHeader);
|
|
3308
3264
|
const dims = [
|
|
3309
|
-
{ label: "
|
|
3310
|
-
{ label: "effectiveOrigin", dim: rule.effectiveOrigin },
|
|
3265
|
+
{ label: "source", dim: rule.source },
|
|
3311
3266
|
{ label: "method", dim: rule.method },
|
|
3312
3267
|
{ label: "resourceType", dim: rule.resourceType }
|
|
3313
3268
|
];
|
|
@@ -3452,6 +3407,7 @@ var EditorControllerImpl = class {
|
|
|
3452
3407
|
}
|
|
3453
3408
|
this.decorateExtensionControls();
|
|
3454
3409
|
this.renderSummary();
|
|
3410
|
+
this.renderMigrationNotices();
|
|
3455
3411
|
this.renderSearchResults();
|
|
3456
3412
|
this.renderConfirmation();
|
|
3457
3413
|
this.restoreFocus();
|
|
@@ -3720,15 +3676,6 @@ var EditorControllerImpl = class {
|
|
|
3720
3676
|
);
|
|
3721
3677
|
settings.append(fields);
|
|
3722
3678
|
this.form.append(settings);
|
|
3723
|
-
this.renderOrigins(
|
|
3724
|
-
this.form,
|
|
3725
|
-
"Group origins",
|
|
3726
|
-
group.origins,
|
|
3727
|
-
"group",
|
|
3728
|
-
groupId,
|
|
3729
|
-
void 0,
|
|
3730
|
-
groupIndex
|
|
3731
|
-
);
|
|
3732
3679
|
const rulesSection = this.document.createElement("section");
|
|
3733
3680
|
rulesSection.dataset.rulesSection = "true";
|
|
3734
3681
|
const rulesHeadingRow = this.document.createElement("div");
|
|
@@ -3929,35 +3876,9 @@ var EditorControllerImpl = class {
|
|
|
3929
3876
|
name.maxLength = 100;
|
|
3930
3877
|
name.value = safeText(rule.name);
|
|
3931
3878
|
this.renderField(grid, "Rule name", `${rulePath}/name`, name);
|
|
3932
|
-
const regex = this.document.createElement("textarea");
|
|
3933
|
-
regex.maxLength = F2_MAX_URL_REGEX_LENGTH2;
|
|
3934
|
-
regex.value = safeText(rule.urlRegex);
|
|
3935
|
-
this.renderField(
|
|
3936
|
-
grid,
|
|
3937
|
-
"URL regular expression",
|
|
3938
|
-
`${rulePath}/urlRegex`,
|
|
3939
|
-
regex
|
|
3940
|
-
);
|
|
3941
|
-
const convert = this.createCommandButton(
|
|
3942
|
-
"Convert to regex",
|
|
3943
|
-
"convert-url",
|
|
3944
|
-
this.saving,
|
|
3945
|
-
{ groupId, ruleId },
|
|
3946
|
-
"secondary"
|
|
3947
|
-
);
|
|
3948
|
-
grid.append(convert);
|
|
3949
3879
|
fields.append(grid);
|
|
3880
|
+
this.renderSource(fields, rule, rulePath, groupId, ruleId);
|
|
3950
3881
|
card.append(fields);
|
|
3951
|
-
this.renderOrigins(
|
|
3952
|
-
card,
|
|
3953
|
-
"Rule origins",
|
|
3954
|
-
rule.origins,
|
|
3955
|
-
"rule",
|
|
3956
|
-
groupId,
|
|
3957
|
-
ruleId,
|
|
3958
|
-
groupIndex,
|
|
3959
|
-
ruleIndex
|
|
3960
|
-
);
|
|
3961
3882
|
this.renderResourceTypes(card, rule, rulePath);
|
|
3962
3883
|
const matcherFields = this.document.createElement("fieldset");
|
|
3963
3884
|
const matcherLegend = this.document.createElement("legend");
|
|
@@ -4046,48 +3967,89 @@ var EditorControllerImpl = class {
|
|
|
4046
3967
|
}
|
|
4047
3968
|
return card;
|
|
4048
3969
|
}
|
|
4049
|
-
|
|
4050
|
-
const
|
|
4051
|
-
const
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
index
|
|
4064
|
-
);
|
|
4065
|
-
const input = this.document.createElement("input");
|
|
4066
|
-
input.type = "text";
|
|
4067
|
-
input.maxLength = 2048;
|
|
4068
|
-
input.value = safeText(values[index]);
|
|
4069
|
-
input.disabled = this.saving;
|
|
4070
|
-
this.renderField(row, `Origin ${index + 1}`, path, input);
|
|
4071
|
-
const remove = this.createCommandButton(
|
|
4072
|
-
`Remove ${owner} origin ${index + 1}`,
|
|
4073
|
-
owner === "group" ? "remove-group-origin" : "remove-rule-origin",
|
|
4074
|
-
this.saving,
|
|
4075
|
-
{ groupId, ruleId, index: String(index) },
|
|
4076
|
-
"danger"
|
|
4077
|
-
);
|
|
4078
|
-
row.append(remove);
|
|
4079
|
-
fieldset.append(row);
|
|
3970
|
+
renderSource(parent, rule, rulePath, groupId, ruleId) {
|
|
3971
|
+
const sourceFieldset = this.document.createElement("fieldset");
|
|
3972
|
+
const sourceLegend = this.document.createElement("legend");
|
|
3973
|
+
sourceLegend.textContent = "Source condition";
|
|
3974
|
+
sourceFieldset.append(sourceLegend);
|
|
3975
|
+
const sourceGrid = this.document.createElement("div");
|
|
3976
|
+
sourceGrid.dataset.editorFields = "true";
|
|
3977
|
+
const sourceKey = rule.source?.key === "host" ? "host" : "url";
|
|
3978
|
+
const keySelect = this.document.createElement("select");
|
|
3979
|
+
for (const value of ["url", "host"]) {
|
|
3980
|
+
const option = this.document.createElement("option");
|
|
3981
|
+
option.value = value;
|
|
3982
|
+
option.textContent = value === "url" ? "URL (full request URL)" : "Host (hostname only)";
|
|
3983
|
+
keySelect.append(option);
|
|
4080
3984
|
}
|
|
4081
|
-
|
|
3985
|
+
keySelect.value = sourceKey;
|
|
3986
|
+
this.renderField(
|
|
3987
|
+
sourceGrid,
|
|
3988
|
+
"Match key",
|
|
3989
|
+
`${rulePath}/source/key`,
|
|
3990
|
+
keySelect
|
|
3991
|
+
);
|
|
3992
|
+
const operator = this.document.createElement("input");
|
|
3993
|
+
operator.type = "text";
|
|
3994
|
+
operator.value = "regex";
|
|
3995
|
+
operator.readOnly = true;
|
|
3996
|
+
operator.disabled = true;
|
|
3997
|
+
this.renderField(
|
|
3998
|
+
sourceGrid,
|
|
3999
|
+
"Operator",
|
|
4000
|
+
`${rulePath}/source/operator`,
|
|
4001
|
+
operator
|
|
4002
|
+
);
|
|
4003
|
+
const regex = this.document.createElement("textarea");
|
|
4004
|
+
regex.maxLength = F2_MAX_URL_REGEX_LENGTH2;
|
|
4005
|
+
regex.value = safeText(rule.source?.value);
|
|
4006
|
+
this.renderField(
|
|
4007
|
+
sourceGrid,
|
|
4008
|
+
"Regular expression",
|
|
4009
|
+
`${rulePath}/source/value`,
|
|
4010
|
+
regex
|
|
4011
|
+
);
|
|
4012
|
+
sourceFieldset.append(sourceGrid);
|
|
4013
|
+
sourceFieldset.append(
|
|
4082
4014
|
this.createCommandButton(
|
|
4083
|
-
"
|
|
4084
|
-
|
|
4015
|
+
"Convert URL to regex",
|
|
4016
|
+
"convert-url",
|
|
4085
4017
|
this.saving,
|
|
4086
4018
|
{ groupId, ruleId },
|
|
4087
4019
|
"secondary"
|
|
4088
4020
|
)
|
|
4089
4021
|
);
|
|
4090
|
-
parent.append(
|
|
4022
|
+
parent.append(sourceFieldset);
|
|
4023
|
+
}
|
|
4024
|
+
renderMigrationNotices() {
|
|
4025
|
+
const existing = this.host.querySelector("[data-migration-notices]");
|
|
4026
|
+
existing?.remove();
|
|
4027
|
+
if (this.migrationNoticesDismissed || !this.options.migrationNotices || this.options.migrationNotices.length === 0) {
|
|
4028
|
+
return;
|
|
4029
|
+
}
|
|
4030
|
+
const banner = this.document.createElement("section");
|
|
4031
|
+
banner.dataset.migrationNotices = "true";
|
|
4032
|
+
banner.setAttribute("role", "status");
|
|
4033
|
+
const heading = this.document.createElement("h2");
|
|
4034
|
+
heading.textContent = "Migration notices";
|
|
4035
|
+
const list = this.document.createElement("ul");
|
|
4036
|
+
for (const notice of this.options.migrationNotices) {
|
|
4037
|
+
const item = this.document.createElement("li");
|
|
4038
|
+
item.textContent = notice.message;
|
|
4039
|
+
list.append(item);
|
|
4040
|
+
}
|
|
4041
|
+
banner.append(
|
|
4042
|
+
heading,
|
|
4043
|
+
list,
|
|
4044
|
+
this.createCommandButton(
|
|
4045
|
+
"Dismiss notices",
|
|
4046
|
+
"dismiss-migration-notices",
|
|
4047
|
+
this.saving,
|
|
4048
|
+
{},
|
|
4049
|
+
"secondary"
|
|
4050
|
+
)
|
|
4051
|
+
);
|
|
4052
|
+
this.main.prepend(banner);
|
|
4091
4053
|
}
|
|
4092
4054
|
renderResourceTypes(parent, rule, rulePath) {
|
|
4093
4055
|
const fieldset = this.document.createElement("fieldset");
|