diff --git a/examples/basic/cli/src/index.ts b/examples/basic/cli/src/index.ts index 427e98fa7..6ea743ddc 100644 --- a/examples/basic/cli/src/index.ts +++ b/examples/basic/cli/src/index.ts @@ -185,6 +185,15 @@ async function runTests() { await checkLinksAndActionsForVentures(); + const testStringClause = await client(BoundariesUsState) + .where({ + usState: { + $startsWith: "N", + }, + }).fetchPage(); + + console.log(testStringClause.data.map(data => data.usState)); + const testAggregateCountNoGroup = await client.objects.BoundariesUsState .aggregateOrThrow({ select: { $count: true, latitude: ["min", "max", "avg"] }, diff --git a/examples/docs_example/src/osdkExample.tsx b/examples/docs_example/src/osdkExample.tsx index 0df98727a..5a7374702 100644 --- a/examples/docs_example/src/osdkExample.tsx +++ b/examples/docs_example/src/osdkExample.tsx @@ -33,7 +33,7 @@ export async function osdkObjectSetExample() { $or: [{ fullName: { $contains: "Clooney" }, employeeId: { $gt: 10 } }, { $and: [{ $not: { fullName: { $contains: "Pitt" } } }, { $or: [{ fullName: { $contains: "Downey" } }, { - fullName: { $contains: "Hemsworth" }, + fullName: { $startsWith: "Hemsworth" }, employeeId: { $gte: 20 }, }], }], diff --git a/packages/client/changelog/@unreleased/pr-111.v2.yml b/packages/client/changelog/@unreleased/pr-111.v2.yml new file mode 100644 index 000000000..e67bdb1e9 --- /dev/null +++ b/packages/client/changelog/@unreleased/pr-111.v2.yml @@ -0,0 +1,5 @@ +type: feature +feature: + description: Add startsWith for string filter + links: + - https://github.com/palantir/osdk-ts/pull/111 diff --git a/packages/client/src/query/WhereClause.ts b/packages/client/src/query/WhereClause.ts index b4ccac5af..904a23b99 100644 --- a/packages/client/src/query/WhereClause.ts +++ b/packages/client/src/query/WhereClause.ts @@ -32,7 +32,8 @@ export type PossibleWhereClauseFilters = | "$lt" | "$lte" | "$within" - | "$intersects"; + | "$intersects" + | "$startsWith"; // We need to conditional here to force the union to be distributed type MakeFilter = K extends string ? { @@ -45,7 +46,7 @@ type BaseFilter = | MakeFilter<"$eq" | "$ne" | "$contains", T> | MakeFilter<"$isNull", boolean>; -type StringFilter = BaseFilter; +type StringFilter = BaseFilter | MakeFilter<"$startsWith", string>; type NumberFilter = | BaseFilter | MakeFilter<"$gt" | "$gte" | "$lt" | "$lte", number>;