@contractspec/lib.progressive-delivery 34.0.19 → 34.0.21

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.
@@ -1 +1 @@
1
- class n{defaults;constructor(e){this.defaults=e}evaluate(e,t){let a={...this.defaults,...e.thresholds},r=[];if(t.errorRate>a.errorRate)r.push(`errorRate ${t.errorRate.toFixed(4)} > ${a.errorRate}`);if(typeof a.latencyP50==="number"&&t.latencyP50>a.latencyP50)r.push(`latencyP50 ${t.latencyP50}ms > ${a.latencyP50}ms`);if(typeof a.latencyP95==="number"&&t.latencyP95>a.latencyP95)r.push(`latencyP95 ${t.latencyP95}ms > ${a.latencyP95}ms`);if(typeof a.latencyP99==="number"&&t.latencyP99>a.latencyP99)r.push(`latencyP99 ${t.latencyP99}ms > ${a.latencyP99}ms`);if(typeof a.throughputDrop==="number"&&t.throughput<a.throughputDrop)r.push(`throughput ${t.throughput} < ${a.throughputDrop}`);if(a.customEvaluator&&!a.customEvaluator(t))r.push("custom evaluator reported failure");return{status:r.length===0?"pass":"fail",reasons:r,metrics:t}}}var l=[{percentage:1,minDurationMs:300000,label:"1%"},{percentage:10,minDurationMs:300000,label:"10%"},{percentage:50,minDurationMs:600000,label:"50%"},{percentage:100,minDurationMs:900000,label:"100%"}];class s{options;stages;constructor(e){this.options=e;this.stages=e.strategy.stages&&e.strategy.stages.length>0?e.strategy.stages:l}getStageList(){return[...this.stages]}async runStage(e){this.options.eventBus?.emit({type:"stage_started",timestamp:new Date,payload:{stage:e}});let t=await this.options.metricsProvider(e,e.minDurationMs),a=this.options.analyzer.evaluate(e,t);return this.options.eventBus?.emit({type:a.status==="pass"?"stage_passed":"stage_failed",timestamp:new Date,payload:{stage:e,metrics:t,analysis:a}}),a}}function g(e,t,a){let r=new n(e.thresholds);return new s({strategy:e,analyzer:r,metricsProvider:t,eventBus:a})}class p{options;constructor(e){this.options=e}async run(){let e=this.options.controller.getStageList();for(let t of e){let a=this.options.trafficShifter.computeSplit(t);await this.options.applyTrafficSplit(t,a);let r=await this.options.controller.runStage(t);if(r.status==="fail"){let i=await this.options.rollbackManager.execute(t,r.reasons.join(", "));return this.options.eventBus?.emit({type:"rolled_back",timestamp:i.triggeredAt,payload:{stage:t,reasons:r.reasons}}),{status:"rolled_back",failedStage:t,reasons:r.reasons}}}if(this.options.strategy.mode==="blue-green")this.options.eventBus?.emit({type:"blue_green_swapped",timestamp:new Date,payload:{strategy:this.options.strategy}});return this.options.eventBus?.emit({type:"completed",timestamp:new Date,payload:{strategy:this.options.strategy}}),{status:"completed"}}}class y{listeners=new Set;on(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e){for(let t of this.listeners)try{t(e)}catch(a){console.error("[progressive-delivery] listener error",a)}}}var o={LIFECYCLE_DETECTION_ALPHA:"lifecycle_detection_alpha",LIFECYCLE_ADVISOR_ALPHA:"lifecycle_advisor_alpha",LIFECYCLE_MANAGED_SERVICE:"lifecycle_managed_service",STUDIO_VISUAL_BUILDER:"studio_visual_builder",STUDIO_AUTO_EVOLUTION:"studio_auto_evolution",STUDIO_BYOK:"studio_byok",STUDIO_DEDICATED_DEPLOYMENT:"studio_dedicated_deployment",STUDIO_INTEGRATION_HUB:"studio_integration_hub",STUDIO_KNOWLEDGE_HUB:"studio_knowledge_hub",STUDIO_TEMPLATES:"studio_templates"},h=[o.LIFECYCLE_DETECTION_ALPHA,o.LIFECYCLE_ADVISOR_ALPHA,o.LIFECYCLE_MANAGED_SERVICE],_=[o.STUDIO_VISUAL_BUILDER,o.STUDIO_AUTO_EVOLUTION,o.STUDIO_BYOK,o.STUDIO_DEDICATED_DEPLOYMENT,o.STUDIO_INTEGRATION_HUB,o.STUDIO_KNOWLEDGE_HUB,o.STUDIO_TEMPLATES];class c{options;constructor(e){this.options=e}async execute(e,t){await this.options.rollback(e,t);let a={reason:t,stage:e,triggeredAt:new Date};return this.options.onRollback?.(a),a}}class u{mode;constructor(e){this.mode=e}computeSplit(e){if(this.mode==="blue-green")return e.percentage>=100?{stable:0,candidate:1}:{stable:1,candidate:0};let t=Math.min(Math.max(e.percentage/100,0),1);return{candidate:t,stable:1-t}}}export{_ as studioFlags,h as lifecycleFlags,g as createDefaultCanaryController,u as TrafficShifter,c as RollbackManager,y as DeploymentEventBus,p as DeploymentCoordinator,o as ContractSpecFeatureFlags,s as CanaryController,n as CanaryAnalyzer};
1
+ class n{defaults;constructor(e){this.defaults=e}evaluate(e,t){let a={...this.defaults,...e.thresholds},r=[];if(t.errorRate>a.errorRate)r.push(`errorRate ${t.errorRate.toFixed(4)} > ${a.errorRate}`);if(typeof a.latencyP50==="number"&&t.latencyP50>a.latencyP50)r.push(`latencyP50 ${t.latencyP50}ms > ${a.latencyP50}ms`);if(typeof a.latencyP95==="number"&&t.latencyP95>a.latencyP95)r.push(`latencyP95 ${t.latencyP95}ms > ${a.latencyP95}ms`);if(typeof a.latencyP99==="number"&&t.latencyP99>a.latencyP99)r.push(`latencyP99 ${t.latencyP99}ms > ${a.latencyP99}ms`);if(typeof a.throughputDrop==="number"&&t.throughput<a.throughputDrop)r.push(`throughput ${t.throughput} < ${a.throughputDrop}`);if(a.customEvaluator&&!a.customEvaluator(t))r.push("custom evaluator reported failure");return{status:r.length===0?"pass":"fail",reasons:r,metrics:t}}}var l=[{percentage:1,minDurationMs:300000,label:"1%"},{percentage:10,minDurationMs:300000,label:"10%"},{percentage:50,minDurationMs:600000,label:"50%"},{percentage:100,minDurationMs:900000,label:"100%"}];class s{options;stages;constructor(e){this.options=e;this.stages=e.strategy.stages&&e.strategy.stages.length>0?e.strategy.stages:l}getStageList(){return[...this.stages]}async runStage(e){this.options.eventBus?.emit({type:"stage_started",timestamp:new Date,payload:{stage:e}});let t=await this.options.metricsProvider(e,e.minDurationMs),a=this.options.analyzer.evaluate(e,t);return this.options.eventBus?.emit({type:a.status==="pass"?"stage_passed":"stage_failed",timestamp:new Date,payload:{stage:e,metrics:t,analysis:a}}),a}}function d(e,t,a){let r=new n(e.thresholds);return new s({strategy:e,analyzer:r,metricsProvider:t,eventBus:a})}class p{options;constructor(e){this.options=e}async run(){let e=this.options.controller.getStageList();for(let t of e){let a=this.options.trafficShifter.computeSplit(t);await this.options.applyTrafficSplit(t,a);let r=await this.options.controller.runStage(t);if(r.status==="fail"){let i=await this.options.rollbackManager.execute(t,r.reasons.join(", "));return this.options.eventBus?.emit({type:"rolled_back",timestamp:i.triggeredAt,payload:{stage:t,reasons:r.reasons}}),{status:"rolled_back",failedStage:t,reasons:r.reasons}}}if(this.options.strategy.mode==="blue-green")this.options.eventBus?.emit({type:"blue_green_swapped",timestamp:new Date,payload:{strategy:this.options.strategy}});return this.options.eventBus?.emit({type:"completed",timestamp:new Date,payload:{strategy:this.options.strategy}}),{status:"completed"}}}class y{listeners=new Set;on(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e){for(let t of this.listeners)try{t(e)}catch(a){console.error("[progressive-delivery] listener error",a)}}}var o={LIFECYCLE_DETECTION_ALPHA:"lifecycle_detection_alpha",LIFECYCLE_ADVISOR_ALPHA:"lifecycle_advisor_alpha",LIFECYCLE_MANAGED_SERVICE:"lifecycle_managed_service",STUDIO_VISUAL_BUILDER:"studio_visual_builder",STUDIO_AUTO_EVOLUTION:"studio_auto_evolution",STUDIO_BYOK:"studio_byok",STUDIO_DEDICATED_DEPLOYMENT:"studio_dedicated_deployment",STUDIO_INTEGRATION_HUB:"studio_integration_hub",STUDIO_KNOWLEDGE_HUB:"studio_knowledge_hub",STUDIO_TEMPLATES:"studio_templates"},_=[o.LIFECYCLE_DETECTION_ALPHA,o.LIFECYCLE_ADVISOR_ALPHA,o.LIFECYCLE_MANAGED_SERVICE],E=[o.STUDIO_VISUAL_BUILDER,o.STUDIO_AUTO_EVOLUTION,o.STUDIO_BYOK,o.STUDIO_DEDICATED_DEPLOYMENT,o.STUDIO_INTEGRATION_HUB,o.STUDIO_KNOWLEDGE_HUB,o.STUDIO_TEMPLATES];import{defineFeature as c}from"@contractspec/lib.contracts-spec/features";var v=c({meta:{key:"libs.progressive-delivery",version:"1.0.0",title:"Progressive Delivery",description:"ContractSpec package declaration for @contractspec/lib.progressive-delivery.",domain:"progressive-delivery",owners:["@contractspec-core"],tags:["package","libs","progressive-delivery"],stability:"experimental"}});class u{options;constructor(e){this.options=e}async execute(e,t){await this.options.rollback(e,t);let a={reason:t,stage:e,triggeredAt:new Date};return this.options.onRollback?.(a),a}}class m{mode;constructor(e){this.mode=e}computeSplit(e){if(this.mode==="blue-green")return e.percentage>=100?{stable:0,candidate:1}:{stable:1,candidate:0};let t=Math.min(Math.max(e.percentage/100,0),1);return{candidate:t,stable:1-t}}}export{E as studioFlags,_ as lifecycleFlags,d as createDefaultCanaryController,m as TrafficShifter,u as RollbackManager,v as ProgressiveDeliveryFeature,y as DeploymentEventBus,p as DeploymentCoordinator,o as ContractSpecFeatureFlags,s as CanaryController,n as CanaryAnalyzer};
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './canary-controller';
3
3
  export * from './deployment-coordinator';
4
4
  export * from './events';
5
5
  export * from './feature-flags';
6
+ export * from './progressive-delivery.feature';
6
7
  export * from './rollback-manager';
7
8
  export * from './traffic-shifter';
8
9
  export * from './types';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- class n{defaults;constructor(e){this.defaults=e}evaluate(e,t){let a={...this.defaults,...e.thresholds},r=[];if(t.errorRate>a.errorRate)r.push(`errorRate ${t.errorRate.toFixed(4)} > ${a.errorRate}`);if(typeof a.latencyP50==="number"&&t.latencyP50>a.latencyP50)r.push(`latencyP50 ${t.latencyP50}ms > ${a.latencyP50}ms`);if(typeof a.latencyP95==="number"&&t.latencyP95>a.latencyP95)r.push(`latencyP95 ${t.latencyP95}ms > ${a.latencyP95}ms`);if(typeof a.latencyP99==="number"&&t.latencyP99>a.latencyP99)r.push(`latencyP99 ${t.latencyP99}ms > ${a.latencyP99}ms`);if(typeof a.throughputDrop==="number"&&t.throughput<a.throughputDrop)r.push(`throughput ${t.throughput} < ${a.throughputDrop}`);if(a.customEvaluator&&!a.customEvaluator(t))r.push("custom evaluator reported failure");return{status:r.length===0?"pass":"fail",reasons:r,metrics:t}}}var l=[{percentage:1,minDurationMs:300000,label:"1%"},{percentage:10,minDurationMs:300000,label:"10%"},{percentage:50,minDurationMs:600000,label:"50%"},{percentage:100,minDurationMs:900000,label:"100%"}];class s{options;stages;constructor(e){this.options=e;this.stages=e.strategy.stages&&e.strategy.stages.length>0?e.strategy.stages:l}getStageList(){return[...this.stages]}async runStage(e){this.options.eventBus?.emit({type:"stage_started",timestamp:new Date,payload:{stage:e}});let t=await this.options.metricsProvider(e,e.minDurationMs),a=this.options.analyzer.evaluate(e,t);return this.options.eventBus?.emit({type:a.status==="pass"?"stage_passed":"stage_failed",timestamp:new Date,payload:{stage:e,metrics:t,analysis:a}}),a}}function g(e,t,a){let r=new n(e.thresholds);return new s({strategy:e,analyzer:r,metricsProvider:t,eventBus:a})}class p{options;constructor(e){this.options=e}async run(){let e=this.options.controller.getStageList();for(let t of e){let a=this.options.trafficShifter.computeSplit(t);await this.options.applyTrafficSplit(t,a);let r=await this.options.controller.runStage(t);if(r.status==="fail"){let i=await this.options.rollbackManager.execute(t,r.reasons.join(", "));return this.options.eventBus?.emit({type:"rolled_back",timestamp:i.triggeredAt,payload:{stage:t,reasons:r.reasons}}),{status:"rolled_back",failedStage:t,reasons:r.reasons}}}if(this.options.strategy.mode==="blue-green")this.options.eventBus?.emit({type:"blue_green_swapped",timestamp:new Date,payload:{strategy:this.options.strategy}});return this.options.eventBus?.emit({type:"completed",timestamp:new Date,payload:{strategy:this.options.strategy}}),{status:"completed"}}}class y{listeners=new Set;on(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e){for(let t of this.listeners)try{t(e)}catch(a){console.error("[progressive-delivery] listener error",a)}}}var o={LIFECYCLE_DETECTION_ALPHA:"lifecycle_detection_alpha",LIFECYCLE_ADVISOR_ALPHA:"lifecycle_advisor_alpha",LIFECYCLE_MANAGED_SERVICE:"lifecycle_managed_service",STUDIO_VISUAL_BUILDER:"studio_visual_builder",STUDIO_AUTO_EVOLUTION:"studio_auto_evolution",STUDIO_BYOK:"studio_byok",STUDIO_DEDICATED_DEPLOYMENT:"studio_dedicated_deployment",STUDIO_INTEGRATION_HUB:"studio_integration_hub",STUDIO_KNOWLEDGE_HUB:"studio_knowledge_hub",STUDIO_TEMPLATES:"studio_templates"},h=[o.LIFECYCLE_DETECTION_ALPHA,o.LIFECYCLE_ADVISOR_ALPHA,o.LIFECYCLE_MANAGED_SERVICE],_=[o.STUDIO_VISUAL_BUILDER,o.STUDIO_AUTO_EVOLUTION,o.STUDIO_BYOK,o.STUDIO_DEDICATED_DEPLOYMENT,o.STUDIO_INTEGRATION_HUB,o.STUDIO_KNOWLEDGE_HUB,o.STUDIO_TEMPLATES];class c{options;constructor(e){this.options=e}async execute(e,t){await this.options.rollback(e,t);let a={reason:t,stage:e,triggeredAt:new Date};return this.options.onRollback?.(a),a}}class u{mode;constructor(e){this.mode=e}computeSplit(e){if(this.mode==="blue-green")return e.percentage>=100?{stable:0,candidate:1}:{stable:1,candidate:0};let t=Math.min(Math.max(e.percentage/100,0),1);return{candidate:t,stable:1-t}}}export{_ as studioFlags,h as lifecycleFlags,g as createDefaultCanaryController,u as TrafficShifter,c as RollbackManager,y as DeploymentEventBus,p as DeploymentCoordinator,o as ContractSpecFeatureFlags,s as CanaryController,n as CanaryAnalyzer};
2
+ class n{defaults;constructor(e){this.defaults=e}evaluate(e,t){let a={...this.defaults,...e.thresholds},r=[];if(t.errorRate>a.errorRate)r.push(`errorRate ${t.errorRate.toFixed(4)} > ${a.errorRate}`);if(typeof a.latencyP50==="number"&&t.latencyP50>a.latencyP50)r.push(`latencyP50 ${t.latencyP50}ms > ${a.latencyP50}ms`);if(typeof a.latencyP95==="number"&&t.latencyP95>a.latencyP95)r.push(`latencyP95 ${t.latencyP95}ms > ${a.latencyP95}ms`);if(typeof a.latencyP99==="number"&&t.latencyP99>a.latencyP99)r.push(`latencyP99 ${t.latencyP99}ms > ${a.latencyP99}ms`);if(typeof a.throughputDrop==="number"&&t.throughput<a.throughputDrop)r.push(`throughput ${t.throughput} < ${a.throughputDrop}`);if(a.customEvaluator&&!a.customEvaluator(t))r.push("custom evaluator reported failure");return{status:r.length===0?"pass":"fail",reasons:r,metrics:t}}}var l=[{percentage:1,minDurationMs:300000,label:"1%"},{percentage:10,minDurationMs:300000,label:"10%"},{percentage:50,minDurationMs:600000,label:"50%"},{percentage:100,minDurationMs:900000,label:"100%"}];class s{options;stages;constructor(e){this.options=e;this.stages=e.strategy.stages&&e.strategy.stages.length>0?e.strategy.stages:l}getStageList(){return[...this.stages]}async runStage(e){this.options.eventBus?.emit({type:"stage_started",timestamp:new Date,payload:{stage:e}});let t=await this.options.metricsProvider(e,e.minDurationMs),a=this.options.analyzer.evaluate(e,t);return this.options.eventBus?.emit({type:a.status==="pass"?"stage_passed":"stage_failed",timestamp:new Date,payload:{stage:e,metrics:t,analysis:a}}),a}}function d(e,t,a){let r=new n(e.thresholds);return new s({strategy:e,analyzer:r,metricsProvider:t,eventBus:a})}class p{options;constructor(e){this.options=e}async run(){let e=this.options.controller.getStageList();for(let t of e){let a=this.options.trafficShifter.computeSplit(t);await this.options.applyTrafficSplit(t,a);let r=await this.options.controller.runStage(t);if(r.status==="fail"){let i=await this.options.rollbackManager.execute(t,r.reasons.join(", "));return this.options.eventBus?.emit({type:"rolled_back",timestamp:i.triggeredAt,payload:{stage:t,reasons:r.reasons}}),{status:"rolled_back",failedStage:t,reasons:r.reasons}}}if(this.options.strategy.mode==="blue-green")this.options.eventBus?.emit({type:"blue_green_swapped",timestamp:new Date,payload:{strategy:this.options.strategy}});return this.options.eventBus?.emit({type:"completed",timestamp:new Date,payload:{strategy:this.options.strategy}}),{status:"completed"}}}class y{listeners=new Set;on(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e){for(let t of this.listeners)try{t(e)}catch(a){console.error("[progressive-delivery] listener error",a)}}}var o={LIFECYCLE_DETECTION_ALPHA:"lifecycle_detection_alpha",LIFECYCLE_ADVISOR_ALPHA:"lifecycle_advisor_alpha",LIFECYCLE_MANAGED_SERVICE:"lifecycle_managed_service",STUDIO_VISUAL_BUILDER:"studio_visual_builder",STUDIO_AUTO_EVOLUTION:"studio_auto_evolution",STUDIO_BYOK:"studio_byok",STUDIO_DEDICATED_DEPLOYMENT:"studio_dedicated_deployment",STUDIO_INTEGRATION_HUB:"studio_integration_hub",STUDIO_KNOWLEDGE_HUB:"studio_knowledge_hub",STUDIO_TEMPLATES:"studio_templates"},_=[o.LIFECYCLE_DETECTION_ALPHA,o.LIFECYCLE_ADVISOR_ALPHA,o.LIFECYCLE_MANAGED_SERVICE],E=[o.STUDIO_VISUAL_BUILDER,o.STUDIO_AUTO_EVOLUTION,o.STUDIO_BYOK,o.STUDIO_DEDICATED_DEPLOYMENT,o.STUDIO_INTEGRATION_HUB,o.STUDIO_KNOWLEDGE_HUB,o.STUDIO_TEMPLATES];import{defineFeature as c}from"@contractspec/lib.contracts-spec/features";var v=c({meta:{key:"libs.progressive-delivery",version:"1.0.0",title:"Progressive Delivery",description:"ContractSpec package declaration for @contractspec/lib.progressive-delivery.",domain:"progressive-delivery",owners:["@contractspec-core"],tags:["package","libs","progressive-delivery"],stability:"experimental"}});class u{options;constructor(e){this.options=e}async execute(e,t){await this.options.rollback(e,t);let a={reason:t,stage:e,triggeredAt:new Date};return this.options.onRollback?.(a),a}}class m{mode;constructor(e){this.mode=e}computeSplit(e){if(this.mode==="blue-green")return e.percentage>=100?{stable:0,candidate:1}:{stable:1,candidate:0};let t=Math.min(Math.max(e.percentage/100,0),1);return{candidate:t,stable:1-t}}}export{E as studioFlags,_ as lifecycleFlags,d as createDefaultCanaryController,m as TrafficShifter,u as RollbackManager,v as ProgressiveDeliveryFeature,y as DeploymentEventBus,p as DeploymentCoordinator,o as ContractSpecFeatureFlags,s as CanaryController,n as CanaryAnalyzer};
@@ -1 +1 @@
1
- class n{defaults;constructor(e){this.defaults=e}evaluate(e,t){let a={...this.defaults,...e.thresholds},r=[];if(t.errorRate>a.errorRate)r.push(`errorRate ${t.errorRate.toFixed(4)} > ${a.errorRate}`);if(typeof a.latencyP50==="number"&&t.latencyP50>a.latencyP50)r.push(`latencyP50 ${t.latencyP50}ms > ${a.latencyP50}ms`);if(typeof a.latencyP95==="number"&&t.latencyP95>a.latencyP95)r.push(`latencyP95 ${t.latencyP95}ms > ${a.latencyP95}ms`);if(typeof a.latencyP99==="number"&&t.latencyP99>a.latencyP99)r.push(`latencyP99 ${t.latencyP99}ms > ${a.latencyP99}ms`);if(typeof a.throughputDrop==="number"&&t.throughput<a.throughputDrop)r.push(`throughput ${t.throughput} < ${a.throughputDrop}`);if(a.customEvaluator&&!a.customEvaluator(t))r.push("custom evaluator reported failure");return{status:r.length===0?"pass":"fail",reasons:r,metrics:t}}}var l=[{percentage:1,minDurationMs:300000,label:"1%"},{percentage:10,minDurationMs:300000,label:"10%"},{percentage:50,minDurationMs:600000,label:"50%"},{percentage:100,minDurationMs:900000,label:"100%"}];class s{options;stages;constructor(e){this.options=e;this.stages=e.strategy.stages&&e.strategy.stages.length>0?e.strategy.stages:l}getStageList(){return[...this.stages]}async runStage(e){this.options.eventBus?.emit({type:"stage_started",timestamp:new Date,payload:{stage:e}});let t=await this.options.metricsProvider(e,e.minDurationMs),a=this.options.analyzer.evaluate(e,t);return this.options.eventBus?.emit({type:a.status==="pass"?"stage_passed":"stage_failed",timestamp:new Date,payload:{stage:e,metrics:t,analysis:a}}),a}}function g(e,t,a){let r=new n(e.thresholds);return new s({strategy:e,analyzer:r,metricsProvider:t,eventBus:a})}class p{options;constructor(e){this.options=e}async run(){let e=this.options.controller.getStageList();for(let t of e){let a=this.options.trafficShifter.computeSplit(t);await this.options.applyTrafficSplit(t,a);let r=await this.options.controller.runStage(t);if(r.status==="fail"){let i=await this.options.rollbackManager.execute(t,r.reasons.join(", "));return this.options.eventBus?.emit({type:"rolled_back",timestamp:i.triggeredAt,payload:{stage:t,reasons:r.reasons}}),{status:"rolled_back",failedStage:t,reasons:r.reasons}}}if(this.options.strategy.mode==="blue-green")this.options.eventBus?.emit({type:"blue_green_swapped",timestamp:new Date,payload:{strategy:this.options.strategy}});return this.options.eventBus?.emit({type:"completed",timestamp:new Date,payload:{strategy:this.options.strategy}}),{status:"completed"}}}class y{listeners=new Set;on(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e){for(let t of this.listeners)try{t(e)}catch(a){console.error("[progressive-delivery] listener error",a)}}}var o={LIFECYCLE_DETECTION_ALPHA:"lifecycle_detection_alpha",LIFECYCLE_ADVISOR_ALPHA:"lifecycle_advisor_alpha",LIFECYCLE_MANAGED_SERVICE:"lifecycle_managed_service",STUDIO_VISUAL_BUILDER:"studio_visual_builder",STUDIO_AUTO_EVOLUTION:"studio_auto_evolution",STUDIO_BYOK:"studio_byok",STUDIO_DEDICATED_DEPLOYMENT:"studio_dedicated_deployment",STUDIO_INTEGRATION_HUB:"studio_integration_hub",STUDIO_KNOWLEDGE_HUB:"studio_knowledge_hub",STUDIO_TEMPLATES:"studio_templates"},h=[o.LIFECYCLE_DETECTION_ALPHA,o.LIFECYCLE_ADVISOR_ALPHA,o.LIFECYCLE_MANAGED_SERVICE],_=[o.STUDIO_VISUAL_BUILDER,o.STUDIO_AUTO_EVOLUTION,o.STUDIO_BYOK,o.STUDIO_DEDICATED_DEPLOYMENT,o.STUDIO_INTEGRATION_HUB,o.STUDIO_KNOWLEDGE_HUB,o.STUDIO_TEMPLATES];class c{options;constructor(e){this.options=e}async execute(e,t){await this.options.rollback(e,t);let a={reason:t,stage:e,triggeredAt:new Date};return this.options.onRollback?.(a),a}}class u{mode;constructor(e){this.mode=e}computeSplit(e){if(this.mode==="blue-green")return e.percentage>=100?{stable:0,candidate:1}:{stable:1,candidate:0};let t=Math.min(Math.max(e.percentage/100,0),1);return{candidate:t,stable:1-t}}}export{_ as studioFlags,h as lifecycleFlags,g as createDefaultCanaryController,u as TrafficShifter,c as RollbackManager,y as DeploymentEventBus,p as DeploymentCoordinator,o as ContractSpecFeatureFlags,s as CanaryController,n as CanaryAnalyzer};
1
+ class n{defaults;constructor(e){this.defaults=e}evaluate(e,t){let a={...this.defaults,...e.thresholds},r=[];if(t.errorRate>a.errorRate)r.push(`errorRate ${t.errorRate.toFixed(4)} > ${a.errorRate}`);if(typeof a.latencyP50==="number"&&t.latencyP50>a.latencyP50)r.push(`latencyP50 ${t.latencyP50}ms > ${a.latencyP50}ms`);if(typeof a.latencyP95==="number"&&t.latencyP95>a.latencyP95)r.push(`latencyP95 ${t.latencyP95}ms > ${a.latencyP95}ms`);if(typeof a.latencyP99==="number"&&t.latencyP99>a.latencyP99)r.push(`latencyP99 ${t.latencyP99}ms > ${a.latencyP99}ms`);if(typeof a.throughputDrop==="number"&&t.throughput<a.throughputDrop)r.push(`throughput ${t.throughput} < ${a.throughputDrop}`);if(a.customEvaluator&&!a.customEvaluator(t))r.push("custom evaluator reported failure");return{status:r.length===0?"pass":"fail",reasons:r,metrics:t}}}var l=[{percentage:1,minDurationMs:300000,label:"1%"},{percentage:10,minDurationMs:300000,label:"10%"},{percentage:50,minDurationMs:600000,label:"50%"},{percentage:100,minDurationMs:900000,label:"100%"}];class s{options;stages;constructor(e){this.options=e;this.stages=e.strategy.stages&&e.strategy.stages.length>0?e.strategy.stages:l}getStageList(){return[...this.stages]}async runStage(e){this.options.eventBus?.emit({type:"stage_started",timestamp:new Date,payload:{stage:e}});let t=await this.options.metricsProvider(e,e.minDurationMs),a=this.options.analyzer.evaluate(e,t);return this.options.eventBus?.emit({type:a.status==="pass"?"stage_passed":"stage_failed",timestamp:new Date,payload:{stage:e,metrics:t,analysis:a}}),a}}function d(e,t,a){let r=new n(e.thresholds);return new s({strategy:e,analyzer:r,metricsProvider:t,eventBus:a})}class p{options;constructor(e){this.options=e}async run(){let e=this.options.controller.getStageList();for(let t of e){let a=this.options.trafficShifter.computeSplit(t);await this.options.applyTrafficSplit(t,a);let r=await this.options.controller.runStage(t);if(r.status==="fail"){let i=await this.options.rollbackManager.execute(t,r.reasons.join(", "));return this.options.eventBus?.emit({type:"rolled_back",timestamp:i.triggeredAt,payload:{stage:t,reasons:r.reasons}}),{status:"rolled_back",failedStage:t,reasons:r.reasons}}}if(this.options.strategy.mode==="blue-green")this.options.eventBus?.emit({type:"blue_green_swapped",timestamp:new Date,payload:{strategy:this.options.strategy}});return this.options.eventBus?.emit({type:"completed",timestamp:new Date,payload:{strategy:this.options.strategy}}),{status:"completed"}}}class y{listeners=new Set;on(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e){for(let t of this.listeners)try{t(e)}catch(a){console.error("[progressive-delivery] listener error",a)}}}var o={LIFECYCLE_DETECTION_ALPHA:"lifecycle_detection_alpha",LIFECYCLE_ADVISOR_ALPHA:"lifecycle_advisor_alpha",LIFECYCLE_MANAGED_SERVICE:"lifecycle_managed_service",STUDIO_VISUAL_BUILDER:"studio_visual_builder",STUDIO_AUTO_EVOLUTION:"studio_auto_evolution",STUDIO_BYOK:"studio_byok",STUDIO_DEDICATED_DEPLOYMENT:"studio_dedicated_deployment",STUDIO_INTEGRATION_HUB:"studio_integration_hub",STUDIO_KNOWLEDGE_HUB:"studio_knowledge_hub",STUDIO_TEMPLATES:"studio_templates"},_=[o.LIFECYCLE_DETECTION_ALPHA,o.LIFECYCLE_ADVISOR_ALPHA,o.LIFECYCLE_MANAGED_SERVICE],E=[o.STUDIO_VISUAL_BUILDER,o.STUDIO_AUTO_EVOLUTION,o.STUDIO_BYOK,o.STUDIO_DEDICATED_DEPLOYMENT,o.STUDIO_INTEGRATION_HUB,o.STUDIO_KNOWLEDGE_HUB,o.STUDIO_TEMPLATES];import{defineFeature as c}from"@contractspec/lib.contracts-spec/features";var v=c({meta:{key:"libs.progressive-delivery",version:"1.0.0",title:"Progressive Delivery",description:"ContractSpec package declaration for @contractspec/lib.progressive-delivery.",domain:"progressive-delivery",owners:["@contractspec-core"],tags:["package","libs","progressive-delivery"],stability:"experimental"}});class u{options;constructor(e){this.options=e}async execute(e,t){await this.options.rollback(e,t);let a={reason:t,stage:e,triggeredAt:new Date};return this.options.onRollback?.(a),a}}class m{mode;constructor(e){this.mode=e}computeSplit(e){if(this.mode==="blue-green")return e.percentage>=100?{stable:0,candidate:1}:{stable:1,candidate:0};let t=Math.min(Math.max(e.percentage/100,0),1);return{candidate:t,stable:1-t}}}export{E as studioFlags,_ as lifecycleFlags,d as createDefaultCanaryController,m as TrafficShifter,u as RollbackManager,v as ProgressiveDeliveryFeature,y as DeploymentEventBus,p as DeploymentCoordinator,o as ContractSpecFeatureFlags,s as CanaryController,n as CanaryAnalyzer};
@@ -0,0 +1 @@
1
+ export declare const ProgressiveDeliveryFeature: import("@contractspec/lib.contracts-spec").FeatureModuleSpec;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/lib.progressive-delivery",
3
- "version": "34.0.19",
3
+ "version": "34.0.21",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -27,12 +27,12 @@
27
27
  "directory": "packages/libs/progressive-delivery"
28
28
  },
29
29
  "peerDependencies": {
30
- "@contractspec/lib.observability": "3.7.20"
30
+ "@contractspec/lib.observability": "3.7.22"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@contractspec/tool.typescript": "3.7.13",
34
34
  "typescript": "^5.9.3",
35
- "@contractspec/tool.bun": "3.7.14"
35
+ "@contractspec/tool.bun": "3.7.17"
36
36
  },
37
37
  "exports": {
38
38
  ".": {
@@ -55,5 +55,8 @@
55
55
  "default": "./dist/index.js"
56
56
  }
57
57
  }
58
+ },
59
+ "dependencies": {
60
+ "@contractspec/lib.contracts-spec": "5.5.1"
58
61
  }
59
62
  }