@jeffusion/bungee-types 5.21.0 → 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/README.md CHANGED
@@ -13,13 +13,13 @@ bun add @jeffusion/bungee-types
13
13
  ## Usage
14
14
 
15
15
  ```typescript
16
- import type { AppConfig, RouteConfig, AuthConfig } from '@jeffusion/bungee-types';
16
+ import type { AppConfig, RouteConfig } from '@jeffusion/bungee-types';
17
17
 
18
18
  const config: AppConfig = {
19
19
  routes: [
20
20
  {
21
21
  path: '/api',
22
- upstreams: [
22
+ endpoints: [
23
23
  { target: 'http://localhost:3000' }
24
24
  ]
25
25
  }
@@ -32,8 +32,7 @@ const config: AppConfig = {
32
32
  ### Core Configuration Types
33
33
  - `AppConfig` - Main application configuration
34
34
  - `RouteConfig` - Route configuration with upstreams and plugins
35
- - `AuthConfig` - Authentication configuration
36
- - `Upstream` - Upstream server configuration
35
+ - `Endpoint` - Upstream target, weight, conditions and directional rules
37
36
 
38
37
  ### Modification and Plugin Types
39
38
  - `ModificationRules` - Request/response modification rules
@@ -42,7 +41,7 @@ const config: AppConfig = {
42
41
 
43
42
  ## Type Exports
44
43
 
45
- ### Default Export
44
+ ### Root Entry
46
45
  ```typescript
47
46
  import type { AppConfig } from '@jeffusion/bungee-types';
48
47
  ```
@@ -54,7 +53,9 @@ import type { RouteConfig } from '@jeffusion/bungee-types/types';
54
53
 
55
54
  ## Documentation
56
55
 
57
- For full documentation, visit [Bungee Documentation](https://github.com/jeffusion/bungee).
56
+ For storage aggregates and runtime validation, see [configuration reference](../../docs/reference/configuration.md). Management identity and proxy Keys are plugin capabilities; an exported TypeScript shape does not bypass configuration validation.
57
+
58
+ Plugin runtime interfaces use `@jeffusion/bungee-core/plugin`, not this package.
58
59
 
59
60
  ## License
60
61
 
@@ -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 './config-v2.js';
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 './config-v2.js';
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
@@ -258,7 +258,7 @@ export interface PluginConfig {
258
258
  * Plugin 名称(唯一标识符)
259
259
  * 这是插件的唯一标识,用于引用和管理插件
260
260
  *
261
- * 示例: "ai-transformer", "token-cache"
261
+ * 示例: "llm-protocol-adapter", "token-cache"
262
262
  */
263
263
  name: string;
264
264
  /**
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@jeffusion/bungee-types",
3
- "version": "5.21.0",
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
- "test": "bun run build && bun test tests/published-runtime.test.ts"
11
+ "test": "bun run build && bun test tests/"
12
12
  },
13
13
  "exports": {
14
14
  ".": {
@@ -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