proxylang 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +37 -1
- package/dist/index.d.ts +241 -147
- package/dist/index.js +7 -603
- package/dist/{host-Bea3np6i.js → profile-build-BLB8hvyw.js} +1963 -996
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { H as compile, U as explain, Z as StaticRuleSetUnknownError, a as surgeBuildFailure, i as runSurgeBuild, n as runBuild, nt as requestSchema, q as targetCatalog, s as buildToDirectory } from "./profile-build-BLB8hvyw.js";
|
|
3
3
|
import { open } from "node:fs/promises";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
@@ -15,6 +15,8 @@ const failure = (code) => {
|
|
|
15
15
|
return 1;
|
|
16
16
|
};
|
|
17
17
|
const usages = {
|
|
18
|
+
"profile-build": ["proxylang profile-build config.ts --out DIRECTORY [--validation]"],
|
|
19
|
+
"surge-build": ["proxylang surge-build config.ts --out DIRECTORY [--validation]"],
|
|
18
20
|
targets: ["proxylang targets"],
|
|
19
21
|
check: ["proxylang check config.ts"],
|
|
20
22
|
explain: ["proxylang explain config.ts --target ID --request JSON", "proxylang explain config.ts --target ID --request-file FILE"],
|
|
@@ -83,6 +85,7 @@ async function main(args) {
|
|
|
83
85
|
});
|
|
84
86
|
return 0;
|
|
85
87
|
}
|
|
88
|
+
if (command === "surge-build" || command === "profile-build") return surgeBuildCommand(file, rest, command === "profile-build");
|
|
86
89
|
if (![
|
|
87
90
|
"check",
|
|
88
91
|
"explain",
|
|
@@ -163,6 +166,39 @@ async function main(args) {
|
|
|
163
166
|
});
|
|
164
167
|
return built.exitCode;
|
|
165
168
|
}
|
|
169
|
+
async function surgeBuildCommand(file, args, portable) {
|
|
170
|
+
const invalid = () => {
|
|
171
|
+
print(surgeBuildFailure("INVALID_ARGUMENTS"));
|
|
172
|
+
return 1;
|
|
173
|
+
};
|
|
174
|
+
if (!file?.trim() || file.startsWith("-")) return invalid();
|
|
175
|
+
let output;
|
|
176
|
+
let validation = false;
|
|
177
|
+
for (let i = 0; i < args.length; i++) {
|
|
178
|
+
const arg = args[i];
|
|
179
|
+
if (arg === "--out" && output === void 0) {
|
|
180
|
+
const value = args[++i];
|
|
181
|
+
if (!value?.trim() || value.startsWith("-")) return invalid();
|
|
182
|
+
output = value;
|
|
183
|
+
} else if (arg === "--validation" && !validation) validation = true;
|
|
184
|
+
else if (arg === "--" && output !== void 0 && !validation && i === args.length - 2 && args[i + 1] === "--validation") {
|
|
185
|
+
validation = true;
|
|
186
|
+
i++;
|
|
187
|
+
} else return invalid();
|
|
188
|
+
}
|
|
189
|
+
if (output === void 0) return invalid();
|
|
190
|
+
let config;
|
|
191
|
+
try {
|
|
192
|
+
const loaded = await tsImport(pathToFileURL(resolve(file)).href, import.meta.url);
|
|
193
|
+
config = loaded.default?.__esModule === true ? loaded.default.default : loaded.default;
|
|
194
|
+
} catch {
|
|
195
|
+
print(surgeBuildFailure("PROFILE_DEFINITION_FAILED", validation));
|
|
196
|
+
return 1;
|
|
197
|
+
}
|
|
198
|
+
const result = portable ? await runBuild(config, output, { validation }) : await runSurgeBuild(config, output, { validation });
|
|
199
|
+
print(result);
|
|
200
|
+
return result.exitCode;
|
|
201
|
+
}
|
|
166
202
|
try {
|
|
167
203
|
process.exitCode = await main(process.argv.slice(2));
|
|
168
204
|
} catch (cause) {
|
package/dist/index.d.ts
CHANGED
|
@@ -494,6 +494,218 @@ export declare function compileSurgeProfile(input: unknown): SurgeProfileCompila
|
|
|
494
494
|
export declare function renderSurgeProfile(compilation: SurgeProfileCompilation, resolveSecret: (token: Secret) => string | undefined): SurgeProfileArtifact;
|
|
495
495
|
export declare function renderSurgeProfiles(compilations: readonly SurgeProfileCompilation[], resolveSecret: (token: Secret) => string | undefined): readonly SurgeProfileArtifact[];
|
|
496
496
|
//#endregion
|
|
497
|
+
//#region src/targets.d.ts
|
|
498
|
+
export declare const targetCatalog: readonly [{
|
|
499
|
+
readonly engine: "sing-box";
|
|
500
|
+
readonly version: "1.11.0";
|
|
501
|
+
readonly autoGroup: "urltest";
|
|
502
|
+
readonly platforms: readonly ["linux", "macos"];
|
|
503
|
+
readonly protocols: readonly ["trojan", "http", "shadowsocks", "vmess", "vless"];
|
|
504
|
+
readonly endpoints: readonly [];
|
|
505
|
+
readonly groups: readonly ["select", "urltest"];
|
|
506
|
+
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
507
|
+
readonly dns: "legacy";
|
|
508
|
+
}, {
|
|
509
|
+
readonly engine: "sing-box";
|
|
510
|
+
readonly version: "1.12.0";
|
|
511
|
+
readonly autoGroup: "urltest";
|
|
512
|
+
readonly platforms: readonly ["linux", "macos"];
|
|
513
|
+
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
514
|
+
readonly endpoints: readonly ["sing-box-tailscale"];
|
|
515
|
+
readonly groups: readonly ["select", "urltest"];
|
|
516
|
+
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
517
|
+
readonly dns: "typed";
|
|
518
|
+
}, {
|
|
519
|
+
readonly engine: "surge";
|
|
520
|
+
readonly version: "6.10.0";
|
|
521
|
+
readonly autoGroup: "surge-smart";
|
|
522
|
+
readonly platforms: readonly ["macos"];
|
|
523
|
+
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
|
|
524
|
+
readonly endpoints: readonly [];
|
|
525
|
+
readonly groups: readonly ["select", "surge-smart"];
|
|
526
|
+
readonly nativeRuleSets: readonly ["rule-set", "domain-set"];
|
|
527
|
+
readonly dns: "general";
|
|
528
|
+
}, {
|
|
529
|
+
readonly engine: "mihomo";
|
|
530
|
+
readonly version: "1.19.32";
|
|
531
|
+
readonly autoGroup: "urltest";
|
|
532
|
+
readonly platforms: readonly ["linux", "macos"];
|
|
533
|
+
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
534
|
+
readonly endpoints: readonly [];
|
|
535
|
+
readonly groups: readonly ["select", "urltest"];
|
|
536
|
+
readonly nativeRuleSets: readonly ["yaml", "text"];
|
|
537
|
+
readonly dns: "clash";
|
|
538
|
+
}, {
|
|
539
|
+
readonly engine: "stash";
|
|
540
|
+
readonly version: "4.2.1";
|
|
541
|
+
readonly autoGroup: null;
|
|
542
|
+
readonly platforms: readonly ["macos"];
|
|
543
|
+
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
|
|
544
|
+
readonly endpoints: readonly [];
|
|
545
|
+
readonly groups: readonly ["select"];
|
|
546
|
+
readonly nativeRuleSets: readonly [];
|
|
547
|
+
readonly dns: "external";
|
|
548
|
+
}];
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/compiler.d.ts
|
|
551
|
+
type TargetPlan = {
|
|
552
|
+
readonly target: Target;
|
|
553
|
+
readonly program: Omit<Program, "groups"> & {
|
|
554
|
+
readonly groups: readonly ConcreteGroup[];
|
|
555
|
+
};
|
|
556
|
+
readonly nativeRuleSets: readonly NativeRuleSet[];
|
|
557
|
+
readonly strategySelections: readonly StrategySelection[];
|
|
558
|
+
readonly rules: readonly ExpandedRule[];
|
|
559
|
+
readonly sourceMap: readonly {
|
|
560
|
+
readonly rule: string;
|
|
561
|
+
readonly nativeIndex: number;
|
|
562
|
+
readonly origin: readonly string[];
|
|
563
|
+
}[];
|
|
564
|
+
readonly preconditions: readonly string[];
|
|
565
|
+
readonly nativeValidation: "not-run";
|
|
566
|
+
};
|
|
567
|
+
type Compilation = {
|
|
568
|
+
readonly ok: boolean;
|
|
569
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
570
|
+
readonly plans: readonly TargetPlan[];
|
|
571
|
+
readonly cases: readonly CaseResult[];
|
|
572
|
+
};
|
|
573
|
+
type CaseResult = {
|
|
574
|
+
readonly id: string;
|
|
575
|
+
readonly passed: boolean;
|
|
576
|
+
readonly actual: {
|
|
577
|
+
readonly rule: string;
|
|
578
|
+
readonly action: Action;
|
|
579
|
+
};
|
|
580
|
+
} | {
|
|
581
|
+
readonly id: string;
|
|
582
|
+
readonly passed: false;
|
|
583
|
+
readonly code: "CASE_INDETERMINATE";
|
|
584
|
+
};
|
|
585
|
+
export declare function compile(input: unknown): Compilation;
|
|
586
|
+
export declare function explain(compilation: Compilation, target: string, request: Request): Explanation;
|
|
587
|
+
//#endregion
|
|
588
|
+
//#region src/surge-definitions.d.ts
|
|
589
|
+
type Builtin = Extract<SurgePolicy, {
|
|
590
|
+
builtin: string;
|
|
591
|
+
}>;
|
|
592
|
+
type Destination = ProxyNode | ProxyGroupDefinition | SurgeTunnel | Builtin;
|
|
593
|
+
interface ProxyGroupDefinition<A extends GroupAlgorithm = Extract<GroupAlgorithm, {
|
|
594
|
+
type: "select" | "surge-smart";
|
|
595
|
+
}>, D extends ProfileDestination = Destination> {
|
|
596
|
+
readonly type: "proxy-group";
|
|
597
|
+
readonly id: string;
|
|
598
|
+
readonly name: string;
|
|
599
|
+
readonly algorithm: A;
|
|
600
|
+
readonly members: readonly D[];
|
|
601
|
+
readonly url?: string;
|
|
602
|
+
readonly intervalSeconds?: number;
|
|
603
|
+
readonly timeoutSeconds?: number;
|
|
604
|
+
}
|
|
605
|
+
type RouteDefinition<C extends ProfileCondition = SurgeCondition, D extends ProfileDestination = Destination> = {
|
|
606
|
+
readonly type: "route";
|
|
607
|
+
readonly when: C;
|
|
608
|
+
readonly to: D;
|
|
609
|
+
};
|
|
610
|
+
type SurgeProfileDefinition = Omit<SurgeProfileInput, "groups" | "rules" | "fallback"> & {
|
|
611
|
+
readonly groups: readonly ProxyGroupDefinition[];
|
|
612
|
+
readonly routes: readonly RouteDefinition[];
|
|
613
|
+
readonly fallback: Destination;
|
|
614
|
+
};
|
|
615
|
+
export declare class ProfileDefinitionError extends Error {
|
|
616
|
+
readonly code: string;
|
|
617
|
+
constructor(code: string);
|
|
618
|
+
}
|
|
619
|
+
export declare const outbound: {
|
|
620
|
+
direct: Readonly<{
|
|
621
|
+
readonly builtin: "DIRECT";
|
|
622
|
+
}>;
|
|
623
|
+
reject: Readonly<{
|
|
624
|
+
readonly builtin: "REJECT";
|
|
625
|
+
}>;
|
|
626
|
+
rejectDrop: Readonly<{
|
|
627
|
+
readonly builtin: "REJECT-DROP";
|
|
628
|
+
}>;
|
|
629
|
+
rejectNoDrop: Readonly<{
|
|
630
|
+
readonly builtin: "REJECT-NO-DROP";
|
|
631
|
+
}>;
|
|
632
|
+
rejectTinyGif: Readonly<{
|
|
633
|
+
readonly builtin: "REJECT-TINYGIF";
|
|
634
|
+
}>;
|
|
635
|
+
};
|
|
636
|
+
export declare function defineProxyGroup<A extends GroupAlgorithm, D extends ProfileDestination>(input: Omit<ProxyGroupDefinition<A, D>, "type">): ProxyGroupDefinition<A, D>;
|
|
637
|
+
export declare function defineRoute<C extends ProfileCondition, D extends ProfileDestination>(input: Omit<RouteDefinition<C, D>, "type">): RouteDefinition<C, D>;
|
|
638
|
+
export declare function defineRoutes<C extends ProfileCondition, D extends ProfileDestination>(input: {
|
|
639
|
+
readonly when: readonly C[];
|
|
640
|
+
readonly to: D;
|
|
641
|
+
}): RouteDefinition<C, D>[];
|
|
642
|
+
export declare function selectProxies(nodes: readonly ProxyNode[], query?: {
|
|
643
|
+
ids?: readonly string[];
|
|
644
|
+
regions?: readonly string[];
|
|
645
|
+
providers?: readonly string[];
|
|
646
|
+
tags?: readonly string[];
|
|
647
|
+
}): ProxyNode[];
|
|
648
|
+
export declare function defineSurgeProfile(input: SurgeProfileDefinition): SurgeProfileInput;
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region src/profile.d.ts
|
|
651
|
+
type DeepReadonly<T> = T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]>; } : T;
|
|
652
|
+
type ProfileCondition = Exclude<Match | SurgeCondition, {
|
|
653
|
+
type: "all" | "any" | "not";
|
|
654
|
+
}> | {
|
|
655
|
+
readonly type: "all" | "any";
|
|
656
|
+
readonly conditions: readonly ProfileCondition[];
|
|
657
|
+
readonly noResolve?: boolean;
|
|
658
|
+
readonly extendedMatching?: boolean;
|
|
659
|
+
} | {
|
|
660
|
+
readonly type: "not";
|
|
661
|
+
readonly condition: ProfileCondition;
|
|
662
|
+
readonly noResolve?: boolean;
|
|
663
|
+
readonly extendedMatching?: boolean;
|
|
664
|
+
};
|
|
665
|
+
interface ProfileProxyGroup extends ProxyGroupDefinition<GroupAlgorithm, ProfileDestination> {}
|
|
666
|
+
type ProfileDestination = ProxyNode | ProfileProxyGroup | SurgeTunnel | TailscaleEndpoint | {
|
|
667
|
+
readonly builtin: "DIRECT" | "REJECT" | "REJECT-DROP" | "REJECT-NO-DROP" | "REJECT-TINYGIF";
|
|
668
|
+
};
|
|
669
|
+
type SurgeConfig = Pick<SurgeProfileInput, "managed" | "general" | "hosts" | "names">;
|
|
670
|
+
type ProfileDefinition = {
|
|
671
|
+
readonly target: SurgeProfileInput["target"] | {
|
|
672
|
+
readonly engine: "sing-box";
|
|
673
|
+
readonly platform: "macos" | "linux";
|
|
674
|
+
readonly version: string;
|
|
675
|
+
};
|
|
676
|
+
readonly nodes: readonly ProxyNode[];
|
|
677
|
+
readonly groups: readonly ProxyGroupDefinition<GroupAlgorithm, ProfileDestination>[];
|
|
678
|
+
readonly routes: readonly RouteDefinition<ProfileCondition, ProfileDestination>[];
|
|
679
|
+
readonly fallback: ProfileDestination;
|
|
680
|
+
readonly endpoints?: readonly (SurgeTunnel | TailscaleEndpoint)[];
|
|
681
|
+
readonly surge?: DeepReadonly<SurgeConfig>;
|
|
682
|
+
readonly singBox?: {
|
|
683
|
+
readonly mode: "fragment" | "standalone";
|
|
684
|
+
readonly listener?: {
|
|
685
|
+
readonly port: number;
|
|
686
|
+
readonly resolver: string;
|
|
687
|
+
};
|
|
688
|
+
};
|
|
689
|
+
};
|
|
690
|
+
type Profile = DeepReadonly<ProfileDefinition>;
|
|
691
|
+
type ProfileCompilation = {
|
|
692
|
+
readonly engine: "surge";
|
|
693
|
+
readonly ok: boolean;
|
|
694
|
+
readonly compilation: SurgeProfileCompilation;
|
|
695
|
+
} | {
|
|
696
|
+
readonly engine: "sing-box";
|
|
697
|
+
readonly ok: boolean;
|
|
698
|
+
readonly compilation: Compilation;
|
|
699
|
+
} | {
|
|
700
|
+
readonly engine: "invalid";
|
|
701
|
+
readonly ok: false;
|
|
702
|
+
readonly code: string;
|
|
703
|
+
};
|
|
704
|
+
declare function surgeConfig(input: SurgeConfig): DeepReadonly<SurgeConfig>;
|
|
705
|
+
export declare function defineProfile(input: ProfileDefinition | Profile): Profile;
|
|
706
|
+
/** No secrets or I/O. All engine adaptations retain strict validation. */
|
|
707
|
+
export declare function compileProfile(input: ProfileDefinition | Profile): ProfileCompilation;
|
|
708
|
+
//#endregion
|
|
497
709
|
//#region src/proxy-builder.d.ts
|
|
498
710
|
type ProxyBuilder<N extends ProxyNode> = {
|
|
499
711
|
readonly via: (id: string) => ProxyBuilder<N>;
|
|
@@ -568,6 +780,7 @@ export declare const group: {
|
|
|
568
780
|
}>;
|
|
569
781
|
};
|
|
570
782
|
export declare const surge: {
|
|
783
|
+
config: typeof surgeConfig;
|
|
571
784
|
match: {
|
|
572
785
|
domain: (value: string, options?: {
|
|
573
786
|
readonly noResolve?: boolean;
|
|
@@ -655,97 +868,6 @@ export declare const singbox: {
|
|
|
655
868
|
tailscale: (options: Omit<TailscaleEndpoint, "type">) => TailscaleEndpoint;
|
|
656
869
|
};
|
|
657
870
|
//#endregion
|
|
658
|
-
//#region src/targets.d.ts
|
|
659
|
-
export declare const targetCatalog: readonly [{
|
|
660
|
-
readonly engine: "sing-box";
|
|
661
|
-
readonly version: "1.11.0";
|
|
662
|
-
readonly autoGroup: "urltest";
|
|
663
|
-
readonly platforms: readonly ["linux", "macos"];
|
|
664
|
-
readonly protocols: readonly ["trojan", "http", "shadowsocks", "vmess", "vless"];
|
|
665
|
-
readonly endpoints: readonly [];
|
|
666
|
-
readonly groups: readonly ["select", "urltest"];
|
|
667
|
-
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
668
|
-
readonly dns: "legacy";
|
|
669
|
-
}, {
|
|
670
|
-
readonly engine: "sing-box";
|
|
671
|
-
readonly version: "1.12.0";
|
|
672
|
-
readonly autoGroup: "urltest";
|
|
673
|
-
readonly platforms: readonly ["linux", "macos"];
|
|
674
|
-
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
675
|
-
readonly endpoints: readonly ["sing-box-tailscale"];
|
|
676
|
-
readonly groups: readonly ["select", "urltest"];
|
|
677
|
-
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
678
|
-
readonly dns: "typed";
|
|
679
|
-
}, {
|
|
680
|
-
readonly engine: "surge";
|
|
681
|
-
readonly version: "6.10.0";
|
|
682
|
-
readonly autoGroup: "surge-smart";
|
|
683
|
-
readonly platforms: readonly ["macos"];
|
|
684
|
-
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
|
|
685
|
-
readonly endpoints: readonly [];
|
|
686
|
-
readonly groups: readonly ["select", "surge-smart"];
|
|
687
|
-
readonly nativeRuleSets: readonly ["rule-set", "domain-set"];
|
|
688
|
-
readonly dns: "general";
|
|
689
|
-
}, {
|
|
690
|
-
readonly engine: "mihomo";
|
|
691
|
-
readonly version: "1.19.32";
|
|
692
|
-
readonly autoGroup: "urltest";
|
|
693
|
-
readonly platforms: readonly ["linux", "macos"];
|
|
694
|
-
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
695
|
-
readonly endpoints: readonly [];
|
|
696
|
-
readonly groups: readonly ["select", "urltest"];
|
|
697
|
-
readonly nativeRuleSets: readonly ["yaml", "text"];
|
|
698
|
-
readonly dns: "clash";
|
|
699
|
-
}, {
|
|
700
|
-
readonly engine: "stash";
|
|
701
|
-
readonly version: "4.2.1";
|
|
702
|
-
readonly autoGroup: null;
|
|
703
|
-
readonly platforms: readonly ["macos"];
|
|
704
|
-
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
|
|
705
|
-
readonly endpoints: readonly [];
|
|
706
|
-
readonly groups: readonly ["select"];
|
|
707
|
-
readonly nativeRuleSets: readonly [];
|
|
708
|
-
readonly dns: "external";
|
|
709
|
-
}];
|
|
710
|
-
//#endregion
|
|
711
|
-
//#region src/compiler.d.ts
|
|
712
|
-
type TargetPlan = {
|
|
713
|
-
readonly target: Target;
|
|
714
|
-
readonly program: Omit<Program, "groups"> & {
|
|
715
|
-
readonly groups: readonly ConcreteGroup[];
|
|
716
|
-
};
|
|
717
|
-
readonly nativeRuleSets: readonly NativeRuleSet[];
|
|
718
|
-
readonly strategySelections: readonly StrategySelection[];
|
|
719
|
-
readonly rules: readonly ExpandedRule[];
|
|
720
|
-
readonly sourceMap: readonly {
|
|
721
|
-
readonly rule: string;
|
|
722
|
-
readonly nativeIndex: number;
|
|
723
|
-
readonly origin: readonly string[];
|
|
724
|
-
}[];
|
|
725
|
-
readonly preconditions: readonly string[];
|
|
726
|
-
readonly nativeValidation: "not-run";
|
|
727
|
-
};
|
|
728
|
-
type Compilation = {
|
|
729
|
-
readonly ok: boolean;
|
|
730
|
-
readonly diagnostics: readonly Diagnostic[];
|
|
731
|
-
readonly plans: readonly TargetPlan[];
|
|
732
|
-
readonly cases: readonly CaseResult[];
|
|
733
|
-
};
|
|
734
|
-
type CaseResult = {
|
|
735
|
-
readonly id: string;
|
|
736
|
-
readonly passed: boolean;
|
|
737
|
-
readonly actual: {
|
|
738
|
-
readonly rule: string;
|
|
739
|
-
readonly action: Action;
|
|
740
|
-
};
|
|
741
|
-
} | {
|
|
742
|
-
readonly id: string;
|
|
743
|
-
readonly passed: false;
|
|
744
|
-
readonly code: "CASE_INDETERMINATE";
|
|
745
|
-
};
|
|
746
|
-
export declare function compile(input: unknown): Compilation;
|
|
747
|
-
export declare function explain(compilation: Compilation, target: string, request: Request): Explanation;
|
|
748
|
-
//#endregion
|
|
749
871
|
//#region src/proxies.d.ts
|
|
750
872
|
export declare class RenderError extends Error {
|
|
751
873
|
readonly code: string;
|
|
@@ -854,63 +976,35 @@ export declare function surgeMembers(nodes: readonly ProxyNode[], query?: Parame
|
|
|
854
976
|
/** Complete-profile batches use the out symlink protocol; the Program host remains unchanged. */
|
|
855
977
|
export declare function buildSurgeProfilesToDirectory(profiles: Readonly<Record<string, SurgeProfileInput>>, output: string, resolveSecret?: (token: Secret) => string | undefined): Promise<BuildResult>;
|
|
856
978
|
//#endregion
|
|
857
|
-
//#region src/
|
|
858
|
-
type
|
|
859
|
-
|
|
860
|
-
}>;
|
|
861
|
-
type Destination = ProxyNode | ProxyGroupDefinition | SurgeTunnel | Builtin;
|
|
862
|
-
type ProxyGroupDefinition = {
|
|
863
|
-
readonly type: "proxy-group";
|
|
864
|
-
readonly id: string;
|
|
865
|
-
readonly name: string;
|
|
866
|
-
readonly algorithm: Extract<GroupAlgorithm, {
|
|
867
|
-
type: "select" | "surge-smart";
|
|
868
|
-
}>;
|
|
869
|
-
readonly members: readonly Destination[];
|
|
870
|
-
readonly url?: string;
|
|
871
|
-
readonly intervalSeconds?: number;
|
|
872
|
-
readonly timeoutSeconds?: number;
|
|
979
|
+
//#region src/build-core.d.ts
|
|
980
|
+
type BuildContext = {
|
|
981
|
+
readonly validation: boolean;
|
|
873
982
|
};
|
|
874
|
-
type
|
|
875
|
-
readonly
|
|
876
|
-
readonly
|
|
877
|
-
readonly
|
|
878
|
-
readonly to: Destination;
|
|
983
|
+
type BuildDefinition$1<T> = {
|
|
984
|
+
readonly profiles: Readonly<Record<string, T>>;
|
|
985
|
+
readonly preflight?: () => readonly string[];
|
|
986
|
+
readonly resolveSecret?: (token: Secret, context: BuildContext) => string | undefined;
|
|
879
987
|
};
|
|
880
|
-
type
|
|
881
|
-
readonly
|
|
882
|
-
readonly
|
|
883
|
-
readonly
|
|
988
|
+
type ProfileBuildResult = BuildResult & {
|
|
989
|
+
readonly warnings: Readonly<Record<string, number>>;
|
|
990
|
+
readonly validation: boolean;
|
|
991
|
+
readonly profileCount: number;
|
|
884
992
|
};
|
|
885
|
-
export declare class ProfileDefinitionError extends Error {
|
|
886
|
-
readonly code: string;
|
|
887
|
-
constructor(code: string);
|
|
888
|
-
}
|
|
889
|
-
export declare const outbound: {
|
|
890
|
-
direct: Readonly<{
|
|
891
|
-
readonly builtin: "DIRECT";
|
|
892
|
-
}>;
|
|
893
|
-
reject: Readonly<{
|
|
894
|
-
readonly builtin: "REJECT";
|
|
895
|
-
}>;
|
|
896
|
-
rejectDrop: Readonly<{
|
|
897
|
-
readonly builtin: "REJECT-DROP";
|
|
898
|
-
}>;
|
|
899
|
-
rejectNoDrop: Readonly<{
|
|
900
|
-
readonly builtin: "REJECT-NO-DROP";
|
|
901
|
-
}>;
|
|
902
|
-
rejectTinyGif: Readonly<{
|
|
903
|
-
readonly builtin: "REJECT-TINYGIF";
|
|
904
|
-
}>;
|
|
905
|
-
};
|
|
906
|
-
export declare function defineProxyGroup(input: Omit<ProxyGroupDefinition, "type">): ProxyGroupDefinition;
|
|
907
|
-
export declare function defineRoute(input: Omit<RouteDefinition, "type">): RouteDefinition;
|
|
908
|
-
export declare function selectProxies(nodes: readonly ProxyNode[], query?: {
|
|
909
|
-
ids?: readonly string[];
|
|
910
|
-
regions?: readonly string[];
|
|
911
|
-
providers?: readonly string[];
|
|
912
|
-
tags?: readonly string[];
|
|
913
|
-
}): ProxyNode[];
|
|
914
|
-
export declare function defineSurgeProfile(input: SurgeProfileDefinition): SurgeProfileInput;
|
|
915
993
|
//#endregion
|
|
916
|
-
|
|
994
|
+
//#region src/surge-build.d.ts
|
|
995
|
+
type SurgeBuildContext = BuildContext;
|
|
996
|
+
type SurgeBuildDefinition = BuildDefinition$1<SurgeProfileInput>;
|
|
997
|
+
type SurgeBuildResult = ProfileBuildResult;
|
|
998
|
+
export declare function defineSurgeBuild(input: SurgeBuildDefinition): SurgeBuildDefinition;
|
|
999
|
+
export declare function runSurgeBuild(input: SurgeBuildDefinition, output: string, options?: {
|
|
1000
|
+
readonly validation?: boolean;
|
|
1001
|
+
}): Promise<SurgeBuildResult>;
|
|
1002
|
+
//#endregion
|
|
1003
|
+
//#region src/profile-build.d.ts
|
|
1004
|
+
type BuildDefinition = BuildDefinition$1<Profile>;
|
|
1005
|
+
export declare function defineBuild(input: BuildDefinition): BuildDefinition;
|
|
1006
|
+
export declare function runBuild(input: BuildDefinition, output: string, options?: {
|
|
1007
|
+
readonly validation?: boolean;
|
|
1008
|
+
}): Promise<ProfileBuildResult>;
|
|
1009
|
+
//#endregion
|
|
1010
|
+
export type { Artifact, BuildContext, BuildDefinition, BuildResult, CaseResult, Compilation, DeepReadonly, Destination, Profile, ProfileBuildResult, ProfileCompilation, ProfileCondition, ProfileDefinition, ProfileDestination, ProxyBuilder, ProxyGroupDefinition, ProxyNodeArtifact, ProxyNodeCompilation, ProxyNodeInput, RouteDefinition, StrategyGroupCompilation, StrategyGroupInput, SurgeBuildContext, SurgeBuildDefinition, SurgeBuildResult, SurgeCondition, SurgeConfig, SurgeGeneral, SurgeGroup, SurgeHost, SurgePolicy, SurgeProfileArtifact, SurgeProfileCompilation, SurgeProfileDefinition, SurgeProfileInput, SurgeRule, SurgeTunnel, TargetPlan };
|