Skip to content

Commit

Permalink
Marks things as @internal to clean up API requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
ericanderson committed Jul 25, 2024
1 parent bc1a240 commit c7bf639
Show file tree
Hide file tree
Showing 35 changed files with 70 additions and 146 deletions.
6 changes: 6 additions & 0 deletions .changeset/giant-pianos-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@osdk/client.api": minor
"@osdk/client": minor
---

Marks things as @internal to clean up API requirements
26 changes: 7 additions & 19 deletions etc/client.api.report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ export interface BaseObjectSet<Q extends ObjectOrInterfaceDefinition> {

// Warning: (ae-forgotten-export) The symbol "ApiNameAsString" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "DropDollarOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-internal-missing-underscore) The name "ConvertProps" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
// @public (undocumented)
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<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">, P extends "$rid" ? true : false, "$rid">)) : UnionIfTrue<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">, P extends "$rid" ? true : false, "$rid">;

// @public
Expand Down Expand Up @@ -650,9 +649,7 @@ export type QueryReturnType<T extends QueryDataTypeDefinition<any, any>> = T ext
// @public (undocumented)
export type QuerySignatureFromDef<T extends QueryDefinition<any, any>> = keyof T["parameters"] extends never ? () => Promise<QueryReturnType<T["output"]>> : (params: QueryParameterType<T["parameters"]>) => Promise<QueryReturnType<T["output"]>>;

// Warning: (ae-internal-missing-underscore) The name "RespectNullability" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
// @public
export type RespectNullability<S extends NullabilityAdherence> = S extends false ? false : true;

// Warning: (ae-forgotten-export) The symbol "ErrorResult" needs to be exported by the entry point index.d.ts
Expand All @@ -679,10 +676,6 @@ export interface SingleLinkAccessor<T extends ObjectTypeDefinition<any>> {
fetchOneWithErrors: <const A extends SelectArg<T, ObjectOrInterfacePropertyKeysFrom2<T>, boolean>>(options?: A) => Promise<Result<DefaultToFalse<A["$includeRid"]> extends false ? Osdk<T, SelectArgToKeys<T, A>> : Osdk<T, SelectArgToKeys<T, A> | "$rid">>>;
}

// Warning: (ae-incompatible-release-tags) The symbol "SingleOsdkResult" is marked as @public, but its signature references "RespectNullability" which is marked as @internal
// Warning: (ae-incompatible-release-tags) The symbol "SingleOsdkResult" is marked as @public, but its signature references "UnionIfTrue" which is marked as @internal
// Warning: (ae-incompatible-release-tags) The symbol "SingleOsdkResult" is marked as @public, but its signature references "UnionIfFalse" which is marked as @internal
//
// @public (undocumented)
export type SingleOsdkResult<Q extends ObjectOrInterfaceDefinition, L extends ObjectOrInterfacePropertyKeysFrom2<Q>, R extends boolean, S extends NullabilityAdherence> = ObjectOrInterfacePropertyKeysFrom2<Q> extends L ? ([
DefaultToFalse<R>,
Expand Down Expand Up @@ -765,14 +758,10 @@ export type TimeSeriesQuery = {
$unit?: never;
};

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

// Warning: (ae-internal-missing-underscore) The name "UnionIfTrue" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
// @public
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)
Expand Down Expand Up @@ -801,10 +790,9 @@ export type WhereClause<T extends ObjectOrInterfaceDefinition<any, any>> = OrWhe

// Warnings were encountered during analysis:
//
// src/OsdkObjectFrom.ts:102:4 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// src/OsdkObjectFrom.ts:103:4 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// src/OsdkObjectFrom.ts:159:5 - (ae-forgotten-export) The symbol "UnderlyingProps" needs to be exported by the entry point index.d.ts
// src/OsdkObjectFrom.ts:159:5 - (ae-incompatible-release-tags) The symbol "$as" is marked as @public, but its signature references "ConvertProps" which is marked as @internal
// src/OsdkObjectFrom.ts:100:4 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// src/OsdkObjectFrom.ts:101:4 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// src/OsdkObjectFrom.ts:157: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
1 change: 0 additions & 1 deletion etc/client.report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import type { Logger } from 'pino';
import { NOOP } from '@osdk/client.api';
import type { ObjectOrInterfaceDefinition } from '@osdk/api';
import { ObjectSet } from '@osdk/client.api';
import type { ObjectSet as ObjectSet_2 } from '@osdk/internal.foundry';
import type { ObjectTypeDefinition } from '@osdk/api';
import { Osdk } from '@osdk/client.api';
import { OsdkActionParameters } from '@osdk/client.api';
Expand Down
4 changes: 2 additions & 2 deletions packages/client.api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"typecheck": "monorepo.tool.typecheck esm"
},
"dependencies": {
"@osdk/api": "workspace:~"
"@osdk/api": "workspace:~",
"type-fest": "^4.18.2"
},
"peerDependencies": {
"@types/geojson": "*"
Expand All @@ -42,7 +43,6 @@
"@osdk/monorepo.tsconfig": "workspace:~",
"@osdk/monorepo.tsup": "workspace:~",
"@types/geojson": "^7946.0.14",
"type-fest": "^4.18.2",
"typescript": "^5.5.2"
},
"publishConfig": {
Expand Down
4 changes: 1 addition & 3 deletions packages/client.api/src/OsdkObjectFrom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ type ApiNameAsString<T extends ObjectOrInterfaceDefinition> = NonNullable<
>;

/**
* DO NOT EXPORT FROM PACKAGE
* @param FROM - the interface or object type to convert from
* @param TO - the interface or object type to convert to
* @param P - the property(s) to convert
* @internal
*/
export type ConvertProps<
FROM extends ObjectTypeDefinition<any> | InterfaceDefinition<any, any>,
Expand Down Expand Up @@ -114,7 +112,7 @@ type UnderlyingProps<
: Z
: Z;

type IsNever<T> = [T] extends [never] ? true : false;
export type IsNever<T> = [T] extends [never] ? true : false;

export type Osdk<
Q extends ObjectTypeDefinition<any> | InterfaceDefinition<any, any>,
Expand Down
9 changes: 4 additions & 5 deletions packages/client.api/src/object/FetchPageResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,23 @@ import type {
ObjectOrInterfaceDefinition,
ObjectOrInterfacePropertyKeysFrom2,
} from "@osdk/api";
import type { IsNever } from "type-fest";
import type { DefaultToFalse } from "../definitions/LinkDefinitions.js";
import type { Osdk } from "../OsdkObjectFrom.js";
import type { IsNever, Osdk } from "../OsdkObjectFrom.js";
import type { PageResult } from "../PageResult.js";
import type { NullabilityAdherence } from "./FetchPageArgs.js";

/** @internal exposed for a test */
/** exposed for a test */
export type RespectNullability<S extends NullabilityAdherence> = S extends false
? false
: true;

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

/** @internal exposed for a test */
/** exposed for a test */
export type UnionIfTrue<
S extends string,
UNION_IF_TRUE extends boolean,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"fetch-retry": "^6.0.0",
"isomorphic-ws": "^5.0.0",
"tiny-invariant": "^1.3.1",
"type-fest": "^4.18.2",
"ws": "^8.18.0"
},
"peerDependencies": {
Expand Down Expand Up @@ -75,7 +76,6 @@
"pino": "^9.1.0",
"pino-pretty": "^11.2.1",
"ts-expect": "^1.3.0",
"type-fest": "^4.18.2",
"typescript": "^5.5.2",
"zod": "^3.23.8"
},
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/MinimalClientContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface MinimalClient extends SharedClientContext {
ontologyRid: string | Promise<string>;
ontologyProvider: OntologyProvider;
logger?: Logger;
/** @internal */
objectSetFactory: ObjectSetFactory<any, any>;
clientCacheKey: ClientCacheKey;
requestContext: RequestContext;
Expand Down
102 changes: 1 addition & 101 deletions packages/client/src/OsdkObjectFrom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,110 +15,10 @@
*/

import type { ObjectOrInterfaceDefinition } from "@osdk/api";
import type { ConvertProps, Osdk, ValidToFrom } from "@osdk/client.api";
import type { Osdk, ValidToFrom } from "@osdk/client.api";
import type { Employee, FooInterface } from "@osdk/client.test.ontology";
import { describe, expectTypeOf, it } from "vitest";

describe("ConvertProps", () => {
describe("converts from an interface to a concrete", () => {
it("handles single prop", () => {
expectTypeOf<ConvertProps<FooInterface, Employee, "fooSpt">>()
.toEqualTypeOf<"fullName">();
});
it("handles $all", () => {
expectTypeOf<ConvertProps<FooInterface, Employee, "$all">>()
.toEqualTypeOf<"fullName">();
});

it("converts non-strict nullness for handles single prop", () => {
expectTypeOf<
ConvertProps<
FooInterface,
Employee,
| "fooSpt"
| "$notStrict"
>
>()
.toEqualTypeOf<"fullName" | "$notStrict">();
});
it("converts non-strict nullness for $all", () => {
expectTypeOf<
ConvertProps<FooInterface, Employee, "$all" | "$notStrict">
>()
.toEqualTypeOf<"fullName" | "$notStrict">();
});
it("handles $all | $rid", () => {
expectTypeOf<ConvertProps<FooInterface, Employee, "$all" | "$rid">>()
.toEqualTypeOf<"fullName" | "$rid">();
});
});

describe("converts from a concrete to an interface", () => {
describe("single prop", () => {
it("handles known prop", () => {
expectTypeOf<ConvertProps<Employee, FooInterface, "fullName">>()
.toEqualTypeOf<"fooSpt">();
});

it("resolves to never for unused", () => {
expectTypeOf<ConvertProps<Employee, FooInterface, "peeps">>()
.toEqualTypeOf<never>();
});

it("resolves to never for unused when not strict", () => {
expectTypeOf<
ConvertProps<Employee, FooInterface, "peeps" | "$notStrict">
>()
.toEqualTypeOf<never>();
});

it("converts non-strict nullness for single prop", () => {
expectTypeOf<
ConvertProps<Employee, FooInterface, "fullName" | "$notStrict">
>()
.toEqualTypeOf<"fooSpt" | "$notStrict">();
});

it("converts non-strict nullness for $all", () => {
expectTypeOf<
ConvertProps<Employee, FooInterface, "$all" | "$notStrict">
>()
.toEqualTypeOf<"$all" | "$notStrict">();
});
});

describe("multiprop", () => {
it("resolves to known only", () => {
expectTypeOf<
ConvertProps<Employee, FooInterface, "peeps" | "fullName">
>()
.toEqualTypeOf<"fooSpt">();
});

it("resolves to known only when not strict", () => {
expectTypeOf<
ConvertProps<
Employee,
FooInterface,
"peeps" | "fullName" | "$notStrict"
>
>()
.toEqualTypeOf<"fooSpt" | "$notStrict">();
});
});

it("handles $all", () => {
expectTypeOf<ConvertProps<Employee, FooInterface, "$all">>()
.toEqualTypeOf<"$all">();
});

it("handles $all | $rid", () => {
expectTypeOf<ConvertProps<Employee, FooInterface, "$all" | "$rid">>()
.toEqualTypeOf<"$all" | "$rid">();
});
});
});

describe("Osdk", () => {
class OsdkAsHelperClass<
FROM extends ObjectOrInterfaceDefinition,
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/createClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ActionInvoker<Q extends ActionDefinition<any, any, any>>
applyAction: (...args: any[]) => any;
}

/** @internal */
export function createClientInternal(
objectSetFactory: ObjectSetFactory<any, any>, // first so i can bind
baseUrl: string,
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/createMinimalClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from "./ontology/StandardOntologyProvider.js";
import { USER_AGENT } from "./util/UserAgent.js";

/** @internal */
export function createMinimalClient(
metadata: MinimalClientParams["metadata"],
baseUrl: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import type { AggregateObjectsResponseV2 } from "@osdk/internal.foundry";
import invariant from "tiny-invariant";
import type { ArrayElement } from "../../util/ArrayElement.js";

/** @internal */
export function legacyToModernSingleAggregationResult<
Q extends ObjectOrInterfaceDefinition,
AC extends UnorderedAggregationClause<Q> | OrderedAggregationClause<Q>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type { AggregationV2 } from "@osdk/internal.foundry";
const directionFieldMap = (dir?: "asc" | "desc" | "unordered") =>
dir === "asc" ? "ASC" : dir === "desc" ? "DESC" : undefined;

/** @internal */
export function modernToLegacyAggregationClause<
AC extends UnorderedAggregationClause<any> | OrderedAggregationClause<any>,
>(select: AC) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type {
AggregationRangeV2,
} from "@osdk/internal.foundry";

/** @internal */
export function modernToLegacyGroupByClause(
groupByClause: GroupByClause<any> | undefined,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import type { SearchJsonQueryV2 } from "@osdk/internal.foundry";
import type { BBox, Position } from "geojson";
import invariant from "tiny-invariant";

/** @internal */
export function modernToLegacyWhereClause<
T extends ObjectOrInterfaceDefinition<any, any>,
>(
Expand Down
3 changes: 2 additions & 1 deletion packages/client/src/object/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import type { MinimalClient } from "../MinimalClientContext.js";
import { addUserAgentAndRequestContextHeaders } from "../util/addUserAgentAndRequestContextHeaders.js";
import type { ArrayElement } from "../util/ArrayElement.js";

/** @deprecated use `aggregate` */
/** @deprecated use `aggregate` @internal */
export async function aggregateOrThrow<
Q extends ObjectOrInterfaceDefinition,
AO extends AggregateOpts<Q>,
Expand All @@ -52,6 +52,7 @@ export async function aggregateOrThrow<
return aggregate<Q, AO>(clientCtx, objectType, objectSet, req);
}

/** @internal */
export async function aggregate<
Q extends ObjectOrInterfaceDefinition,
AO extends AggregateOpts<Q>,
Expand Down
7 changes: 1 addition & 6 deletions packages/client/src/object/convertWireToOsdkObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@ import type {
ObjectOrInterfaceDefinition,
ObjectTypeDefinition,
} from "@osdk/api";
import type {
ConvertProps,
NullabilityAdherence,
Osdk,
} from "@osdk/client.api";
import type { NullabilityAdherence, Osdk } from "@osdk/client.api";
import type { OntologyObjectV2 } from "@osdk/internal.foundry";
import invariant from "tiny-invariant";
import type { MinimalClient } from "../MinimalClientContext.js";
import {
type FetchedObjectTypeDefinition,
InterfaceDefinitions,
} from "../ontology/OntologyProvider.js";
import { createOsdkObject } from "./convertWireToOsdkObjects/createOsdkObject.js";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@ import type {
UnderlyingOsdkObject,
} from "./InternalSymbols.js";

/** @internal */
export interface ObjectHolderPrototypeOwnProps {
readonly [ObjectDefRef]: FetchedObjectTypeDefinition<any, any>;
readonly [ClientRef]: MinimalClient;
readonly "$as": DollarAsFn;
readonly "$link": ReturnType<typeof get$link>;
readonly "$updateInternalValues": (newValues: Record<string, any>) => void;
}
/** @internal */
export interface ObjectHolderOwnProperties {
[RawObject]: OntologyObjectV2;
}

/** @internal */
export interface ObjectHolder<Q extends FetchedObjectTypeDefinition<any, any>>
extends ObjectHolderPrototypeOwnProps, ObjectHolderOwnProperties
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const handlerCache = createSimpleCache<
createInterfaceProxyHandler,
);

/** @internal */
export function createOsdkInterface<
Q extends FetchedObjectTypeDefinition<any, any>,
>(
Expand Down
Loading

0 comments on commit c7bf639

Please sign in to comment.