@osdk/api 0.0.4 → 0.0.6
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.
- package/CHANGELOG.md +16 -0
- package/build/js/chunk-4D6JZ4TL.js +7 -0
- package/build/js/chunk-4D6JZ4TL.js.map +1 -0
- package/build/js/chunk-BZ6L26S2.mjs +7 -0
- package/build/js/chunk-BZ6L26S2.mjs.map +1 -0
- package/build/js/chunk-SHYKLQMU.js +15 -0
- package/build/js/chunk-SHYKLQMU.js.map +1 -0
- package/build/js/chunk-SM47N47Q.js +19 -0
- package/build/js/chunk-SM47N47Q.js.map +1 -0
- package/build/js/chunk-TPXDMNRT.mjs +9 -0
- package/build/js/chunk-TPXDMNRT.mjs.map +1 -0
- package/build/js/chunk-XIJ2ZQRX.mjs +5 -0
- package/build/js/chunk-XIJ2ZQRX.mjs.map +1 -0
- package/build/js/index.js +11 -10
- package/build/js/index.js.map +1 -1
- package/build/js/index.mjs +6 -5
- package/build/js/index.mjs.map +1 -1
- package/build/js/public/objects.js +4 -3
- package/build/js/public/objects.mjs +2 -1
- package/build/js/public/utils.js +17 -0
- package/build/js/public/utils.js.map +1 -0
- package/build/js/public/utils.mjs +4 -0
- package/build/js/public/utils.mjs.map +1 -0
- package/build/types/client/Client.d.ts +1 -1
- package/build/types/client/ObjectSetCreator.d.ts +1 -1
- package/build/types/client/PageResult.d.ts +1 -1
- package/build/types/client/ThinClient.d.ts +2 -2
- package/build/types/client/createClient.d.ts +2 -2
- package/build/types/client/createOpenApiRequest.d.ts +2 -0
- package/build/types/client/createThinClient.d.ts +2 -2
- package/build/types/client/internal/conversions/legacyToModernSingleAggregationResult.d.ts +3 -3
- package/build/types/client/internal/conversions/modernToLegacyAggregationClause.d.ts +2 -2
- package/build/types/client/internal/conversions/modernToLegacyGroupByClause.d.ts +2 -2
- package/build/types/client/internal/conversions/modernToLegacyWhereClause.d.ts +3 -3
- package/build/types/client/internal/net/index.d.ts +0 -1
- package/build/types/client/object/aggregateOrThrow.d.ts +3 -3
- package/build/types/client/object/fetchPageOrThrow.d.ts +4 -4
- package/build/types/client/objectSet/LinkTypesFrom.d.ts +2 -2
- package/build/types/client/objectSet/ObjectSet.d.ts +5 -5
- package/build/types/client/objectSet/createObjectSet.d.ts +3 -3
- package/build/types/client/query/WhereClause.d.ts +1 -1
- package/build/types/client/query/aggregations/AggregatableKeys.d.ts +1 -1
- package/build/types/client/query/aggregations/AggregateOpts.d.ts +2 -2
- package/build/types/client/query/aggregations/AggregationResultsWithGroups.d.ts +1 -1
- package/build/types/client/query/aggregations/AggregationResultsWithoutGroups.d.ts +2 -2
- package/build/types/client/query/aggregations/AggregationsClause.d.ts +1 -1
- package/build/types/client/query/aggregations/AggregationsClause.test.d.ts +6 -0
- package/build/types/client/query/aggregations/AggregationsResults.d.ts +1 -1
- package/build/types/client/query/aggregations/GroupByClause.d.ts +1 -1
- package/build/types/client/query/aggregations/GroupByClause.test.d.ts +3 -0
- package/build/types/index.d.ts +6 -3
- package/build/types/ontology/ActionDefinition.d.ts +36 -0
- package/build/types/ontology/Definition.d.ts +36 -8
- package/build/types/ontology/OsdkObjectFrom.d.ts +3 -3
- package/build/types/ontology/QueryDefinition.d.ts +77 -0
- package/build/types/ontology/index.d.ts +2 -0
- package/build/types/public/utils.d.ts +2 -0
- package/package.json +3 -9
- package/build/js/chunk-I3UIWCJ4.js +0 -17
- package/build/js/chunk-I3UIWCJ4.js.map +0 -1
- package/build/js/chunk-II7ELH2S.mjs +0 -8
- package/build/js/chunk-II7ELH2S.mjs.map +0 -1
- package/build/types/client/internal/net/createOpenApiRequest.d.ts +0 -2
- /package/build/types/client/{internal/net/createOpenApiRequest.test.d.ts → createOpenApiRequest.test.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type * as ontology from "
|
|
2
|
-
import type { FetchAsJsonFn } from "
|
|
1
|
+
import type * as ontology from "../ontology";
|
|
2
|
+
import type { FetchAsJsonFn } from "../util";
|
|
3
3
|
export interface ThinClient<O extends ontology.OntologyDefinition<any>> {
|
|
4
4
|
ontology: O;
|
|
5
5
|
stack: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { OntologyDefinition } from "
|
|
1
|
+
import type { OntologyDefinition } from "../ontology";
|
|
2
2
|
import type { Client } from "./Client";
|
|
3
|
-
export declare function createClient<O extends OntologyDefinition<any>>(ontology: O, stack: string, tokenProvider: () => string, fetchFn?: typeof globalThis.fetch): Client<O>;
|
|
3
|
+
export declare function createClient<O extends OntologyDefinition<any>>(ontology: O, stack: string, tokenProvider: () => Promise<string> | string, fetchFn?: typeof globalThis.fetch): Client<O>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { OpenApiRequest } from "@osdk/gateway/types";
|
|
2
|
+
export declare function createOpenApiRequest<TExpectedResponse, AsReadableStream extends boolean = false>(basePath: string, fetchFn: typeof fetch, contextPath?: string, asReadableStream?: AsReadableStream): OpenApiRequest<AsReadableStream extends true ? ReadableStream<Uint8Array> : Exclude<TExpectedResponse, ReadableStream<Uint8Array>>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OntologyDefinition } from "
|
|
1
|
+
import type { OntologyDefinition } from "../ontology";
|
|
2
2
|
import type { ThinClient } from "./ThinClient";
|
|
3
3
|
/**
|
|
4
4
|
* The goal of the thin client is to provide a way to tree shake as much as possible.
|
|
5
5
|
*/
|
|
6
|
-
export declare function createThinClient<T extends OntologyDefinition<any>>(ontology: T, stack: string, tokenProvider: () => string, fetchFn?: typeof globalThis.fetch): ThinClient<T>;
|
|
6
|
+
export declare function createThinClient<T extends OntologyDefinition<any>>(ontology: T, stack: string, tokenProvider: () => Promise<string> | string, fetchFn?: typeof globalThis.fetch): ThinClient<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { ArrayElement } from "../../../util";
|
|
2
|
+
import type { AggregationClause, AggregationResultsWithoutGroups } from "../../query";
|
|
3
|
+
import type { Wire } from "../net";
|
|
4
4
|
export declare function legacyToModernSingleAggregationResult<AC extends AggregationClause<any, any>>(entry: ArrayElement<Wire.AggregateObjectsResponseV2["data"]>): AggregationResultsWithoutGroups<any, any, AC>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AggregationClause } from "#client/query";
|
|
2
|
-
import type { ObjectTypesFrom, OntologyDefinition } from "#ontology";
|
|
3
1
|
import type { Aggregation } from "@osdk/gateway/types";
|
|
2
|
+
import type { ObjectTypesFrom, OntologyDefinition } from "../../../ontology";
|
|
3
|
+
import type { AggregationClause } from "../../query";
|
|
4
4
|
export declare function modernToLegacyAggregationClause<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, AC extends AggregationClause<T, K>>(select: AC): Aggregation[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GroupByClause } from "#client/query";
|
|
2
|
-
import type { ObjectTypesFrom, OntologyDefinition } from "#ontology";
|
|
3
1
|
import type { AggregationGroupByV2 } from "@osdk/gateway/types";
|
|
2
|
+
import type { ObjectTypesFrom, OntologyDefinition } from "../../../ontology";
|
|
3
|
+
import type { GroupByClause } from "../../query";
|
|
4
4
|
export declare function modernToLegacyGroupByClause<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>>(groupByClause: GroupByClause<O, K> | undefined): AggregationGroupByV2[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { ObjectDefinition } from "../../../ontology";
|
|
2
|
+
import type { WhereClause } from "../../query";
|
|
3
|
+
import type { Wire } from "../net";
|
|
4
4
|
export declare function modernToLegacyWhereClause<T extends ObjectDefinition<any, any>>(whereClause: WhereClause<T>): Wire.SearchJsonQueryV2;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ObjectTypesFrom, OntologyDefinition } from "../../ontology";
|
|
2
|
+
import type { AggregationsResults } from "../query";
|
|
3
3
|
import type { AggregateOpts } from "../query/aggregations/AggregateOpts";
|
|
4
4
|
import type { ThinClient } from "../ThinClient";
|
|
5
|
-
export declare function aggregateOrThrow<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, const AO extends AggregateOpts<T, K, any>>(thinClient: ThinClient<T>, objectType: K, req: AO): Promise<AggregationsResults<T, K, AO>>;
|
|
5
|
+
export declare function aggregateOrThrow<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, const AO extends AggregateOpts<T, K, any>>(thinClient: ThinClient<T>, objectType: K & string, req: AO): Promise<AggregationsResults<T, K, AO>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectFrom, PropertyKeysFrom } from "../../ontology";
|
|
2
|
+
import type { NOOP } from "../../util";
|
|
3
|
+
import type { Wire } from "../internal/net";
|
|
4
4
|
import type { PageResult } from "../PageResult";
|
|
5
5
|
import type { ThinClient } from "../ThinClient";
|
|
6
6
|
export interface FetchPageOrThrowArgs<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, L extends PropertyKeysFrom<O, K>> {
|
|
7
7
|
select?: readonly L[];
|
|
8
8
|
nextPageToken?: string;
|
|
9
9
|
}
|
|
10
|
-
export declare function fetchPageOrThrow<O extends OntologyDefinition<any>, T extends ObjectTypesFrom<O>, const A extends FetchPageOrThrowArgs<O, T, PropertyKeysFrom<O, T>>>(client: ThinClient<O>, objectType: T, args: A, objectSet?: Wire.ObjectSet): Promise<PageResult<NOOP<OsdkObjectFrom<T, O, A["select"] extends readonly string[] ? A["select"][number] : PropertyKeysFrom<O, T>>>>>;
|
|
10
|
+
export declare function fetchPageOrThrow<O extends OntologyDefinition<any>, T extends ObjectTypesFrom<O>, const A extends FetchPageOrThrowArgs<O, T, PropertyKeysFrom<O, T>>>(client: ThinClient<O>, objectType: T & string, args: A, objectSet?: Wire.ObjectSet): Promise<PageResult<NOOP<OsdkObjectFrom<T, O, A["select"] extends readonly string[] ? A["select"][number] : PropertyKeysFrom<O, T>>>>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ObjectTypesFrom, OntologyDefinition } from "
|
|
2
|
-
export type LinkTypesFrom<O extends OntologyDefinition<string>, K extends ObjectTypesFrom<O>> = keyof O["objects"][K]["links"]
|
|
1
|
+
import type { ObjectTypesFrom, OntologyDefinition } from "../../ontology";
|
|
2
|
+
export type LinkTypesFrom<O extends OntologyDefinition<string>, K extends ObjectTypesFrom<O>> = keyof O["objects"][K]["links"];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectFrom, PropertyKeysFrom } from "#ontology";
|
|
1
|
+
import type { ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectFrom, PropertyKeysFrom } from "../../ontology";
|
|
3
2
|
import type { FetchPageOrThrowArgs } from "../object/fetchPageOrThrow";
|
|
4
3
|
import type { PageResult } from "../PageResult";
|
|
4
|
+
import type { AggregationsResults, WhereClause } from "../query";
|
|
5
5
|
import type { AggregateOpts } from "../query/aggregations/AggregateOpts";
|
|
6
6
|
import type { ResultOrError } from "../ResultOrError";
|
|
7
7
|
import type { LinkTypesFrom } from "./LinkTypesFrom";
|
|
8
8
|
export type ObjectSet<O extends OntologyDefinition<string>, K extends ObjectTypesFrom<O>> = BaseObjectSet<O, K>;
|
|
9
9
|
export type SearchAround<O extends OntologyDefinition<string>, K extends ObjectTypesFrom<O>> = {
|
|
10
|
-
[L in LinkTypesFrom<O, K> as `searchAround_${L}`]: () => ObjectSet<O, L>;
|
|
10
|
+
[L in LinkTypesFrom<O, K> & string as `searchAround_${L}`]: () => ObjectSet<O, L>;
|
|
11
11
|
};
|
|
12
12
|
export interface BaseObjectSet<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> {
|
|
13
13
|
fetchPageOrThrow: <L extends PropertyKeysFrom<O, K>>(args?: FetchPageOrThrowArgs<O, K, L>) => Promise<PageResult<OsdkObjectFrom<K, O, L>>>;
|
|
@@ -17,9 +17,9 @@ export interface BaseObjectSet<O extends OntologyDefinition<any>, K extends Obje
|
|
|
17
17
|
aggregateOrThrow: <const AO extends AggregateOpts<O, K, any>>(req: AO) => Promise<AggregationsResults<O, K, AO>>;
|
|
18
18
|
aggregate: <const AO extends AggregateOpts<O, K, any>>(req: AO) => Promise<ResultOrError<AggregationsResults<O, K, typeof req>>>;
|
|
19
19
|
where: (clause: WhereClause<ObjectInfoFrom<O, K>>) => ObjectSet<O, K>;
|
|
20
|
-
pivotTo: <T extends LinkTypesFrom<O, K>>(type: T, opts?: ObjectSetOptions<O, O["objects"][K]["links"][T]["targetType"]>) => ObjectSet<O, O["objects"][K]["links"][T]["targetType"]>;
|
|
20
|
+
pivotTo: <T extends LinkTypesFrom<O, K>>(type: T & string, opts?: ObjectSetOptions<O, O["objects"][K]["links"][T]["targetType"]>) => ObjectSet<O, O["objects"][K]["links"][T]["targetType"]>;
|
|
21
21
|
}
|
|
22
22
|
export interface ObjectSetOptions<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> {
|
|
23
23
|
$where?: WhereClause<ObjectInfoFrom<O, K>>;
|
|
24
24
|
}
|
|
25
|
-
export type ObjectSetFactory<O extends OntologyDefinition<any>> = <K extends ObjectTypesFrom<O>>(type: K, opts?: ObjectSetOptions<O, K>) => ObjectSet<O, K>;
|
|
25
|
+
export type ObjectSetFactory<O extends OntologyDefinition<any>> = <K extends ObjectTypesFrom<O>>(type: K & string, opts?: ObjectSetOptions<O, K>) => ObjectSet<O, K>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ObjectTypesFrom, OntologyDefinition } from "../../ontology";
|
|
2
|
+
import type { Wire } from "../internal/net";
|
|
3
3
|
import type { ThinClient } from "../ThinClient";
|
|
4
4
|
import type { ObjectSet, ObjectSetOptions } from "./ObjectSet";
|
|
5
|
-
export declare function createObjectSet<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>>(objectType: K, thinClient: ThinClient<O>, opts: ObjectSetOptions<O, K> | undefined, objectSet?: Wire.ObjectSet): ObjectSet<O, K>;
|
|
5
|
+
export declare function createObjectSet<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>>(objectType: K & string, thinClient: ThinClient<O>, opts: ObjectSetOptions<O, K> | undefined, objectSet?: Wire.ObjectSet): ObjectSet<O, K>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectDefinition, PropertyDefinition } from "
|
|
1
|
+
import type { ObjectDefinition, PropertyDefinition } from "../../ontology";
|
|
2
2
|
export type PossibleWhereClauseFilters = "gt" | "eq" | "ne" | "isNull" | "gte" | "lt" | "lte";
|
|
3
3
|
type MakeFilter<K extends PossibleWhereClauseFilters, V> = K extends string ? Omit<{
|
|
4
4
|
[k in PossibleWhereClauseFilters]?: undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectTypesFrom, OntologyDefinition, PropertyKeysFrom } from "
|
|
1
|
+
import type { ObjectTypesFrom, OntologyDefinition, PropertyKeysFrom } from "../../../ontology";
|
|
2
2
|
export type AggregatableKeys<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = keyof {
|
|
3
3
|
[P in PropertyKeysFrom<O, K>]: any;
|
|
4
4
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition } from "../../../ontology";
|
|
2
|
+
import type { AggregationClause, GroupByClause, WhereClause } from "../../query";
|
|
3
3
|
export type AggregateOpts<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, AC extends AggregationClause<T, K>> = {
|
|
4
4
|
select: AC;
|
|
5
5
|
where?: WhereClause<ObjectInfoFrom<T, K>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinitionFrom, PropertyKeysFrom } from "
|
|
1
|
+
import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinitionFrom, PropertyKeysFrom } from "../../../ontology";
|
|
2
2
|
import type { AggregationResultsWithoutGroups } from "./AggregationResultsWithoutGroups";
|
|
3
3
|
import type { AggregationClause } from "./AggregationsClause";
|
|
4
4
|
import type { GroupByClause } from "./GroupByClause";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinitionFrom, PropertyKeysFrom } from "
|
|
2
|
-
import type { StringArrayToUnion } from "
|
|
1
|
+
import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinitionFrom, PropertyKeysFrom } from "../../../ontology";
|
|
2
|
+
import type { StringArrayToUnion } from "../../../util";
|
|
3
3
|
import type { AggregationClause } from "./AggregationsClause";
|
|
4
4
|
type SubselectKeys<AC extends AggregationClause<any, any>, P extends keyof AC> = AC[P] extends readonly string[] | string ? P : never;
|
|
5
5
|
export type AggregationResultsWithoutGroups<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, AC extends AggregationClause<O, K>> = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectTypesFrom, OntologyDefinition, PropertyDefinitionsFrom } from "
|
|
1
|
+
import type { ObjectTypesFrom, OntologyDefinition, PropertyDefinitionsFrom } from "../../../ontology";
|
|
2
2
|
import type { AggregatableKeys } from "./AggregatableKeys";
|
|
3
3
|
type StringAggregateOption = "approximateDistinct";
|
|
4
4
|
type NumericAggregateOption = "min" | "max" | "sum" | "avg" | "approximateDistinct";
|
|
@@ -5,6 +5,7 @@ export type huh = AggregatableKeys<{
|
|
|
5
5
|
objects: {
|
|
6
6
|
Todo: {
|
|
7
7
|
apiName: "Todo";
|
|
8
|
+
primaryKeyType: "double";
|
|
8
9
|
links: {};
|
|
9
10
|
properties: {
|
|
10
11
|
text: {
|
|
@@ -16,12 +17,15 @@ export type huh = AggregatableKeys<{
|
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
19
|
};
|
|
20
|
+
actions: {};
|
|
21
|
+
queries: {};
|
|
19
22
|
}, "Todo">;
|
|
20
23
|
export type Q = AggregationClause<{
|
|
21
24
|
metadata: any;
|
|
22
25
|
objects: {
|
|
23
26
|
Todo: {
|
|
24
27
|
apiName: "Todo";
|
|
28
|
+
primaryKeyType: "double";
|
|
25
29
|
links: {};
|
|
26
30
|
properties: {
|
|
27
31
|
text: {
|
|
@@ -33,4 +37,6 @@ export type Q = AggregationClause<{
|
|
|
33
37
|
};
|
|
34
38
|
};
|
|
35
39
|
};
|
|
40
|
+
actions: {};
|
|
41
|
+
queries: {};
|
|
36
42
|
}, "Todo">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectTypesFrom, OntologyDefinition } from "
|
|
1
|
+
import type { ObjectTypesFrom, OntologyDefinition } from "../../../ontology";
|
|
2
2
|
import type { AggregateOpts } from "./AggregateOpts";
|
|
3
3
|
import type { AggregationResultsWithGroups } from "./AggregationResultsWithGroups";
|
|
4
4
|
import type { AggregationResultsWithoutGroups } from "./AggregationResultsWithoutGroups";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectTypesFrom, OntologyDefinition, PropertyDefinitionFrom } from "
|
|
1
|
+
import type { ObjectTypesFrom, OntologyDefinition, PropertyDefinitionFrom } from "../../../ontology";
|
|
2
2
|
import type { AggregatableKeys } from "./AggregatableKeys";
|
|
3
3
|
import type { GroupByMapper } from "./GroupByMapper";
|
|
4
4
|
export type GroupByClause<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = {
|
|
@@ -4,6 +4,7 @@ export type F = GroupByClause<{
|
|
|
4
4
|
objects: {
|
|
5
5
|
Todo: {
|
|
6
6
|
apiName: "Todo";
|
|
7
|
+
primaryKeyType: "double";
|
|
7
8
|
links: {};
|
|
8
9
|
properties: {
|
|
9
10
|
text: {
|
|
@@ -15,4 +16,6 @@ export type F = GroupByClause<{
|
|
|
15
16
|
};
|
|
16
17
|
};
|
|
17
18
|
};
|
|
19
|
+
actions: {};
|
|
20
|
+
queries: {};
|
|
18
21
|
}, "Todo">;
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export type { WhereClause } from "#client/query";
|
|
2
|
-
export type { OsdkObject } from "#ontology";
|
|
3
1
|
export { createClient, createThinClient, isOk } from "./client";
|
|
4
2
|
export type { Client, ObjectSet, ResultOrError, ThinClient } from "./client";
|
|
3
|
+
export { createOpenApiRequest } from "./client/createOpenApiRequest";
|
|
4
|
+
export type { WhereClause } from "./client/query";
|
|
5
|
+
export type { OsdkObject } from "./ontology";
|
|
5
6
|
export * as Objects from "./client/object";
|
|
6
|
-
export type { ObjectDefinition, OntologyDefinition, } from "./ontology/Definition";
|
|
7
|
+
export type { LinkDefinitionFrom, LinkKeysFrom, LinkTargetTypeFrom, ObjectDefinition, ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinition, PropertyDefinitionFrom, PropertyDefinitionsFrom, PropertyKeysFrom, ValidPropertyTypes, } from "./ontology/Definition";
|
|
8
|
+
export type { ActionDefinition, ActionModifiedEntity, ActionParameterDefinition, ValidActionParameterTypes, } from "./ontology/ActionDefinition";
|
|
9
|
+
export type { QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalQueryAggregationDefinition, } from "./ontology/QueryDefinition";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface ActionDefinition<A extends string, K extends string> {
|
|
2
|
+
apiName: A;
|
|
3
|
+
description?: string;
|
|
4
|
+
displayName?: string;
|
|
5
|
+
parameters: Record<string, ActionParameterDefinition<K>>;
|
|
6
|
+
modifiedEntities?: Partial<Record<K, ActionModifiedEntity>>;
|
|
7
|
+
}
|
|
8
|
+
export interface ActionModifiedEntity {
|
|
9
|
+
created: boolean;
|
|
10
|
+
modified: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ValidBaseActionParameterTypes {
|
|
13
|
+
boolean: boolean;
|
|
14
|
+
string: string;
|
|
15
|
+
integer: number;
|
|
16
|
+
long: number;
|
|
17
|
+
double: number;
|
|
18
|
+
datetime: Date;
|
|
19
|
+
timestamp: Date;
|
|
20
|
+
attachment: any;
|
|
21
|
+
}
|
|
22
|
+
export interface ObjectActionDataType<K extends string> {
|
|
23
|
+
type: "object";
|
|
24
|
+
object: K;
|
|
25
|
+
}
|
|
26
|
+
export interface ObjectSetActionDataType<K extends string> {
|
|
27
|
+
type: "objectSet";
|
|
28
|
+
objectSet: K;
|
|
29
|
+
}
|
|
30
|
+
export type ValidActionParameterTypes<K extends string = never> = keyof ValidBaseActionParameterTypes | ObjectActionDataType<K> | ObjectSetActionDataType<K>;
|
|
31
|
+
export interface ActionParameterDefinition<K extends string = never> {
|
|
32
|
+
type: ValidActionParameterTypes<K>;
|
|
33
|
+
description?: string;
|
|
34
|
+
multiplicity?: boolean;
|
|
35
|
+
nullable?: boolean;
|
|
36
|
+
}
|
|
@@ -1,36 +1,64 @@
|
|
|
1
|
+
import type { ActionDefinition } from "./ActionDefinition";
|
|
1
2
|
import type { OntologyMetadata } from "./OntologyMetadata";
|
|
3
|
+
import type { QueryDefinition } from "./QueryDefinition";
|
|
2
4
|
export type ObjectInfoFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = O["objects"][K];
|
|
3
|
-
export type ObjectTypesFrom<O extends OntologyDefinition<string>> = keyof O["objects"]
|
|
4
|
-
export type PropertyKeysFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = keyof ObjectInfoFrom<O, K>["properties"]
|
|
5
|
+
export type ObjectTypesFrom<O extends OntologyDefinition<string>> = keyof O["objects"];
|
|
6
|
+
export type PropertyKeysFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = keyof ObjectInfoFrom<O, K>["properties"];
|
|
5
7
|
export type PropertyDefinitionsFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = ObjectInfoFrom<O, K>["properties"];
|
|
6
8
|
export type PropertyDefinitionFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, P extends PropertyKeysFrom<O, K>> = PropertyDefinitionsFrom<O, K>[P];
|
|
7
|
-
export interface OntologyDefinition<K extends string> {
|
|
9
|
+
export interface OntologyDefinition<K extends string, A extends string = any, Q extends string = any> {
|
|
8
10
|
metadata: OntologyMetadata;
|
|
9
11
|
objects: {
|
|
10
12
|
[KK in K]: ObjectDefinition<KK, K>;
|
|
11
13
|
};
|
|
14
|
+
actions: {
|
|
15
|
+
[AA in A]: ActionDefinition<AA, K>;
|
|
16
|
+
};
|
|
17
|
+
queries: {
|
|
18
|
+
[QQ in Q]: QueryDefinition<Q>;
|
|
19
|
+
};
|
|
12
20
|
}
|
|
13
|
-
export interface ObjectDefinition<
|
|
14
|
-
apiName:
|
|
21
|
+
export interface ObjectDefinition<K extends string, L extends string> {
|
|
22
|
+
apiName: K;
|
|
23
|
+
description?: string;
|
|
24
|
+
primaryKeyType: keyof ValidPropertyTypes;
|
|
15
25
|
properties: Record<string, PropertyDefinition>;
|
|
16
|
-
links: Record<string, LinkDefinition<
|
|
26
|
+
links: Record<string, LinkDefinition<L>>;
|
|
17
27
|
}
|
|
28
|
+
export type LinkKeysFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = keyof ObjectInfoFrom<O, K>["links"];
|
|
18
29
|
export interface LinkDefinition<K extends string> {
|
|
19
30
|
targetType: K;
|
|
20
31
|
multiplicity: boolean;
|
|
21
32
|
}
|
|
33
|
+
export type LinkDefinitionFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, L extends LinkKeysFrom<O, K>> = ObjectInfoFrom<O, K>["links"][L];
|
|
34
|
+
export type LinkTargetTypeFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, L extends LinkKeysFrom<O, K>> = LinkDefinitionFrom<O, K, L>["targetType"];
|
|
22
35
|
export interface PropertyDefinition {
|
|
23
36
|
readonly?: boolean;
|
|
37
|
+
displayName?: string;
|
|
38
|
+
description?: string;
|
|
24
39
|
type: keyof ValidPropertyTypes;
|
|
40
|
+
multiplicity?: boolean;
|
|
25
41
|
nullable?: boolean;
|
|
26
42
|
}
|
|
27
|
-
interface ValidPropertyTypes {
|
|
43
|
+
export interface ValidPropertyTypes {
|
|
28
44
|
string: string;
|
|
29
45
|
datetime: Date;
|
|
30
46
|
double: number;
|
|
31
47
|
boolean: boolean;
|
|
48
|
+
integer: number;
|
|
49
|
+
timestamp: Date;
|
|
50
|
+
short: number;
|
|
51
|
+
long: number;
|
|
52
|
+
float: number;
|
|
53
|
+
decimal: number;
|
|
54
|
+
byte: number;
|
|
55
|
+
attachment: any;
|
|
56
|
+
geopoint: any;
|
|
57
|
+
geoshape: any;
|
|
32
58
|
}
|
|
33
|
-
|
|
59
|
+
type MaybeArray<T extends PropertyDefinition, U> = T["multiplicity"] extends true ? Array<U> : U;
|
|
60
|
+
type MaybeNullable<T extends PropertyDefinition, U> = T["nullable"] extends true ? U | undefined : U;
|
|
61
|
+
export type OsdkObjectPropertyType<T extends PropertyDefinition> = MaybeNullable<T, MaybeArray<T, ValidPropertyTypes[T["type"]]>>;
|
|
34
62
|
export type OsdkObjectLink<K extends string, O extends OntologyDefinition<K>, T extends LinkDefinition<any>> = T["multiplicity"] extends true ? Array<OsdkObjectLink_Inner<K, O, T>> : OsdkObjectLink_Inner<K, O, T>;
|
|
35
63
|
type OsdkObjectLink_Inner<K extends string, O extends OntologyDefinition<K>, T extends LinkDefinition<any>> = T["targetType"] extends keyof O["objects"] ? O["objects"][T["targetType"]] : never;
|
|
36
64
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OntologyDefinition, OsdkObjectPropertyType, PropertyKeysFrom } from "./Definition";
|
|
2
|
-
export type OsdkObjectFrom<K extends
|
|
3
|
-
[P in
|
|
1
|
+
import type { ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyKeysFrom } from "./Definition";
|
|
2
|
+
export type OsdkObjectFrom<K extends ObjectTypesFrom<T>, T extends OntologyDefinition<any>, PP extends PropertyKeysFrom<T, K>> = {
|
|
3
|
+
[P in PP]: OsdkObjectPropertyType<ObjectInfoFrom<T, K>["properties"][P]>;
|
|
4
4
|
} & {
|
|
5
5
|
__name: K;
|
|
6
6
|
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export interface QueryDefinition<Q extends string> {
|
|
2
|
+
apiName: Q;
|
|
3
|
+
description?: string;
|
|
4
|
+
displayName?: string;
|
|
5
|
+
rid: string;
|
|
6
|
+
version: string;
|
|
7
|
+
parameters: Record<string, QueryParameterDefinition>;
|
|
8
|
+
output: QueryDataTypeDefinition;
|
|
9
|
+
}
|
|
10
|
+
export interface QueryParameterDefinition {
|
|
11
|
+
description?: string;
|
|
12
|
+
dataType: QueryDataTypeDefinition;
|
|
13
|
+
}
|
|
14
|
+
export interface QueryDataTypeDefinition {
|
|
15
|
+
type: QueryDataType;
|
|
16
|
+
multiplicity?: boolean;
|
|
17
|
+
nullable?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export type QueryDataType = keyof ValidBaseQueryDataTypes | ObjectQueryDataType<any> | ObjectSetQueryDataType<any> | SetQueryDataType | UnionQueryDataType | StructQueryDataType | TwoDimensionalAggregationDataType | ThreeDimensionalAggregationDataType;
|
|
20
|
+
export interface ValidBaseQueryDataTypes {
|
|
21
|
+
double: number;
|
|
22
|
+
float: number;
|
|
23
|
+
integer: number;
|
|
24
|
+
long: number;
|
|
25
|
+
boolean: boolean;
|
|
26
|
+
string: string;
|
|
27
|
+
date: Date;
|
|
28
|
+
timestamp: Date;
|
|
29
|
+
attachment: any;
|
|
30
|
+
}
|
|
31
|
+
export interface ObjectQueryDataType<K extends string> {
|
|
32
|
+
type: "object";
|
|
33
|
+
object: K;
|
|
34
|
+
}
|
|
35
|
+
export interface ObjectSetQueryDataType<K extends string> {
|
|
36
|
+
type: "objectSet";
|
|
37
|
+
objectSet: K;
|
|
38
|
+
}
|
|
39
|
+
export interface SetQueryDataType {
|
|
40
|
+
type: "set";
|
|
41
|
+
set: QueryDataTypeDefinition;
|
|
42
|
+
}
|
|
43
|
+
export interface UnionQueryDataType {
|
|
44
|
+
type: "union";
|
|
45
|
+
union: ReadonlyArray<QueryDataTypeDefinition>;
|
|
46
|
+
}
|
|
47
|
+
export interface StructQueryDataType {
|
|
48
|
+
type: "struct";
|
|
49
|
+
struct: ReadonlyArray<{
|
|
50
|
+
name: string;
|
|
51
|
+
fieldType: QueryDataTypeDefinition;
|
|
52
|
+
}>;
|
|
53
|
+
}
|
|
54
|
+
export interface TwoDimensionalAggregationDataType {
|
|
55
|
+
type: "twoDimensionalAggregation";
|
|
56
|
+
twoDimensionalAggregation: TwoDimensionalQueryAggregationDefinition;
|
|
57
|
+
}
|
|
58
|
+
export interface ThreeDimensionalAggregationDataType {
|
|
59
|
+
type: "threeDimensionalAggregation";
|
|
60
|
+
threeDimensionalAggregation: ThreeDimensionalQueryAggregationDefinition;
|
|
61
|
+
}
|
|
62
|
+
export type TwoDimensionalQueryAggregationDefinition = {
|
|
63
|
+
valueType: "date" | "double" | "timestamp";
|
|
64
|
+
} & ({
|
|
65
|
+
keyType: "boolean" | "date" | "double" | "integer" | "string" | "timestamp";
|
|
66
|
+
} | {
|
|
67
|
+
keyType: "range";
|
|
68
|
+
keySubtype: "date" | "double" | "integer" | "timestamp";
|
|
69
|
+
});
|
|
70
|
+
export type ThreeDimensionalQueryAggregationDefinition = {
|
|
71
|
+
valueType: TwoDimensionalQueryAggregationDefinition;
|
|
72
|
+
} & ({
|
|
73
|
+
keyType: "boolean" | "date" | "double" | "integer" | "string" | "timestamp";
|
|
74
|
+
} | {
|
|
75
|
+
keyType: "range";
|
|
76
|
+
keySubtype: "date" | "double" | "integer" | "timestamp";
|
|
77
|
+
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export type * from "./ActionDefinition";
|
|
1
2
|
export type * from "./Definition";
|
|
2
3
|
export type { OntologyMetadata } from "./OntologyMetadata";
|
|
3
4
|
export type { OsdkObject } from "./OsdkObject";
|
|
4
5
|
export type { OsdkObjectFrom } from "./OsdkObjectFrom";
|
|
6
|
+
export type * from "./QueryDefinition";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"fetch-retry": "^5.0.6",
|
|
21
21
|
"tiny-invariant": "^1.3.1",
|
|
22
|
-
"@osdk/gateway": "0.0.
|
|
22
|
+
"@osdk/gateway": "0.0.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"ts-expect": "^1.3.0",
|
|
@@ -28,13 +28,6 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"imports": {
|
|
32
|
-
"#net": "./src/client/internal/net/index.ts",
|
|
33
|
-
"#util": "./src/util/index.ts",
|
|
34
|
-
"#ontology": "./src/ontology/index.ts",
|
|
35
|
-
"#client/converters": "./src/client/internal/conversions/index.ts",
|
|
36
|
-
"#client/query": "./src/client/query/index.ts"
|
|
37
|
-
},
|
|
38
31
|
"keywords": [],
|
|
39
32
|
"files": [
|
|
40
33
|
"build/types",
|
|
@@ -42,6 +35,7 @@
|
|
|
42
35
|
"CHANGELOG.md",
|
|
43
36
|
"package.json"
|
|
44
37
|
],
|
|
38
|
+
"types": "./build/types/index.d.ts",
|
|
45
39
|
"scripts": {
|
|
46
40
|
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
|
|
47
41
|
"dev:transpile": "tsup --watch",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var a = require('tiny-invariant');
|
|
4
|
-
var requests = require('@osdk/gateway/requests');
|
|
5
|
-
|
|
6
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var a__default = /*#__PURE__*/_interopDefault(a);
|
|
9
|
-
|
|
10
|
-
var E=Object.defineProperty;var $=(o,r)=>{for(var e in r)E(o,e,{get:r[e],enumerable:!0});};function g(o){return o.metrics.reduce((r,e)=>{let t=e.name.split(".");return t.length!=2&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"assumed we were getting a `${key}.${type}`"):a__default.default(!1)),t[0]in r||(r[t[0]]={}),r[t[0]][t[1]]=e.value,r},{})}function y(o){return Object.entries(o).flatMap(([r,e])=>Array.isArray(e)?e.map(t=>({type:t,name:`${r}.${t}`,field:r})):[{type:e,name:`${r}.${e}`,field:r}])}function m(o){return o?Object.entries(o).flatMap(([r,e])=>e==="exact"?[{type:e,field:r}]:e.exactWithLimit?[{type:"exact",field:r,maxGroupCount:e.exactWithLimit}]:[]):[]}function p(o){if("$and"in o)return {type:"and",value:o.$and.map(p)};if("$or"in o)return {type:"or",value:o.$or.map(p)};if("$not"in o)return {type:"not",value:p(o.$not)};let r=Object.entries(o);if(r.length===1){let[e,t]=r[0];if(t==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"Defined key values are only allowed when they are not undefined."):a__default.default(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"WhereClause Filter with multiple properties isn't allowed"):a__default.default(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}}return {type:"and",value:Object.entries(o).map(([e,t])=>{if(t==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"Defined key values are only allowed when they are not undefined."):a__default.default(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"WhereClause Filter with multiple properties isn't allowed"):a__default.default(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}})}}function u(o,r,e="/api"){return async function(n,l,s,b,A,h,v){let d=new URL(`${e}${l}`,j(o));for(let[f,i]of Object.entries(b||{}))if(Array.isArray(i))for(let w of i)d.searchParams.append(f,w);else d.searchParams.append(f,i);let c=new Headers;return h!=null&&c.set("Content-Type",h),v!=null&&c.set("Accept",v),Object.entries(A||{}).forEach(([f,i])=>{i!=null&&c.append(f,i.toString());}),(await r(d.toString(),{body:JSON.stringify(s),method:n,headers:c})).json()}}function j(o){let r=/^https?:\/\//i,e="https://";return r.test(o)?o.replace(/^http:\/\//i,e):`${e}${o}`}async function N(o,r,e){let t={aggregation:y(e.select),groupBy:[],where:void 0};e.groupBy&&(t.groupBy=m(e.groupBy)),e.where&&(t.where=p(e.where));let n=await requests.aggregateObjectsV2(u(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,t);return e.groupBy?n.data.map(s=>({group:s.group,values:g(s)})):(n.data.length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"no group by clause should mean only one data result"):a__default.default(!1)),g(n.data[0]))}async function T(o,r,e,t={type:"base",objectType:r}){let n={objectSet:t,select:e?.select??[]};e?.nextPageToken&&(n.pageToken=e.nextPageToken);let l=await requests.loadObjectSetV2(u(o.stack,o.fetchJson),o.ontology.metadata.ontologyApiName,n);return {data:l.data.map(s=>({...s,__name:r})),nextPageToken:l.nextPageToken}}var D={};$(D,{aggregateOrThrow:()=>N,fetchPageOrThrow:()=>T});
|
|
11
|
-
|
|
12
|
-
exports.a = p;
|
|
13
|
-
exports.b = N;
|
|
14
|
-
exports.c = T;
|
|
15
|
-
exports.d = D;
|
|
16
|
-
//# sourceMappingURL=out.js.map
|
|
17
|
-
//# sourceMappingURL=chunk-I3UIWCJ4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/client/internal/conversions/modernToLegacyAggregationClause.ts","../../src/client/internal/conversions/modernToLegacyGroupByClause.ts","../../src/client/internal/conversions/modernToLegacyWhereClause.ts","../../src/client/internal/net/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../src/client/object/fetchPageOrThrow.ts","../../src/client/object/index.ts"],"names":["invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","createOpenApiRequest","basePath","fetchFn","contextPath","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","protocolRegex","httpsProtocol","aggregateObjectsV2","aggregateOrThrow","thinClient","objectType","req","body","result","loadObjectSetV2","fetchPageOrThrow","client","args","objectSet","r","d","object_exports","__export"],"mappings":"0FAgBA,OAAOA,MAAe,iBACf,SAASC,EAAsCC,EAAO,CAC3D,OAAOA,EAAM,QAAQ,OAAO,CAACC,EAAaC,IAAa,CACrD,IAAMC,EAAQD,EAAS,KAAK,MAAM,GAAG,EACrC,OAAEC,EAAM,QAAU,IAAK,QAAQ,IAAI,WAAa,aAAeL,EAAU,GAAO,4CAA4C,EAAIA,EA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V,MAAO,MACT,EACIA,EAAI,UACNC,EAAK,QAAUhC,EAA4B+B,EAAI,OAAO,GAEpDA,EAAI,QACNC,EAAK,MAAQ5B,EAA0B2B,EAAI,KAAK,GAKlD,IAAME,EAAS,MAAMN,EAAmBnB,EAAqBqB,EAAW,MAAOA,EAAW,KAAK,EAAGA,EAAW,SAAS,SAAS,gBAAiBC,EAAYE,CAAI,EAChK,OAAKD,EAAI,QAIGE,EAAO,KAAK,IAAI1C,IACnB,CACL,MAAOA,EAAM,MACb,OAAQD,EAAsCC,CAAK,CACrD,EACD,GARG0C,EAAO,KAAK,SAAW,IAAK,QAAQ,IAAI,WAAa,aAAe5C,EAAU,GAAO,qDAAqD,EAAIA,EAAU,EAAK,GACxJC,EAAsC2C,EAAO,KAAK,CAAC,CAAC,EAU/D,CC/BA,OAAS,mBAAAC,MAAuB,yBAChC,eAAsBC,EAAiBC,EAAQN,EAAYO,EAAMC,EAAY,CAC3E,KAAM,OACN,WAAAR,CACF,EAAG,CACD,IAAME,EAAO,CACX,UAAAM,EAEA,OAAQD,GAAM,QAAU,CAAC,CAC3B,EAEIA,GAAM,gBACRL,EAAK,UAAYK,EAAK,eAExB,IAAME,EAAI,MAAML,EAAgB1B,EAAqB4B,EAAO,MAAOA,EAAO,SAAS,EAAGA,EAAO,SAAS,SAAS,gBAAiBJ,CAAI,EACpI,MAAO,CACL,KAAMO,EAAE,KAAK,IAAIC,IAAM,CACrB,GAAGA,EACH,OAAQV,CACV,EAAE,EACF,cAAeS,EAAE,aACnB,CACF,CCvCA,IAAAE,EAAA,GAAAC,EAAAD,EAAA,sBAAAb,EAAA,qBAAAO","sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nexport function legacyToModernSingleAggregationResult(entry) {\n return entry.metrics.reduce((accumulator, curValue) => {\n const parts = curValue.name.split(\".\");\n !(parts.length == 2) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"assumed we were getting a `${key}.${type}`\") : invariant(false) : void 0;\n if (!(parts[0] in accumulator)) {\n accumulator[parts[0]] = {};\n }\n accumulator[parts[0]][parts[1]] = curValue.value;\n return accumulator;\n }, {});\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyAggregationClause(select) {\n return Object.entries(select).flatMap(([k, v]) => {\n if (Array.isArray(v)) {\n return v.map(v2 => {\n return {\n type: v2,\n name: `${k}.${v2}`,\n field: k\n };\n });\n } else {\n return [{\n type: v,\n // FIXME v has additional possible values\n name: `${k}.${v}`,\n field: k\n }];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyGroupByClause(groupByClause) {\n if (!groupByClause) return [];\n return Object.entries(groupByClause).flatMap(([field, type]) => {\n if (type === \"exact\") {\n return [{\n type,\n field\n }];\n } else if (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause)\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause)\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not)\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n const [field, filter] = parts[0];\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([field, filter]) => {\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\n };\n })\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport default function createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\") {\n return async function openApiRequest(method, endpointPath, data, queryArguments, headers, requestMediaType, responseMediaType) {\n const url = new URL(`${contextPath}${endpointPath}`, withHttps(basePath));\n for (const [key, value] of Object.entries(queryArguments || {})) {\n if (Array.isArray(value)) {\n for (const item of value) {\n url.searchParams.append(key, item);\n }\n } else {\n url.searchParams.append(key, value);\n }\n }\n const headersInit = new Headers();\n if (requestMediaType != null) {\n headersInit.set(\"Content-Type\", requestMediaType);\n }\n if (responseMediaType != null) {\n headersInit.set(\"Accept\", responseMediaType);\n }\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const response = await fetchFn(url.toString(), {\n body: JSON.stringify(data),\n method: method,\n headers: headersInit\n });\n return response.json();\n };\n}\nfunction withHttps(url) {\n const protocolRegex = /^https?:\\/\\//i;\n const httpsProtocol = \"https://\";\n return protocolRegex.test(url) ? url.replace(/^http:\\/\\//i, httpsProtocol) : `${httpsProtocol}${url}`;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"#client/converters\";\nimport { createOpenApiRequest } from \"#net\";\nimport { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nexport async function aggregateOrThrow(thinClient, objectType, req) {\n const body = {\n aggregation: modernToLegacyAggregationClause(req.select),\n groupBy: [],\n where: undefined\n };\n if (req.groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.groupBy);\n }\n if (req.where) {\n body.where = modernToLegacyWhereClause(req.where);\n // TODO: orderBy\n // TODO The token stuff here sucks\n }\n\n const result = await aggregateObjectsV2(createOpenApiRequest(thinClient.stack, thinClient.fetch), thinClient.ontology.metadata.ontologyApiName, objectType, body);\n if (!req.groupBy) {\n !(result.data.length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"no group by clause should mean only one data result\") : invariant(false) : void 0;\n return legacyToModernSingleAggregationResult(result.data[0]);\n }\n const ret = result.data.map(entry => {\n return {\n group: entry.group,\n values: legacyToModernSingleAggregationResult(entry)\n };\n }); // fixme\n\n return ret; // FIXME\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createOpenApiRequest } from \"#net\";\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nexport async function fetchPageOrThrow(client, objectType, args, objectSet = {\n type: \"base\",\n objectType\n}) {\n const body = {\n objectSet,\n // We have to do the following case because LoadObjectSetRequestV2 isnt readonly\n select: args?.select ?? [] // FIXME?\n };\n\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetchJson), client.ontology.metadata.ontologyApiName, body);\n return {\n data: r.data.map(d => ({\n ...d,\n __name: objectType\n })),\n nextPageToken: r.nextPageToken\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { aggregateOrThrow } from \"./aggregateOrThrow\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow\";"]}
|