From b06240dcb90875aa5e2c0633fa2f978634f06f11 Mon Sep 17 00:00:00 2001 From: AustinFash <164974949+AustinFash@users.noreply.github.com> Date: Mon, 9 Mar 2026 11:43:04 -0400 Subject: [PATCH 1/5] add then to audience sdk --- sdk/typescript-schema/common/operator.ts | 8 +++++++ .../expression/expression.ts | 23 ++++++++++++++++++- sdk/typescript-schema/index.ts | 1 + sdk/typescript-schema/operand/date-operand.ts | 19 +++++++++++++-- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/sdk/typescript-schema/common/operator.ts b/sdk/typescript-schema/common/operator.ts index df624d9..f5d8ac8 100644 --- a/sdk/typescript-schema/common/operator.ts +++ b/sdk/typescript-schema/common/operator.ts @@ -113,3 +113,11 @@ export type LocationOperator = export type LogicalOperator = "and" | "or" + +/** + * Represents operators for expressing ordered event sequences. + * Examples: + * - "then": user performed Event A, then Event B + * { operator: "then", sequence: [{ alias: "a", operand: {...} }, { alias: "b", operand: {...} }] } + */ +export type SequenceOperator = "then" diff --git a/sdk/typescript-schema/expression/expression.ts b/sdk/typescript-schema/expression/expression.ts index 5752742..1ce2435 100644 --- a/sdk/typescript-schema/expression/expression.ts +++ b/sdk/typescript-schema/expression/expression.ts @@ -1,5 +1,6 @@ import { Operand } from "../operand/operand"; -import { BinaryOperator, LogicalOperator, UnaryOperator } from "../common/operator"; +import { BinaryOperator, LogicalOperator, SequenceOperator, UnaryOperator } from "../common/operator"; +import { ModelPath } from "../common/model-path"; /** * Represents a complex expression that can evaluate to true, false, or noop. @@ -30,6 +31,24 @@ import { BinaryOperator, LogicalOperator, UnaryOperator } from "../common/operat * "right": { "model": "user", "path": "location" } * } */ +/** + * Represents a single step in an event sequence. + * The alias uniquely identifies this step so other parts of the definition (e.g., relative_to) + * can reference it. + * Examples: + * 1. Step A with a timestamp operand and event name filter: + * { + * "alias": "event1", + * "operand": { "model": "events", "path": "timestamp" }, + * "condition": { "operator": "equal", "left": { "model": "events", "path": "name" }, "right": "purchase" } + * } + */ +export type SequenceOperand = { + alias: string, + operand: ModelPath, + condition?: Expression +}; + export type Expression = // unary expression { operator: UnaryOperator, operand: Operand } @@ -37,3 +56,5 @@ export type Expression = { operator: BinaryOperator, left: Operand, right: Operand } | // logical expression group { operator: LogicalOperator, expressions: Expression[] } + | // sequence expression (A THEN B) + { operator: SequenceOperator, sequence: SequenceOperand[] } diff --git a/sdk/typescript-schema/index.ts b/sdk/typescript-schema/index.ts index dd6e5d2..6fb15b9 100644 --- a/sdk/typescript-schema/index.ts +++ b/sdk/typescript-schema/index.ts @@ -18,6 +18,7 @@ export * from './operand/date-operand'; // Export common types export * from './common/location'; +export * from './common/model-path'; export * from './common/operator'; export * from './common/version'; diff --git a/sdk/typescript-schema/operand/date-operand.ts b/sdk/typescript-schema/operand/date-operand.ts index f07f27f..27bf03c 100644 --- a/sdk/typescript-schema/operand/date-operand.ts +++ b/sdk/typescript-schema/operand/date-operand.ts @@ -38,7 +38,18 @@ export type AbsoluteDate = }; /** - * Represents a date/time relative to the current time. + * References a specific field on a named alias (e.g., a step in an event sequence). + * Examples: + * 1. Reference event1's timestamp: + * { alias: "event1", path: "timestamp" } + */ +export type AliasPath = { + alias: string, + path: string +}; + +/** + * Represents a date/time relative to the current time, or optionally relative to a named alias field. * Examples: * 1. 7 days ago: * { relative: { offset: -7, unit: "day" } } @@ -48,13 +59,17 @@ export type AbsoluteDate = * * 3. End of previous quarter: * { relative: { offset: -1, unit: "quarter", boundary: "end" } } + * + * 4. Within 7 days of event1's timestamp (for event sequencing): + * { relative: { offset: 7, unit: "day", relative_to: { alias: "event1", path: "timestamp" } } } */ export type RelativeDate = { "relative": { offset: number, unit: DateUnit, - boundary?: "start" | "end" + boundary?: "start" | "end", + relative_to?: AliasPath } }; From 326aa5554a5a3c203a70ecef312619dd87eb110c Mon Sep 17 00:00:00 2001 From: AustinFash <164974949+AustinFash@users.noreply.github.com> Date: Mon, 9 Mar 2026 12:04:51 -0400 Subject: [PATCH 2/5] fix pr --- .../expression/expression.ts | 20 +------------------ sdk/typescript-schema/index.ts | 1 + sdk/typescript-schema/operand/operand.ts | 2 ++ .../operand/sequence-operand.ts | 20 +++++++++++++++++++ 4 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 sdk/typescript-schema/operand/sequence-operand.ts diff --git a/sdk/typescript-schema/expression/expression.ts b/sdk/typescript-schema/expression/expression.ts index 1ce2435..daf9890 100644 --- a/sdk/typescript-schema/expression/expression.ts +++ b/sdk/typescript-schema/expression/expression.ts @@ -1,6 +1,6 @@ import { Operand } from "../operand/operand"; import { BinaryOperator, LogicalOperator, SequenceOperator, UnaryOperator } from "../common/operator"; -import { ModelPath } from "../common/model-path"; +import { SequenceOperand } from "../operand/sequence-operand"; /** * Represents a complex expression that can evaluate to true, false, or noop. @@ -31,24 +31,6 @@ import { ModelPath } from "../common/model-path"; * "right": { "model": "user", "path": "location" } * } */ -/** - * Represents a single step in an event sequence. - * The alias uniquely identifies this step so other parts of the definition (e.g., relative_to) - * can reference it. - * Examples: - * 1. Step A with a timestamp operand and event name filter: - * { - * "alias": "event1", - * "operand": { "model": "events", "path": "timestamp" }, - * "condition": { "operator": "equal", "left": { "model": "events", "path": "name" }, "right": "purchase" } - * } - */ -export type SequenceOperand = { - alias: string, - operand: ModelPath, - condition?: Expression -}; - export type Expression = // unary expression { operator: UnaryOperator, operand: Operand } diff --git a/sdk/typescript-schema/index.ts b/sdk/typescript-schema/index.ts index 6fb15b9..498d738 100644 --- a/sdk/typescript-schema/index.ts +++ b/sdk/typescript-schema/index.ts @@ -15,6 +15,7 @@ export * from './expression/path-expression'; export * from './operand/operand'; export * from './operand/location-operand'; export * from './operand/date-operand'; +export * from './operand/sequence-operand'; // Export common types export * from './common/location'; diff --git a/sdk/typescript-schema/operand/operand.ts b/sdk/typescript-schema/operand/operand.ts index 6e4810f..e6eb581 100644 --- a/sdk/typescript-schema/operand/operand.ts +++ b/sdk/typescript-schema/operand/operand.ts @@ -4,6 +4,7 @@ import { AggregationOperator } from "../common/operator"; import { Expression } from "../expression/expression"; import { AudienceOperand } from "./audience-operand"; import { ModelOperand } from "./model-operand"; +import { SequenceOperand } from "./sequence-operand"; /** * Represents a value that can be used in expressions, including primitive values, paths, and arithmetic operations. @@ -41,5 +42,6 @@ export type Operand = | ModelPath | ModelOperand | AudienceOperand + | SequenceOperand | { operator: AggregationOperator, group_by_model: string, operand: Operand, condition?: Expression }; // | { operator: ArithmeticOperator, left: Operand, right: Operand }; diff --git a/sdk/typescript-schema/operand/sequence-operand.ts b/sdk/typescript-schema/operand/sequence-operand.ts new file mode 100644 index 0000000..89a6a26 --- /dev/null +++ b/sdk/typescript-schema/operand/sequence-operand.ts @@ -0,0 +1,20 @@ +import { ModelPath } from "../common/model-path"; +import { Expression } from "../expression/expression"; + +/** + * Represents a single step in an event sequence. + * The alias uniquely identifies this step so other parts of the definition (e.g., relative_to) + * can reference it. + * Examples: + * 1. Step A with a timestamp operand and event name filter: + * { + * "alias": "event1", + * "operand": { "model": "events", "path": "timestamp" }, + * "condition": { "operator": "equal", "left": { "model": "events", "path": "name" }, "right": "purchase" } + * } + */ +export type SequenceOperand = { + alias: string, + operand: ModelPath, + condition?: Expression +}; From e48399d2b2559db5d2de03295c03484a9447f593 Mon Sep 17 00:00:00 2001 From: AustinFash <164974949+AustinFash@users.noreply.github.com> Date: Mon, 9 Mar 2026 12:28:41 -0400 Subject: [PATCH 3/5] more changes --- schema/audience-definition-schema.json | 66 ++++++++++++++++++- .../mp_audience_sdk/models/audience_models.py | 48 ++++++++++++-- sdk/typescript-schema/operand/operand.ts | 2 - .../schema/audience-schema.json | 66 ++++++++++++++++++- sdk/typescript-schema/tsconfig.json | 3 +- 5 files changed, 174 insertions(+), 11 deletions(-) diff --git a/schema/audience-definition-schema.json b/schema/audience-definition-schema.json index 26f0763..6ba8993 100644 --- a/schema/audience-definition-schema.json +++ b/schema/audience-definition-schema.json @@ -26,6 +26,23 @@ ], "type": "string" }, + "AliasPath": { + "additionalProperties": false, + "description": "References a specific field on a named alias (e.g., a step in an event sequence). Examples: 1. Reference event1's timestamp: { alias: \"event1\", path: \"timestamp\" }", + "properties": { + "alias": { + "type": "string" + }, + "path": { + "type": "string" + } + }, + "required": [ + "alias", + "path" + ], + "type": "object" + }, "ArithmeticOperator": { "description": "Represents mathematical operators for numeric calculations. Examples:\n- \"plus\": { value1: 5, value2: 3 } // result: 8\n- \"multiply\": { value1: 4, value2: 2 } // result: 8\n- \"mod\": { value1: 10, value2: 3 } // result: 1", "enum": [ @@ -309,6 +326,25 @@ ], "type": "object", "title": "LogicalExpression" + }, + { + "additionalProperties": false, + "properties": { + "operator": { + "$ref": "#/definitions/SequenceOperator" + }, + "sequence": { + "items": { + "$ref": "#/definitions/SequenceOperand" + }, + "type": "array" + } + }, + "required": [ + "operator", + "sequence" + ], + "type": "object" } ], "description": "Represents a complex expression that can evaluate to true, false, or noop. Examples: 1. Join expression (combining expressions from different models): { \"model\": \"user\", \"expression\": { \"operator\": \"equals\", \"left\": { \"path\": \"age\" }, \"right\": 18 } }\n\n2. Logical expression (AND): { \"operator\": \"and\", \"expressions\": [ { \"operator\": \"equals\", \"left\": { \"path\": \"country\" }, \"right\": \"US\" }, { \"operator\": \"greater_than\", \"left\": { \"path\": \"age\" }, \"right\": 18 } ] }\n\n3. Location expression: { \"operator\": \"within\", \"left\": { \"location\": { \"latitude\": 37.7749, \"longitude\": -122.4194, \"distance\": { \"value\": 10, \"unit\": \"miles\" } } }, \"right\": { \"model\": \"user\", \"path\": \"location\" } }" @@ -562,7 +598,7 @@ }, "RelativeDate": { "additionalProperties": false, - "description": "Represents a date/time relative to the current time. Examples: 1. 7 days ago: { relative: { offset: -7, unit: \"day\" } }\n\n2. Start of current month: { relative: { offset: 0, unit: \"month\", boundary: \"start\" } }\n\n3. End of previous quarter: { relative: { offset: -1, unit: \"quarter\", boundary: \"end\" } }", + "description": "Represents a date/time relative to the current time, or optionally relative to a named alias field. Examples: 1. 7 days ago: { relative: { offset: -7, unit: \"day\" } }\n\n2. Start of current month: { relative: { offset: 0, unit: \"month\", boundary: \"start\" } }\n\n3. End of previous quarter: { relative: { offset: -1, unit: \"quarter\", boundary: \"end\" } }\n\n4. Within 7 days of event1's timestamp (for event sequencing): { relative: { offset: 7, unit: \"day\", relative_to: { alias: \"event1\", path: \"timestamp\" } } }", "properties": { "relative": { "additionalProperties": false, @@ -577,6 +613,9 @@ "offset": { "type": "number" }, + "relative_to": { + "$ref": "#/definitions/AliasPath" + }, "unit": { "$ref": "#/definitions/DateUnit" } @@ -593,6 +632,31 @@ ], "type": "object" }, + "SequenceOperand": { + "additionalProperties": false, + "description": "Represents a single step in an event sequence. The alias uniquely identifies this step so other parts of the definition (e.g., relative_to) can reference it. Examples: 1. Step A with a timestamp operand and event name filter: { \"alias\": \"event1\", \"operand\": { \"model\": \"events\", \"path\": \"timestamp\" }, \"condition\": { \"operator\": \"equal\", \"left\": { \"model\": \"events\", \"path\": \"name\" }, \"right\": \"purchase\" } }", + "properties": { + "alias": { + "type": "string" + }, + "condition": { + "$ref": "#/definitions/Expression" + }, + "operand": { + "$ref": "#/definitions/ModelPath" + } + }, + "required": [ + "alias", + "operand" + ], + "type": "object" + }, + "SequenceOperator": { + "const": "then", + "description": "Represents operators for expressing ordered event sequences. Examples:\n- \"then\": user performed Event A, then Event B { operator: \"then\", sequence: [{ alias: \"a\", operand: {...} }, { alias: \"b\", operand: {...} }] }", + "type": "string" + }, "UnaryOperator": { "description": "Represents unary operators that operate on a single value. Examples:\n- \"not\": Negates a boolean expression\n- \"exist\": Checks if a value exists", "enum": [ diff --git a/sdk/python/mp_audience_sdk/models/audience_models.py b/sdk/python/mp_audience_sdk/models/audience_models.py index 2984ee8..9d50708 100644 --- a/sdk/python/mp_audience_sdk/models/audience_models.py +++ b/sdk/python/mp_audience_sdk/models/audience_models.py @@ -1,11 +1,11 @@ # generated by datamodel-codegen: # filename: audience-definition-schema.json -# timestamp: 2026-01-26T22:57:53+00:00 +# timestamp: 2026-03-09T16:26:39+00:00 from __future__ import annotations from enum import Enum -from typing import Any, List, Optional, Union +from typing import Any, List, Literal, Optional, Union from pydantic import BaseModel, ConfigDict, Field, RootModel @@ -30,6 +30,14 @@ class AggregationOperator(Enum): count = "count" +class AliasPath(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + alias: str + path: str + + class ArithmeticOperator(Enum): plus = "plus" minus = "minus" @@ -164,6 +172,7 @@ class Relative(BaseModel): ) boundary: Optional[Boundary] = None offset: float + relative_to: Optional[AliasPath] = None unit: DateUnit @@ -174,6 +183,13 @@ class RelativeDate(BaseModel): relative: Relative +class SequenceOperator(RootModel[Literal["then"]]): + root: Literal["then"] = Field( + ..., + description='Represents operators for expressing ordered event sequences. Examples:\n- "then": user performed Event A, then Event B { operator: "then", sequence: [{ alias: "a", operand: {...} }, { alias: "b", operand: {...} }] }', + ) + + class UnaryOperator(Enum): null = "null" not_null = "not_null" @@ -299,12 +315,22 @@ class LogicalExpression(BaseModel): operator: LogicalOperator +class Expression1(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + operator: SequenceOperator + sequence: List[SequenceOperand] + + class Expression( - RootModel[Union[UnaryExpression, BinaryExpression, LogicalExpression]] + RootModel[Union[UnaryExpression, BinaryExpression, LogicalExpression, Expression1]] ): - root: Union[UnaryExpression, BinaryExpression, LogicalExpression] = Field( - ..., - description='Represents a complex expression that can evaluate to true, false, or noop. Examples: 1. Join expression (combining expressions from different models): { "model": "user", "expression": { "operator": "equals", "left": { "path": "age" }, "right": 18 } }\n\n2. Logical expression (AND): { "operator": "and", "expressions": [ { "operator": "equals", "left": { "path": "country" }, "right": "US" }, { "operator": "greater_than", "left": { "path": "age" }, "right": 18 } ] }\n\n3. Location expression: { "operator": "within", "left": { "location": { "latitude": 37.7749, "longitude": -122.4194, "distance": { "value": 10, "unit": "miles" } } }, "right": { "model": "user", "path": "location" } }', + root: Union[UnaryExpression, BinaryExpression, LogicalExpression, Expression1] = ( + Field( + ..., + description='Represents a complex expression that can evaluate to true, false, or noop. Examples: 1. Join expression (combining expressions from different models): { "model": "user", "expression": { "operator": "equals", "left": { "path": "age" }, "right": 18 } }\n\n2. Logical expression (AND): { "operator": "and", "expressions": [ { "operator": "equals", "left": { "path": "country" }, "right": "US" }, { "operator": "greater_than", "left": { "path": "age" }, "right": 18 } ] }\n\n3. Location expression: { "operator": "within", "left": { "location": { "latitude": 37.7749, "longitude": -122.4194, "distance": { "value": 10, "unit": "miles" } } }, "right": { "model": "user", "path": "location" } }', + ) ) @@ -389,6 +415,15 @@ class PathExpression( ) +class SequenceOperand(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + alias: str + condition: Optional[Expression] = None + operand: ModelPath + + AudienceDefinition.model_rebuild() CountExpression1.model_rebuild() CountExpression2.model_rebuild() @@ -396,6 +431,7 @@ class PathExpression( UnaryExpression.model_rebuild() BinaryExpression.model_rebuild() LogicalExpression.model_rebuild() +Expression1.model_rebuild() LocationExpression2.model_rebuild() ModelAggregationOperand.model_rebuild() UnaryPathExpression.model_rebuild() diff --git a/sdk/typescript-schema/operand/operand.ts b/sdk/typescript-schema/operand/operand.ts index e6eb581..6e4810f 100644 --- a/sdk/typescript-schema/operand/operand.ts +++ b/sdk/typescript-schema/operand/operand.ts @@ -4,7 +4,6 @@ import { AggregationOperator } from "../common/operator"; import { Expression } from "../expression/expression"; import { AudienceOperand } from "./audience-operand"; import { ModelOperand } from "./model-operand"; -import { SequenceOperand } from "./sequence-operand"; /** * Represents a value that can be used in expressions, including primitive values, paths, and arithmetic operations. @@ -42,6 +41,5 @@ export type Operand = | ModelPath | ModelOperand | AudienceOperand - | SequenceOperand | { operator: AggregationOperator, group_by_model: string, operand: Operand, condition?: Expression }; // | { operator: ArithmeticOperator, left: Operand, right: Operand }; diff --git a/sdk/typescript-schema/schema/audience-schema.json b/sdk/typescript-schema/schema/audience-schema.json index 26f0763..6ba8993 100644 --- a/sdk/typescript-schema/schema/audience-schema.json +++ b/sdk/typescript-schema/schema/audience-schema.json @@ -26,6 +26,23 @@ ], "type": "string" }, + "AliasPath": { + "additionalProperties": false, + "description": "References a specific field on a named alias (e.g., a step in an event sequence). Examples: 1. Reference event1's timestamp: { alias: \"event1\", path: \"timestamp\" }", + "properties": { + "alias": { + "type": "string" + }, + "path": { + "type": "string" + } + }, + "required": [ + "alias", + "path" + ], + "type": "object" + }, "ArithmeticOperator": { "description": "Represents mathematical operators for numeric calculations. Examples:\n- \"plus\": { value1: 5, value2: 3 } // result: 8\n- \"multiply\": { value1: 4, value2: 2 } // result: 8\n- \"mod\": { value1: 10, value2: 3 } // result: 1", "enum": [ @@ -309,6 +326,25 @@ ], "type": "object", "title": "LogicalExpression" + }, + { + "additionalProperties": false, + "properties": { + "operator": { + "$ref": "#/definitions/SequenceOperator" + }, + "sequence": { + "items": { + "$ref": "#/definitions/SequenceOperand" + }, + "type": "array" + } + }, + "required": [ + "operator", + "sequence" + ], + "type": "object" } ], "description": "Represents a complex expression that can evaluate to true, false, or noop. Examples: 1. Join expression (combining expressions from different models): { \"model\": \"user\", \"expression\": { \"operator\": \"equals\", \"left\": { \"path\": \"age\" }, \"right\": 18 } }\n\n2. Logical expression (AND): { \"operator\": \"and\", \"expressions\": [ { \"operator\": \"equals\", \"left\": { \"path\": \"country\" }, \"right\": \"US\" }, { \"operator\": \"greater_than\", \"left\": { \"path\": \"age\" }, \"right\": 18 } ] }\n\n3. Location expression: { \"operator\": \"within\", \"left\": { \"location\": { \"latitude\": 37.7749, \"longitude\": -122.4194, \"distance\": { \"value\": 10, \"unit\": \"miles\" } } }, \"right\": { \"model\": \"user\", \"path\": \"location\" } }" @@ -562,7 +598,7 @@ }, "RelativeDate": { "additionalProperties": false, - "description": "Represents a date/time relative to the current time. Examples: 1. 7 days ago: { relative: { offset: -7, unit: \"day\" } }\n\n2. Start of current month: { relative: { offset: 0, unit: \"month\", boundary: \"start\" } }\n\n3. End of previous quarter: { relative: { offset: -1, unit: \"quarter\", boundary: \"end\" } }", + "description": "Represents a date/time relative to the current time, or optionally relative to a named alias field. Examples: 1. 7 days ago: { relative: { offset: -7, unit: \"day\" } }\n\n2. Start of current month: { relative: { offset: 0, unit: \"month\", boundary: \"start\" } }\n\n3. End of previous quarter: { relative: { offset: -1, unit: \"quarter\", boundary: \"end\" } }\n\n4. Within 7 days of event1's timestamp (for event sequencing): { relative: { offset: 7, unit: \"day\", relative_to: { alias: \"event1\", path: \"timestamp\" } } }", "properties": { "relative": { "additionalProperties": false, @@ -577,6 +613,9 @@ "offset": { "type": "number" }, + "relative_to": { + "$ref": "#/definitions/AliasPath" + }, "unit": { "$ref": "#/definitions/DateUnit" } @@ -593,6 +632,31 @@ ], "type": "object" }, + "SequenceOperand": { + "additionalProperties": false, + "description": "Represents a single step in an event sequence. The alias uniquely identifies this step so other parts of the definition (e.g., relative_to) can reference it. Examples: 1. Step A with a timestamp operand and event name filter: { \"alias\": \"event1\", \"operand\": { \"model\": \"events\", \"path\": \"timestamp\" }, \"condition\": { \"operator\": \"equal\", \"left\": { \"model\": \"events\", \"path\": \"name\" }, \"right\": \"purchase\" } }", + "properties": { + "alias": { + "type": "string" + }, + "condition": { + "$ref": "#/definitions/Expression" + }, + "operand": { + "$ref": "#/definitions/ModelPath" + } + }, + "required": [ + "alias", + "operand" + ], + "type": "object" + }, + "SequenceOperator": { + "const": "then", + "description": "Represents operators for expressing ordered event sequences. Examples:\n- \"then\": user performed Event A, then Event B { operator: \"then\", sequence: [{ alias: \"a\", operand: {...} }, { alias: \"b\", operand: {...} }] }", + "type": "string" + }, "UnaryOperator": { "description": "Represents unary operators that operate on a single value. Examples:\n- \"not\": Negates a boolean expression\n- \"exist\": Checks if a value exists", "enum": [ diff --git a/sdk/typescript-schema/tsconfig.json b/sdk/typescript-schema/tsconfig.json index 65dc70b..152cdbc 100644 --- a/sdk/typescript-schema/tsconfig.json +++ b/sdk/typescript-schema/tsconfig.json @@ -22,7 +22,8 @@ "outDir": "dist", "declaration": true, "declarationDir": "dist", - "declarationMap": false + "declarationMap": false, + "emitDeclarationOnly": true }, "include": [ "./**/*" From 0a2ad5235037315f64fdd5c79d9d6a52710514db Mon Sep 17 00:00:00 2001 From: AustinFash <164974949+AustinFash@users.noreply.github.com> Date: Mon, 9 Mar 2026 12:39:37 -0400 Subject: [PATCH 4/5] update toml --- sdk/python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml index c6e2087..7d60f0b 100644 --- a/sdk/python/pyproject.toml +++ b/sdk/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "mp_audience_sdk" -version = "0.2.8" +version = "0.2.9" description = "mParticle Audience SDK" readme = "README.md" requires-python = ">=3.11" From 2387caef367e0f087b2b6fe80145abb748bf27e1 Mon Sep 17 00:00:00 2001 From: AustinFash <164974949+AustinFash@users.noreply.github.com> Date: Tue, 10 Mar 2026 11:27:10 -0400 Subject: [PATCH 5/5] fix naming --- schema/audience-definition-schema.json | 3 ++- .../mp_audience_sdk/models/audience_models.py | 20 ++++++++++--------- .../schema/audience-schema.json | 3 ++- .../scripts/add_titles_to_schema.sh | 1 + 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/schema/audience-definition-schema.json b/schema/audience-definition-schema.json index 6ba8993..f53e15d 100644 --- a/schema/audience-definition-schema.json +++ b/schema/audience-definition-schema.json @@ -344,7 +344,8 @@ "operator", "sequence" ], - "type": "object" + "type": "object", + "title": "SequenceExpression" } ], "description": "Represents a complex expression that can evaluate to true, false, or noop. Examples: 1. Join expression (combining expressions from different models): { \"model\": \"user\", \"expression\": { \"operator\": \"equals\", \"left\": { \"path\": \"age\" }, \"right\": 18 } }\n\n2. Logical expression (AND): { \"operator\": \"and\", \"expressions\": [ { \"operator\": \"equals\", \"left\": { \"path\": \"country\" }, \"right\": \"US\" }, { \"operator\": \"greater_than\", \"left\": { \"path\": \"age\" }, \"right\": 18 } ] }\n\n3. Location expression: { \"operator\": \"within\", \"left\": { \"location\": { \"latitude\": 37.7749, \"longitude\": -122.4194, \"distance\": { \"value\": 10, \"unit\": \"miles\" } } }, \"right\": { \"model\": \"user\", \"path\": \"location\" } }" diff --git a/sdk/python/mp_audience_sdk/models/audience_models.py b/sdk/python/mp_audience_sdk/models/audience_models.py index 9d50708..62022b6 100644 --- a/sdk/python/mp_audience_sdk/models/audience_models.py +++ b/sdk/python/mp_audience_sdk/models/audience_models.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: audience-definition-schema.json -# timestamp: 2026-03-09T16:26:39+00:00 +# timestamp: 2026-03-10T15:26:29+00:00 from __future__ import annotations @@ -315,7 +315,7 @@ class LogicalExpression(BaseModel): operator: LogicalOperator -class Expression1(BaseModel): +class SequenceExpression(BaseModel): model_config = ConfigDict( extra="forbid", ) @@ -324,13 +324,15 @@ class Expression1(BaseModel): class Expression( - RootModel[Union[UnaryExpression, BinaryExpression, LogicalExpression, Expression1]] + RootModel[ + Union[UnaryExpression, BinaryExpression, LogicalExpression, SequenceExpression] + ] ): - root: Union[UnaryExpression, BinaryExpression, LogicalExpression, Expression1] = ( - Field( - ..., - description='Represents a complex expression that can evaluate to true, false, or noop. Examples: 1. Join expression (combining expressions from different models): { "model": "user", "expression": { "operator": "equals", "left": { "path": "age" }, "right": 18 } }\n\n2. Logical expression (AND): { "operator": "and", "expressions": [ { "operator": "equals", "left": { "path": "country" }, "right": "US" }, { "operator": "greater_than", "left": { "path": "age" }, "right": 18 } ] }\n\n3. Location expression: { "operator": "within", "left": { "location": { "latitude": 37.7749, "longitude": -122.4194, "distance": { "value": 10, "unit": "miles" } } }, "right": { "model": "user", "path": "location" } }', - ) + root: Union[ + UnaryExpression, BinaryExpression, LogicalExpression, SequenceExpression + ] = Field( + ..., + description='Represents a complex expression that can evaluate to true, false, or noop. Examples: 1. Join expression (combining expressions from different models): { "model": "user", "expression": { "operator": "equals", "left": { "path": "age" }, "right": 18 } }\n\n2. Logical expression (AND): { "operator": "and", "expressions": [ { "operator": "equals", "left": { "path": "country" }, "right": "US" }, { "operator": "greater_than", "left": { "path": "age" }, "right": 18 } ] }\n\n3. Location expression: { "operator": "within", "left": { "location": { "latitude": 37.7749, "longitude": -122.4194, "distance": { "value": 10, "unit": "miles" } } }, "right": { "model": "user", "path": "location" } }', ) @@ -431,7 +433,7 @@ class SequenceOperand(BaseModel): UnaryExpression.model_rebuild() BinaryExpression.model_rebuild() LogicalExpression.model_rebuild() -Expression1.model_rebuild() +SequenceExpression.model_rebuild() LocationExpression2.model_rebuild() ModelAggregationOperand.model_rebuild() UnaryPathExpression.model_rebuild() diff --git a/sdk/typescript-schema/schema/audience-schema.json b/sdk/typescript-schema/schema/audience-schema.json index 6ba8993..f53e15d 100644 --- a/sdk/typescript-schema/schema/audience-schema.json +++ b/sdk/typescript-schema/schema/audience-schema.json @@ -344,7 +344,8 @@ "operator", "sequence" ], - "type": "object" + "type": "object", + "title": "SequenceExpression" } ], "description": "Represents a complex expression that can evaluate to true, false, or noop. Examples: 1. Join expression (combining expressions from different models): { \"model\": \"user\", \"expression\": { \"operator\": \"equals\", \"left\": { \"path\": \"age\" }, \"right\": 18 } }\n\n2. Logical expression (AND): { \"operator\": \"and\", \"expressions\": [ { \"operator\": \"equals\", \"left\": { \"path\": \"country\" }, \"right\": \"US\" }, { \"operator\": \"greater_than\", \"left\": { \"path\": \"age\" }, \"right\": 18 } ] }\n\n3. Location expression: { \"operator\": \"within\", \"left\": { \"location\": { \"latitude\": 37.7749, \"longitude\": -122.4194, \"distance\": { \"value\": 10, \"unit\": \"miles\" } } }, \"right\": { \"model\": \"user\", \"path\": \"location\" } }" diff --git a/sdk/typescript-schema/scripts/add_titles_to_schema.sh b/sdk/typescript-schema/scripts/add_titles_to_schema.sh index 563cfea..9d0f3b5 100755 --- a/sdk/typescript-schema/scripts/add_titles_to_schema.sh +++ b/sdk/typescript-schema/scripts/add_titles_to_schema.sh @@ -22,6 +22,7 @@ $.definitions.DateOperand.anyOf[1]|RelativeDateOperand $.definitions.Expression.anyOf[0]|UnaryExpression $.definitions.Expression.anyOf[1]|BinaryExpression $.definitions.Expression.anyOf[2]|LogicalExpression +$.definitions.Expression.anyOf[3]|SequenceExpression $.definitions.PathExpression.anyOf[0]|BooleanPathExpression $.definitions.PathExpression.anyOf[1]|NumberPathExpression $.definitions.PathExpression.anyOf[2]|StringPathExpression