Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeseries #435

Merged
merged 17 commits into from
Jul 23, 2024
9 changes: 9 additions & 0 deletions .changeset/smooth-lemons-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@osdk/e2e.generated.catchall": minor
"@osdk/e2e.sandbox.catchall": minor
"@osdk/shared.test": minor
"@osdk/client.api": minor
"@osdk/client": minor
---

Add support for timeseries in 2.0 syntax.
93 changes: 83 additions & 10 deletions etc/client.api.report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export interface BaseObjectSet<Q extends ObjectOrInterfaceDefinition> {
// Warning: (ae-incompatible-release-tags) The symbol "ConvertProps" is marked as @public, but its signature references "UnionIfTrue" which is marked as @internal
//
// @public
export type ConvertProps<FROM extends ObjectTypeDefinition<any> | InterfaceDefinition<any, any>, TO extends ValidToFrom<FROM>, P extends string = "$all"> = TO extends FROM ? P : TO extends ObjectTypeDefinition<any> ? ((UnionIfTrue<TO["interfaceMap"][ApiNameAsString<FROM>][P extends "$all" ? (keyof FROM["properties"] extends keyof TO["interfaceMap"][ApiNameAsString<FROM>] ? keyof FROM["properties"] : never) : DropDollarOptions<P>], P extends "$notStrict" ? true : false, "$notStrict">)) : UnionIfTrue<TO extends InterfaceDefinition<any> ? P extends "$all" ? "$all" : FROM extends ObjectTypeDefinition<any> ? DropDollarOptions<P> extends keyof FROM["inverseInterfaceMap"][ApiNameAsString<TO>] ? FROM["inverseInterfaceMap"][ApiNameAsString<TO>][DropDollarOptions<P>] : never : never : never, P extends "$notStrict" ? true : false, "$notStrict">;
export type ConvertProps<FROM extends ObjectTypeDefinition<any> | InterfaceDefinition<any, any>, TO extends ValidToFrom<FROM>, P extends string = "$all"> = TO extends FROM ? P : TO extends ObjectTypeDefinition<any> ? ((UnionIfTrue<NonNullable<TO["interfaceMap"]>[ApiNameAsString<FROM>][P extends "$all" ? (keyof FROM["properties"] extends NonNullable<keyof TO["interfaceMap"]>[ApiNameAsString<FROM>] ? keyof FROM["properties"] : never) : DropDollarOptions<P>], P extends "$notStrict" ? true : false, "$notStrict">)) : UnionIfTrue<TO extends InterfaceDefinition<any> ? P extends "$all" ? "$all" : FROM extends ObjectTypeDefinition<any> ? DropDollarOptions<P> extends keyof NonNullable<FROM["inverseInterfaceMap"]>[ApiNameAsString<TO>] ? NonNullable<FROM["inverseInterfaceMap"]>[ApiNameAsString<TO>][DropDollarOptions<P>] : never : never : never, P extends "$notStrict" ? true : false, "$notStrict">;

// @public
export interface DataValueClientToWire {
Expand Down Expand Up @@ -307,6 +307,8 @@ export const DistanceUnitMapping: {

// @public (undocumented)
export const DurationMapping: {
quarter: "QUARTERS";
quarters: "QUARTERS";
sec: "SECONDS";
seconds: "SECONDS";
min: "MINUTES";
Expand All @@ -327,8 +329,6 @@ export const DurationMapping: {
yr: "YEARS";
year: "YEARS";
years: "YEARS";
quarter: "QUARTERS";
quarters: "QUARTERS";
};

// @public (undocumented)
Expand Down Expand Up @@ -578,13 +578,13 @@ export interface PropertyValueClientToWire {
// (undocumented)
marking: string;
// (undocumented)
numericTimeseries: unknown;
numericTimeseries: TimeSeriesProperty<number>;
// (undocumented)
short: number;
// (undocumented)
string: string;
// (undocumented)
stringTimeseries: unknown;
stringTimeseries: TimeSeriesProperty<string>;
// (undocumented)
timestamp: string;
}
Expand Down Expand Up @@ -616,13 +616,13 @@ export interface PropertyValueWireToClient {
// (undocumented)
marking: string;
// (undocumented)
numericTimeseries: unknown;
numericTimeseries: TimeSeriesProperty<number>;
// (undocumented)
short: number;
// (undocumented)
string: string;
// (undocumented)
stringTimeseries: unknown;
stringTimeseries: TimeSeriesProperty<string>;
// (undocumented)
timestamp: string;
}
Expand Down Expand Up @@ -682,6 +682,79 @@ RespectNullability<S>
// @public (undocumented)
export type StringAggregateOption = "approximateDistinct";

// @public (undocumented)
export const TimeseriesDurationMapping: {
sec: "SECONDS";
seconds: "SECONDS";
min: "MINUTES";
minute: "MINUTES";
minutes: "MINUTES";
hr: "HOURS";
hrs: "HOURS";
hour: "HOURS";
hours: "HOURS";
day: "DAYS";
days: "DAYS";
wk: "WEEKS";
week: "WEEKS";
weeks: "WEEKS";
mos: "MONTHS";
month: "MONTHS";
months: "MONTHS";
yr: "YEARS";
year: "YEARS";
years: "YEARS";
ms: "MILLISECONDS";
milliseconds: "MILLISECONDS";
};

// @public (undocumented)
export interface TimeSeriesPoint<T extends string | number> {
// (undocumented)
time: string;
// (undocumented)
value: T;
}

// @public (undocumented)
export interface TimeSeriesProperty<T extends number | string> {
// (undocumented)
asyncIterPoints(query: TimeSeriesQuery): AsyncGenerator<TimeSeriesPoint<T>>;
// (undocumented)
getAllPoints(query: TimeSeriesQuery): Promise<Array<TimeSeriesPoint<T>>>;
// (undocumented)
getFirstPoint(): Promise<TimeSeriesPoint<T>>;
// (undocumented)
getLastPoint(): Promise<TimeSeriesPoint<T>>;
}

// @public (undocumented)
export type TimeSeriesQuery = {
$before: number;
$unit: keyof typeof TimeseriesDurationMapping;
$after?: never;
$startTime?: never;
$endTime?: never;
} | {
$after: number;
$unit: keyof typeof TimeseriesDurationMapping;
$before?: never;
$startTime?: never;
$endTime?: never;
} | {
$startTime: string;
$endTime?: string;
$before?: never;
$after?: never;
$unit?: never;
} | {
$startTime?: string;
$endTime: string;
$before?: never;
$after?: never;
$unit?: never;
};

// Warning: (ae-internal-missing-underscore) The name "UnionIfFalse" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
Expand All @@ -690,7 +763,7 @@ export type UnionIfFalse<S extends string, JUST_S_IF_TRUE extends boolean, E> =
// Warning: (ae-internal-missing-underscore) The name "UnionIfTrue" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
export type UnionIfTrue<S extends string, UNION_IF_TRUE extends boolean, E> = IsNever_2<S> extends true ? never : UNION_IF_TRUE extends true ? S | E : S;
export type UnionIfTrue<S extends string, UNION_IF_TRUE extends boolean, E extends string> = IsNever_2<S> extends true ? never : UNION_IF_TRUE extends true ? S | E : S;

// @public (undocumented)
export type UnorderedAggregationClause<Q extends ObjectOrInterfaceDefinition> = {
Expand Down Expand Up @@ -718,9 +791,9 @@ export type WhereClause<T extends ObjectOrInterfaceDefinition<any, any>> = OrWhe

// Warnings were encountered during analysis:
//
// src/OsdkObjectFrom.ts:92:4 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// src/OsdkObjectFrom.ts:93:4 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// src/OsdkObjectFrom.ts:149:5 - (ae-forgotten-export) The symbol "UnderlyingProps" needs to be exported by the entry point index.d.ts
// src/OsdkObjectFrom.ts:94:4 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// src/OsdkObjectFrom.ts:150:5 - (ae-forgotten-export) The symbol "UnderlyingProps" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
11 changes: 6 additions & 5 deletions packages/client.api/src/OsdkObjectFrom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export type ConvertProps<
: TO extends ObjectTypeDefinition<any> ? (
(
UnionIfTrue<
TO["interfaceMap"][ApiNameAsString<FROM>][
NonNullable<TO["interfaceMap"]>[ApiNameAsString<FROM>][
P extends "$all" ? (
keyof FROM["properties"] extends
keyof TO["interfaceMap"][ApiNameAsString<FROM>]
NonNullable<keyof TO["interfaceMap"]>[ApiNameAsString<FROM>]
? keyof FROM["properties"]
: never
)
Expand All @@ -70,9 +70,10 @@ export type ConvertProps<
: UnionIfTrue<
TO extends InterfaceDefinition<any> ? P extends "$all" ? "$all"
: FROM extends ObjectTypeDefinition<any>
? DropDollarOptions<P> extends keyof FROM["inverseInterfaceMap"][
ApiNameAsString<TO>
] ? FROM["inverseInterfaceMap"][ApiNameAsString<TO>][
? DropDollarOptions<P> extends
keyof NonNullable<FROM["inverseInterfaceMap"]>[
ApiNameAsString<TO>
] ? NonNullable<FROM["inverseInterfaceMap"]>[ApiNameAsString<TO>][
DropDollarOptions<P>
]
: never
Expand Down
23 changes: 2 additions & 21 deletions packages/client.api/src/groupby/GroupByClause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import type { ObjectOrInterfaceDefinition } from "@osdk/api";
import type { AggregatableKeys } from "../aggregate/AggregatableKeys.js";
import { TimeDurationMapping } from "../mapping/DurationMapping.js";
import type { GroupByMapper } from "./GroupByMapper.js";

export type GroupByClause<
Expand Down Expand Up @@ -52,28 +53,8 @@ export type TimestampTimeUnits =
| "HOURS";

export type DateTimeUnits = "DAYS" | "WEEKS" | "MONTHS" | "YEARS" | "QUARTERS";

export const DurationMapping = {
"sec": "SECONDS",
"seconds": "SECONDS",
"min": "MINUTES",
"minute": "MINUTES",
"minutes": "MINUTES",
"hr": "HOURS",
"hrs": "HOURS",
"hour": "HOURS",
"hours": "HOURS",
"day": "DAYS",
"days": "DAYS",
"wk": "WEEKS",
"week": "WEEKS",
"weeks": "WEEKS",
"mos": "MONTHS",
"month": "MONTHS",
"months": "MONTHS",
"yr": "YEARS",
"year": "YEARS",
"years": "YEARS",
...TimeDurationMapping,
"quarter": "QUARTERS",
"quarters": "QUARTERS",
} satisfies Record<string, DateTimeUnits | TimestampTimeUnits>;
Expand Down
7 changes: 7 additions & 0 deletions packages/client.api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ export type {
QueryReturnType,
QuerySignatureFromDef,
} from "./queries/Queries.js";
export type {
TimeSeriesPoint,
TimeSeriesProperty,
TimeSeriesQuery,
} from "./timeseries/timeseries.js";
export { TimeseriesDurationMapping } from "./timeseries/timeseries.js";

export type { LinkedType, LinkNames } from "./util/LinkUtils.js";
export type { NOOP } from "./util/NOOP.js";

Expand Down
47 changes: 47 additions & 0 deletions packages/client.api/src/mapping/DurationMapping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export const TimeDurationMapping = {
"sec": "SECONDS",
"seconds": "SECONDS",
"min": "MINUTES",
"minute": "MINUTES",
"minutes": "MINUTES",
"hr": "HOURS",
"hrs": "HOURS",
"hour": "HOURS",
"hours": "HOURS",
"day": "DAYS",
"days": "DAYS",
"wk": "WEEKS",
"week": "WEEKS",
"weeks": "WEEKS",
"mos": "MONTHS",
"month": "MONTHS",
"months": "MONTHS",
"yr": "YEARS",
"year": "YEARS",
"years": "YEARS",
} satisfies Record<
string,
| "YEARS"
| "MONTHS"
| "WEEKS"
| "DAYS"
| "HOURS"
| "MINUTES"
| "SECONDS"
>;
9 changes: 5 additions & 4 deletions packages/client.api/src/mapping/PropertyValueMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import type { Attachment, AttachmentUpload } from "../object/Attachment.js";
import type { TimeSeriesProperty } from "../timeseries/timeseries.js";

/**
* Map from the PropertyDefinition type to the typescript type that we return
Expand All @@ -36,8 +37,8 @@ export interface PropertyValueWireToClient {
string: string;
timestamp: string;

numericTimeseries: unknown;
stringTimeseries: unknown;
numericTimeseries: TimeSeriesProperty<number>;
stringTimeseries: TimeSeriesProperty<string>;
}

/**
Expand All @@ -60,6 +61,6 @@ export interface PropertyValueClientToWire {
string: string;
timestamp: string;

numericTimeseries: unknown;
stringTimeseries: unknown;
numericTimeseries: TimeSeriesProperty<number>;
stringTimeseries: TimeSeriesProperty<string>;
}
11 changes: 7 additions & 4 deletions packages/client.api/src/object/FetchPageResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ export type UnionIfFalse<S extends string, JUST_S_IF_TRUE extends boolean, E> =
: S | E;

/** @internal exposed for a test */
export type UnionIfTrue<S extends string, UNION_IF_TRUE extends boolean, E> =
IsNever<S> extends true ? never
: UNION_IF_TRUE extends true ? S | E
: S;
export type UnionIfTrue<
S extends string,
UNION_IF_TRUE extends boolean,
E extends string,
> = IsNever<S> extends true ? never
: UNION_IF_TRUE extends true ? S | E
: S;

export type FetchPageResult<
Q extends ObjectOrInterfaceDefinition,
Expand Down
Loading