norn-cli 1.10.4 → 1.10.5
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/AGENTS.md +8 -0
- package/CHANGELOG.md +15 -0
- package/dist/cli.js +148 -31
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
These instructions apply to all conversations about the Norn VS Code extension.
|
|
4
4
|
|
|
5
|
+
## Repo Boundary
|
|
6
|
+
|
|
7
|
+
These instructions apply only inside `/Users/petercrest/Worktable/Projects/vsApi`.
|
|
8
|
+
|
|
9
|
+
- Do **not** apply them to standalone work in sibling repos such as `/Users/petercrest/Worktable/Projects/norn_website`.
|
|
10
|
+
- If a task is website-only, prefer the website repo's local instructions instead.
|
|
11
|
+
- Only use these rules for cross-repo work when the task explicitly includes `vsApi`.
|
|
12
|
+
|
|
5
13
|
## CLI Support is Mandatory
|
|
6
14
|
|
|
7
15
|
Every feature implementation must work in both:
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ All notable changes to the "Norn" extension will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [1.10.5] - 2026-03-28
|
|
8
|
+
|
|
9
|
+
### Improved
|
|
10
|
+
- **URL-Encoded Request Bodies (Extension + CLI)**:
|
|
11
|
+
- Added stricter shared validation for `application/x-www-form-urlencoded` request bodies so malformed lines now fail fast with clear preflight errors in both the editor and CLI.
|
|
12
|
+
- Added support for single-line ampersand-delimited form bodies such as `key1=value1&key2=value2`.
|
|
13
|
+
- Preserved raw-request header-group workflows by stripping standalone header-group lines from the request body before validation and send.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- **Imported Parameterized Sequences**:
|
|
17
|
+
- Fixed `.norn` import resolution so imported helper sequences keep their parameter lists and can be invoked correctly from other files.
|
|
18
|
+
|
|
19
|
+
- **Form Body Syntax Highlighting**:
|
|
20
|
+
- Fixed `.norn` syntax coloring so URL-encoded body lines are highlighted correctly after inline headers in raw request blocks.
|
|
21
|
+
|
|
7
22
|
## [1.10.4] - 2026-03-21
|
|
8
23
|
|
|
9
24
|
### Improved
|
package/dist/cli.js
CHANGED
|
@@ -102749,8 +102749,9 @@ ${resolvedContent}`);
|
|
|
102749
102749
|
});
|
|
102750
102750
|
} else {
|
|
102751
102751
|
sequenceSources.set(lowerName, absolutePath);
|
|
102752
|
+
const resolvedDeclaration = substituteVariables(seq.declaration, importedVariables);
|
|
102752
102753
|
const resolvedContent = substituteVariables(seq.content, importedVariables);
|
|
102753
|
-
importedContents.push(
|
|
102754
|
+
importedContents.push(`${resolvedDeclaration}
|
|
102754
102755
|
${resolvedContent}
|
|
102755
102756
|
end sequence`);
|
|
102756
102757
|
}
|
|
@@ -102781,17 +102782,20 @@ function extractSequencesFromText(text) {
|
|
|
102781
102782
|
let currentSequence = null;
|
|
102782
102783
|
for (let i = 0; i < lines.length; i++) {
|
|
102783
102784
|
const line2 = lines[i].trim();
|
|
102784
|
-
const
|
|
102785
|
+
const lineWithoutComment = stripInlineComment(line2);
|
|
102786
|
+
const sequenceMatch = lineWithoutComment.match(/^sequence\s+([a-zA-Z_][a-zA-Z0-9_-]*)(\s*\([^)]*\))?\s*$/);
|
|
102785
102787
|
if (sequenceMatch) {
|
|
102786
102788
|
currentSequence = {
|
|
102787
102789
|
name: sequenceMatch[1],
|
|
102790
|
+
declaration: `sequence ${sequenceMatch[1]}${sequenceMatch[2] || ""}`,
|
|
102788
102791
|
lines: []
|
|
102789
102792
|
};
|
|
102790
102793
|
continue;
|
|
102791
102794
|
}
|
|
102792
|
-
if (
|
|
102795
|
+
if (lineWithoutComment === "end sequence" && currentSequence) {
|
|
102793
102796
|
sequences.push({
|
|
102794
102797
|
name: currentSequence.name,
|
|
102798
|
+
declaration: currentSequence.declaration,
|
|
102795
102799
|
content: currentSequence.lines.join("\n")
|
|
102796
102800
|
});
|
|
102797
102801
|
currentSequence = null;
|
|
@@ -108597,6 +108601,88 @@ function getVerifyTlsCertificates() {
|
|
|
108597
108601
|
return verifyTlsCertificates;
|
|
108598
108602
|
}
|
|
108599
108603
|
|
|
108604
|
+
// src/formUrlEncoded.ts
|
|
108605
|
+
function parseEqualsField(segment) {
|
|
108606
|
+
const eqIndex = segment.indexOf("=");
|
|
108607
|
+
if (eqIndex <= 0) {
|
|
108608
|
+
return null;
|
|
108609
|
+
}
|
|
108610
|
+
return {
|
|
108611
|
+
key: segment.substring(0, eqIndex).trim(),
|
|
108612
|
+
value: segment.substring(eqIndex + 1).trim()
|
|
108613
|
+
};
|
|
108614
|
+
}
|
|
108615
|
+
function isFormUrlEncodedContentType(contentType) {
|
|
108616
|
+
return Boolean(contentType && contentType.toLowerCase().includes("application/x-www-form-urlencoded"));
|
|
108617
|
+
}
|
|
108618
|
+
function parseFormUrlEncodedLines(lines) {
|
|
108619
|
+
const fields = [];
|
|
108620
|
+
const errors = [];
|
|
108621
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
108622
|
+
const line2 = lines[lineIndex].trim();
|
|
108623
|
+
if (!line2) {
|
|
108624
|
+
continue;
|
|
108625
|
+
}
|
|
108626
|
+
const firstEqIndex = line2.indexOf("=");
|
|
108627
|
+
const firstColonIndex = line2.indexOf(":");
|
|
108628
|
+
if (firstEqIndex > 0 && (firstColonIndex === -1 || firstEqIndex < firstColonIndex)) {
|
|
108629
|
+
if (line2.includes("&")) {
|
|
108630
|
+
const segments = line2.split("&").map((segment) => segment.trim());
|
|
108631
|
+
const hasInvalidSegment = segments.some((segment) => !parseEqualsField(segment));
|
|
108632
|
+
if (hasInvalidSegment) {
|
|
108633
|
+
errors.push({
|
|
108634
|
+
lineIndex,
|
|
108635
|
+
line: line2,
|
|
108636
|
+
message: "Ampersand-delimited form body lines must use key=value for every segment."
|
|
108637
|
+
});
|
|
108638
|
+
continue;
|
|
108639
|
+
}
|
|
108640
|
+
for (const segment of segments) {
|
|
108641
|
+
const field2 = parseEqualsField(segment);
|
|
108642
|
+
if (field2) {
|
|
108643
|
+
fields.push(field2);
|
|
108644
|
+
}
|
|
108645
|
+
}
|
|
108646
|
+
continue;
|
|
108647
|
+
}
|
|
108648
|
+
const field = parseEqualsField(line2);
|
|
108649
|
+
if (field) {
|
|
108650
|
+
fields.push(field);
|
|
108651
|
+
continue;
|
|
108652
|
+
}
|
|
108653
|
+
}
|
|
108654
|
+
if (firstColonIndex > 0) {
|
|
108655
|
+
fields.push({
|
|
108656
|
+
key: line2.substring(0, firstColonIndex).trim(),
|
|
108657
|
+
value: line2.substring(firstColonIndex + 1).trim()
|
|
108658
|
+
});
|
|
108659
|
+
continue;
|
|
108660
|
+
}
|
|
108661
|
+
errors.push({
|
|
108662
|
+
lineIndex,
|
|
108663
|
+
line: line2,
|
|
108664
|
+
message: "Expected key=value, key: value, or ampersand-delimited key=value pairs."
|
|
108665
|
+
});
|
|
108666
|
+
}
|
|
108667
|
+
return { fields, errors };
|
|
108668
|
+
}
|
|
108669
|
+
function parseFormUrlEncodedBody(body) {
|
|
108670
|
+
if (!body) {
|
|
108671
|
+
return { fields: [], errors: [] };
|
|
108672
|
+
}
|
|
108673
|
+
return parseFormUrlEncodedLines(body.split("\n"));
|
|
108674
|
+
}
|
|
108675
|
+
function encodeFormUrlEncodedBody(body) {
|
|
108676
|
+
const { fields, errors } = parseFormUrlEncodedBody(body);
|
|
108677
|
+
if (errors.length > 0) {
|
|
108678
|
+
return { encodedBody: "", errors };
|
|
108679
|
+
}
|
|
108680
|
+
return {
|
|
108681
|
+
encodedBody: fields.map((field) => `${encodeURIComponent(field.key)}=${encodeURIComponent(field.value)}`).join("&"),
|
|
108682
|
+
errors: []
|
|
108683
|
+
};
|
|
108684
|
+
}
|
|
108685
|
+
|
|
108600
108686
|
// src/httpClient.ts
|
|
108601
108687
|
var sharedCookieJar = new CookieJar();
|
|
108602
108688
|
var insecureHttpsAgent = new https2.Agent({ rejectUnauthorized: false });
|
|
@@ -108661,24 +108747,23 @@ async function sendRequestWithJar(request, jar, retryOptions) {
|
|
|
108661
108747
|
(key) => key.toLowerCase() === "content-type"
|
|
108662
108748
|
);
|
|
108663
108749
|
const contentTypeValue = contentType ? headers[contentType] : "";
|
|
108664
|
-
if (contentTypeValue
|
|
108665
|
-
const
|
|
108666
|
-
|
|
108667
|
-
|
|
108668
|
-
|
|
108669
|
-
|
|
108670
|
-
|
|
108671
|
-
|
|
108672
|
-
|
|
108673
|
-
|
|
108674
|
-
|
|
108675
|
-
|
|
108676
|
-
|
|
108677
|
-
|
|
108678
|
-
}
|
|
108679
|
-
|
|
108680
|
-
|
|
108681
|
-
data = params.join("&");
|
|
108750
|
+
if (isFormUrlEncodedContentType(contentTypeValue)) {
|
|
108751
|
+
const encoded = encodeFormUrlEncodedBody(currentBody);
|
|
108752
|
+
if (encoded.errors.length > 0) {
|
|
108753
|
+
throw new NornError({
|
|
108754
|
+
category: "syntax",
|
|
108755
|
+
code: "invalid-form-urlencoded-body",
|
|
108756
|
+
message: "Request body is not valid application/x-www-form-urlencoded syntax.",
|
|
108757
|
+
details: encoded.errors.map((error) => `Body line ${error.lineIndex + 1}: ${error.message} (${error.line})`),
|
|
108758
|
+
hint: "Use key=value, key: value, or a single line like key1=value1&key2=value2.",
|
|
108759
|
+
context: {
|
|
108760
|
+
source: "httpClient",
|
|
108761
|
+
method: currentMethod,
|
|
108762
|
+
url: currentUrl
|
|
108763
|
+
}
|
|
108764
|
+
});
|
|
108765
|
+
}
|
|
108766
|
+
data = encoded.encodedBody;
|
|
108682
108767
|
} else if (contentTypeValue.includes("application/json")) {
|
|
108683
108768
|
try {
|
|
108684
108769
|
data = JSON.parse(currentBody);
|
|
@@ -109333,6 +109418,15 @@ function buildRequestContext(parsed, context) {
|
|
|
109333
109418
|
environment: context?.environment
|
|
109334
109419
|
};
|
|
109335
109420
|
}
|
|
109421
|
+
function getHeaderValueCaseInsensitive(headers, headerName) {
|
|
109422
|
+
const targetName = headerName.toLowerCase();
|
|
109423
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
109424
|
+
if (name.toLowerCase() === targetName) {
|
|
109425
|
+
return value;
|
|
109426
|
+
}
|
|
109427
|
+
}
|
|
109428
|
+
return void 0;
|
|
109429
|
+
}
|
|
109336
109430
|
function describeUnresolvedLocation(label, vars) {
|
|
109337
109431
|
if (vars.length === 0) {
|
|
109338
109432
|
return void 0;
|
|
@@ -109388,6 +109482,20 @@ function validatePreparedRequest(parsed, context) {
|
|
|
109388
109482
|
cause: error
|
|
109389
109483
|
});
|
|
109390
109484
|
}
|
|
109485
|
+
const contentType = getHeaderValueCaseInsensitive(parsed.headers, "Content-Type");
|
|
109486
|
+
if (isFormUrlEncodedContentType(contentType)) {
|
|
109487
|
+
const { errors } = parseFormUrlEncodedBody(parsed.body);
|
|
109488
|
+
if (errors.length > 0) {
|
|
109489
|
+
throw new NornError({
|
|
109490
|
+
category: "syntax",
|
|
109491
|
+
code: "invalid-form-urlencoded-body",
|
|
109492
|
+
message: "Request could not be prepared: invalid application/x-www-form-urlencoded body syntax.",
|
|
109493
|
+
details: errors.map((error) => `Body line ${error.lineIndex + 1}: ${error.message} (${error.line})`),
|
|
109494
|
+
hint: "Use key=value, key: value, or a single line like key1=value1&key2=value2.",
|
|
109495
|
+
context: buildRequestContext(parsed, context)
|
|
109496
|
+
});
|
|
109497
|
+
}
|
|
109498
|
+
}
|
|
109391
109499
|
}
|
|
109392
109500
|
|
|
109393
109501
|
// src/sequenceRunner.ts
|
|
@@ -110257,13 +110365,17 @@ function applyHeaderGroupsToRequest(parsed, requestText, headerGroups, variables
|
|
|
110257
110365
|
const headerGroupNames = headerGroups.map((hg) => hg.name);
|
|
110258
110366
|
const headerGroupHeaders = {};
|
|
110259
110367
|
const foundGroups = [];
|
|
110368
|
+
const cleanedBodyLines = [];
|
|
110369
|
+
let sawRequestLine = false;
|
|
110370
|
+
let inBodySection = false;
|
|
110260
110371
|
for (const line2 of lines) {
|
|
110261
110372
|
const trimmed = line2.trim();
|
|
110262
110373
|
if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith("var ")) {
|
|
110263
110374
|
continue;
|
|
110264
110375
|
}
|
|
110265
110376
|
const methodMatch = trimmed.match(/^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s+(.+)$/i);
|
|
110266
|
-
if (methodMatch) {
|
|
110377
|
+
if (!sawRequestLine && methodMatch) {
|
|
110378
|
+
sawRequestLine = true;
|
|
110267
110379
|
const afterMethod = methodMatch[2];
|
|
110268
110380
|
const tokens = afterMethod.split(/\s+/);
|
|
110269
110381
|
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
@@ -110275,18 +110387,22 @@ function applyHeaderGroupsToRequest(parsed, requestText, headerGroups, variables
|
|
|
110275
110387
|
}
|
|
110276
110388
|
continue;
|
|
110277
110389
|
}
|
|
110278
|
-
if (
|
|
110279
|
-
continue;
|
|
110280
|
-
}
|
|
110281
|
-
if (trimmed.startsWith("{") || trimmed.startsWith("[") || trimmed.startsWith('"')) {
|
|
110390
|
+
if (!sawRequestLine) {
|
|
110282
110391
|
continue;
|
|
110283
110392
|
}
|
|
110284
|
-
|
|
110285
|
-
|
|
110286
|
-
|
|
110287
|
-
|
|
110393
|
+
if (!inBodySection) {
|
|
110394
|
+
if (/^[A-Za-z0-9\-_]+\s*:\s*.+$/.test(trimmed)) {
|
|
110395
|
+
continue;
|
|
110396
|
+
}
|
|
110397
|
+
const potentialGroups = trimmed.split(/\s+/).filter(Boolean);
|
|
110398
|
+
const matchingGroups = potentialGroups.filter((groupName) => headerGroupNames.includes(groupName));
|
|
110399
|
+
if (matchingGroups.length > 0 && matchingGroups.length === potentialGroups.length) {
|
|
110400
|
+
foundGroups.push(...matchingGroups);
|
|
110401
|
+
continue;
|
|
110288
110402
|
}
|
|
110403
|
+
inBodySection = true;
|
|
110289
110404
|
}
|
|
110405
|
+
cleanedBodyLines.push(trimmed);
|
|
110290
110406
|
}
|
|
110291
110407
|
for (const groupName of foundGroups) {
|
|
110292
110408
|
const group = headerGroups.find((hg) => hg.name === groupName);
|
|
@@ -110303,7 +110419,8 @@ function applyHeaderGroupsToRequest(parsed, requestText, headerGroups, variables
|
|
|
110303
110419
|
modifiedUrl = modifiedUrl.trim();
|
|
110304
110420
|
const result = {
|
|
110305
110421
|
...parsed,
|
|
110306
|
-
url: modifiedUrl
|
|
110422
|
+
url: modifiedUrl,
|
|
110423
|
+
body: cleanedBodyLines.length > 0 ? substituteVariables(cleanedBodyLines.join("\n"), variables) : void 0
|
|
110307
110424
|
};
|
|
110308
110425
|
if (Object.keys(headerGroupHeaders).length > 0) {
|
|
110309
110426
|
result.headers = { ...headerGroupHeaders, ...parsed.headers };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "norn-cli",
|
|
3
3
|
"displayName": "Norn - REST Client",
|
|
4
4
|
"description": "A powerful REST client for making HTTP requests with sequences, variables, scripts, and cookie support",
|
|
5
|
-
"version": "1.10.
|
|
5
|
+
"version": "1.10.5",
|
|
6
6
|
"publisher": "Norn-PeterKrustanov",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Peter Krastanov"
|