@matdata/yasqe 5.14.0 → 5.16.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/build/ts/src/__tests__/share-test.js +30 -1
- package/build/ts/src/__tests__/share-test.js.map +1 -1
- package/build/ts/src/defaults.d.ts +1 -1
- package/build/ts/src/index.d.ts +12 -3
- package/build/ts/src/index.js +176 -18
- package/build/ts/src/index.js.map +1 -1
- package/build/ts/src/sparql.js +32 -5
- package/build/ts/src/sparql.js.map +1 -1
- package/build/yasqe.min.css +1 -1
- package/build/yasqe.min.css.map +3 -3
- package/build/yasqe.min.js +81 -81
- package/build/yasqe.min.js.map +3 -3
- package/package.json +1 -1
- package/src/__tests__/share-test.ts +32 -1
- package/src/index.ts +206 -22
- package/src/scss/buttons.scss +125 -25
- package/src/sparql.ts +43 -5
package/src/sparql.ts
CHANGED
|
@@ -520,10 +520,48 @@ export function getAsPowerShellString(yasqe: Yasqe, _config?: Config["requestCon
|
|
|
520
520
|
lines.push(headersLines.join("\n"));
|
|
521
521
|
lines.push(" }");
|
|
522
522
|
}
|
|
523
|
-
lines.push(` OutFile = "
|
|
523
|
+
lines.push(` OutFile = "sparql-generated.${fileExtension}"`);
|
|
524
524
|
lines.push("}");
|
|
525
525
|
} else if (ajaxConfig.reqMethod === "POST") {
|
|
526
|
-
|
|
526
|
+
// Extract the query/update parameter and other parameters separately
|
|
527
|
+
// Determine the query parameter name first (query takes precedence over update)
|
|
528
|
+
const queryParamName = ajaxConfig.args.query !== undefined ? "query" : "update";
|
|
529
|
+
const queryParam = ajaxConfig.args[queryParamName];
|
|
530
|
+
|
|
531
|
+
const otherArgs: RequestArgs = {};
|
|
532
|
+
for (const key in ajaxConfig.args) {
|
|
533
|
+
if (key !== "query" && key !== "update") {
|
|
534
|
+
otherArgs[key] = ajaxConfig.args[key];
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// Build the query string using here-string for easy editing
|
|
539
|
+
if (queryParam) {
|
|
540
|
+
// Handle both string and string[] cases - use first element if array
|
|
541
|
+
const queryText = Array.isArray(queryParam) ? queryParam[0] : queryParam;
|
|
542
|
+
lines.push(`$${queryParamName} = @"`);
|
|
543
|
+
lines.push(queryText);
|
|
544
|
+
lines.push(`"@`);
|
|
545
|
+
lines.push("");
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// Build the body with the query variable and any other parameters
|
|
549
|
+
// The query must be URL-encoded for application/x-www-form-urlencoded
|
|
550
|
+
let bodyExpression: string;
|
|
551
|
+
const urlEncodeExpr = `[System.Net.WebUtility]::UrlEncode($${queryParamName})`;
|
|
552
|
+
if (queryParam && Object.keys(otherArgs).length > 0) {
|
|
553
|
+
// Both query variable and other args
|
|
554
|
+
const otherArgsString = queryString.stringify(otherArgs);
|
|
555
|
+
bodyExpression = `"${queryParamName}=$(${urlEncodeExpr})&${escapePowerShellString(otherArgsString)}"`;
|
|
556
|
+
} else if (queryParam) {
|
|
557
|
+
// Only query variable - use subexpression for URL encoding
|
|
558
|
+
bodyExpression = `"${queryParamName}=$(${urlEncodeExpr})"`;
|
|
559
|
+
} else {
|
|
560
|
+
// Only other args (shouldn't happen, but handle it)
|
|
561
|
+
const otherArgsString = queryString.stringify(otherArgs);
|
|
562
|
+
bodyExpression = `"${escapePowerShellString(otherArgsString)}"`;
|
|
563
|
+
}
|
|
564
|
+
|
|
527
565
|
lines.push("$params = @{");
|
|
528
566
|
lines.push(` Uri = "${escapePowerShellString(url)}"`);
|
|
529
567
|
lines.push(` Method = "Post"`);
|
|
@@ -533,8 +571,8 @@ export function getAsPowerShellString(yasqe: Yasqe, _config?: Config["requestCon
|
|
|
533
571
|
lines.push(" }");
|
|
534
572
|
}
|
|
535
573
|
lines.push(` ContentType = "application/x-www-form-urlencoded"`);
|
|
536
|
-
lines.push(` Body =
|
|
537
|
-
lines.push(` OutFile = "
|
|
574
|
+
lines.push(` Body = ${bodyExpression}`);
|
|
575
|
+
lines.push(` OutFile = "sparql-generated.${fileExtension}"`);
|
|
538
576
|
lines.push("}");
|
|
539
577
|
} else {
|
|
540
578
|
// Handle other methods (PUT, DELETE, etc.)
|
|
@@ -552,7 +590,7 @@ export function getAsPowerShellString(yasqe: Yasqe, _config?: Config["requestCon
|
|
|
552
590
|
lines.push(` ContentType = "application/x-www-form-urlencoded"`);
|
|
553
591
|
lines.push(` Body = "${body.replace(/"/g, '`"')}"`);
|
|
554
592
|
}
|
|
555
|
-
lines.push(` OutFile = "
|
|
593
|
+
lines.push(` OutFile = "sparql-generated.${fileExtension}"`);
|
|
556
594
|
lines.push("}");
|
|
557
595
|
}
|
|
558
596
|
|