@jeffusion/bungee-types 5.21.1 → 5.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configuration.d.ts +68 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/plugin-config-contract.d.ts +14 -0
- package/dist/plugin-config-contract.js +7 -0
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
- package/dist/config-v2.d.ts +0 -68
- /package/dist/{config-v2.js → configuration.js} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AppConfig, Endpoint, PluginConfigOptions, RouteConfig, Service } from './types.js';
|
|
2
|
+
export type ConfigurationId = string;
|
|
3
|
+
export type Sha256Digest = `sha256:${string}`;
|
|
4
|
+
export interface PluginActivation {
|
|
5
|
+
readonly plugin_name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PluginBinding {
|
|
8
|
+
readonly id: ConfigurationId;
|
|
9
|
+
readonly position: number;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly options?: PluginConfigOptions;
|
|
12
|
+
readonly enabled: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface UpstreamManagedBy {
|
|
15
|
+
readonly plugin: string;
|
|
16
|
+
readonly contributionId: string;
|
|
17
|
+
readonly bindingId: ConfigurationId;
|
|
18
|
+
}
|
|
19
|
+
type ConfigurationUpstreamPolicy = Omit<Endpoint, 'id' | 'plugins' | 'weight' | 'priority' | 'is_disabled'>;
|
|
20
|
+
export interface ConfigurationUpstream extends ConfigurationUpstreamPolicy {
|
|
21
|
+
readonly id: ConfigurationId;
|
|
22
|
+
readonly position: number;
|
|
23
|
+
readonly weight: number;
|
|
24
|
+
readonly priority: number;
|
|
25
|
+
readonly is_disabled: boolean;
|
|
26
|
+
readonly managedBy?: UpstreamManagedBy;
|
|
27
|
+
readonly plugins: readonly PluginBinding[];
|
|
28
|
+
}
|
|
29
|
+
type ConfigurationServicePolicy = Omit<Service, 'name' | 'endpoints' | 'plugins'>;
|
|
30
|
+
export interface ConfigurationService extends ConfigurationServicePolicy {
|
|
31
|
+
readonly id: ConfigurationId;
|
|
32
|
+
readonly position: number;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly endpoints: readonly ConfigurationUpstream[];
|
|
35
|
+
readonly plugins: readonly PluginBinding[];
|
|
36
|
+
}
|
|
37
|
+
type ConfigurationRoutePolicy = Omit<RouteConfig, 'path' | 'service' | 'endpoints' | 'plugins'>;
|
|
38
|
+
interface ConfigurationRouteBase extends ConfigurationRoutePolicy {
|
|
39
|
+
readonly id: ConfigurationId;
|
|
40
|
+
readonly position: number;
|
|
41
|
+
readonly path: string;
|
|
42
|
+
readonly plugins: readonly PluginBinding[];
|
|
43
|
+
}
|
|
44
|
+
export interface ConfigurationServiceRoute extends ConfigurationRouteBase {
|
|
45
|
+
readonly service_id: ConfigurationId;
|
|
46
|
+
readonly endpoints?: never;
|
|
47
|
+
}
|
|
48
|
+
export interface ConfigurationDirectRoute extends ConfigurationRouteBase {
|
|
49
|
+
readonly service_id?: never;
|
|
50
|
+
readonly endpoints: readonly ConfigurationUpstream[];
|
|
51
|
+
}
|
|
52
|
+
export type ConfigurationRoute = ConfigurationServiceRoute | ConfigurationDirectRoute;
|
|
53
|
+
type ConfigurationGlobalPolicy = Omit<AppConfig, 'config_version' | 'plugins' | 'services' | 'routes'>;
|
|
54
|
+
export interface LogicalConfiguration extends ConfigurationGlobalPolicy {
|
|
55
|
+
readonly services: readonly ConfigurationService[];
|
|
56
|
+
readonly routes: readonly ConfigurationRoute[];
|
|
57
|
+
readonly plugins: readonly PluginBinding[];
|
|
58
|
+
}
|
|
59
|
+
export interface ConfigurationAggregate {
|
|
60
|
+
readonly logical_configuration: LogicalConfiguration;
|
|
61
|
+
readonly plugin_activations: readonly PluginActivation[];
|
|
62
|
+
}
|
|
63
|
+
export interface CommittedConfigurationSnapshot {
|
|
64
|
+
readonly revision: number;
|
|
65
|
+
readonly content_hash: Sha256Digest;
|
|
66
|
+
readonly aggregate: ConfigurationAggregate;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './configuration.js';
|
|
3
3
|
export * from './rate-limit.js';
|
|
4
4
|
export * from './daemon-control.js';
|
|
5
5
|
export * from './publication-policy.js';
|
|
6
6
|
export * from './sse-log.js';
|
|
7
|
+
export * from './plugin-config-contract.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './configuration.js';
|
|
3
3
|
export * from './rate-limit.js';
|
|
4
4
|
export * from './daemon-control.js';
|
|
5
5
|
export * from './publication-policy.js';
|
|
6
6
|
export * from './sse-log.js';
|
|
7
|
+
export * from './plugin-config-contract.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Runtime instance placement declared by a plugin manifest. */
|
|
2
|
+
export type PluginRuntimeScope = 'global' | 'scoped' | 'global-and-scoped';
|
|
3
|
+
/** Whitelist of scalar tuples across independent, top-level config fields.
|
|
4
|
+
* Omitted fields do not match a tuple; an entirely omitted optional group is ignored.
|
|
5
|
+
* Required-field checks remain the responsibility of configSchema.
|
|
6
|
+
*/
|
|
7
|
+
export interface PluginAllowedTuplesConstraint {
|
|
8
|
+
readonly type: 'allowed-tuples';
|
|
9
|
+
readonly fields: readonly string[];
|
|
10
|
+
readonly tuples: readonly (readonly (string | number | boolean | null)[])[];
|
|
11
|
+
readonly message?: string;
|
|
12
|
+
}
|
|
13
|
+
export type PluginConfigConstraint = PluginAllowedTuplesConstraint;
|
|
14
|
+
export declare function pluginConfigConstraintSatisfied(options: Readonly<Record<string, unknown>>, constraint: PluginConfigConstraint): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function pluginConfigConstraintSatisfied(options, constraint) {
|
|
2
|
+
const values = constraint.fields.map(field => options[field]);
|
|
3
|
+
if (values.every(value => value === undefined))
|
|
4
|
+
return true;
|
|
5
|
+
return constraint.tuples.some(tuple => tuple.length === values.length
|
|
6
|
+
&& tuple.every((value, index) => value === values[index]));
|
|
7
|
+
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffusion/bungee-types",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.22.0",
|
|
4
4
|
"description": "TypeScript type definitions for Bungee",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "tsc",
|
|
9
|
+
"build": "rm -rf dist && tsc",
|
|
10
10
|
"prepublishOnly": "bun run build",
|
|
11
11
|
"test": "bun run build && bun test tests/"
|
|
12
12
|
},
|
package/dist/config-v2.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { AppConfig, Endpoint, PluginConfigOptions, RouteConfig, Service } from './types.js';
|
|
2
|
-
export type ConfigurationId = string;
|
|
3
|
-
export type Sha256Digest = `sha256:${string}`;
|
|
4
|
-
export interface PluginActivationV2 {
|
|
5
|
-
readonly plugin_name: string;
|
|
6
|
-
}
|
|
7
|
-
export interface PluginBindingV2 {
|
|
8
|
-
readonly id: ConfigurationId;
|
|
9
|
-
readonly position: number;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly options?: PluginConfigOptions;
|
|
12
|
-
readonly enabled: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface UpstreamManagedByV2 {
|
|
15
|
-
readonly plugin: string;
|
|
16
|
-
readonly contributionId: string;
|
|
17
|
-
readonly bindingId: ConfigurationId;
|
|
18
|
-
}
|
|
19
|
-
type UpstreamPolicyV2 = Omit<Endpoint, 'id' | 'plugins' | 'weight' | 'priority' | 'is_disabled'>;
|
|
20
|
-
export interface UpstreamV2 extends UpstreamPolicyV2 {
|
|
21
|
-
readonly id: ConfigurationId;
|
|
22
|
-
readonly position: number;
|
|
23
|
-
readonly weight: number;
|
|
24
|
-
readonly priority: number;
|
|
25
|
-
readonly is_disabled: boolean;
|
|
26
|
-
readonly managedBy?: UpstreamManagedByV2;
|
|
27
|
-
readonly plugins: readonly PluginBindingV2[];
|
|
28
|
-
}
|
|
29
|
-
type ServicePolicyV2 = Omit<Service, 'name' | 'endpoints' | 'plugins'>;
|
|
30
|
-
export interface ServiceV2 extends ServicePolicyV2 {
|
|
31
|
-
readonly id: ConfigurationId;
|
|
32
|
-
readonly position: number;
|
|
33
|
-
readonly name: string;
|
|
34
|
-
readonly endpoints: readonly UpstreamV2[];
|
|
35
|
-
readonly plugins: readonly PluginBindingV2[];
|
|
36
|
-
}
|
|
37
|
-
type RoutePolicyV2 = Omit<RouteConfig, 'path' | 'service' | 'endpoints' | 'plugins'>;
|
|
38
|
-
interface RouteV2Base extends RoutePolicyV2 {
|
|
39
|
-
readonly id: ConfigurationId;
|
|
40
|
-
readonly position: number;
|
|
41
|
-
readonly path: string;
|
|
42
|
-
readonly plugins: readonly PluginBindingV2[];
|
|
43
|
-
}
|
|
44
|
-
export interface ServiceRouteV2 extends RouteV2Base {
|
|
45
|
-
readonly service_id: ConfigurationId;
|
|
46
|
-
readonly endpoints?: never;
|
|
47
|
-
}
|
|
48
|
-
export interface DirectRouteV2 extends RouteV2Base {
|
|
49
|
-
readonly service_id?: never;
|
|
50
|
-
readonly endpoints: readonly UpstreamV2[];
|
|
51
|
-
}
|
|
52
|
-
export type RouteV2 = ServiceRouteV2 | DirectRouteV2;
|
|
53
|
-
type GlobalPolicyV2 = Omit<AppConfig, 'config_version' | 'plugins' | 'services' | 'routes'>;
|
|
54
|
-
export interface LogicalConfigurationV2 extends GlobalPolicyV2 {
|
|
55
|
-
readonly services: readonly ServiceV2[];
|
|
56
|
-
readonly routes: readonly RouteV2[];
|
|
57
|
-
readonly plugins: readonly PluginBindingV2[];
|
|
58
|
-
}
|
|
59
|
-
export interface ConfigurationAggregateV2 {
|
|
60
|
-
readonly logical_configuration: LogicalConfigurationV2;
|
|
61
|
-
readonly plugin_activations: readonly PluginActivationV2[];
|
|
62
|
-
}
|
|
63
|
-
export interface CommittedConfigurationSnapshotV2 {
|
|
64
|
-
readonly revision: number;
|
|
65
|
-
readonly content_hash: Sha256Digest;
|
|
66
|
-
readonly aggregate: ConfigurationAggregateV2;
|
|
67
|
-
}
|
|
68
|
-
export {};
|
|
File without changes
|