@desplega.ai/agent-swarm 1.103.0 → 1.104.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/README.md +2 -0
- package/dist/{actions-7txktrdj.js → actions-2expzt47.js} +6 -6
- package/dist/{app-xm3xsdye.js → app-dr8hwx7z.js} +3 -3
- package/dist/{assistant-qpv63wk6.js → assistant-9rhgsw7v.js} +9 -10
- package/dist/{boot-reembed-chxhrwv8.js → boot-reembed-3q1aywnz.js} +5 -4
- package/dist/{boot-reembed-9cxqka3e.js → boot-reembed-9kt97g1z.js} +4 -3
- package/dist/{boot-scrub-logs-8qtfkcz8.js → boot-scrub-logs-vskq108e.js} +2 -2
- package/dist/{cli-fedn86nz.js → cli-0jw6j755.js} +8 -3
- package/dist/{cli-yeemwevj.js → cli-23zk7xqy.js} +20 -16
- package/dist/{cli-v9283nma.js → cli-2g9jf9ek.js} +1 -1
- package/dist/{cli-rvae030h.js → cli-2hap19dv.js} +3 -3
- package/dist/{cli-wjyyv518.js → cli-3j01d33e.js} +9 -14
- package/dist/{cli-8hyv6c2v.js → cli-54h5daha.js} +41 -23
- package/dist/{cli-fygaw191.js → cli-5pf0b84v.js} +2 -2
- package/dist/{cli-m8f6qzck.js → cli-7v4y3hyd.js} +1 -1
- package/dist/{cli-fwxdt7kt.js → cli-d4z1csms.js} +30 -5
- package/dist/{cli-jt9d9fjw.js → cli-e7bwjntj.js} +1 -1
- package/dist/{cli-s14sb64w.js → cli-etvgz5x8.js} +5 -7
- package/dist/{cli-2qynerth.js → cli-gj2n2ec1.js} +1 -1
- package/dist/{cli-dz3d6zjg.js → cli-nzc0h54v.js} +121 -2
- package/dist/{cli-8w95v19d.js → cli-p4cj4vhc.js} +351 -24
- package/dist/{cli-xmtsan9k.js → cli-q5tshxd6.js} +1 -1
- package/dist/{http-zts4haq7.js → cli-qvzgncd8.js} +83966 -76422
- package/dist/{cli-4fnp2tc3.js → cli-s42f54ja.js} +1 -1
- package/dist/{cli-krvxq8bc.js → cli-t9v14cnd.js} +23 -4
- package/dist/{cli-gzepjz54.js → cli-v1syqkcb.js} +900 -352
- package/dist/{cli-ksq38x4n.js → cli-w1nfskkg.js} +2 -2
- package/dist/{cli-ns0r7mkr.js → cli-y9p3e94h.js} +3 -3
- package/dist/{cli-85pf4z38.js → cli-yjt8a36k.js} +3 -3
- package/dist/{cli-yfwwjeft.js → cli-yvektv79.js} +1 -1
- package/dist/{cli-kk51f3tf.js → cli-zaxksbgj.js} +5 -5
- package/dist/{cli-rttgde5f.js → cli-zghef0em.js} +1 -1
- package/dist/cli.js +10 -10
- package/dist/{commands-aqn63mcw.js → commands-wfrkef57.js} +2 -2
- package/dist/{db-azrvwsnj.js → db-c42pxt7h.js} +2 -2
- package/dist/{handlers-hf61har3.js → handlers-n36zkfvx.js} +10 -12
- package/dist/{hook-306p3yz4.js → hook-gw3vhv6s.js} +7 -5
- package/dist/http-59ygpn2h.js +17263 -0
- package/dist/{index-h2yqjyk0.js → index-881c1baf.js} +9 -8
- package/dist/{index-29vg51x6.js → index-jca7jdpt.js} +23 -10
- package/dist/{index-bfh9hgek.js → index-xf6fp4y1.js} +5 -5
- package/dist/{index-3c651yfk.js → index-xz8vaa5c.js} +14 -11
- package/dist/{keepalive-a0dg5pds.js → keepalive-mj4302vw.js} +4 -4
- package/dist/{lead-7mcxedkc.js → lead-qm0xjvkv.js} +19 -19
- package/dist/{maintenance-mrzqd53t.js → maintenance-xppxbe4t.js} +5 -4
- package/dist/{onboard-4dkpv9wa.js → onboard-ejx6yxh8.js} +2 -2
- package/dist/{otel-impl-jt7gpyp9.js → otel-impl-zs5exkpk.js} +1 -1
- package/dist/{pricing-refresh-xqnzh8dt.js → pricing-refresh-nqyf8bkb.js} +4 -4
- package/dist/{seed-pricing-56tjm1fj.js → seed-pricing-w3x550cj.js} +3 -3
- package/dist/{setup-tbwk8j10.js → setup-7729ktfj.js} +2 -2
- package/dist/{worker-e03za92t.js → worker-4ttemwhw.js} +19 -19
- package/openapi.json +90 -4
- package/package.json +3 -3
- package/src/be/memory/constants.ts +6 -0
- package/src/be/memory/providers/sqlite-store.ts +468 -71
- package/src/be/memory/raters/retrieval.ts +4 -2
- package/src/be/memory/reranker.ts +5 -2
- package/src/be/memory/retrieval-store.ts +2 -0
- package/src/be/memory/types.ts +46 -0
- package/src/be/migrations/099_memory_structured_key_versioning.sql +41 -0
- package/src/be/migrations/100_memory_retrieval_source.sql +8 -0
- package/src/be/migrations/101_script_connections.sql +67 -0
- package/src/be/script-connections.ts +744 -0
- package/src/be/script-credential-broker.ts +38 -0
- package/src/be/scripts/typecheck.ts +23 -2
- package/src/be/seed-scripts/catalog/boot-triage.inline.ts +16 -4
- package/src/be/seed-scripts/catalog/boot-triage.ts +16 -4
- package/src/commands/runner.ts +8 -6
- package/src/heartbeat/heartbeat.ts +42 -1
- package/src/heartbeat/index.ts +7 -1
- package/src/http/memory.ts +127 -14
- package/src/http/scripts.ts +15 -14
- package/src/scripts-runtime/api-client.ts +100 -0
- package/src/scripts-runtime/api-types.ts +45 -0
- package/src/scripts-runtime/credential-broker/README.md +40 -0
- package/src/scripts-runtime/credential-broker/broker.ts +51 -0
- package/src/scripts-runtime/credential-broker/default-bindings.ts +19 -0
- package/src/scripts-runtime/credential-broker/fetch-patch.ts +102 -0
- package/src/scripts-runtime/credential-broker/index.ts +17 -0
- package/src/scripts-runtime/credential-broker/store.ts +72 -0
- package/src/scripts-runtime/credential-broker/types.ts +54 -0
- package/src/scripts-runtime/ctx.ts +11 -1
- package/src/scripts-runtime/egress-secrets.ts +14 -76
- package/src/scripts-runtime/eval-harness.ts +1 -1
- package/src/scripts-runtime/executors/types.ts +5 -5
- package/src/scripts-runtime/loader.ts +6 -1
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/types/stdlib.d.ts +11 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +11 -0
- package/src/server.ts +6 -0
- package/src/tests/credential-broker.test.ts +281 -0
- package/src/tests/heartbeat.test.ts +239 -0
- package/src/tests/memory-edit.test.ts +177 -0
- package/src/tests/memory-hybrid.test.ts +212 -0
- package/src/tests/runner-repo-autostash.test.ts +39 -8
- package/src/tests/script-connections.test.ts +360 -0
- package/src/tests/scripts-http.test.ts +16 -10
- package/src/tests/scripts-runtime-secret-egress.test.ts +26 -5
- package/src/tests/swarm-config-reserved-keys.test.ts +23 -0
- package/src/tests/update-schedule-mcp-tool.test.ts +83 -4
- package/src/tools/credential-bindings/index.ts +1 -0
- package/src/tools/credential-bindings/tool.ts +238 -0
- package/src/tools/memory-edit.ts +148 -0
- package/src/tools/memory-search.ts +17 -10
- package/src/tools/schedules/delete-schedule.ts +18 -8
- package/src/tools/schedules/update-schedule.ts +4 -9
- package/src/tools/script-connections/index.ts +1 -0
- package/src/tools/script-connections/tool.ts +167 -0
- package/src/tools/swarm-config/delete-config.ts +5 -0
- package/src/tools/swarm-config/set-config.ts +23 -1
- package/src/tools/tool-config.ts +6 -1
- package/src/types.ts +6 -0
- package/src/workflows/executors/swarm-script.ts +2 -0
- package/templates/community/dora-metrics/PLAYBOOK.md +294 -0
- package/templates/community/dora-metrics/README.md +39 -0
- package/templates/community/dora-metrics/lead-prompt.md +56 -0
- package/templates/community/dora-metrics/report.mjs +393 -0
- package/templates/community/dora-metrics/run.sh +113 -0
- package/templates/schedules/weekly-dora-metrics/config.json +13 -0
- package/templates/schedules/weekly-dora-metrics/content.md +61 -0
- package/dist/cli-2307phk1.js +0 -24223
- package/dist/cli-2deg0cen.js +0 -120
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
embedScript
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-5pf0b84v.js";
|
|
4
4
|
import {
|
|
5
5
|
computeContentHash,
|
|
6
6
|
getDb,
|
|
7
|
+
getSwarmConfigs,
|
|
7
8
|
init_db
|
|
8
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-0jw6j755.js";
|
|
10
|
+
import {
|
|
11
|
+
init_zod
|
|
12
|
+
} from "./cli-q21d49ac.js";
|
|
13
|
+
import {
|
|
14
|
+
_enum,
|
|
15
|
+
array,
|
|
16
|
+
boolean,
|
|
17
|
+
object,
|
|
18
|
+
string,
|
|
19
|
+
union
|
|
20
|
+
} from "./cli-anrj584m.js";
|
|
9
21
|
import {
|
|
10
22
|
__commonJS,
|
|
11
23
|
__require,
|
|
@@ -2306,13 +2318,13 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2306
2318
|
})(Comparison || {});
|
|
2307
2319
|
var emptyArray = [];
|
|
2308
2320
|
var emptyMap = /* @__PURE__ */ new Map;
|
|
2309
|
-
function length(
|
|
2310
|
-
return
|
|
2321
|
+
function length(array2) {
|
|
2322
|
+
return array2 !== undefined ? array2.length : 0;
|
|
2311
2323
|
}
|
|
2312
|
-
function forEach(
|
|
2313
|
-
if (
|
|
2314
|
-
for (let i = 0;i <
|
|
2315
|
-
const result = callback(
|
|
2324
|
+
function forEach(array2, callback) {
|
|
2325
|
+
if (array2 !== undefined) {
|
|
2326
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2327
|
+
const result = callback(array2[i], i);
|
|
2316
2328
|
if (result) {
|
|
2317
2329
|
return result;
|
|
2318
2330
|
}
|
|
@@ -2320,10 +2332,10 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2320
2332
|
}
|
|
2321
2333
|
return;
|
|
2322
2334
|
}
|
|
2323
|
-
function forEachRight(
|
|
2324
|
-
if (
|
|
2325
|
-
for (let i =
|
|
2326
|
-
const result = callback(
|
|
2335
|
+
function forEachRight(array2, callback) {
|
|
2336
|
+
if (array2 !== undefined) {
|
|
2337
|
+
for (let i = array2.length - 1;i >= 0; i--) {
|
|
2338
|
+
const result = callback(array2[i], i);
|
|
2327
2339
|
if (result) {
|
|
2328
2340
|
return result;
|
|
2329
2341
|
}
|
|
@@ -2331,12 +2343,12 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2331
2343
|
}
|
|
2332
2344
|
return;
|
|
2333
2345
|
}
|
|
2334
|
-
function firstDefined(
|
|
2335
|
-
if (
|
|
2346
|
+
function firstDefined(array2, callback) {
|
|
2347
|
+
if (array2 === undefined) {
|
|
2336
2348
|
return;
|
|
2337
2349
|
}
|
|
2338
|
-
for (let i = 0;i <
|
|
2339
|
-
const result = callback(
|
|
2350
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2351
|
+
const result = callback(array2[i], i);
|
|
2340
2352
|
if (result !== undefined) {
|
|
2341
2353
|
return result;
|
|
2342
2354
|
}
|
|
@@ -2383,62 +2395,62 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2383
2395
|
}
|
|
2384
2396
|
return result;
|
|
2385
2397
|
}
|
|
2386
|
-
function every(
|
|
2387
|
-
if (
|
|
2388
|
-
for (let i = 0;i <
|
|
2389
|
-
if (!callback(
|
|
2398
|
+
function every(array2, callback) {
|
|
2399
|
+
if (array2 !== undefined) {
|
|
2400
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2401
|
+
if (!callback(array2[i], i)) {
|
|
2390
2402
|
return false;
|
|
2391
2403
|
}
|
|
2392
2404
|
}
|
|
2393
2405
|
}
|
|
2394
2406
|
return true;
|
|
2395
2407
|
}
|
|
2396
|
-
function find(
|
|
2397
|
-
if (
|
|
2408
|
+
function find(array2, predicate, startIndex) {
|
|
2409
|
+
if (array2 === undefined)
|
|
2398
2410
|
return;
|
|
2399
|
-
for (let i = startIndex ?? 0;i <
|
|
2400
|
-
const value =
|
|
2411
|
+
for (let i = startIndex ?? 0;i < array2.length; i++) {
|
|
2412
|
+
const value = array2[i];
|
|
2401
2413
|
if (predicate(value, i)) {
|
|
2402
2414
|
return value;
|
|
2403
2415
|
}
|
|
2404
2416
|
}
|
|
2405
2417
|
return;
|
|
2406
2418
|
}
|
|
2407
|
-
function findLast(
|
|
2408
|
-
if (
|
|
2419
|
+
function findLast(array2, predicate, startIndex) {
|
|
2420
|
+
if (array2 === undefined)
|
|
2409
2421
|
return;
|
|
2410
|
-
for (let i = startIndex ??
|
|
2411
|
-
const value =
|
|
2422
|
+
for (let i = startIndex ?? array2.length - 1;i >= 0; i--) {
|
|
2423
|
+
const value = array2[i];
|
|
2412
2424
|
if (predicate(value, i)) {
|
|
2413
2425
|
return value;
|
|
2414
2426
|
}
|
|
2415
2427
|
}
|
|
2416
2428
|
return;
|
|
2417
2429
|
}
|
|
2418
|
-
function findIndex(
|
|
2419
|
-
if (
|
|
2430
|
+
function findIndex(array2, predicate, startIndex) {
|
|
2431
|
+
if (array2 === undefined)
|
|
2420
2432
|
return -1;
|
|
2421
|
-
for (let i = startIndex ?? 0;i <
|
|
2422
|
-
if (predicate(
|
|
2433
|
+
for (let i = startIndex ?? 0;i < array2.length; i++) {
|
|
2434
|
+
if (predicate(array2[i], i)) {
|
|
2423
2435
|
return i;
|
|
2424
2436
|
}
|
|
2425
2437
|
}
|
|
2426
2438
|
return -1;
|
|
2427
2439
|
}
|
|
2428
|
-
function findLastIndex(
|
|
2429
|
-
if (
|
|
2440
|
+
function findLastIndex(array2, predicate, startIndex) {
|
|
2441
|
+
if (array2 === undefined)
|
|
2430
2442
|
return -1;
|
|
2431
|
-
for (let i = startIndex ??
|
|
2432
|
-
if (predicate(
|
|
2443
|
+
for (let i = startIndex ?? array2.length - 1;i >= 0; i--) {
|
|
2444
|
+
if (predicate(array2[i], i)) {
|
|
2433
2445
|
return i;
|
|
2434
2446
|
}
|
|
2435
2447
|
}
|
|
2436
2448
|
return -1;
|
|
2437
2449
|
}
|
|
2438
|
-
function contains(
|
|
2439
|
-
if (
|
|
2440
|
-
for (let i = 0;i <
|
|
2441
|
-
if (equalityComparer(
|
|
2450
|
+
function contains(array2, value, equalityComparer = equateValues) {
|
|
2451
|
+
if (array2 !== undefined) {
|
|
2452
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2453
|
+
if (equalityComparer(array2[i], value)) {
|
|
2442
2454
|
return true;
|
|
2443
2455
|
}
|
|
2444
2456
|
}
|
|
@@ -2453,11 +2465,11 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2453
2465
|
}
|
|
2454
2466
|
return -1;
|
|
2455
2467
|
}
|
|
2456
|
-
function countWhere(
|
|
2468
|
+
function countWhere(array2, predicate) {
|
|
2457
2469
|
let count = 0;
|
|
2458
|
-
if (
|
|
2459
|
-
for (let i = 0;i <
|
|
2460
|
-
const v =
|
|
2470
|
+
if (array2 !== undefined) {
|
|
2471
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2472
|
+
const v = array2[i];
|
|
2461
2473
|
if (predicate(v, i)) {
|
|
2462
2474
|
count++;
|
|
2463
2475
|
}
|
|
@@ -2465,17 +2477,17 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2465
2477
|
}
|
|
2466
2478
|
return count;
|
|
2467
2479
|
}
|
|
2468
|
-
function filter(
|
|
2469
|
-
if (
|
|
2470
|
-
const len =
|
|
2480
|
+
function filter(array2, f) {
|
|
2481
|
+
if (array2 !== undefined) {
|
|
2482
|
+
const len = array2.length;
|
|
2471
2483
|
let i = 0;
|
|
2472
|
-
while (i < len && f(
|
|
2484
|
+
while (i < len && f(array2[i]))
|
|
2473
2485
|
i++;
|
|
2474
2486
|
if (i < len) {
|
|
2475
|
-
const result =
|
|
2487
|
+
const result = array2.slice(0, i);
|
|
2476
2488
|
i++;
|
|
2477
2489
|
while (i < len) {
|
|
2478
|
-
const item =
|
|
2490
|
+
const item = array2[i];
|
|
2479
2491
|
if (f(item)) {
|
|
2480
2492
|
result.push(item);
|
|
2481
2493
|
}
|
|
@@ -2484,27 +2496,27 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2484
2496
|
return result;
|
|
2485
2497
|
}
|
|
2486
2498
|
}
|
|
2487
|
-
return
|
|
2499
|
+
return array2;
|
|
2488
2500
|
}
|
|
2489
|
-
function filterMutate(
|
|
2501
|
+
function filterMutate(array2, f) {
|
|
2490
2502
|
let outIndex = 0;
|
|
2491
|
-
for (let i = 0;i <
|
|
2492
|
-
if (f(
|
|
2493
|
-
|
|
2503
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2504
|
+
if (f(array2[i], i, array2)) {
|
|
2505
|
+
array2[outIndex] = array2[i];
|
|
2494
2506
|
outIndex++;
|
|
2495
2507
|
}
|
|
2496
2508
|
}
|
|
2497
|
-
|
|
2509
|
+
array2.length = outIndex;
|
|
2498
2510
|
}
|
|
2499
|
-
function clear(
|
|
2500
|
-
|
|
2511
|
+
function clear(array2) {
|
|
2512
|
+
array2.length = 0;
|
|
2501
2513
|
}
|
|
2502
|
-
function map(
|
|
2514
|
+
function map(array2, f) {
|
|
2503
2515
|
let result;
|
|
2504
|
-
if (
|
|
2516
|
+
if (array2 !== undefined) {
|
|
2505
2517
|
result = [];
|
|
2506
|
-
for (let i = 0;i <
|
|
2507
|
-
result.push(f(
|
|
2518
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2519
|
+
result.push(f(array2[i], i));
|
|
2508
2520
|
}
|
|
2509
2521
|
}
|
|
2510
2522
|
return result;
|
|
@@ -2514,27 +2526,27 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2514
2526
|
yield mapFn(x);
|
|
2515
2527
|
}
|
|
2516
2528
|
}
|
|
2517
|
-
function sameMap(
|
|
2518
|
-
if (
|
|
2519
|
-
for (let i = 0;i <
|
|
2520
|
-
const item =
|
|
2529
|
+
function sameMap(array2, f) {
|
|
2530
|
+
if (array2 !== undefined) {
|
|
2531
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2532
|
+
const item = array2[i];
|
|
2521
2533
|
const mapped = f(item, i);
|
|
2522
2534
|
if (item !== mapped) {
|
|
2523
|
-
const result =
|
|
2535
|
+
const result = array2.slice(0, i);
|
|
2524
2536
|
result.push(mapped);
|
|
2525
|
-
for (i++;i <
|
|
2526
|
-
result.push(f(
|
|
2537
|
+
for (i++;i < array2.length; i++) {
|
|
2538
|
+
result.push(f(array2[i], i));
|
|
2527
2539
|
}
|
|
2528
2540
|
return result;
|
|
2529
2541
|
}
|
|
2530
2542
|
}
|
|
2531
2543
|
}
|
|
2532
|
-
return
|
|
2544
|
+
return array2;
|
|
2533
2545
|
}
|
|
2534
|
-
function flatten(
|
|
2546
|
+
function flatten(array2) {
|
|
2535
2547
|
const result = [];
|
|
2536
|
-
for (let i = 0;i <
|
|
2537
|
-
const v =
|
|
2548
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2549
|
+
const v = array2[i];
|
|
2538
2550
|
if (v) {
|
|
2539
2551
|
if (isArray(v)) {
|
|
2540
2552
|
addRange(result, v);
|
|
@@ -2545,11 +2557,11 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2545
2557
|
}
|
|
2546
2558
|
return result;
|
|
2547
2559
|
}
|
|
2548
|
-
function flatMap(
|
|
2560
|
+
function flatMap(array2, mapfn) {
|
|
2549
2561
|
let result;
|
|
2550
|
-
if (
|
|
2551
|
-
for (let i = 0;i <
|
|
2552
|
-
const v = mapfn(
|
|
2562
|
+
if (array2 !== undefined) {
|
|
2563
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2564
|
+
const v = mapfn(array2[i], i);
|
|
2553
2565
|
if (v) {
|
|
2554
2566
|
if (isArray(v)) {
|
|
2555
2567
|
result = addRange(result, v);
|
|
@@ -2561,11 +2573,11 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2561
2573
|
}
|
|
2562
2574
|
return result ?? emptyArray;
|
|
2563
2575
|
}
|
|
2564
|
-
function flatMapToMutable(
|
|
2576
|
+
function flatMapToMutable(array2, mapfn) {
|
|
2565
2577
|
const result = [];
|
|
2566
|
-
if (
|
|
2567
|
-
for (let i = 0;i <
|
|
2568
|
-
const v = mapfn(
|
|
2578
|
+
if (array2 !== undefined) {
|
|
2579
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2580
|
+
const v = mapfn(array2[i], i);
|
|
2569
2581
|
if (v) {
|
|
2570
2582
|
if (isArray(v)) {
|
|
2571
2583
|
addRange(result, v);
|
|
@@ -2585,15 +2597,15 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2585
2597
|
yield* iter2;
|
|
2586
2598
|
}
|
|
2587
2599
|
}
|
|
2588
|
-
function sameFlatMap(
|
|
2600
|
+
function sameFlatMap(array2, mapfn) {
|
|
2589
2601
|
let result;
|
|
2590
|
-
if (
|
|
2591
|
-
for (let i = 0;i <
|
|
2592
|
-
const item =
|
|
2602
|
+
if (array2 !== undefined) {
|
|
2603
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2604
|
+
const item = array2[i];
|
|
2593
2605
|
const mapped = mapfn(item, i);
|
|
2594
2606
|
if (result || item !== mapped || isArray(mapped)) {
|
|
2595
2607
|
if (!result) {
|
|
2596
|
-
result =
|
|
2608
|
+
result = array2.slice(0, i);
|
|
2597
2609
|
}
|
|
2598
2610
|
if (isArray(mapped)) {
|
|
2599
2611
|
addRange(result, mapped);
|
|
@@ -2603,12 +2615,12 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2603
2615
|
}
|
|
2604
2616
|
}
|
|
2605
2617
|
}
|
|
2606
|
-
return result ??
|
|
2618
|
+
return result ?? array2;
|
|
2607
2619
|
}
|
|
2608
|
-
function mapAllOrFail(
|
|
2620
|
+
function mapAllOrFail(array2, mapFn) {
|
|
2609
2621
|
const result = [];
|
|
2610
|
-
for (let i = 0;i <
|
|
2611
|
-
const mapped = mapFn(
|
|
2622
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2623
|
+
const mapped = mapFn(array2[i], i);
|
|
2612
2624
|
if (mapped === undefined) {
|
|
2613
2625
|
return;
|
|
2614
2626
|
}
|
|
@@ -2616,11 +2628,11 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2616
2628
|
}
|
|
2617
2629
|
return result;
|
|
2618
2630
|
}
|
|
2619
|
-
function mapDefined(
|
|
2631
|
+
function mapDefined(array2, mapFn) {
|
|
2620
2632
|
const result = [];
|
|
2621
|
-
if (
|
|
2622
|
-
for (let i = 0;i <
|
|
2623
|
-
const mapped = mapFn(
|
|
2633
|
+
if (array2 !== undefined) {
|
|
2634
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2635
|
+
const mapped = mapFn(array2[i], i);
|
|
2624
2636
|
if (mapped !== undefined) {
|
|
2625
2637
|
result.push(mapped);
|
|
2626
2638
|
}
|
|
@@ -2654,18 +2666,18 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2654
2666
|
function* singleIterator(value) {
|
|
2655
2667
|
yield value;
|
|
2656
2668
|
}
|
|
2657
|
-
function spanMap(
|
|
2669
|
+
function spanMap(array2, keyfn, mapfn) {
|
|
2658
2670
|
let result;
|
|
2659
|
-
if (
|
|
2671
|
+
if (array2 !== undefined) {
|
|
2660
2672
|
result = [];
|
|
2661
|
-
const len =
|
|
2673
|
+
const len = array2.length;
|
|
2662
2674
|
let previousKey;
|
|
2663
2675
|
let key;
|
|
2664
2676
|
let start = 0;
|
|
2665
2677
|
let pos = 0;
|
|
2666
2678
|
while (start < len) {
|
|
2667
2679
|
while (pos < len) {
|
|
2668
|
-
const value =
|
|
2680
|
+
const value = array2[pos];
|
|
2669
2681
|
key = keyfn(value, pos);
|
|
2670
2682
|
if (pos === 0) {
|
|
2671
2683
|
previousKey = key;
|
|
@@ -2675,7 +2687,7 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2675
2687
|
pos++;
|
|
2676
2688
|
}
|
|
2677
2689
|
if (start < pos) {
|
|
2678
|
-
const v = mapfn(
|
|
2690
|
+
const v = mapfn(array2.slice(start, pos), previousKey, start, pos);
|
|
2679
2691
|
if (v) {
|
|
2680
2692
|
result.push(v);
|
|
2681
2693
|
}
|
|
@@ -2698,16 +2710,16 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2698
2710
|
});
|
|
2699
2711
|
return result;
|
|
2700
2712
|
}
|
|
2701
|
-
function some(
|
|
2702
|
-
if (
|
|
2713
|
+
function some(array2, predicate) {
|
|
2714
|
+
if (array2 !== undefined) {
|
|
2703
2715
|
if (predicate !== undefined) {
|
|
2704
|
-
for (let i = 0;i <
|
|
2705
|
-
if (predicate(
|
|
2716
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2717
|
+
if (predicate(array2[i])) {
|
|
2706
2718
|
return true;
|
|
2707
2719
|
}
|
|
2708
2720
|
}
|
|
2709
2721
|
} else {
|
|
2710
|
-
return
|
|
2722
|
+
return array2.length > 0;
|
|
2711
2723
|
}
|
|
2712
2724
|
}
|
|
2713
2725
|
return false;
|
|
@@ -2737,42 +2749,42 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2737
2749
|
function selectIndex(_, i) {
|
|
2738
2750
|
return i;
|
|
2739
2751
|
}
|
|
2740
|
-
function indicesOf(
|
|
2741
|
-
return
|
|
2752
|
+
function indicesOf(array2) {
|
|
2753
|
+
return array2.map(selectIndex);
|
|
2742
2754
|
}
|
|
2743
|
-
function deduplicateRelational(
|
|
2744
|
-
const indices = indicesOf(
|
|
2745
|
-
stableSortIndices(
|
|
2746
|
-
let last2 =
|
|
2755
|
+
function deduplicateRelational(array2, equalityComparer, comparer) {
|
|
2756
|
+
const indices = indicesOf(array2);
|
|
2757
|
+
stableSortIndices(array2, indices, comparer);
|
|
2758
|
+
let last2 = array2[indices[0]];
|
|
2747
2759
|
const deduplicated = [indices[0]];
|
|
2748
2760
|
for (let i = 1;i < indices.length; i++) {
|
|
2749
2761
|
const index = indices[i];
|
|
2750
|
-
const item =
|
|
2762
|
+
const item = array2[index];
|
|
2751
2763
|
if (!equalityComparer(last2, item)) {
|
|
2752
2764
|
deduplicated.push(index);
|
|
2753
2765
|
last2 = item;
|
|
2754
2766
|
}
|
|
2755
2767
|
}
|
|
2756
2768
|
deduplicated.sort();
|
|
2757
|
-
return deduplicated.map((i) =>
|
|
2769
|
+
return deduplicated.map((i) => array2[i]);
|
|
2758
2770
|
}
|
|
2759
|
-
function deduplicateEquality(
|
|
2771
|
+
function deduplicateEquality(array2, equalityComparer) {
|
|
2760
2772
|
const result = [];
|
|
2761
|
-
for (let i = 0;i <
|
|
2762
|
-
pushIfUnique(result,
|
|
2773
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2774
|
+
pushIfUnique(result, array2[i], equalityComparer);
|
|
2763
2775
|
}
|
|
2764
2776
|
return result;
|
|
2765
2777
|
}
|
|
2766
|
-
function deduplicate(
|
|
2767
|
-
return
|
|
2778
|
+
function deduplicate(array2, equalityComparer, comparer) {
|
|
2779
|
+
return array2.length === 0 ? [] : array2.length === 1 ? array2.slice() : comparer ? deduplicateRelational(array2, equalityComparer, comparer) : deduplicateEquality(array2, equalityComparer);
|
|
2768
2780
|
}
|
|
2769
|
-
function deduplicateSorted(
|
|
2770
|
-
if (
|
|
2781
|
+
function deduplicateSorted(array2, comparer) {
|
|
2782
|
+
if (array2.length === 0)
|
|
2771
2783
|
return emptyArray;
|
|
2772
|
-
let last2 =
|
|
2784
|
+
let last2 = array2[0];
|
|
2773
2785
|
const deduplicated = [last2];
|
|
2774
|
-
for (let i = 1;i <
|
|
2775
|
-
const next =
|
|
2786
|
+
for (let i = 1;i < array2.length; i++) {
|
|
2787
|
+
const next = array2[i];
|
|
2776
2788
|
switch (comparer(next, last2)) {
|
|
2777
2789
|
case true:
|
|
2778
2790
|
case 0:
|
|
@@ -2787,34 +2799,34 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2787
2799
|
function createSortedArray() {
|
|
2788
2800
|
return [];
|
|
2789
2801
|
}
|
|
2790
|
-
function insertSorted(
|
|
2791
|
-
if (
|
|
2792
|
-
|
|
2802
|
+
function insertSorted(array2, insert, compare, equalityComparer, allowDuplicates) {
|
|
2803
|
+
if (array2.length === 0) {
|
|
2804
|
+
array2.push(insert);
|
|
2793
2805
|
return true;
|
|
2794
2806
|
}
|
|
2795
|
-
const insertIndex = binarySearch(
|
|
2807
|
+
const insertIndex = binarySearch(array2, insert, identity, compare);
|
|
2796
2808
|
if (insertIndex < 0) {
|
|
2797
2809
|
if (equalityComparer && !allowDuplicates) {
|
|
2798
2810
|
const idx = ~insertIndex;
|
|
2799
|
-
if (idx > 0 && equalityComparer(insert,
|
|
2811
|
+
if (idx > 0 && equalityComparer(insert, array2[idx - 1])) {
|
|
2800
2812
|
return false;
|
|
2801
2813
|
}
|
|
2802
|
-
if (idx <
|
|
2803
|
-
|
|
2814
|
+
if (idx < array2.length && equalityComparer(insert, array2[idx])) {
|
|
2815
|
+
array2.splice(idx, 1, insert);
|
|
2804
2816
|
return true;
|
|
2805
2817
|
}
|
|
2806
2818
|
}
|
|
2807
|
-
|
|
2819
|
+
array2.splice(~insertIndex, 0, insert);
|
|
2808
2820
|
return true;
|
|
2809
2821
|
}
|
|
2810
2822
|
if (allowDuplicates) {
|
|
2811
|
-
|
|
2823
|
+
array2.splice(insertIndex, 0, insert);
|
|
2812
2824
|
return true;
|
|
2813
2825
|
}
|
|
2814
2826
|
return false;
|
|
2815
2827
|
}
|
|
2816
|
-
function sortAndDeduplicate(
|
|
2817
|
-
return deduplicateSorted(toSorted(
|
|
2828
|
+
function sortAndDeduplicate(array2, comparer, equalityComparer) {
|
|
2829
|
+
return deduplicateSorted(toSorted(array2, comparer), equalityComparer ?? comparer ?? compareStringsCaseSensitive);
|
|
2818
2830
|
}
|
|
2819
2831
|
function arrayIsEqualTo(array1, array2, equalityComparer = equateValues) {
|
|
2820
2832
|
if (array1 === undefined || array2 === undefined) {
|
|
@@ -2830,20 +2842,20 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2830
2842
|
}
|
|
2831
2843
|
return true;
|
|
2832
2844
|
}
|
|
2833
|
-
function compact(
|
|
2845
|
+
function compact(array2) {
|
|
2834
2846
|
let result;
|
|
2835
|
-
if (
|
|
2836
|
-
for (let i = 0;i <
|
|
2837
|
-
const v =
|
|
2847
|
+
if (array2 !== undefined) {
|
|
2848
|
+
for (let i = 0;i < array2.length; i++) {
|
|
2849
|
+
const v = array2[i];
|
|
2838
2850
|
if (result ?? !v) {
|
|
2839
|
-
result ?? (result =
|
|
2851
|
+
result ?? (result = array2.slice(0, i));
|
|
2840
2852
|
if (v) {
|
|
2841
2853
|
result.push(v);
|
|
2842
2854
|
}
|
|
2843
2855
|
}
|
|
2844
2856
|
}
|
|
2845
2857
|
}
|
|
2846
|
-
return result ??
|
|
2858
|
+
return result ?? array2;
|
|
2847
2859
|
}
|
|
2848
2860
|
function relativeComplement(arrayA, arrayB, comparer) {
|
|
2849
2861
|
if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0)
|
|
@@ -2891,8 +2903,8 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2891
2903
|
return append(ys, xs);
|
|
2892
2904
|
return [xs, ys];
|
|
2893
2905
|
}
|
|
2894
|
-
function toOffset(
|
|
2895
|
-
return offset < 0 ?
|
|
2906
|
+
function toOffset(array2, offset) {
|
|
2907
|
+
return offset < 0 ? array2.length + offset : offset;
|
|
2896
2908
|
}
|
|
2897
2909
|
function addRange(to, from, start, end) {
|
|
2898
2910
|
if (from === undefined || from.length === 0)
|
|
@@ -2908,31 +2920,31 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2908
2920
|
}
|
|
2909
2921
|
return to;
|
|
2910
2922
|
}
|
|
2911
|
-
function pushIfUnique(
|
|
2912
|
-
if (contains(
|
|
2923
|
+
function pushIfUnique(array2, toAdd, equalityComparer) {
|
|
2924
|
+
if (contains(array2, toAdd, equalityComparer)) {
|
|
2913
2925
|
return false;
|
|
2914
2926
|
} else {
|
|
2915
|
-
|
|
2927
|
+
array2.push(toAdd);
|
|
2916
2928
|
return true;
|
|
2917
2929
|
}
|
|
2918
2930
|
}
|
|
2919
|
-
function appendIfUnique(
|
|
2920
|
-
if (
|
|
2921
|
-
pushIfUnique(
|
|
2922
|
-
return
|
|
2931
|
+
function appendIfUnique(array2, toAdd, equalityComparer) {
|
|
2932
|
+
if (array2 !== undefined) {
|
|
2933
|
+
pushIfUnique(array2, toAdd, equalityComparer);
|
|
2934
|
+
return array2;
|
|
2923
2935
|
} else {
|
|
2924
2936
|
return [toAdd];
|
|
2925
2937
|
}
|
|
2926
2938
|
}
|
|
2927
|
-
function stableSortIndices(
|
|
2928
|
-
indices.sort((x, y) => comparer(
|
|
2939
|
+
function stableSortIndices(array2, indices, comparer) {
|
|
2940
|
+
indices.sort((x, y) => comparer(array2[x], array2[y]) || compareValues(x, y));
|
|
2929
2941
|
}
|
|
2930
|
-
function toSorted(
|
|
2931
|
-
return
|
|
2942
|
+
function toSorted(array2, comparer) {
|
|
2943
|
+
return array2.length === 0 ? emptyArray : array2.slice().sort(comparer);
|
|
2932
2944
|
}
|
|
2933
|
-
function* arrayReverseIterator(
|
|
2934
|
-
for (let i =
|
|
2935
|
-
yield
|
|
2945
|
+
function* arrayReverseIterator(array2) {
|
|
2946
|
+
for (let i = array2.length - 1;i >= 0; i--) {
|
|
2947
|
+
yield array2[i];
|
|
2936
2948
|
}
|
|
2937
2949
|
}
|
|
2938
2950
|
function rangeEquals(array1, array2, pos, end) {
|
|
@@ -2944,17 +2956,17 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2944
2956
|
}
|
|
2945
2957
|
return true;
|
|
2946
2958
|
}
|
|
2947
|
-
var elementAt = Array.prototype.at ? (
|
|
2948
|
-
if (
|
|
2949
|
-
offset = toOffset(
|
|
2950
|
-
if (offset <
|
|
2951
|
-
return
|
|
2959
|
+
var elementAt = Array.prototype.at ? (array2, offset) => array2 == null ? undefined : array2.at(offset) : (array2, offset) => {
|
|
2960
|
+
if (array2 !== undefined) {
|
|
2961
|
+
offset = toOffset(array2, offset);
|
|
2962
|
+
if (offset < array2.length) {
|
|
2963
|
+
return array2[offset];
|
|
2952
2964
|
}
|
|
2953
2965
|
}
|
|
2954
2966
|
return;
|
|
2955
2967
|
};
|
|
2956
|
-
function firstOrUndefined(
|
|
2957
|
-
return
|
|
2968
|
+
function firstOrUndefined(array2) {
|
|
2969
|
+
return array2 === undefined || array2.length === 0 ? undefined : array2[0];
|
|
2958
2970
|
}
|
|
2959
2971
|
function firstOrUndefinedIterator(iter) {
|
|
2960
2972
|
if (iter !== undefined) {
|
|
@@ -2964,9 +2976,9 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2964
2976
|
}
|
|
2965
2977
|
return;
|
|
2966
2978
|
}
|
|
2967
|
-
function first(
|
|
2968
|
-
Debug.assert(
|
|
2969
|
-
return
|
|
2979
|
+
function first(array2) {
|
|
2980
|
+
Debug.assert(array2.length !== 0);
|
|
2981
|
+
return array2[0];
|
|
2970
2982
|
}
|
|
2971
2983
|
function firstIterator(iter) {
|
|
2972
2984
|
for (const value of iter) {
|
|
@@ -2974,39 +2986,39 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
2974
2986
|
}
|
|
2975
2987
|
Debug.fail("iterator is empty");
|
|
2976
2988
|
}
|
|
2977
|
-
function lastOrUndefined(
|
|
2978
|
-
return
|
|
2989
|
+
function lastOrUndefined(array2) {
|
|
2990
|
+
return array2 === undefined || array2.length === 0 ? undefined : array2[array2.length - 1];
|
|
2979
2991
|
}
|
|
2980
|
-
function last(
|
|
2981
|
-
Debug.assert(
|
|
2982
|
-
return
|
|
2992
|
+
function last(array2) {
|
|
2993
|
+
Debug.assert(array2.length !== 0);
|
|
2994
|
+
return array2[array2.length - 1];
|
|
2983
2995
|
}
|
|
2984
|
-
function singleOrUndefined(
|
|
2985
|
-
return
|
|
2996
|
+
function singleOrUndefined(array2) {
|
|
2997
|
+
return array2 !== undefined && array2.length === 1 ? array2[0] : undefined;
|
|
2986
2998
|
}
|
|
2987
|
-
function single(
|
|
2988
|
-
return Debug.checkDefined(singleOrUndefined(
|
|
2999
|
+
function single(array2) {
|
|
3000
|
+
return Debug.checkDefined(singleOrUndefined(array2));
|
|
2989
3001
|
}
|
|
2990
|
-
function singleOrMany(
|
|
2991
|
-
return
|
|
3002
|
+
function singleOrMany(array2) {
|
|
3003
|
+
return array2 !== undefined && array2.length === 1 ? array2[0] : array2;
|
|
2992
3004
|
}
|
|
2993
|
-
function replaceElement(
|
|
2994
|
-
const result =
|
|
3005
|
+
function replaceElement(array2, index, value) {
|
|
3006
|
+
const result = array2.slice(0);
|
|
2995
3007
|
result[index] = value;
|
|
2996
3008
|
return result;
|
|
2997
3009
|
}
|
|
2998
|
-
function binarySearch(
|
|
2999
|
-
return binarySearchKey(
|
|
3010
|
+
function binarySearch(array2, value, keySelector, keyComparer, offset) {
|
|
3011
|
+
return binarySearchKey(array2, keySelector(value), keySelector, keyComparer, offset);
|
|
3000
3012
|
}
|
|
3001
|
-
function binarySearchKey(
|
|
3002
|
-
if (!some(
|
|
3013
|
+
function binarySearchKey(array2, key, keySelector, keyComparer, offset) {
|
|
3014
|
+
if (!some(array2)) {
|
|
3003
3015
|
return -1;
|
|
3004
3016
|
}
|
|
3005
3017
|
let low = offset ?? 0;
|
|
3006
|
-
let high =
|
|
3018
|
+
let high = array2.length - 1;
|
|
3007
3019
|
while (low <= high) {
|
|
3008
3020
|
const middle = low + (high - low >> 1);
|
|
3009
|
-
const midKey = keySelector(
|
|
3021
|
+
const midKey = keySelector(array2[middle], middle);
|
|
3010
3022
|
switch (keyComparer(midKey, key)) {
|
|
3011
3023
|
case -1:
|
|
3012
3024
|
low = middle + 1;
|
|
@@ -3020,21 +3032,21 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
3020
3032
|
}
|
|
3021
3033
|
return ~low;
|
|
3022
3034
|
}
|
|
3023
|
-
function reduceLeft(
|
|
3024
|
-
if (
|
|
3025
|
-
const size =
|
|
3035
|
+
function reduceLeft(array2, f, initial, start, count) {
|
|
3036
|
+
if (array2 && array2.length > 0) {
|
|
3037
|
+
const size = array2.length;
|
|
3026
3038
|
if (size > 0) {
|
|
3027
3039
|
let pos = start === undefined || start < 0 ? 0 : start;
|
|
3028
3040
|
const end = count === undefined || pos + count > size - 1 ? size - 1 : pos + count;
|
|
3029
3041
|
let result;
|
|
3030
3042
|
if (arguments.length <= 2) {
|
|
3031
|
-
result =
|
|
3043
|
+
result = array2[pos];
|
|
3032
3044
|
pos++;
|
|
3033
3045
|
} else {
|
|
3034
3046
|
result = initial;
|
|
3035
3047
|
}
|
|
3036
3048
|
while (pos <= end) {
|
|
3037
|
-
result = f(result,
|
|
3049
|
+
result = f(result, array2[pos], pos);
|
|
3038
3050
|
pos++;
|
|
3039
3051
|
}
|
|
3040
3052
|
return result;
|
|
@@ -3124,20 +3136,20 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
3124
3136
|
}
|
|
3125
3137
|
return true;
|
|
3126
3138
|
}
|
|
3127
|
-
function arrayToMap(
|
|
3139
|
+
function arrayToMap(array2, makeKey, makeValue = identity) {
|
|
3128
3140
|
const result = /* @__PURE__ */ new Map;
|
|
3129
|
-
for (let i = 0;i <
|
|
3130
|
-
const value =
|
|
3141
|
+
for (let i = 0;i < array2.length; i++) {
|
|
3142
|
+
const value = array2[i];
|
|
3131
3143
|
const key = makeKey(value);
|
|
3132
3144
|
if (key !== undefined)
|
|
3133
3145
|
result.set(key, makeValue(value));
|
|
3134
3146
|
}
|
|
3135
3147
|
return result;
|
|
3136
3148
|
}
|
|
3137
|
-
function arrayToNumericMap(
|
|
3149
|
+
function arrayToNumericMap(array2, makeKey, makeValue = identity) {
|
|
3138
3150
|
const result = [];
|
|
3139
|
-
for (let i = 0;i <
|
|
3140
|
-
const value =
|
|
3151
|
+
for (let i = 0;i < array2.length; i++) {
|
|
3152
|
+
const value = array2[i];
|
|
3141
3153
|
result[makeKey(value)] = makeValue(value);
|
|
3142
3154
|
}
|
|
3143
3155
|
return result;
|
|
@@ -3159,17 +3171,17 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
3159
3171
|
for (let i = 0;i < values.length; i++) {
|
|
3160
3172
|
const value = values[i];
|
|
3161
3173
|
const key = `${keySelector(value)}`;
|
|
3162
|
-
const
|
|
3163
|
-
|
|
3174
|
+
const array2 = result[key] ?? (result[key] = []);
|
|
3175
|
+
array2.push(value);
|
|
3164
3176
|
}
|
|
3165
3177
|
}
|
|
3166
3178
|
return result;
|
|
3167
3179
|
}
|
|
3168
|
-
function clone(
|
|
3180
|
+
function clone(object2) {
|
|
3169
3181
|
const result = {};
|
|
3170
|
-
for (const id in
|
|
3171
|
-
if (hasOwnProperty.call(
|
|
3172
|
-
result[id] =
|
|
3182
|
+
for (const id in object2) {
|
|
3183
|
+
if (hasOwnProperty.call(object2, id)) {
|
|
3184
|
+
result[id] = object2[id];
|
|
3173
3185
|
}
|
|
3174
3186
|
}
|
|
3175
3187
|
return result;
|
|
@@ -3628,32 +3640,32 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
3628
3640
|
}
|
|
3629
3641
|
return end === fileName.length ? fileName : fileName.slice(0, end);
|
|
3630
3642
|
}
|
|
3631
|
-
function orderedRemoveItem(
|
|
3632
|
-
for (let i = 0;i <
|
|
3633
|
-
if (
|
|
3634
|
-
orderedRemoveItemAt(
|
|
3643
|
+
function orderedRemoveItem(array2, item) {
|
|
3644
|
+
for (let i = 0;i < array2.length; i++) {
|
|
3645
|
+
if (array2[i] === item) {
|
|
3646
|
+
orderedRemoveItemAt(array2, i);
|
|
3635
3647
|
return true;
|
|
3636
3648
|
}
|
|
3637
3649
|
}
|
|
3638
3650
|
return false;
|
|
3639
3651
|
}
|
|
3640
|
-
function orderedRemoveItemAt(
|
|
3641
|
-
for (let i = index;i <
|
|
3642
|
-
|
|
3652
|
+
function orderedRemoveItemAt(array2, index) {
|
|
3653
|
+
for (let i = index;i < array2.length - 1; i++) {
|
|
3654
|
+
array2[i] = array2[i + 1];
|
|
3643
3655
|
}
|
|
3644
|
-
|
|
3656
|
+
array2.pop();
|
|
3645
3657
|
}
|
|
3646
|
-
function unorderedRemoveItemAt(
|
|
3647
|
-
|
|
3648
|
-
|
|
3658
|
+
function unorderedRemoveItemAt(array2, index) {
|
|
3659
|
+
array2[index] = array2[array2.length - 1];
|
|
3660
|
+
array2.pop();
|
|
3649
3661
|
}
|
|
3650
|
-
function unorderedRemoveItem(
|
|
3651
|
-
return unorderedRemoveFirstItemWhere(
|
|
3662
|
+
function unorderedRemoveItem(array2, item) {
|
|
3663
|
+
return unorderedRemoveFirstItemWhere(array2, (element) => element === item);
|
|
3652
3664
|
}
|
|
3653
|
-
function unorderedRemoveFirstItemWhere(
|
|
3654
|
-
for (let i = 0;i <
|
|
3655
|
-
if (predicate(
|
|
3656
|
-
unorderedRemoveItemAt(
|
|
3665
|
+
function unorderedRemoveFirstItemWhere(array2, predicate) {
|
|
3666
|
+
for (let i = 0;i < array2.length; i++) {
|
|
3667
|
+
if (predicate(array2[i])) {
|
|
3668
|
+
unorderedRemoveItemAt(array2, i);
|
|
3657
3669
|
return true;
|
|
3658
3670
|
}
|
|
3659
3671
|
}
|
|
@@ -3772,24 +3784,24 @@ var require_typescript = __commonJS((exports, module) => {
|
|
|
3772
3784
|
}
|
|
3773
3785
|
}
|
|
3774
3786
|
}
|
|
3775
|
-
function takeWhile(
|
|
3776
|
-
if (
|
|
3777
|
-
const len =
|
|
3787
|
+
function takeWhile(array2, predicate) {
|
|
3788
|
+
if (array2 !== undefined) {
|
|
3789
|
+
const len = array2.length;
|
|
3778
3790
|
let index = 0;
|
|
3779
|
-
while (index < len && predicate(
|
|
3791
|
+
while (index < len && predicate(array2[index])) {
|
|
3780
3792
|
index++;
|
|
3781
3793
|
}
|
|
3782
|
-
return
|
|
3794
|
+
return array2.slice(0, index);
|
|
3783
3795
|
}
|
|
3784
3796
|
}
|
|
3785
|
-
function skipWhile(
|
|
3786
|
-
if (
|
|
3787
|
-
const len =
|
|
3797
|
+
function skipWhile(array2, predicate) {
|
|
3798
|
+
if (array2 !== undefined) {
|
|
3799
|
+
const len = array2.length;
|
|
3788
3800
|
let index = 0;
|
|
3789
|
-
while (index < len && predicate(
|
|
3801
|
+
while (index < len && predicate(array2[index])) {
|
|
3790
3802
|
index++;
|
|
3791
3803
|
}
|
|
3792
|
-
return
|
|
3804
|
+
return array2.slice(index);
|
|
3793
3805
|
}
|
|
3794
3806
|
}
|
|
3795
3807
|
function isNodeLikeSystem() {
|
|
@@ -4157,9 +4169,9 @@ Verbose Debug Information: ` + (typeof verboseDebugInfo === "string" ? verboseDe
|
|
|
4157
4169
|
}
|
|
4158
4170
|
Debug2.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo;
|
|
4159
4171
|
let nodeArrayProto;
|
|
4160
|
-
function attachNodeArrayDebugInfoWorker(
|
|
4161
|
-
if (!("__tsDebuggerDisplay" in
|
|
4162
|
-
Object.defineProperties(
|
|
4172
|
+
function attachNodeArrayDebugInfoWorker(array2) {
|
|
4173
|
+
if (!("__tsDebuggerDisplay" in array2)) {
|
|
4174
|
+
Object.defineProperties(array2, {
|
|
4163
4175
|
__tsDebuggerDisplay: {
|
|
4164
4176
|
value(defaultValue) {
|
|
4165
4177
|
defaultValue = String(defaultValue).replace(/(?:,[\s\w]+:[^,]+)+\]$/, "]");
|
|
@@ -4169,16 +4181,16 @@ Verbose Debug Information: ` + (typeof verboseDebugInfo === "string" ? verboseDe
|
|
|
4169
4181
|
});
|
|
4170
4182
|
}
|
|
4171
4183
|
}
|
|
4172
|
-
function attachNodeArrayDebugInfo(
|
|
4184
|
+
function attachNodeArrayDebugInfo(array2) {
|
|
4173
4185
|
if (isDebugInfoEnabled) {
|
|
4174
4186
|
if (typeof Object.setPrototypeOf === "function") {
|
|
4175
4187
|
if (!nodeArrayProto) {
|
|
4176
4188
|
nodeArrayProto = Object.create(Array.prototype);
|
|
4177
4189
|
attachNodeArrayDebugInfoWorker(nodeArrayProto);
|
|
4178
4190
|
}
|
|
4179
|
-
Object.setPrototypeOf(
|
|
4191
|
+
Object.setPrototypeOf(array2, nodeArrayProto);
|
|
4180
4192
|
} else {
|
|
4181
|
-
attachNodeArrayDebugInfoWorker(
|
|
4193
|
+
attachNodeArrayDebugInfoWorker(array2);
|
|
4182
4194
|
}
|
|
4183
4195
|
}
|
|
4184
4196
|
}
|
|
@@ -4683,15 +4695,15 @@ ${lanes.join(`
|
|
|
4683
4695
|
}
|
|
4684
4696
|
return " ";
|
|
4685
4697
|
}
|
|
4686
|
-
function fill(
|
|
4687
|
-
if (
|
|
4688
|
-
|
|
4698
|
+
function fill(array2, value) {
|
|
4699
|
+
if (array2.fill) {
|
|
4700
|
+
array2.fill(value);
|
|
4689
4701
|
} else {
|
|
4690
|
-
for (let i = 0;i <
|
|
4691
|
-
|
|
4702
|
+
for (let i = 0;i < array2.length; i++) {
|
|
4703
|
+
array2[i] = value;
|
|
4692
4704
|
}
|
|
4693
4705
|
}
|
|
4694
|
-
return
|
|
4706
|
+
return array2;
|
|
4695
4707
|
}
|
|
4696
4708
|
function repeat(ch, length2) {
|
|
4697
4709
|
if (ch.repeat) {
|
|
@@ -14820,8 +14832,8 @@ ${lanes.join(`
|
|
|
14820
14832
|
function isToken(n) {
|
|
14821
14833
|
return isTokenKind(n.kind);
|
|
14822
14834
|
}
|
|
14823
|
-
function isNodeArray(
|
|
14824
|
-
return hasProperty(
|
|
14835
|
+
function isNodeArray(array2) {
|
|
14836
|
+
return hasProperty(array2, "pos") && hasProperty(array2, "end");
|
|
14825
14837
|
}
|
|
14826
14838
|
function isLiteralKind(kind) {
|
|
14827
14839
|
return 9 <= kind && kind <= 15;
|
|
@@ -22054,12 +22066,12 @@ ${lanes.join(`
|
|
|
22054
22066
|
function isIdentifierTypeReference(node) {
|
|
22055
22067
|
return isTypeReferenceNode(node) && isIdentifier(node.typeName);
|
|
22056
22068
|
}
|
|
22057
|
-
function arrayIsHomogeneous(
|
|
22058
|
-
if (
|
|
22069
|
+
function arrayIsHomogeneous(array2, comparer = equateValues) {
|
|
22070
|
+
if (array2.length < 2)
|
|
22059
22071
|
return true;
|
|
22060
|
-
const first2 =
|
|
22061
|
-
for (let i = 1, length2 =
|
|
22062
|
-
const target =
|
|
22072
|
+
const first2 = array2[0];
|
|
22073
|
+
for (let i = 1, length2 = array2.length;i < length2; i++) {
|
|
22074
|
+
const target = array2[i];
|
|
22063
22075
|
if (!comparer(first2, target))
|
|
22064
22076
|
return false;
|
|
22065
22077
|
}
|
|
@@ -24415,23 +24427,23 @@ ${lanes.join(`
|
|
|
24415
24427
|
Debug.attachNodeArrayDebugInfo(elements);
|
|
24416
24428
|
return elements;
|
|
24417
24429
|
}
|
|
24418
|
-
const
|
|
24419
|
-
|
|
24420
|
-
|
|
24421
|
-
|
|
24422
|
-
|
|
24423
|
-
Debug.attachNodeArrayDebugInfo(
|
|
24424
|
-
return
|
|
24430
|
+
const array22 = elements.slice();
|
|
24431
|
+
array22.pos = elements.pos;
|
|
24432
|
+
array22.end = elements.end;
|
|
24433
|
+
array22.hasTrailingComma = hasTrailingComma;
|
|
24434
|
+
array22.transformFlags = elements.transformFlags;
|
|
24435
|
+
Debug.attachNodeArrayDebugInfo(array22);
|
|
24436
|
+
return array22;
|
|
24425
24437
|
}
|
|
24426
24438
|
const length2 = elements.length;
|
|
24427
|
-
const
|
|
24428
|
-
|
|
24429
|
-
|
|
24430
|
-
|
|
24431
|
-
|
|
24432
|
-
aggregateChildrenFlags(
|
|
24433
|
-
Debug.attachNodeArrayDebugInfo(
|
|
24434
|
-
return
|
|
24439
|
+
const array2 = length2 >= 1 && length2 <= 4 ? elements.slice() : elements;
|
|
24440
|
+
array2.pos = -1;
|
|
24441
|
+
array2.end = -1;
|
|
24442
|
+
array2.hasTrailingComma = !!hasTrailingComma;
|
|
24443
|
+
array2.transformFlags = 0;
|
|
24444
|
+
aggregateChildrenFlags(array2);
|
|
24445
|
+
Debug.attachNodeArrayDebugInfo(array2);
|
|
24446
|
+
return array2;
|
|
24435
24447
|
}
|
|
24436
24448
|
function createBaseNode(kind) {
|
|
24437
24449
|
return baseFactory2.createBaseNode(kind);
|
|
@@ -27312,11 +27324,11 @@ ${lanes.join(`
|
|
|
27312
27324
|
function createIsNotTypeCheck(value, tag) {
|
|
27313
27325
|
return tag === "null" ? factory2.createStrictInequality(value, createNull()) : tag === "undefined" ? factory2.createStrictInequality(value, createVoidZero()) : factory2.createStrictInequality(createTypeOfExpression(value), createStringLiteral(tag));
|
|
27314
27326
|
}
|
|
27315
|
-
function createMethodCall(
|
|
27316
|
-
if (isCallChain(
|
|
27317
|
-
return createCallChain(createPropertyAccessChain(
|
|
27327
|
+
function createMethodCall(object2, methodName2, argumentsList) {
|
|
27328
|
+
if (isCallChain(object2)) {
|
|
27329
|
+
return createCallChain(createPropertyAccessChain(object2, undefined, methodName2), undefined, undefined, argumentsList);
|
|
27318
27330
|
}
|
|
27319
|
-
return createCallExpression(createPropertyAccessExpression(
|
|
27331
|
+
return createCallExpression(createPropertyAccessExpression(object2, methodName2), undefined, argumentsList);
|
|
27320
27332
|
}
|
|
27321
27333
|
function createFunctionBindCall(target, thisArg, argumentsList) {
|
|
27322
27334
|
return createMethodCall(target, "bind", [thisArg, ...argumentsList]);
|
|
@@ -27327,14 +27339,14 @@ ${lanes.join(`
|
|
|
27327
27339
|
function createFunctionApplyCall(target, thisArg, argumentsExpression) {
|
|
27328
27340
|
return createMethodCall(target, "apply", [thisArg, argumentsExpression]);
|
|
27329
27341
|
}
|
|
27330
|
-
function createGlobalMethodCall(globalObjectName,
|
|
27331
|
-
return createMethodCall(createIdentifier(globalObjectName),
|
|
27342
|
+
function createGlobalMethodCall(globalObjectName, methodName2, argumentsList) {
|
|
27343
|
+
return createMethodCall(createIdentifier(globalObjectName), methodName2, argumentsList);
|
|
27332
27344
|
}
|
|
27333
|
-
function createArraySliceCall(
|
|
27334
|
-
return createMethodCall(
|
|
27345
|
+
function createArraySliceCall(array2, start) {
|
|
27346
|
+
return createMethodCall(array2, "slice", start === undefined ? [] : [asExpression(start)]);
|
|
27335
27347
|
}
|
|
27336
|
-
function createArrayConcatCall(
|
|
27337
|
-
return createMethodCall(
|
|
27348
|
+
function createArrayConcatCall(array2, argumentsList) {
|
|
27349
|
+
return createMethodCall(array2, "concat", argumentsList);
|
|
27338
27350
|
}
|
|
27339
27351
|
function createObjectDefinePropertyCall(target, propertyName, attributes) {
|
|
27340
27352
|
return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]);
|
|
@@ -27572,9 +27584,9 @@ ${lanes.join(`
|
|
|
27572
27584
|
Debug.assert(every(nodes, isStatementOrBlock), "Cannot lift nodes to a Block.");
|
|
27573
27585
|
return singleOrUndefined(nodes) || createBlock(nodes);
|
|
27574
27586
|
}
|
|
27575
|
-
function findSpanEnd(
|
|
27587
|
+
function findSpanEnd(array2, test, start) {
|
|
27576
27588
|
let i = start;
|
|
27577
|
-
while (i <
|
|
27589
|
+
while (i < array2.length && test(array2[i])) {
|
|
27578
27590
|
i++;
|
|
27579
27591
|
}
|
|
27580
27592
|
return i;
|
|
@@ -27653,8 +27665,8 @@ ${lanes.join(`
|
|
|
27653
27665
|
return updatePropertyAssignment(node, name, node.initializer);
|
|
27654
27666
|
}
|
|
27655
27667
|
}
|
|
27656
|
-
function asNodeArray(
|
|
27657
|
-
return
|
|
27668
|
+
function asNodeArray(array2) {
|
|
27669
|
+
return array2 ? createNodeArray(array2) : undefined;
|
|
27658
27670
|
}
|
|
27659
27671
|
function asName(name) {
|
|
27660
27672
|
return typeof name === "string" ? createIdentifier(name) : name;
|
|
@@ -31926,9 +31938,9 @@ ${lanes.join(`
|
|
|
31926
31938
|
return tryParseSemicolon() || parseExpected(27);
|
|
31927
31939
|
}
|
|
31928
31940
|
function createNodeArray(elements, pos, end, hasTrailingComma) {
|
|
31929
|
-
const
|
|
31930
|
-
setTextRangePosEnd(
|
|
31931
|
-
return
|
|
31941
|
+
const array2 = factoryCreateNodeArray(elements, hasTrailingComma);
|
|
31942
|
+
setTextRangePosEnd(array2, pos, end ?? scanner2.getTokenFullStart());
|
|
31943
|
+
return array2;
|
|
31932
31944
|
}
|
|
31933
31945
|
function finishNode(node, pos, end) {
|
|
31934
31946
|
setTextRangePosEnd(node, pos, end ?? scanner2.getTokenFullStart());
|
|
@@ -37157,9 +37169,9 @@ ${lanes.join(`
|
|
|
37157
37169
|
}
|
|
37158
37170
|
checkNodePositions(node, aggressiveChecks);
|
|
37159
37171
|
}
|
|
37160
|
-
function visitArray2(
|
|
37161
|
-
setTextRangePosEnd(
|
|
37162
|
-
for (const node of
|
|
37172
|
+
function visitArray2(array2) {
|
|
37173
|
+
setTextRangePosEnd(array2, array2.pos + delta, array2.end + delta);
|
|
37174
|
+
for (const node of array2) {
|
|
37163
37175
|
visitNode3(node);
|
|
37164
37176
|
}
|
|
37165
37177
|
}
|
|
@@ -37228,17 +37240,17 @@ ${lanes.join(`
|
|
|
37228
37240
|
}
|
|
37229
37241
|
Debug.assert(fullEnd < changeStart);
|
|
37230
37242
|
}
|
|
37231
|
-
function visitArray2(
|
|
37232
|
-
Debug.assert(
|
|
37233
|
-
if (
|
|
37234
|
-
moveElementEntirelyPastChangeRange(
|
|
37243
|
+
function visitArray2(array2) {
|
|
37244
|
+
Debug.assert(array2.pos <= array2.end);
|
|
37245
|
+
if (array2.pos > changeRangeOldEnd) {
|
|
37246
|
+
moveElementEntirelyPastChangeRange(array2, sourceFile, true, delta, oldText, newText, aggressiveChecks);
|
|
37235
37247
|
return;
|
|
37236
37248
|
}
|
|
37237
|
-
const fullEnd =
|
|
37249
|
+
const fullEnd = array2.end;
|
|
37238
37250
|
if (fullEnd >= changeStart) {
|
|
37239
|
-
markAsIntersectingIncrementalChange(
|
|
37240
|
-
adjustIntersectingElement(
|
|
37241
|
-
for (const node of
|
|
37251
|
+
markAsIntersectingIncrementalChange(array2);
|
|
37252
|
+
adjustIntersectingElement(array2, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
|
37253
|
+
for (const node of array2) {
|
|
37242
37254
|
visitNode3(node);
|
|
37243
37255
|
}
|
|
37244
37256
|
return;
|
|
@@ -37350,13 +37362,13 @@ ${lanes.join(`
|
|
|
37350
37362
|
}
|
|
37351
37363
|
return false;
|
|
37352
37364
|
}
|
|
37353
|
-
function visitArray2(
|
|
37354
|
-
if (position >=
|
|
37355
|
-
for (let i = 0;i <
|
|
37356
|
-
const child =
|
|
37365
|
+
function visitArray2(array2) {
|
|
37366
|
+
if (position >= array2.pos && position < array2.end) {
|
|
37367
|
+
for (let i = 0;i < array2.length; i++) {
|
|
37368
|
+
const child = array2[i];
|
|
37357
37369
|
if (child) {
|
|
37358
37370
|
if (child.pos === position) {
|
|
37359
|
-
currentArray =
|
|
37371
|
+
currentArray = array2;
|
|
37360
37372
|
currentArrayIndex = i;
|
|
37361
37373
|
current = child;
|
|
37362
37374
|
return true;
|
|
@@ -54492,11 +54504,11 @@ ${lanes.join(`
|
|
|
54492
54504
|
addRelatedInfo(error2(s.valueDeclaration, Diagnostics.Duplicate_identifier_0, unescapedName), createDiagnosticForNode(exportedMemberName, Diagnostics._0_was_also_declared_here, unescapedName));
|
|
54493
54505
|
addRelatedInfo(error2(exportedMemberName, Diagnostics.Duplicate_identifier_0, unescapedName), createDiagnosticForNode(s.valueDeclaration, Diagnostics._0_was_also_declared_here, unescapedName));
|
|
54494
54506
|
}
|
|
54495
|
-
const
|
|
54496
|
-
|
|
54497
|
-
|
|
54498
|
-
|
|
54499
|
-
members.set(name,
|
|
54507
|
+
const union2 = createSymbol(s.flags | exportedMember.flags, name);
|
|
54508
|
+
union2.links.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
|
|
54509
|
+
union2.valueDeclaration = exportedMember.valueDeclaration;
|
|
54510
|
+
union2.declarations = concatenate(exportedMember.declarations, s.declarations);
|
|
54511
|
+
members.set(name, union2);
|
|
54500
54512
|
} else {
|
|
54501
54513
|
members.set(name, mergeSymbol(s, exportedMember));
|
|
54502
54514
|
}
|
|
@@ -56217,12 +56229,12 @@ ${lanes.join(`
|
|
|
56217
56229
|
}
|
|
56218
56230
|
return signatures;
|
|
56219
56231
|
}
|
|
56220
|
-
function appendIndexInfo(indexInfos, newInfo,
|
|
56232
|
+
function appendIndexInfo(indexInfos, newInfo, union2) {
|
|
56221
56233
|
if (indexInfos) {
|
|
56222
56234
|
for (let i = 0;i < indexInfos.length; i++) {
|
|
56223
56235
|
const info = indexInfos[i];
|
|
56224
56236
|
if (info.keyType === newInfo.keyType) {
|
|
56225
|
-
indexInfos[i] = createIndexInfo(info.keyType,
|
|
56237
|
+
indexInfos[i] = createIndexInfo(info.keyType, union2 ? getUnionType([info.type, newInfo.type]) : getIntersectionType([info.type, newInfo.type]), union2 ? info.isReadonly || newInfo.isReadonly : info.isReadonly && newInfo.isReadonly);
|
|
56226
56238
|
return indexInfos;
|
|
56227
56239
|
}
|
|
56228
56240
|
}
|
|
@@ -59043,14 +59055,14 @@ ${lanes.join(`
|
|
|
59043
59055
|
addNamedUnions(namedUnions, types);
|
|
59044
59056
|
const reducedTypes = [];
|
|
59045
59057
|
for (const t of typeSet) {
|
|
59046
|
-
if (!some(namedUnions, (
|
|
59058
|
+
if (!some(namedUnions, (union2) => containsType(union2.types, t))) {
|
|
59047
59059
|
reducedTypes.push(t);
|
|
59048
59060
|
}
|
|
59049
59061
|
}
|
|
59050
59062
|
if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) {
|
|
59051
59063
|
return namedUnions[0];
|
|
59052
59064
|
}
|
|
59053
|
-
const namedTypesCount = reduceLeft(namedUnions, (sum,
|
|
59065
|
+
const namedTypesCount = reduceLeft(namedUnions, (sum, union2) => sum + union2.types.length, 0);
|
|
59054
59066
|
if (namedTypesCount + reducedTypes.length === typeSet.length) {
|
|
59055
59067
|
for (const t of namedUnions) {
|
|
59056
59068
|
insertType(reducedTypes, t);
|
|
@@ -78558,11 +78570,11 @@ ${lanes.join(`
|
|
|
78558
78570
|
}
|
|
78559
78571
|
return { yieldType, returnType, nextType };
|
|
78560
78572
|
}
|
|
78561
|
-
function combineIterationTypes(
|
|
78573
|
+
function combineIterationTypes(array2) {
|
|
78562
78574
|
let yieldTypes;
|
|
78563
78575
|
let returnTypes;
|
|
78564
78576
|
let nextTypes;
|
|
78565
|
-
for (const iterationTypes of
|
|
78577
|
+
for (const iterationTypes of array2) {
|
|
78566
78578
|
if (iterationTypes === undefined || iterationTypes === noIterationTypes) {
|
|
78567
78579
|
continue;
|
|
78568
78580
|
}
|
|
@@ -78808,55 +78820,55 @@ ${lanes.join(`
|
|
|
78808
78820
|
}
|
|
78809
78821
|
return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType, returnType || voidType, undefined));
|
|
78810
78822
|
}
|
|
78811
|
-
function getIterationTypesOfMethod(type, resolver,
|
|
78823
|
+
function getIterationTypesOfMethod(type, resolver, methodName2, errorNode, errorOutputContainer) {
|
|
78812
78824
|
var _a, _b, _c, _d;
|
|
78813
|
-
const method = getPropertyOfType(type,
|
|
78814
|
-
if (!method &&
|
|
78825
|
+
const method = getPropertyOfType(type, methodName2);
|
|
78826
|
+
if (!method && methodName2 !== "next") {
|
|
78815
78827
|
return;
|
|
78816
78828
|
}
|
|
78817
|
-
const methodType = method && !(
|
|
78829
|
+
const methodType = method && !(methodName2 === "next" && method.flags & 16777216) ? methodName2 === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152) : undefined;
|
|
78818
78830
|
if (isTypeAny(methodType)) {
|
|
78819
78831
|
return anyIterationTypes;
|
|
78820
78832
|
}
|
|
78821
78833
|
const methodSignatures = methodType ? getSignaturesOfType(methodType, 0) : emptyArray;
|
|
78822
78834
|
if (methodSignatures.length === 0) {
|
|
78823
78835
|
if (errorNode) {
|
|
78824
|
-
const diagnostic =
|
|
78836
|
+
const diagnostic = methodName2 === "next" ? resolver.mustHaveANextMethodDiagnostic : resolver.mustBeAMethodDiagnostic;
|
|
78825
78837
|
if (errorOutputContainer) {
|
|
78826
78838
|
errorOutputContainer.errors ?? (errorOutputContainer.errors = []);
|
|
78827
|
-
errorOutputContainer.errors.push(createDiagnosticForNode(errorNode, diagnostic,
|
|
78839
|
+
errorOutputContainer.errors.push(createDiagnosticForNode(errorNode, diagnostic, methodName2));
|
|
78828
78840
|
} else {
|
|
78829
|
-
error2(errorNode, diagnostic,
|
|
78841
|
+
error2(errorNode, diagnostic, methodName2);
|
|
78830
78842
|
}
|
|
78831
78843
|
}
|
|
78832
|
-
return
|
|
78844
|
+
return methodName2 === "next" ? noIterationTypes : undefined;
|
|
78833
78845
|
}
|
|
78834
78846
|
if ((methodType == null ? undefined : methodType.symbol) && methodSignatures.length === 1) {
|
|
78835
78847
|
const globalGeneratorType = resolver.getGlobalGeneratorType(false);
|
|
78836
78848
|
const globalIteratorType = resolver.getGlobalIteratorType(false);
|
|
78837
|
-
const isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) == null ? undefined : _a.members) == null ? undefined : _b.get(
|
|
78838
|
-
const isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) == null ? undefined : _c.members) == null ? undefined : _d.get(
|
|
78849
|
+
const isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) == null ? undefined : _a.members) == null ? undefined : _b.get(methodName2)) === methodType.symbol;
|
|
78850
|
+
const isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) == null ? undefined : _c.members) == null ? undefined : _d.get(methodName2)) === methodType.symbol;
|
|
78839
78851
|
if (isGeneratorMethod || isIteratorMethod) {
|
|
78840
78852
|
const globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
|
|
78841
78853
|
const { mapper } = methodType;
|
|
78842
|
-
return createIterationTypes(getMappedType(globalType.typeParameters[0], mapper), getMappedType(globalType.typeParameters[1], mapper),
|
|
78854
|
+
return createIterationTypes(getMappedType(globalType.typeParameters[0], mapper), getMappedType(globalType.typeParameters[1], mapper), methodName2 === "next" ? getMappedType(globalType.typeParameters[2], mapper) : undefined);
|
|
78843
78855
|
}
|
|
78844
78856
|
}
|
|
78845
78857
|
let methodParameterTypes;
|
|
78846
78858
|
let methodReturnTypes;
|
|
78847
78859
|
for (const signature of methodSignatures) {
|
|
78848
|
-
if (
|
|
78860
|
+
if (methodName2 !== "throw" && some(signature.parameters)) {
|
|
78849
78861
|
methodParameterTypes = append(methodParameterTypes, getTypeAtPosition(signature, 0));
|
|
78850
78862
|
}
|
|
78851
78863
|
methodReturnTypes = append(methodReturnTypes, getReturnTypeOfSignature(signature));
|
|
78852
78864
|
}
|
|
78853
78865
|
let returnTypes;
|
|
78854
78866
|
let nextType;
|
|
78855
|
-
if (
|
|
78867
|
+
if (methodName2 !== "throw") {
|
|
78856
78868
|
const methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType;
|
|
78857
|
-
if (
|
|
78869
|
+
if (methodName2 === "next") {
|
|
78858
78870
|
nextType = methodParameterType;
|
|
78859
|
-
} else if (
|
|
78871
|
+
} else if (methodName2 === "return") {
|
|
78860
78872
|
const resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
|
|
78861
78873
|
returnTypes = append(returnTypes, resolvedMethodParameterType);
|
|
78862
78874
|
}
|
|
@@ -78869,9 +78881,9 @@ ${lanes.join(`
|
|
|
78869
78881
|
if (errorNode) {
|
|
78870
78882
|
if (errorOutputContainer) {
|
|
78871
78883
|
errorOutputContainer.errors ?? (errorOutputContainer.errors = []);
|
|
78872
|
-
errorOutputContainer.errors.push(createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic,
|
|
78884
|
+
errorOutputContainer.errors.push(createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName2));
|
|
78873
78885
|
} else {
|
|
78874
|
-
error2(errorNode, resolver.mustHaveAValueDiagnostic,
|
|
78886
|
+
error2(errorNode, resolver.mustHaveAValueDiagnostic, methodName2);
|
|
78875
78887
|
}
|
|
78876
78888
|
}
|
|
78877
78889
|
yieldType = anyType;
|
|
@@ -89234,11 +89246,11 @@ ${lanes.join(`
|
|
|
89234
89246
|
}
|
|
89235
89247
|
}
|
|
89236
89248
|
function addPrivateIdentifierMethodDeclarationToEnvironment(_node, name, lex, privateEnv, isStatic2, isValid, _previousInfo) {
|
|
89237
|
-
const
|
|
89249
|
+
const methodName2 = createHoistedVariableForPrivateName(name);
|
|
89238
89250
|
const brandCheckIdentifier = isStatic2 ? Debug.checkDefined(lex.classThis ?? lex.classConstructor, "classConstructor should be set in private identifier environment") : Debug.checkDefined(privateEnv.data.weakSetName, "weakSetName should be set in private identifier environment");
|
|
89239
89251
|
setPrivateIdentifier(privateEnv, name, {
|
|
89240
89252
|
kind: "m",
|
|
89241
|
-
methodName,
|
|
89253
|
+
methodName: methodName2,
|
|
89242
89254
|
brandCheckIdentifier,
|
|
89243
89255
|
isStatic: isStatic2,
|
|
89244
89256
|
isValid
|
|
@@ -110920,8 +110932,8 @@ ${lanes.join(`
|
|
|
110920
110932
|
const next = convertOrRepopulateDiagnosticMessageChainArray(chain.next, sourceFile, newProgram, repopulateInfo);
|
|
110921
110933
|
return next === chain.next ? chain : { ...chain, next };
|
|
110922
110934
|
}
|
|
110923
|
-
function convertOrRepopulateDiagnosticMessageChainArray(
|
|
110924
|
-
return sameMap(
|
|
110935
|
+
function convertOrRepopulateDiagnosticMessageChainArray(array2, sourceFile, newProgram, repopulateInfo) {
|
|
110936
|
+
return sameMap(array2, (chain) => convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram, repopulateInfo));
|
|
110925
110937
|
}
|
|
110926
110938
|
function convertToDiagnostics(diagnostics, diagnosticFilePath, newProgram) {
|
|
110927
110939
|
if (!diagnostics.length)
|
|
@@ -111458,20 +111470,20 @@ ${lanes.join(`
|
|
|
111458
111470
|
const next = toReusableDiagnosticMessageChainArray(chain.next);
|
|
111459
111471
|
return next === chain.next ? chain : { ...chain, next };
|
|
111460
111472
|
}
|
|
111461
|
-
function toReusableDiagnosticMessageChainArray(
|
|
111462
|
-
if (!
|
|
111463
|
-
return
|
|
111464
|
-
return forEach(
|
|
111473
|
+
function toReusableDiagnosticMessageChainArray(array2) {
|
|
111474
|
+
if (!array2)
|
|
111475
|
+
return array2;
|
|
111476
|
+
return forEach(array2, (chain, index) => {
|
|
111465
111477
|
const reusable = toReusableDiagnosticMessageChain(chain);
|
|
111466
111478
|
if (chain === reusable)
|
|
111467
111479
|
return;
|
|
111468
|
-
const result = index > 0 ?
|
|
111480
|
+
const result = index > 0 ? array2.slice(0, index - 1) : [];
|
|
111469
111481
|
result.push(reusable);
|
|
111470
|
-
for (let i = index + 1;i <
|
|
111471
|
-
result.push(toReusableDiagnosticMessageChain(
|
|
111482
|
+
for (let i = index + 1;i < array2.length; i++) {
|
|
111483
|
+
result.push(toReusableDiagnosticMessageChain(array2[i]));
|
|
111472
111484
|
}
|
|
111473
111485
|
return result;
|
|
111474
|
-
}) ||
|
|
111486
|
+
}) || array2;
|
|
111475
111487
|
}
|
|
111476
111488
|
function toChangeFileSet() {
|
|
111477
111489
|
let changeFileSet;
|
|
@@ -119495,11 +119507,11 @@ ${lanes.join(`
|
|
|
119495
119507
|
function getDocumentSpansEqualityComparer(useCaseSensitiveFileNames2) {
|
|
119496
119508
|
return (a, b) => documentSpansEqual(a, b, useCaseSensitiveFileNames2);
|
|
119497
119509
|
}
|
|
119498
|
-
function forEachUnique(
|
|
119499
|
-
if (
|
|
119500
|
-
for (let i = 0;i <
|
|
119501
|
-
if (
|
|
119502
|
-
const result = callback(
|
|
119510
|
+
function forEachUnique(array2, callback) {
|
|
119511
|
+
if (array2) {
|
|
119512
|
+
for (let i = 0;i < array2.length; i++) {
|
|
119513
|
+
if (array2.indexOf(array2[i]) === i) {
|
|
119514
|
+
const result = callback(array2[i], i);
|
|
119503
119515
|
if (result) {
|
|
119504
119516
|
return result;
|
|
119505
119517
|
}
|
|
@@ -131402,10 +131414,10 @@ ${newComment.split(`
|
|
|
131402
131414
|
return;
|
|
131403
131415
|
}
|
|
131404
131416
|
function getSymbolAtLocationForQuickInfo(node, checker) {
|
|
131405
|
-
const
|
|
131406
|
-
if (
|
|
131407
|
-
const contextualType = checker.getContextualType(
|
|
131408
|
-
const properties = contextualType && getPropertySymbolsFromContextualType(
|
|
131417
|
+
const object2 = getContainingObjectLiteralElement(node);
|
|
131418
|
+
if (object2) {
|
|
131419
|
+
const contextualType = checker.getContextualType(object2.parent);
|
|
131420
|
+
const properties = contextualType && getPropertySymbolsFromContextualType(object2, checker, contextualType, false);
|
|
131409
131421
|
if (properties && properties.length === 1) {
|
|
131410
131422
|
return first(properties);
|
|
131411
131423
|
}
|
|
@@ -134134,8 +134146,8 @@ ${newComment.split(`
|
|
|
134134
134146
|
}
|
|
134135
134147
|
return false;
|
|
134136
134148
|
}
|
|
134137
|
-
function tryChangeModuleExportsObject(
|
|
134138
|
-
const statements = mapAllOrFail(
|
|
134149
|
+
function tryChangeModuleExportsObject(object2, useSitesToUnqualify) {
|
|
134150
|
+
const statements = mapAllOrFail(object2.properties, (prop) => {
|
|
134139
134151
|
switch (prop.kind) {
|
|
134140
134152
|
case 178:
|
|
134141
134153
|
case 179:
|
|
@@ -136957,11 +136969,11 @@ ${newComment.split(`
|
|
|
136957
136969
|
if (call === undefined) {
|
|
136958
136970
|
return;
|
|
136959
136971
|
}
|
|
136960
|
-
const
|
|
136972
|
+
const methodName2 = token.text;
|
|
136961
136973
|
const addMethodDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addMethodDeclaration(context, t, call, token, modifierFlags2, parentDeclaration, declSourceFile));
|
|
136962
|
-
const actions2 = [createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 256), [modifierFlags & 256 ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0,
|
|
136974
|
+
const actions2 = [createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 256), [modifierFlags & 256 ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0, methodName2], fixMissingMember, Diagnostics.Add_all_missing_members)];
|
|
136963
136975
|
if (modifierFlags & 2) {
|
|
136964
|
-
actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(2), [Diagnostics.Declare_private_method_0,
|
|
136976
|
+
actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(2), [Diagnostics.Declare_private_method_0, methodName2]));
|
|
136965
136977
|
}
|
|
136966
136978
|
return actions2;
|
|
136967
136979
|
}
|
|
@@ -145350,8 +145362,8 @@ ${newComment.split(`
|
|
|
145350
145362
|
return node;
|
|
145351
145363
|
}
|
|
145352
145364
|
}
|
|
145353
|
-
function getAlreadyUsedTypesInStringLiteralUnion(
|
|
145354
|
-
return mapDefined(
|
|
145365
|
+
function getAlreadyUsedTypesInStringLiteralUnion(union2, current) {
|
|
145366
|
+
return mapDefined(union2.types, (type) => type !== current && isLiteralTypeNode(type) && isStringLiteral(type.literal) ? type.literal.text : undefined);
|
|
145355
145367
|
}
|
|
145356
145368
|
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
|
|
145357
145369
|
let isNewIdentifier = false;
|
|
@@ -168733,6 +168745,542 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
168733
168745
|
} });
|
|
168734
168746
|
});
|
|
168735
168747
|
|
|
168748
|
+
// src/scripts-runtime/credential-broker/types.ts
|
|
168749
|
+
init_zod();
|
|
168750
|
+
var CREDENTIAL_BINDINGS_CONFIG_KEY = "SCRIPT_CREDENTIAL_BINDINGS";
|
|
168751
|
+
var REDACTED_PLACEHOLDER_PREFIX = "[REDACTED:";
|
|
168752
|
+
var CredentialBindingScopeSchema = _enum(["global", "agent", "repo"]);
|
|
168753
|
+
var CredentialBindingSchema = object({
|
|
168754
|
+
configKey: string().min(1).max(255),
|
|
168755
|
+
allowedHosts: array(string().min(1)).min(1),
|
|
168756
|
+
headerTemplate: string().min(1).optional(),
|
|
168757
|
+
queryTemplate: string().min(1).optional(),
|
|
168758
|
+
scope: CredentialBindingScopeSchema.default("global"),
|
|
168759
|
+
scopeId: string().nullable().optional(),
|
|
168760
|
+
active: boolean().default(true)
|
|
168761
|
+
}).refine((binding) => binding.headerTemplate || binding.queryTemplate, {
|
|
168762
|
+
message: "At least one of headerTemplate or queryTemplate is required."
|
|
168763
|
+
});
|
|
168764
|
+
var CredentialBindingsDocumentSchema = union([
|
|
168765
|
+
array(CredentialBindingSchema),
|
|
168766
|
+
object({ bindings: array(CredentialBindingSchema) })
|
|
168767
|
+
]);
|
|
168768
|
+
function placeholderForConfigKey(configKey) {
|
|
168769
|
+
return `${REDACTED_PLACEHOLDER_PREFIX}${configKey}]`;
|
|
168770
|
+
}
|
|
168771
|
+
function normalizeCredentialBindingsDocument(input) {
|
|
168772
|
+
const parsed = CredentialBindingsDocumentSchema.parse(input);
|
|
168773
|
+
return Array.isArray(parsed) ? parsed : parsed.bindings;
|
|
168774
|
+
}
|
|
168775
|
+
|
|
168776
|
+
// src/scripts-runtime/credential-broker/broker.ts
|
|
168777
|
+
function bindingHasPlaceholder(binding) {
|
|
168778
|
+
const placeholder = placeholderForConfigKey(binding.configKey);
|
|
168779
|
+
return binding.headerTemplate?.includes(placeholder) === true || binding.queryTemplate?.includes(placeholder) === true;
|
|
168780
|
+
}
|
|
168781
|
+
|
|
168782
|
+
class CredentialBroker {
|
|
168783
|
+
store;
|
|
168784
|
+
resolveCredential;
|
|
168785
|
+
defaults;
|
|
168786
|
+
constructor(store, resolveCredential, defaults = []) {
|
|
168787
|
+
this.store = store;
|
|
168788
|
+
this.resolveCredential = resolveCredential;
|
|
168789
|
+
this.defaults = defaults;
|
|
168790
|
+
}
|
|
168791
|
+
resolveBindings(context) {
|
|
168792
|
+
const merged = [...this.defaults, ...this.store.listActiveBindings(context)];
|
|
168793
|
+
const resolved = [];
|
|
168794
|
+
const seen = new Set;
|
|
168795
|
+
for (const binding of merged) {
|
|
168796
|
+
if (binding.active === false)
|
|
168797
|
+
continue;
|
|
168798
|
+
if (!bindingHasPlaceholder(binding))
|
|
168799
|
+
continue;
|
|
168800
|
+
const value = this.resolveCredential(binding.configKey);
|
|
168801
|
+
if (!value)
|
|
168802
|
+
continue;
|
|
168803
|
+
const dedupeKey = [
|
|
168804
|
+
binding.configKey,
|
|
168805
|
+
[...binding.allowedHosts].sort().join(","),
|
|
168806
|
+
binding.headerTemplate ?? "",
|
|
168807
|
+
binding.queryTemplate ?? "",
|
|
168808
|
+
binding.scope,
|
|
168809
|
+
binding.scopeId ?? ""
|
|
168810
|
+
].join("\x00");
|
|
168811
|
+
if (seen.has(dedupeKey))
|
|
168812
|
+
continue;
|
|
168813
|
+
seen.add(dedupeKey);
|
|
168814
|
+
resolved.push({
|
|
168815
|
+
...binding,
|
|
168816
|
+
placeholder: placeholderForConfigKey(binding.configKey),
|
|
168817
|
+
value
|
|
168818
|
+
});
|
|
168819
|
+
}
|
|
168820
|
+
return resolved;
|
|
168821
|
+
}
|
|
168822
|
+
}
|
|
168823
|
+
// src/scripts-runtime/credential-broker/default-bindings.ts
|
|
168824
|
+
var DEFAULT_CREDENTIAL_BINDINGS = [
|
|
168825
|
+
{
|
|
168826
|
+
configKey: "GITHUB_TOKEN",
|
|
168827
|
+
allowedHosts: ["api.github.com"],
|
|
168828
|
+
headerTemplate: "Authorization: Bearer [REDACTED:GITHUB_TOKEN]",
|
|
168829
|
+
scope: "global",
|
|
168830
|
+
scopeId: null,
|
|
168831
|
+
active: true
|
|
168832
|
+
}
|
|
168833
|
+
];
|
|
168834
|
+
// src/scripts-runtime/credential-broker/store.ts
|
|
168835
|
+
function appliesToContext(binding, context) {
|
|
168836
|
+
if (binding.scope === "global")
|
|
168837
|
+
return true;
|
|
168838
|
+
if (binding.scope === "agent")
|
|
168839
|
+
return Boolean(context.agentId && binding.scopeId === context.agentId);
|
|
168840
|
+
if (binding.scope === "repo")
|
|
168841
|
+
return Boolean(context.repoId && binding.scopeId === context.repoId);
|
|
168842
|
+
return false;
|
|
168843
|
+
}
|
|
168844
|
+
function parseBindingsFromConfig(config) {
|
|
168845
|
+
let raw;
|
|
168846
|
+
try {
|
|
168847
|
+
raw = JSON.parse(config.value);
|
|
168848
|
+
} catch {
|
|
168849
|
+
return [];
|
|
168850
|
+
}
|
|
168851
|
+
try {
|
|
168852
|
+
const rawBindings = Array.isArray(raw) ? raw : raw && typeof raw === "object" && Array.isArray(raw.bindings) ? raw.bindings : [];
|
|
168853
|
+
return normalizeCredentialBindingsDocument(raw).map((binding, index) => {
|
|
168854
|
+
const rawBinding = rawBindings[index];
|
|
168855
|
+
const bindingProvidedScope = rawBinding !== null && typeof rawBinding === "object" && Object.hasOwn(rawBinding, "scope");
|
|
168856
|
+
return {
|
|
168857
|
+
...binding,
|
|
168858
|
+
scope: bindingProvidedScope ? binding.scope : config.scope,
|
|
168859
|
+
scopeId: binding.scopeId ?? config.scopeId ?? null
|
|
168860
|
+
};
|
|
168861
|
+
});
|
|
168862
|
+
} catch {
|
|
168863
|
+
return [];
|
|
168864
|
+
}
|
|
168865
|
+
}
|
|
168866
|
+
function bindingHasPlaceholder2(binding) {
|
|
168867
|
+
const placeholder = placeholderForConfigKey(binding.configKey);
|
|
168868
|
+
return binding.headerTemplate?.includes(placeholder) === true || binding.queryTemplate?.includes(placeholder) === true;
|
|
168869
|
+
}
|
|
168870
|
+
|
|
168871
|
+
class SwarmConfigCredentialBindingStore {
|
|
168872
|
+
readConfigs;
|
|
168873
|
+
constructor(readConfigs) {
|
|
168874
|
+
this.readConfigs = readConfigs;
|
|
168875
|
+
}
|
|
168876
|
+
listActiveBindings(context) {
|
|
168877
|
+
const rows = this.readConfigs({ key: CREDENTIAL_BINDINGS_CONFIG_KEY });
|
|
168878
|
+
return rows.flatMap(parseBindingsFromConfig).filter((binding) => binding.active !== false).filter((binding) => appliesToContext(binding, context)).filter(bindingHasPlaceholder2);
|
|
168879
|
+
}
|
|
168880
|
+
}
|
|
168881
|
+
// src/be/script-connections.ts
|
|
168882
|
+
init_db();
|
|
168883
|
+
function parseJsonArray(value) {
|
|
168884
|
+
try {
|
|
168885
|
+
const parsed = JSON.parse(value);
|
|
168886
|
+
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
|
|
168887
|
+
} catch {
|
|
168888
|
+
return [];
|
|
168889
|
+
}
|
|
168890
|
+
}
|
|
168891
|
+
function bindingFromRow(row) {
|
|
168892
|
+
return {
|
|
168893
|
+
id: row.id,
|
|
168894
|
+
configKey: row.config_key,
|
|
168895
|
+
allowedHosts: parseJsonArray(row.allowed_hosts_json),
|
|
168896
|
+
headerTemplate: row.header_template ?? undefined,
|
|
168897
|
+
queryTemplate: row.query_template ?? undefined,
|
|
168898
|
+
scope: row.scope,
|
|
168899
|
+
scopeId: row.scope_id,
|
|
168900
|
+
active: row.active === 1,
|
|
168901
|
+
source: row.source,
|
|
168902
|
+
createdAt: row.created_at,
|
|
168903
|
+
updatedAt: row.updated_at,
|
|
168904
|
+
createdBy: row.created_by,
|
|
168905
|
+
updatedBy: row.updated_by
|
|
168906
|
+
};
|
|
168907
|
+
}
|
|
168908
|
+
function connectionFromRow(row) {
|
|
168909
|
+
return {
|
|
168910
|
+
id: row.id,
|
|
168911
|
+
slug: row.slug,
|
|
168912
|
+
displayName: row.display_name,
|
|
168913
|
+
kind: row.kind,
|
|
168914
|
+
scope: row.scope,
|
|
168915
|
+
scopeId: row.scope_id,
|
|
168916
|
+
baseUrl: row.base_url,
|
|
168917
|
+
allowedHosts: parseJsonArray(row.allowed_hosts_json),
|
|
168918
|
+
credentialBindingId: row.credential_binding_id,
|
|
168919
|
+
openapiSpecSourceKind: row.openapi_spec_source_kind,
|
|
168920
|
+
openapiSpecSource: row.openapi_spec_source,
|
|
168921
|
+
openapiSpecJson: row.openapi_spec_json,
|
|
168922
|
+
openapiSpecEtag: row.openapi_spec_etag,
|
|
168923
|
+
openapiSpecFetchedAt: row.openapi_spec_fetched_at,
|
|
168924
|
+
mcpServerId: row.mcp_server_id,
|
|
168925
|
+
generatedTypes: row.generated_types,
|
|
168926
|
+
generatedRuntimeJson: row.generated_runtime_json,
|
|
168927
|
+
generatedAt: row.generated_at,
|
|
168928
|
+
generationError: row.generation_error,
|
|
168929
|
+
enabled: row.enabled === 1,
|
|
168930
|
+
version: row.version,
|
|
168931
|
+
createdAt: row.created_at,
|
|
168932
|
+
updatedAt: row.updated_at,
|
|
168933
|
+
createdBy: row.created_by,
|
|
168934
|
+
updatedBy: row.updated_by
|
|
168935
|
+
};
|
|
168936
|
+
}
|
|
168937
|
+
function applies(scope, scopeId, context) {
|
|
168938
|
+
if (scope === "global")
|
|
168939
|
+
return true;
|
|
168940
|
+
if (scope === "agent")
|
|
168941
|
+
return Boolean(context.agentId && scopeId === context.agentId);
|
|
168942
|
+
return Boolean(context.repoId && scopeId === context.repoId);
|
|
168943
|
+
}
|
|
168944
|
+
function normalizeSlug(slug) {
|
|
168945
|
+
const cleaned = slug.trim().replace(/[^A-Za-z0-9]+(.)/g, (_m, chr) => chr.toUpperCase()).replace(/^[^A-Za-z_]+/, "").replace(/[^A-Za-z0-9_]/g, "");
|
|
168946
|
+
if (!cleaned)
|
|
168947
|
+
throw new Error("slug must contain at least one letter");
|
|
168948
|
+
return `${cleaned[0]?.toLowerCase()}${cleaned.slice(1)}`;
|
|
168949
|
+
}
|
|
168950
|
+
function pascal(name) {
|
|
168951
|
+
const camel = normalizeSlug(name);
|
|
168952
|
+
return `${camel[0]?.toUpperCase()}${camel.slice(1)}`;
|
|
168953
|
+
}
|
|
168954
|
+
function listRelationalCredentialBindings(context) {
|
|
168955
|
+
const rows = getDb().prepare("SELECT * FROM script_credential_bindings ORDER BY config_key ASC").all();
|
|
168956
|
+
return rows.map(bindingFromRow).filter((binding) => context?.includeInactive || binding.active !== false).filter((binding) => !context || applies(binding.scope, binding.scopeId ?? null, context));
|
|
168957
|
+
}
|
|
168958
|
+
function getCredentialBindingById(id) {
|
|
168959
|
+
const row = getDb().prepare("SELECT * FROM script_credential_bindings WHERE id = ?").get(id);
|
|
168960
|
+
return row ? bindingFromRow(row) : null;
|
|
168961
|
+
}
|
|
168962
|
+
function findCredentialBindingByIdentity(data) {
|
|
168963
|
+
const row = getDb().prepare(`SELECT * FROM script_credential_bindings
|
|
168964
|
+
WHERE config_key = ?
|
|
168965
|
+
AND scope = ?
|
|
168966
|
+
AND COALESCE(scope_id, '') = ?
|
|
168967
|
+
AND COALESCE(header_template, '') = ?
|
|
168968
|
+
AND COALESCE(query_template, '') = ?`).get(data.configKey, data.scope, data.scopeId ?? "", data.headerTemplate ?? "", data.queryTemplate ?? "");
|
|
168969
|
+
return row ? bindingFromRow(row) : null;
|
|
168970
|
+
}
|
|
168971
|
+
function upsertCredentialBinding(data) {
|
|
168972
|
+
const now = new Date().toISOString();
|
|
168973
|
+
const id = data.id ?? crypto.randomUUID();
|
|
168974
|
+
const scope = data.scope ?? "global";
|
|
168975
|
+
const scopeId = scope === "global" ? null : data.scopeId ?? null;
|
|
168976
|
+
const active = data.active === false ? 0 : 1;
|
|
168977
|
+
const source = data.source ?? "user";
|
|
168978
|
+
const existing = (data.id ? getCredentialBindingById(data.id) : null) ?? findCredentialBindingByIdentity({
|
|
168979
|
+
configKey: data.configKey,
|
|
168980
|
+
scope,
|
|
168981
|
+
scopeId,
|
|
168982
|
+
headerTemplate: data.headerTemplate,
|
|
168983
|
+
queryTemplate: data.queryTemplate
|
|
168984
|
+
});
|
|
168985
|
+
if (existing) {
|
|
168986
|
+
const targetId = existing.id;
|
|
168987
|
+
const row2 = getDb().prepare(`UPDATE script_credential_bindings
|
|
168988
|
+
SET config_key = ?, allowed_hosts_json = ?, header_template = ?, query_template = ?,
|
|
168989
|
+
scope = ?, scope_id = ?, active = ?, source = ?, updated_by = ?, updated_at = ?
|
|
168990
|
+
WHERE id = ? RETURNING *`).get(data.configKey, JSON.stringify(data.allowedHosts), data.headerTemplate ?? null, data.queryTemplate ?? null, scope, scopeId, active, source, data.userId ?? null, now, targetId);
|
|
168991
|
+
if (!row2)
|
|
168992
|
+
throw new Error("Failed to update credential binding");
|
|
168993
|
+
return bindingFromRow(row2);
|
|
168994
|
+
}
|
|
168995
|
+
const row = getDb().prepare(`INSERT INTO script_credential_bindings
|
|
168996
|
+
(id, config_key, allowed_hosts_json, header_template, query_template, scope, scope_id,
|
|
168997
|
+
active, source, created_at, updated_at, created_by, updated_by)
|
|
168998
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, data.configKey, JSON.stringify(data.allowedHosts), data.headerTemplate ?? null, data.queryTemplate ?? null, scope, scopeId, active, source, now, now, data.userId ?? null, data.userId ?? null);
|
|
168999
|
+
if (!row)
|
|
169000
|
+
throw new Error("Failed to create credential binding");
|
|
169001
|
+
return bindingFromRow(row);
|
|
169002
|
+
}
|
|
169003
|
+
function disableCredentialBinding(id, userId) {
|
|
169004
|
+
const row = getDb().prepare(`UPDATE script_credential_bindings SET active = 0, updated_at = ?, updated_by = ? WHERE id = ? RETURNING *`).get(new Date().toISOString(), userId ?? null, id);
|
|
169005
|
+
return row ? bindingFromRow(row) : null;
|
|
169006
|
+
}
|
|
169007
|
+
function importLegacyCredentialBindings(userId) {
|
|
169008
|
+
let imported = 0;
|
|
169009
|
+
for (const config of getSwarmConfigs({ key: CREDENTIAL_BINDINGS_CONFIG_KEY })) {
|
|
169010
|
+
let bindings;
|
|
169011
|
+
try {
|
|
169012
|
+
bindings = normalizeCredentialBindingsDocument(JSON.parse(config.value));
|
|
169013
|
+
} catch {
|
|
169014
|
+
continue;
|
|
169015
|
+
}
|
|
169016
|
+
for (const binding of bindings) {
|
|
169017
|
+
const scope = binding.scope ?? config.scope;
|
|
169018
|
+
upsertCredentialBinding({
|
|
169019
|
+
configKey: binding.configKey,
|
|
169020
|
+
allowedHosts: binding.allowedHosts,
|
|
169021
|
+
headerTemplate: binding.headerTemplate,
|
|
169022
|
+
queryTemplate: binding.queryTemplate,
|
|
169023
|
+
scope,
|
|
169024
|
+
scopeId: binding.scopeId ?? config.scopeId ?? null,
|
|
169025
|
+
active: binding.active !== false,
|
|
169026
|
+
source: "migration",
|
|
169027
|
+
userId
|
|
169028
|
+
});
|
|
169029
|
+
imported += 1;
|
|
169030
|
+
}
|
|
169031
|
+
}
|
|
169032
|
+
return imported;
|
|
169033
|
+
}
|
|
169034
|
+
function listScriptConnections(context) {
|
|
169035
|
+
const rows = getDb().prepare("SELECT * FROM script_connections ORDER BY slug ASC").all();
|
|
169036
|
+
return rows.map(connectionFromRow).filter((connection) => !context?.kind || connection.kind === context.kind).filter((connection) => context?.includeDisabled || connection.enabled).filter((connection) => !context || applies(connection.scope, connection.scopeId, context));
|
|
169037
|
+
}
|
|
169038
|
+
function schemaToTs(schema) {
|
|
169039
|
+
if (!schema || typeof schema !== "object")
|
|
169040
|
+
return "JsonValue";
|
|
169041
|
+
const s = schema;
|
|
169042
|
+
if (typeof s.$ref === "string")
|
|
169043
|
+
return "JsonValue";
|
|
169044
|
+
if (Array.isArray(s.enum))
|
|
169045
|
+
return s.enum.map((v) => JSON.stringify(v)).join(" | ") || "JsonValue";
|
|
169046
|
+
const type = s.type;
|
|
169047
|
+
if (type === "string")
|
|
169048
|
+
return "string";
|
|
169049
|
+
if (type === "integer" || type === "number")
|
|
169050
|
+
return "number";
|
|
169051
|
+
if (type === "boolean")
|
|
169052
|
+
return "boolean";
|
|
169053
|
+
if (type === "array")
|
|
169054
|
+
return `${schemaToTs(s.items)}[]`;
|
|
169055
|
+
if (type === "object" || s.properties) {
|
|
169056
|
+
const required = new Set(Array.isArray(s.required) ? s.required.filter((v) => typeof v === "string") : []);
|
|
169057
|
+
const props = s.properties && typeof s.properties === "object" ? s.properties : {};
|
|
169058
|
+
const entries = Object.entries(props);
|
|
169059
|
+
if (entries.length === 0)
|
|
169060
|
+
return "{ [key: string]: JsonValue }";
|
|
169061
|
+
return `{ ${entries.map(([key, value]) => `${JSON.stringify(key)}${required.has(key) ? "" : "?"}: ${schemaToTs(value)}`).join("; ")} }`;
|
|
169062
|
+
}
|
|
169063
|
+
return "JsonValue";
|
|
169064
|
+
}
|
|
169065
|
+
function toJsonValue(value) {
|
|
169066
|
+
if (value === null)
|
|
169067
|
+
return null;
|
|
169068
|
+
if (["boolean", "number", "string"].includes(typeof value))
|
|
169069
|
+
return value;
|
|
169070
|
+
if (Array.isArray(value)) {
|
|
169071
|
+
return value.map((item) => toJsonValue(item)).filter((item) => item !== undefined);
|
|
169072
|
+
}
|
|
169073
|
+
if (value && typeof value === "object") {
|
|
169074
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, toJsonValue(item)]).filter((entry) => entry[1] !== undefined));
|
|
169075
|
+
}
|
|
169076
|
+
return;
|
|
169077
|
+
}
|
|
169078
|
+
function jsonSchema(schema) {
|
|
169079
|
+
if (typeof schema === "boolean")
|
|
169080
|
+
return schema;
|
|
169081
|
+
const value = toJsonValue(schema);
|
|
169082
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
169083
|
+
}
|
|
169084
|
+
function methodName(operationId, method, path) {
|
|
169085
|
+
if (operationId)
|
|
169086
|
+
return normalizeSlug(operationId);
|
|
169087
|
+
return normalizeSlug(`${method}_${path.replace(/[{}]/g, "").replace(/\//g, "_")}`);
|
|
169088
|
+
}
|
|
169089
|
+
function extractOperations(spec, slug) {
|
|
169090
|
+
if (!spec || typeof spec !== "object")
|
|
169091
|
+
throw new Error("OpenAPI spec must be an object");
|
|
169092
|
+
const root = spec;
|
|
169093
|
+
const paths = root.paths;
|
|
169094
|
+
if (!paths || typeof paths !== "object")
|
|
169095
|
+
throw new Error("OpenAPI spec must contain paths");
|
|
169096
|
+
const operations = [];
|
|
169097
|
+
const typeBlocks = [];
|
|
169098
|
+
const verbs = new Set(["get", "post", "put", "patch", "delete"]);
|
|
169099
|
+
for (const [path, pathItem] of Object.entries(paths)) {
|
|
169100
|
+
if (!pathItem || typeof pathItem !== "object")
|
|
169101
|
+
continue;
|
|
169102
|
+
const inheritedParams = Array.isArray(pathItem.parameters) ? pathItem.parameters : [];
|
|
169103
|
+
for (const [method, op] of Object.entries(pathItem)) {
|
|
169104
|
+
if (!verbs.has(method) || !op || typeof op !== "object")
|
|
169105
|
+
continue;
|
|
169106
|
+
const operation = op;
|
|
169107
|
+
const name = methodName(typeof operation.operationId === "string" ? operation.operationId : undefined, method, path);
|
|
169108
|
+
const typeBase = `${pascal(slug)}${pascal(name)}`;
|
|
169109
|
+
const parameters = [
|
|
169110
|
+
...inheritedParams,
|
|
169111
|
+
...Array.isArray(operation.parameters) ? operation.parameters : []
|
|
169112
|
+
].filter((param) => Boolean(param && typeof param === "object" && typeof param.name === "string")).map((param) => ({
|
|
169113
|
+
name: String(param.name),
|
|
169114
|
+
in: ["path", "query", "header"].includes(String(param.in)) ? String(param.in) : "query",
|
|
169115
|
+
required: param.required === true,
|
|
169116
|
+
type: schemaToTs(param.schema),
|
|
169117
|
+
schema: jsonSchema(param.schema)
|
|
169118
|
+
}));
|
|
169119
|
+
const requestBody = operation.requestBody && typeof operation.requestBody === "object" ? operation.requestBody : null;
|
|
169120
|
+
const jsonContent = requestBody && typeof requestBody.content === "object" ? requestBody.content["application/json"] : undefined;
|
|
169121
|
+
const requestBodySchema = jsonContent?.schema ? jsonSchema(jsonContent.schema) : undefined;
|
|
169122
|
+
const bodyType = jsonContent?.schema ? schemaToTs(jsonContent.schema) : "JsonValue";
|
|
169123
|
+
const responses = operation.responses && typeof operation.responses === "object" ? operation.responses : {};
|
|
169124
|
+
const successStatus = Object.keys(responses).find((status) => /^2\d\d$/.test(status)) ?? "default";
|
|
169125
|
+
const response = responses[successStatus];
|
|
169126
|
+
const responseContent = response && typeof response === "object" && typeof response.content === "object" ? response.content["application/json"] : undefined;
|
|
169127
|
+
const responseType = responseContent?.schema ? schemaToTs(responseContent.schema) : "JsonValue";
|
|
169128
|
+
const responseSchema = responseContent?.schema ? jsonSchema(responseContent.schema) : {};
|
|
169129
|
+
const paramsByPlace = (place) => parameters.filter((param) => param.in === place).map((param) => `${JSON.stringify(param.name)}${param.required ? "" : "?"}: ${param.type}`).join("; ");
|
|
169130
|
+
const hasBody = Boolean(jsonContent?.schema || requestBody);
|
|
169131
|
+
const requestType = `export type ${typeBase}Args = {${paramsByPlace("path") ? ` path: { ${paramsByPlace("path")} };` : ""}${paramsByPlace("query") ? ` query?: { ${paramsByPlace("query")} };` : ""}${paramsByPlace("header") ? ` header?: { ${paramsByPlace("header")} };` : ""}${hasBody ? ` body: ${bodyType};` : ""}};`;
|
|
169132
|
+
const responseDecl = `export type ${typeBase}Response = ${responseType};`;
|
|
169133
|
+
typeBlocks.push(requestType, responseDecl);
|
|
169134
|
+
operations.push({
|
|
169135
|
+
name,
|
|
169136
|
+
method: method.toUpperCase(),
|
|
169137
|
+
path,
|
|
169138
|
+
parameters: parameters.map(({ name: name2, in: where, required, schema }) => ({
|
|
169139
|
+
name: name2,
|
|
169140
|
+
in: where,
|
|
169141
|
+
required,
|
|
169142
|
+
schema
|
|
169143
|
+
})),
|
|
169144
|
+
hasBody,
|
|
169145
|
+
successStatus,
|
|
169146
|
+
requestBodySchema,
|
|
169147
|
+
responseSchema,
|
|
169148
|
+
requestType: `${typeBase}Args`,
|
|
169149
|
+
responseType: `${typeBase}Response`
|
|
169150
|
+
});
|
|
169151
|
+
}
|
|
169152
|
+
}
|
|
169153
|
+
if (operations.length === 0)
|
|
169154
|
+
throw new Error("OpenAPI spec did not contain supported operations");
|
|
169155
|
+
return { operations, types: typeBlocks.join(`
|
|
169156
|
+
`) };
|
|
169157
|
+
}
|
|
169158
|
+
function buildGeneratedArtifacts(input) {
|
|
169159
|
+
const slug = normalizeSlug(input.slug);
|
|
169160
|
+
const { operations, types } = extractOperations(input.openapiSpec, slug);
|
|
169161
|
+
const credential = input.credentialBinding ? {
|
|
169162
|
+
configKey: input.credentialBinding.configKey,
|
|
169163
|
+
headerTemplate: input.credentialBinding.headerTemplate,
|
|
169164
|
+
queryTemplate: input.credentialBinding.queryTemplate
|
|
169165
|
+
} : null;
|
|
169166
|
+
const descriptor = {
|
|
169167
|
+
slug,
|
|
169168
|
+
baseUrl: input.baseUrl,
|
|
169169
|
+
credential,
|
|
169170
|
+
operations
|
|
169171
|
+
};
|
|
169172
|
+
const generatedTypes = [
|
|
169173
|
+
types,
|
|
169174
|
+
`export interface ${pascal(slug)}Api {`,
|
|
169175
|
+
...operations.map((operation) => ` ${operation.name}(args: ${operation.requestType}): Promise<${operation.responseType}>;`),
|
|
169176
|
+
"}"
|
|
169177
|
+
].join(`
|
|
169178
|
+
`);
|
|
169179
|
+
return { generatedTypes, generatedRuntimeJson: JSON.stringify(descriptor) };
|
|
169180
|
+
}
|
|
169181
|
+
function upsertScriptConnection(data) {
|
|
169182
|
+
const now = new Date().toISOString();
|
|
169183
|
+
const id = data.id ?? crypto.randomUUID();
|
|
169184
|
+
const scope = data.scope ?? "global";
|
|
169185
|
+
const scopeId = scope === "global" ? null : data.scopeId ?? null;
|
|
169186
|
+
let generatedTypes = null;
|
|
169187
|
+
let generatedRuntimeJson = null;
|
|
169188
|
+
let generationError = null;
|
|
169189
|
+
let generatedAt = null;
|
|
169190
|
+
if (data.kind === "openapi") {
|
|
169191
|
+
try {
|
|
169192
|
+
const spec = JSON.parse(data.openapiSpecJson ?? "{}");
|
|
169193
|
+
const binding = data.credentialBindingId ? getCredentialBindingById(data.credentialBindingId) : null;
|
|
169194
|
+
const artifacts = buildGeneratedArtifacts({
|
|
169195
|
+
slug: data.slug,
|
|
169196
|
+
baseUrl: data.baseUrl ?? "",
|
|
169197
|
+
credentialBinding: binding,
|
|
169198
|
+
openapiSpec: spec
|
|
169199
|
+
});
|
|
169200
|
+
generatedTypes = artifacts.generatedTypes;
|
|
169201
|
+
generatedRuntimeJson = artifacts.generatedRuntimeJson;
|
|
169202
|
+
generatedAt = now;
|
|
169203
|
+
} catch (err) {
|
|
169204
|
+
generationError = err instanceof Error ? err.message : String(err);
|
|
169205
|
+
}
|
|
169206
|
+
}
|
|
169207
|
+
const existing = data.id ? getDb().prepare("SELECT id, version FROM script_connections WHERE id = ?").get(data.id) : getDb().prepare("SELECT id, version FROM script_connections WHERE slug = ? AND scope = ? AND COALESCE(scope_id, '') = COALESCE(?, '')").get(normalizeSlug(data.slug), scope, scopeId);
|
|
169208
|
+
const params = [
|
|
169209
|
+
normalizeSlug(data.slug),
|
|
169210
|
+
data.displayName ?? null,
|
|
169211
|
+
data.kind,
|
|
169212
|
+
scope,
|
|
169213
|
+
scopeId,
|
|
169214
|
+
data.baseUrl ?? null,
|
|
169215
|
+
JSON.stringify(data.allowedHosts ?? []),
|
|
169216
|
+
data.credentialBindingId ?? null,
|
|
169217
|
+
data.openapiSpecSourceKind ?? (data.kind === "openapi" ? "inline" : null),
|
|
169218
|
+
data.openapiSpecSource ?? null,
|
|
169219
|
+
data.openapiSpecJson ?? null,
|
|
169220
|
+
data.mcpServerId ?? null,
|
|
169221
|
+
generatedTypes,
|
|
169222
|
+
generatedRuntimeJson,
|
|
169223
|
+
generatedAt,
|
|
169224
|
+
generationError,
|
|
169225
|
+
data.enabled === false ? 0 : 1
|
|
169226
|
+
];
|
|
169227
|
+
if (existing) {
|
|
169228
|
+
const row2 = getDb().prepare(`UPDATE script_connections SET
|
|
169229
|
+
slug = ?, display_name = ?, kind = ?, scope = ?, scope_id = ?, base_url = ?,
|
|
169230
|
+
allowed_hosts_json = ?, credential_binding_id = ?, openapi_spec_source_kind = ?,
|
|
169231
|
+
openapi_spec_source = ?, openapi_spec_json = ?, mcp_server_id = ?, generated_types = ?,
|
|
169232
|
+
generated_runtime_json = ?, generated_at = ?, generation_error = ?, enabled = ?,
|
|
169233
|
+
updated_at = ?, updated_by = ?, version = ?
|
|
169234
|
+
WHERE id = ? RETURNING *`).get(...params, now, data.userId ?? null, existing.version + 1, existing.id);
|
|
169235
|
+
if (!row2)
|
|
169236
|
+
throw new Error("Failed to update script connection");
|
|
169237
|
+
return connectionFromRow(row2);
|
|
169238
|
+
}
|
|
169239
|
+
const row = getDb().prepare(`INSERT INTO script_connections
|
|
169240
|
+
(id, slug, display_name, kind, scope, scope_id, base_url, allowed_hosts_json,
|
|
169241
|
+
credential_binding_id, openapi_spec_source_kind, openapi_spec_source, openapi_spec_json,
|
|
169242
|
+
mcp_server_id, generated_types, generated_runtime_json, generated_at, generation_error,
|
|
169243
|
+
enabled, created_at, updated_at, created_by, updated_by)
|
|
169244
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, ...params, now, now, data.userId ?? null, data.userId ?? null);
|
|
169245
|
+
if (!row)
|
|
169246
|
+
throw new Error("Failed to create script connection");
|
|
169247
|
+
return connectionFromRow(row);
|
|
169248
|
+
}
|
|
169249
|
+
function setScriptConnectionEnabled(id, enabled, userId) {
|
|
169250
|
+
const row = getDb().prepare(`UPDATE script_connections
|
|
169251
|
+
SET enabled = ?, updated_at = ?, updated_by = ?, version = version + 1
|
|
169252
|
+
WHERE id = ? RETURNING *`).get(enabled ? 1 : 0, new Date().toISOString(), userId ?? null, id);
|
|
169253
|
+
return row ? connectionFromRow(row) : null;
|
|
169254
|
+
}
|
|
169255
|
+
function getScriptApiConnectionDescriptors(context = {}) {
|
|
169256
|
+
return listScriptConnections({ ...context, kind: "openapi" }).map((connection) => {
|
|
169257
|
+
if (!connection.generatedRuntimeJson)
|
|
169258
|
+
return null;
|
|
169259
|
+
try {
|
|
169260
|
+
return JSON.parse(connection.generatedRuntimeJson);
|
|
169261
|
+
} catch {
|
|
169262
|
+
return null;
|
|
169263
|
+
}
|
|
169264
|
+
}).filter((descriptor) => Boolean(descriptor));
|
|
169265
|
+
}
|
|
169266
|
+
function getScriptApiTypes(context = {}) {
|
|
169267
|
+
const connections = listScriptConnections({ ...context, kind: "openapi" });
|
|
169268
|
+
const blocks = connections.filter((connection) => connection.generatedTypes).map((connection) => connection.generatedTypes);
|
|
169269
|
+
if (blocks.length === 0)
|
|
169270
|
+
return `export interface ScriptApiRegistry {}
|
|
169271
|
+
`;
|
|
169272
|
+
const members = connections.filter((connection) => connection.generatedTypes).map((connection) => ` ${connection.slug}: ${pascal(connection.slug)}Api;`);
|
|
169273
|
+
return `${blocks.join(`
|
|
169274
|
+
|
|
169275
|
+
`)}
|
|
169276
|
+
|
|
169277
|
+
export interface ScriptApiRegistry {
|
|
169278
|
+
${members.join(`
|
|
169279
|
+
`)}
|
|
169280
|
+
}
|
|
169281
|
+
`;
|
|
169282
|
+
}
|
|
169283
|
+
|
|
168736
169284
|
// src/be/scripts/db.ts
|
|
168737
169285
|
init_db();
|
|
168738
169286
|
function normalizeScopeId(scope, scopeId) {
|
|
@@ -168996,4 +169544,4 @@ function validateScriptImports(source) {
|
|
|
168996
169544
|
return { ok: false, diagnostic: reason, imports: rejected };
|
|
168997
169545
|
}
|
|
168998
169546
|
|
|
168999
|
-
export { upsertScriptByName, getScript, getScriptById, getScriptVersion, listScripts, listScriptVersions, deleteScript, require_typescript, validateScriptImports };
|
|
169547
|
+
export { CREDENTIAL_BINDINGS_CONFIG_KEY, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, SwarmConfigCredentialBindingStore, listRelationalCredentialBindings, upsertCredentialBinding, disableCredentialBinding, importLegacyCredentialBindings, listScriptConnections, upsertScriptConnection, setScriptConnectionEnabled, getScriptApiConnectionDescriptors, getScriptApiTypes, upsertScriptByName, getScript, getScriptById, getScriptVersion, listScripts, listScriptVersions, deleteScript, require_typescript, validateScriptImports };
|