@osdk/api 0.0.0-20230929184205
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/.eslintrc.cjs +4 -0
- package/.turbo/turbo-build.log +26 -0
- package/.turbo/turbo-lint.log +4 -0
- package/CHANGELOG.md +7 -0
- package/dist/chunk-TTS63OIX.mjs +7 -0
- package/dist/chunk-TTS63OIX.mjs.map +1 -0
- package/dist/chunk-ZJRKQTOR.js +16 -0
- package/dist/chunk-ZJRKQTOR.js.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +9 -0
- package/dist/index.mjs.map +1 -0
- package/dist/public/objects.js +16 -0
- package/dist/public/objects.js.map +1 -0
- package/dist/public/objects.mjs +3 -0
- package/dist/public/objects.mjs.map +1 -0
- package/lib/client/Client.d.ts +8 -0
- package/lib/client/ObjectSetCreator.d.ts +15 -0
- package/lib/client/PageResult.d.ts +5 -0
- package/lib/client/PalantirApiError.d.ts +9 -0
- package/lib/client/ResultOrError.d.ts +11 -0
- package/lib/client/ThinClient.d.ts +13 -0
- package/lib/client/UnknownError.d.ts +5 -0
- package/lib/client/createClient.d.ts +3 -0
- package/lib/client/createThinClient.d.ts +6 -0
- package/lib/client/index.d.ts +8 -0
- package/lib/client/internal/conversions/index.d.ts +4 -0
- package/lib/client/internal/conversions/legacyToModernSingleAggregationResult.d.ts +4 -0
- package/lib/client/internal/conversions/modernToLegacyAggregationClause.d.ts +4 -0
- package/lib/client/internal/conversions/modernToLegacyGroupByClause.d.ts +4 -0
- package/lib/client/internal/conversions/modernToLegacyWhereClause.d.ts +4 -0
- package/lib/client/internal/net/V2_BASE.d.ts +1 -0
- package/lib/client/internal/net/aggregateObjectsV2.d.ts +3 -0
- package/lib/client/internal/net/index.d.ts +3 -0
- package/lib/client/internal/net/listObjectsFromObjectSetV2.d.ts +3 -0
- package/lib/client/internal/net/types.d.ts +357 -0
- package/lib/client/object/aggregateOrThrow.d.ts +5 -0
- package/lib/client/object/aggregateOrThrow.test.d.ts +2 -0
- package/lib/client/object/fetchPageOrThrow.d.ts +10 -0
- package/lib/client/object/index.d.ts +2 -0
- package/lib/client/objectSet/LinkTypesFrom.d.ts +2 -0
- package/lib/client/objectSet/ObjectSet.d.ts +25 -0
- package/lib/client/objectSet/createObjectSet.d.ts +5 -0
- package/lib/client/query/WhereClause.d.ts +24 -0
- package/lib/client/query/aggregations/AggregatableKeys.d.ts +4 -0
- package/lib/client/query/aggregations/AggregateOpts.d.ts +7 -0
- package/lib/client/query/aggregations/AggregationResultsWithGroups.d.ts +10 -0
- package/lib/client/query/aggregations/AggregationResultsWithoutGroups.d.ts +8 -0
- package/lib/client/query/aggregations/AggregationsClause.d.ts +8 -0
- package/lib/client/query/aggregations/AggregationsClause.test.d.ts +36 -0
- package/lib/client/query/aggregations/AggregationsResults.d.ts +5 -0
- package/lib/client/query/aggregations/AggregationsResults.test.d.ts +1 -0
- package/lib/client/query/aggregations/GroupByClause.d.ts +12 -0
- package/lib/client/query/aggregations/GroupByClause.test.d.ts +18 -0
- package/lib/client/query/aggregations/GroupByMapper.d.ts +4 -0
- package/lib/client/query/index.d.ts +7 -0
- package/lib/index.d.ts +6 -0
- package/lib/ontology/Definition.d.ts +36 -0
- package/lib/ontology/OntologyMetadata.d.ts +5 -0
- package/lib/ontology/OsdkObject.d.ts +3 -0
- package/lib/ontology/OsdkObjectFrom.d.ts +6 -0
- package/lib/ontology/index.d.ts +4 -0
- package/lib/public/objects.d.ts +1 -0
- package/lib/util/ArrayElement.d.ts +1 -0
- package/lib/util/FetchAsJson.d.ts +15 -0
- package/lib/util/NOOP.d.ts +3 -0
- package/lib/util/StringArrayToUnion.d.ts +1 -0
- package/lib/util/createFetchHeaderMutator.d.ts +1 -0
- package/lib/util/createFetchOrThrow.d.ts +9 -0
- package/lib/util/createRetryingFetch.d.ts +2 -0
- package/lib/util/index.d.ts +9 -0
- package/lib/util/stringifyBody.d.ts +1 -0
- package/package.json +46 -0
- package/src/client/Client.ts +33 -0
- package/src/client/ObjectSetCreator.ts +44 -0
- package/src/client/PageResult.ts +22 -0
- package/src/client/PalantirApiError.ts +41 -0
- package/src/client/ResultOrError.ts +23 -0
- package/src/client/ThinClient.ts +31 -0
- package/src/client/UnknownError.ts +25 -0
- package/src/client/createClient.ts +49 -0
- package/src/client/createThinClient.ts +52 -0
- package/src/client/index.ts +24 -0
- package/src/client/internal/conversions/index.ts +20 -0
- package/src/client/internal/conversions/legacyToModernSingleAggregationResult.ts +46 -0
- package/src/client/internal/conversions/modernToLegacyAggregationClause.ts +45 -0
- package/src/client/internal/conversions/modernToLegacyGroupByClause.ts +44 -0
- package/src/client/internal/conversions/modernToLegacyWhereClause.ts +135 -0
- package/src/client/internal/net/V2_BASE.ts +17 -0
- package/src/client/internal/net/aggregateObjectsV2.ts +37 -0
- package/src/client/internal/net/index.ts +19 -0
- package/src/client/internal/net/listObjectsFromObjectSetV2.ts +41 -0
- package/src/client/internal/net/types.ts +302 -0
- package/src/client/object/aggregateOrThrow.test.ts +137 -0
- package/src/client/object/aggregateOrThrow.ts +87 -0
- package/src/client/object/fetchPageOrThrow.ts +83 -0
- package/src/client/object/index.ts +18 -0
- package/src/client/objectSet/LinkTypesFrom.ts +22 -0
- package/src/client/objectSet/ObjectSet.ts +92 -0
- package/src/client/objectSet/createObjectSet.ts +130 -0
- package/src/client/query/WhereClause.ts +68 -0
- package/src/client/query/aggregations/AggregatableKeys.ts +37 -0
- package/src/client/query/aggregations/AggregateOpts.ts +36 -0
- package/src/client/query/aggregations/AggregationResultsWithGroups.ts +40 -0
- package/src/client/query/aggregations/AggregationResultsWithoutGroups.ts +37 -0
- package/src/client/query/aggregations/AggregationsClause.test.ts +60 -0
- package/src/client/query/aggregations/AggregationsClause.ts +44 -0
- package/src/client/query/aggregations/AggregationsResults.test.ts +74 -0
- package/src/client/query/aggregations/AggregationsResults.ts +30 -0
- package/src/client/query/aggregations/GroupByClause.test.ts +38 -0
- package/src/client/query/aggregations/GroupByClause.ts +41 -0
- package/src/client/query/aggregations/GroupByMapper.ts +21 -0
- package/src/client/query/index.ts +32 -0
- package/src/index.ts +28 -0
- package/src/ontology/Definition.ts +89 -0
- package/src/ontology/OntologyMetadata.ts +21 -0
- package/src/ontology/OsdkObject.ts +17 -0
- package/src/ontology/OsdkObjectFrom.ts +33 -0
- package/src/ontology/index.ts +20 -0
- package/src/public/objects.ts +17 -0
- package/src/util/ArrayElement.ts +18 -0
- package/src/util/FetchAsJson.ts +55 -0
- package/src/util/NOOP.ts +21 -0
- package/src/util/StringArrayToUnion.ts +18 -0
- package/src/util/createFetchHeaderMutator.ts +34 -0
- package/src/util/createFetchOrThrow.ts +71 -0
- package/src/util/createRetryingFetch.ts +55 -0
- package/src/util/index.ts +25 -0
- package/src/util/stringifyBody.ts +21 -0
- package/tsconfig.json +5 -0
- package/tsup.config.js +21 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { AggregatableKeys } from "./AggregatableKeys";
|
|
18
|
+
import type { AggregationClause } from "./AggregationsClause";
|
|
19
|
+
|
|
20
|
+
export type huh = AggregatableKeys<
|
|
21
|
+
{
|
|
22
|
+
metadata: any;
|
|
23
|
+
objects: {
|
|
24
|
+
Todo: {
|
|
25
|
+
apiName: "Todo";
|
|
26
|
+
links: {};
|
|
27
|
+
properties: {
|
|
28
|
+
text: {
|
|
29
|
+
type: "string";
|
|
30
|
+
};
|
|
31
|
+
id: {
|
|
32
|
+
type: "double";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
"Todo"
|
|
39
|
+
>;
|
|
40
|
+
|
|
41
|
+
export type Q = AggregationClause<
|
|
42
|
+
{
|
|
43
|
+
metadata: any;
|
|
44
|
+
objects: {
|
|
45
|
+
Todo: {
|
|
46
|
+
apiName: "Todo";
|
|
47
|
+
links: {};
|
|
48
|
+
properties: {
|
|
49
|
+
text: {
|
|
50
|
+
type: "string";
|
|
51
|
+
};
|
|
52
|
+
id: {
|
|
53
|
+
type: "double";
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
"Todo"
|
|
60
|
+
>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type {
|
|
18
|
+
ObjectTypesFrom,
|
|
19
|
+
OntologyDefinition,
|
|
20
|
+
PropertyDefinitionsFrom,
|
|
21
|
+
} from "#ontology";
|
|
22
|
+
import type { AggregatableKeys } from "./AggregatableKeys";
|
|
23
|
+
|
|
24
|
+
type StringAggregateOption = "approximateDistinct";
|
|
25
|
+
type NumericAggregateOption =
|
|
26
|
+
| "min"
|
|
27
|
+
| "max"
|
|
28
|
+
| "sum"
|
|
29
|
+
| "avg"
|
|
30
|
+
| "approximateDistinct";
|
|
31
|
+
|
|
32
|
+
export type AggregationClause<
|
|
33
|
+
O extends OntologyDefinition<any>,
|
|
34
|
+
K extends ObjectTypesFrom<O>,
|
|
35
|
+
> = {
|
|
36
|
+
[P in AggregatableKeys<O, K>]?: PropertyDefinitionsFrom<
|
|
37
|
+
O,
|
|
38
|
+
K
|
|
39
|
+
>[P]["type"] extends "string"
|
|
40
|
+
? StringAggregateOption | StringAggregateOption[]
|
|
41
|
+
: PropertyDefinitionsFrom<O, K>[P]["type"] extends "double"
|
|
42
|
+
? NumericAggregateOption | NumericAggregateOption[]
|
|
43
|
+
: PropertyDefinitionsFrom<O, K>[P]["type"];
|
|
44
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { AggregationResultsWithoutGroups } from "./AggregationResultsWithoutGroups";
|
|
18
|
+
import type { AggregationsResults } from "./AggregationsResults";
|
|
19
|
+
|
|
20
|
+
type T_AGG_RESULTS_TEST_1 = AggregationsResults<
|
|
21
|
+
{
|
|
22
|
+
metadata: any;
|
|
23
|
+
objects: {
|
|
24
|
+
Todo: {
|
|
25
|
+
apiName: "Todo";
|
|
26
|
+
links: {};
|
|
27
|
+
properties: {
|
|
28
|
+
text: {
|
|
29
|
+
type: "string";
|
|
30
|
+
};
|
|
31
|
+
id: {
|
|
32
|
+
type: "double";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
"Todo",
|
|
39
|
+
{
|
|
40
|
+
select: {
|
|
41
|
+
locationCity: "approximateDistinct";
|
|
42
|
+
text: "approximateDistinct";
|
|
43
|
+
};
|
|
44
|
+
groupBy: {
|
|
45
|
+
text: "exact";
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
>;
|
|
49
|
+
|
|
50
|
+
type Q = AggregationResultsWithoutGroups<
|
|
51
|
+
{
|
|
52
|
+
metadata: any;
|
|
53
|
+
objects: {
|
|
54
|
+
Todo: {
|
|
55
|
+
apiName: "Todo";
|
|
56
|
+
links: {};
|
|
57
|
+
properties: {
|
|
58
|
+
text: {
|
|
59
|
+
type: "string";
|
|
60
|
+
};
|
|
61
|
+
id: {
|
|
62
|
+
type: "double";
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
"Todo",
|
|
69
|
+
{
|
|
70
|
+
locationCity: "approximateDistinct";
|
|
71
|
+
id: ["max", "sum"];
|
|
72
|
+
text: "approximateDistinct";
|
|
73
|
+
}
|
|
74
|
+
>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { ObjectTypesFrom, OntologyDefinition } from "#ontology";
|
|
18
|
+
import type { AggregateOpts } from "./AggregateOpts";
|
|
19
|
+
import type { AggregationResultsWithGroups } from "./AggregationResultsWithGroups";
|
|
20
|
+
import type { AggregationResultsWithoutGroups } from "./AggregationResultsWithoutGroups";
|
|
21
|
+
|
|
22
|
+
export type AggregationsResults<
|
|
23
|
+
T extends OntologyDefinition<any>,
|
|
24
|
+
K extends ObjectTypesFrom<T>,
|
|
25
|
+
AO extends AggregateOpts<T, K, any>,
|
|
26
|
+
> = unknown extends AO["groupBy"] // groupBy is missing
|
|
27
|
+
? AggregationResultsWithoutGroups<T, K, AO["select"]>
|
|
28
|
+
: Exclude<AO["groupBy"], undefined> extends never // groupBy is explicitly undefined
|
|
29
|
+
? AggregationResultsWithoutGroups<T, K, AO["select"]>
|
|
30
|
+
: AggregationResultsWithGroups<T, K, AO["select"], AO["groupBy"]>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { GroupByClause } from "./GroupByClause";
|
|
18
|
+
|
|
19
|
+
export type F = GroupByClause<
|
|
20
|
+
{
|
|
21
|
+
metadata: any;
|
|
22
|
+
objects: {
|
|
23
|
+
Todo: {
|
|
24
|
+
apiName: "Todo";
|
|
25
|
+
links: {};
|
|
26
|
+
properties: {
|
|
27
|
+
text: {
|
|
28
|
+
type: "string";
|
|
29
|
+
};
|
|
30
|
+
id: {
|
|
31
|
+
type: "double";
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
"Todo"
|
|
38
|
+
>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type {
|
|
18
|
+
ObjectTypesFrom,
|
|
19
|
+
OntologyDefinition,
|
|
20
|
+
PropertyDefinitionFrom,
|
|
21
|
+
} from "#ontology";
|
|
22
|
+
import type { AggregatableKeys } from "./AggregatableKeys";
|
|
23
|
+
import type { GroupByMapper } from "./GroupByMapper";
|
|
24
|
+
|
|
25
|
+
export type GroupByClause<
|
|
26
|
+
O extends OntologyDefinition<any>,
|
|
27
|
+
K extends ObjectTypesFrom<O>,
|
|
28
|
+
> = {
|
|
29
|
+
[P in AggregatableKeys<O, K>]?: GroupByEntry<O, K, P>;
|
|
30
|
+
};
|
|
31
|
+
export type StringGroupByValue = "exact" | { exactWithLimit: number };
|
|
32
|
+
|
|
33
|
+
type GroupByEntry<
|
|
34
|
+
O extends OntologyDefinition<any>,
|
|
35
|
+
K extends ObjectTypesFrom<O>,
|
|
36
|
+
P extends AggregatableKeys<O, K>,
|
|
37
|
+
> = PropertyDefinitionFrom<O, K, P>["type"] extends keyof GroupByMapper
|
|
38
|
+
? GroupByMapper[PropertyDefinitionFrom<O, K, P>["type"]]
|
|
39
|
+
: never;
|
|
40
|
+
|
|
41
|
+
export type AllGroupByValues = GroupByMapper[keyof GroupByMapper];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { StringGroupByValue } from "./GroupByClause";
|
|
18
|
+
|
|
19
|
+
export interface GroupByMapper {
|
|
20
|
+
string: StringGroupByValue;
|
|
21
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type * from "./aggregations/AggregatableKeys";
|
|
18
|
+
export type * from "./aggregations/AggregationResultsWithGroups";
|
|
19
|
+
export type * from "./aggregations/AggregationResultsWithoutGroups";
|
|
20
|
+
export type * from "./aggregations/AggregationsClause";
|
|
21
|
+
export type * from "./aggregations/AggregationsResults";
|
|
22
|
+
export type {
|
|
23
|
+
AllGroupByValues,
|
|
24
|
+
GroupByClause,
|
|
25
|
+
} from "./aggregations/GroupByClause";
|
|
26
|
+
export type {
|
|
27
|
+
AndWhereClause,
|
|
28
|
+
NotWhereClause,
|
|
29
|
+
OrWhereClause,
|
|
30
|
+
PossibleWhereClauseFilters,
|
|
31
|
+
WhereClause,
|
|
32
|
+
} from "./WhereClause";
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type { WhereClause } from "#client/query";
|
|
18
|
+
export type { OsdkObject } from "#ontology";
|
|
19
|
+
export { createClient, createThinClient, isOk } from "./client";
|
|
20
|
+
export type { Client, ObjectSet, ResultOrError, ThinClient } from "./client";
|
|
21
|
+
|
|
22
|
+
// FIXME: Shoudl this be Objects or Object?
|
|
23
|
+
export * as Objects from "./client/object";
|
|
24
|
+
|
|
25
|
+
export type {
|
|
26
|
+
ObjectDefinition,
|
|
27
|
+
OntologyDefinition,
|
|
28
|
+
} from "./ontology/Definition";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { OntologyMetadata } from "./OntologyMetadata";
|
|
18
|
+
|
|
19
|
+
export type ObjectInfoFrom<
|
|
20
|
+
O extends OntologyDefinition<any>,
|
|
21
|
+
K extends ObjectTypesFrom<O>,
|
|
22
|
+
> = O["objects"][K];
|
|
23
|
+
|
|
24
|
+
export type ObjectTypesFrom<O extends OntologyDefinition<string>> =
|
|
25
|
+
& keyof O["objects"]
|
|
26
|
+
& string;
|
|
27
|
+
|
|
28
|
+
export type PropertyKeysFrom<
|
|
29
|
+
O extends OntologyDefinition<any>,
|
|
30
|
+
K extends ObjectTypesFrom<O>,
|
|
31
|
+
> = keyof ObjectInfoFrom<O, K>["properties"] & string;
|
|
32
|
+
|
|
33
|
+
export type PropertyDefinitionsFrom<
|
|
34
|
+
O extends OntologyDefinition<any>,
|
|
35
|
+
K extends ObjectTypesFrom<O>,
|
|
36
|
+
> = ObjectInfoFrom<O, K>["properties"];
|
|
37
|
+
|
|
38
|
+
export type PropertyDefinitionFrom<
|
|
39
|
+
O extends OntologyDefinition<any>,
|
|
40
|
+
K extends ObjectTypesFrom<O>,
|
|
41
|
+
P extends PropertyKeysFrom<O, K>,
|
|
42
|
+
> = PropertyDefinitionsFrom<O, K>[P];
|
|
43
|
+
|
|
44
|
+
export interface OntologyDefinition<K extends string> {
|
|
45
|
+
metadata: OntologyMetadata;
|
|
46
|
+
objects: {
|
|
47
|
+
[KK in K]: ObjectDefinition<KK, K>;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ObjectDefinition<N extends K, K extends string> {
|
|
52
|
+
apiName: N;
|
|
53
|
+
properties: Record<string, PropertyDefinition>;
|
|
54
|
+
links: Record<string, LinkDefinition<K>>;
|
|
55
|
+
}
|
|
56
|
+
export interface LinkDefinition<K extends string> {
|
|
57
|
+
targetType: K;
|
|
58
|
+
multiplicity: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface PropertyDefinition {
|
|
61
|
+
readonly?: boolean;
|
|
62
|
+
type: keyof ValidPropertyTypes; // FIXME WHAT ARE THE TYPES
|
|
63
|
+
nullable?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface ValidPropertyTypes {
|
|
67
|
+
string: string;
|
|
68
|
+
datetime: Date;
|
|
69
|
+
double: number;
|
|
70
|
+
boolean: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type OsdkObjectPropertyType<T extends PropertyDefinition> =
|
|
74
|
+
T["nullable"] extends false ? ValidPropertyTypes[T["type"]]
|
|
75
|
+
: ValidPropertyTypes[T["type"]] | undefined;
|
|
76
|
+
|
|
77
|
+
export type OsdkObjectLink<
|
|
78
|
+
K extends string,
|
|
79
|
+
O extends OntologyDefinition<K>,
|
|
80
|
+
T extends LinkDefinition<any>,
|
|
81
|
+
> = T["multiplicity"] extends true ? Array<OsdkObjectLink_Inner<K, O, T>>
|
|
82
|
+
: OsdkObjectLink_Inner<K, O, T>;
|
|
83
|
+
|
|
84
|
+
type OsdkObjectLink_Inner<
|
|
85
|
+
K extends string,
|
|
86
|
+
O extends OntologyDefinition<K>,
|
|
87
|
+
T extends LinkDefinition<any>,
|
|
88
|
+
> = T["targetType"] extends keyof O["objects"] ? O["objects"][T["targetType"]]
|
|
89
|
+
: never;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface OntologyMetadata {
|
|
18
|
+
ontologyRid: string;
|
|
19
|
+
ontologyApiName: string;
|
|
20
|
+
userAgent: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type OsdkObject<N extends string> = { __name: N };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type {
|
|
18
|
+
OntologyDefinition,
|
|
19
|
+
OsdkObjectPropertyType,
|
|
20
|
+
PropertyKeysFrom,
|
|
21
|
+
} from "./Definition";
|
|
22
|
+
|
|
23
|
+
export type OsdkObjectFrom<
|
|
24
|
+
K extends string,
|
|
25
|
+
T extends OntologyDefinition<K>,
|
|
26
|
+
L extends PropertyKeysFrom<T, K>,
|
|
27
|
+
> =
|
|
28
|
+
& {
|
|
29
|
+
[P in L]: OsdkObjectPropertyType<T["objects"][K]["properties"][P]>;
|
|
30
|
+
}
|
|
31
|
+
& {
|
|
32
|
+
__name: K;
|
|
33
|
+
}; // TODO
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type * from "./Definition";
|
|
18
|
+
export type { OntologyMetadata } from "./OntologyMetadata";
|
|
19
|
+
export type { OsdkObject } from "./OsdkObject";
|
|
20
|
+
export type { OsdkObjectFrom } from "./OsdkObjectFrom";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export * from "../client/object";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type ArrayElement<ArrayType extends readonly unknown[]> =
|
|
18
|
+
ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createFetchHeaderMutator } from "./createFetchHeaderMutator";
|
|
18
|
+
import { stringifyBody } from "./stringifyBody";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Fetches the given URL, converting the body to JSON, setting the Content-Type header to application/json,
|
|
22
|
+
* and calling .json() on the response.
|
|
23
|
+
*/
|
|
24
|
+
export type FetchAsJsonFn = (
|
|
25
|
+
url: URL,
|
|
26
|
+
requestInit: Omit<RequestInit, "body"> & { body?: object | undefined },
|
|
27
|
+
) => Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Wraps a fetch function to set the Content-Type header to application/json, to handle JSON.stringify(),
|
|
30
|
+
* and to parse the response as JSON.
|
|
31
|
+
*
|
|
32
|
+
* @param fetchFn The fetch function to wrap
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
export function createFetchAsJson(
|
|
36
|
+
fetchFn: typeof fetch = fetch,
|
|
37
|
+
): FetchAsJsonFn {
|
|
38
|
+
fetchFn = createFetchHeaderMutator(fetchFn, (headers) => {
|
|
39
|
+
headers.set("Content-Type", "application/json");
|
|
40
|
+
return headers;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return async function fetchAsJson(
|
|
44
|
+
url: URL,
|
|
45
|
+
requestInit: Omit<RequestInit, "body"> & { body?: object },
|
|
46
|
+
) {
|
|
47
|
+
return (
|
|
48
|
+
await fetchFn(url, {
|
|
49
|
+
...requestInit,
|
|
50
|
+
body: stringifyBody(requestInit.body),
|
|
51
|
+
// TODO fix headers
|
|
52
|
+
})
|
|
53
|
+
).json();
|
|
54
|
+
};
|
|
55
|
+
}
|
package/src/util/NOOP.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type NOOP<T> = T extends (...args: any[]) => any ? T
|
|
18
|
+
: T extends abstract new(...args: any[]) => any ? T
|
|
19
|
+
: {
|
|
20
|
+
[K in keyof T]: T[K];
|
|
21
|
+
};
|