Skip to content

Commit

Permalink
more decision model work
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanyoung-dev committed Sep 9, 2024
1 parent ac24f6d commit 571f7ef
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 32 deletions.
10 changes: 10 additions & 0 deletions src/models/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@ export interface IHrefProp {
href: string;
archived: boolean;
}

export interface ISampleSizeDefinition {
baseValue?: number;
minimumDetectableDifference?: number;
confidenceLevel?: number;
}

export interface ITemplateVariables {
[key: string]: string;
}
34 changes: 14 additions & 20 deletions src/models/decision.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import { IHrefProp, ISampleSizeDefinition, ITemplateVariables } from './common';

export interface IDecisionModelDefinition {
clientKey?: string;
href?: string;
ref?: string;
name: string;
revision: number;
archived: boolean;
deploymentConfiguration: IDeploymentConfiguration;
tags: string[];
variants: {
href: string;
};
revisions: {
href: string;
};
sampleSizeCConfig: {
baseValue: string;
minimumDetectableEffect: string;
confidenceLevel: string;
};
name?: string;
revision?: number;
archived?: boolean;
modifiedByRef?: string;
modifiedAt?: string;
deploymentConfiguration?: IDeploymentConfiguration;
tags?: string[];
variants?: IHrefProp;
revisions?: IHrefProp;
sampleSizeCConfig?: ISampleSizeDefinition;
}

export interface IDeploymentConfiguration {
Expand All @@ -44,10 +40,8 @@ export interface IDecisionModelVariant {
decisionModelDefinitionRef: string;
definition: string;
transpiledDefinition: string;
revisions: {
href: string;
};
templateVariables: string;
revisions: IHrefProp;
templateVariables: ITemplateVariables[];
inProduction?: boolean;
}

Expand Down
14 changes: 2 additions & 12 deletions src/models/flow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IHrefProp, ITemplateElement } from '.';
import { IHrefProp, ISampleSizeDefinition, ITemplateElement, ITemplateVariables } from '.';
import { IGoals } from './goal';
import { ITask } from './task';

Expand Down Expand Up @@ -62,14 +62,10 @@ export interface IFlowVariant {
name?: string;
isControl?: boolean;
assets?: ITemplateElement[];
templateVariables?: IFlowTemplateVariables;
templateVariables?: ITemplateVariables;
tasks: ITask[];
}

export interface IFlowTemplateVariables {
[key: string]: string;
}

export interface IScheduleDefinition {
type?: string;
startDate?: string;
Expand Down Expand Up @@ -143,9 +139,3 @@ export enum FlowChannel {
SMS = 'SMS',
Web = 'WEB',
}

export interface ISampleSizeDefinition {
baseValue?: number;
minimumDetectableDifference?: number;
confidenceLevel?: number;
}
3 changes: 3 additions & 0 deletions src/schema/decisionSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { z } from 'zod';

export const createDecisionSchema = z.object({});
28 changes: 28 additions & 0 deletions src/services/decisions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,34 @@ export class DecisionService extends BaseService {
}
};

/**
* Update Decision Variant
* @param {string} decisionVariantRef
* Pass in a decision variant reference (Id or FriendlyId)
* @param {IDecisionModelVariant} decisionVariant
* Pass in a decision variant, with your changes to update a decision model variant
* @returns
*/
public UpdateDecisionModelVariant = async (
decisionVariantRef: string,
decisionVariant: IDecisionModelVariant
): Promise<IDecisionModelVariant | undefined> => {
try {
const response = await this.Put(
`v2/decisionModelVariants/${decisionVariantRef}`,
decisionVariant
);

if (response.ok) {
let variant: IDecisionModelVariant = (await response.json()) as IDecisionModelVariant;

return variant;
}
} catch (ex) {
throw new Error(ex as string);
}
};

/**
* Test a decision model
* @param {IGuestContext} guestContext
Expand Down

0 comments on commit 571f7ef

Please sign in to comment.