Skip to content

Commit

Permalink
Refactor codebase to enable cleaner separation (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericanderson authored May 21, 2024
1 parent e054c23 commit cd1a098
Show file tree
Hide file tree
Showing 99 changed files with 1,516 additions and 560 deletions.
2 changes: 1 addition & 1 deletion .changeset/four-ways-add.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@osdk/shared.net": patch
"@osdk/shared.net.platformapi": patch
---

URL encode path portions for foundry platform sdk
19 changes: 19 additions & 0 deletions .monorepolint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ const nonStandardPackages = [
"@osdk/tests.*",
"@osdk/foundry-sdk-generator",
"@osdk/examples.*",
"@osdk/shared.client",
];

const legacyPackages = [
"@osdk/api",
"@osdk/gateway",
"@osdk/legacy-client",
"@osdk/shared.net",
"@osdk/shared.net.errors",
"@osdk/shared.net.fetch",
];

const esmOnlyPackages = [
Expand All @@ -61,6 +64,7 @@ const esmOnlyPackages = [
"@osdk/platform-sdk-generator",
"@osdk/tool.release",
"@osdk/version-updater",
"@osdk/shared.net.platformapi",
"watch",
// "@osdk/examples.*", but they have their own config cause they are nonstandard
];
Expand Down Expand Up @@ -401,6 +405,21 @@ export default {
},
}),

requireDependency({
includePackages: [
"@osdk/foundry.*",
"@osdk/internal.foundry.*",
"@osdk/foundry",
"@osdk/internal.foundry",
],
options: {
dependencies: {
"@osdk/shared.client": "workspace:^",
"@osdk/shared.net.platformapi": "workspace:^",
},
},
}),

packageEntry({
options: {
entries: {
Expand Down
5 changes: 4 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
"dependencies": {
"@osdk/api": "workspace:^",
"@osdk/generator-converters": "workspace:^",
"@osdk/shared.net": "workspace:^",
"@osdk/shared.client": "workspace:^",
"@osdk/shared.client.impl": "workspace:^",
"@osdk/shared.net.errors": "workspace:^",
"@osdk/shared.net.fetch": "workspace:^",
"conjure-lite": "^0.4.4",
"fast-deep-equal": "^3.1.3",
"fetch-retry": "^6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
ObjectTypeDefinition,
VersionBound,
} from "@osdk/api";
import type { SharedClient } from "@osdk/shared.net";
import type { SharedClient } from "@osdk/shared.client";
import type { ActionSignatureFromDef } from "./actions/Actions.js";
import type { MinimalClient } from "./MinimalClientContext.js";
import type { ObjectSet } from "./objectSet/ObjectSet.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/MinimalClientContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

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

export type ResultOrError<T extends object> =
| ({ type: "ok"; err?: never } & T)
| { type: "err"; data?: never; err?: unknown };

export function isOk(result: ResultOrError<any>): result is { type: "ok" } {
return result.type === "ok";
}
3 changes: 1 addition & 2 deletions packages/client/src/__unstable/UNSTABLE_createClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
*/

import type { ObjectOrInterfaceDefinition } from "@osdk/api";
import { symbolClientContext } from "@osdk/shared.net";
import { symbolClientContext } from "@osdk/shared.client";
import type { Client } from "../Client.js";
import type { createClient } from "../createClient.js";
import { createClientInternal } from "../createClient.js";
import type { MinimalClient } from "../MinimalClientContext.js";
import { UNSTABLE_createObjectSet } from "../objectSet/createUnstableObjectSet.js";
import { createBulkLinksAsyncIterFactory } from "./createBulkLinksAsyncIterFactory.js";
import type { UnstableClient } from "./UnstableClient.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/createClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
ObjectOrInterfaceDefinition,
ObjectTypeDefinition,
} from "@osdk/api";
import { symbolClientContext } from "@osdk/shared.net";
import { symbolClientContext } from "@osdk/shared.client";
import type { Logger } from "pino";
import type { ActionSignatureFromDef } from "./actions/Actions.js";
import { createActionInvoker } from "./actions/createActionInvoker.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/createMinimalClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { createSharedClientContext } from "@osdk/shared.net";
import { createSharedClientContext } from "@osdk/shared.client.impl";
import type { Logger } from "pino";
import type {
MinimalClient,
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
export type { Client } from "./Client.js";
export { createClient } from "./createClient.js";

export { isOk } from "@osdk/shared.net";
export type { ResultOrError } from "@osdk/shared.net";
export { PalantirApiError } from "@osdk/shared.net";
export { PalantirApiError } from "@osdk/shared.net.errors";
export type {
ActionEditResponse,
ActionValidationResponse,
Expand All @@ -33,4 +31,6 @@ export type { OsdkObject } from "./OsdkObject.js";
export type { Osdk } from "./OsdkObjectFrom.js";
export type { PageResult } from "./PageResult.js";
export type { WhereClause } from "./query/WhereClause.js";
export { isOk } from "./ResultOrError.js";
export type { ResultOrError } from "./ResultOrError.js";
export type { NOOP } from "./util/NOOP.js";
4 changes: 2 additions & 2 deletions packages/client/src/object/convertWireToOsdkObjects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { createSharedClientContext } from "@osdk/shared.net";
import { createSharedClientContext } from "@osdk/shared.client.impl";
import { apiServer } from "@osdk/shared.test";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import type { Client } from "../Client.js";
Expand Down Expand Up @@ -107,7 +107,7 @@ describe("convertWireToOsdkObjects", () => {
);
createSharedClientContext(
"https://stack.palantir.com",
() => "myAccessToken",
async () => "myAccessToken",
"userAgent",
);

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/object/fetchSingle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import type { ObjectOrInterfaceDefinition } from "@osdk/api";
import type { ObjectSet } from "@osdk/internal.foundry";
import { PalantirApiError } from "@osdk/shared.net";
import { PalantirApiError } from "@osdk/shared.net.errors";
import type { Osdk } from "../index.js";
import type { MinimalClient } from "../MinimalClientContext.js";
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/ontology/makeConjureContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import type { SharedClientContext } from "@osdk/shared.net";
import type { SharedClientContext } from "@osdk/shared.client";
import type { ConjureContext } from "conjure-lite";

export function makeConjureContext(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/util/addUserAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import type { ObjectOrInterfaceDefinition } from "@osdk/api";
import { createFetchHeaderMutator } from "@osdk/shared.net";
import { createFetchHeaderMutator } from "@osdk/shared.net.fetch";
import type { MinimalClient } from "../MinimalClientContext.js";

export function addUserAgent(
Expand Down
11 changes: 3 additions & 8 deletions packages/foundry.core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@
"typecheck": "../../scripts/build_common/typecheck.sh esm"
},
"dependencies": {
"@osdk/api": "workspace:^"
},
"peerDependencies": {
"@osdk/client": "workspace:^",
"@osdk/shared.net": "workspace:^"
"@osdk/shared.client": "workspace:^",
"@osdk/shared.net.platformapi": "workspace:^"
},
"devDependencies": {
"@osdk/api": "workspace:^",
"@osdk/shared.net": "workspace:^",
"typescript": "^5.4.5"
},
"publishConfig": {
Expand All @@ -54,7 +49,7 @@
"sls": {
"dependencies": {
"com.palantir.foundry.api:api-gateway": {
"minVersion": "1.834.0",
"minVersion": "1.840.0",
"maxVersion": "1.x.x"
}
}
Expand Down
37 changes: 37 additions & 0 deletions packages/foundry.core/src/_components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ export type GroupMembershipExpiration = string;
*/
export type GroupName = LooselyBrandedString<"GroupName">;

/**
* Log Safety: UNSAFE
*/
export interface GroupSearchFilter {
type: PrincipalFilterType;
value: string;
}

/**
* Log Safety: SAFE
*/
Expand Down Expand Up @@ -179,6 +187,11 @@ export type PageToken = LooselyBrandedString<"PageToken">;
*/
export type PreviewMode = boolean;

/**
* Log Safety: SAFE
*/
export type PrincipalFilterType = "queryString";

/**
* The ID of a Foundry Group or User.
*
Expand Down Expand Up @@ -206,6 +219,22 @@ export type Realm = LooselyBrandedString<"Realm">;
*/
export type ReleaseStatus = "ACTIVE" | "EXPERIMENTAL" | "DEPRECATED";

/**
* Log Safety: UNSAFE
*/
export interface SearchGroupsResponse {
data: Array<Group>;
nextPageToken?: PageToken;
}

/**
* Log Safety: UNSAFE
*/
export interface SearchUsersResponse {
data: Array<User>;
nextPageToken?: PageToken;
}

/**
* The size of the file or attachment in bytes.
*
Expand Down Expand Up @@ -285,6 +314,14 @@ export interface User {
*/
export type UserId = string;

/**
* Log Safety: UNSAFE
*/
export interface UserSearchFilter {
type: PrincipalFilterType;
value: string;
}

/**
* Log Safety: UNSAFE
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/foundry.core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ export type {
GroupMembership,
GroupMembershipExpiration,
GroupName,
GroupSearchFilter,
OrganizationRid,
PageSize,
PageToken,
PreviewMode,
PrincipalFilterType,
PrincipalId,
PrincipalType,
Realm,
ReleaseStatus,
SearchGroupsResponse,
SearchUsersResponse,
SizeBytes,
Subdomain,
ThirdPartyApplication,
Expand All @@ -51,6 +55,7 @@ export type {
UpdatedTime,
User,
UserId,
UserSearchFilter,
UserUsername,
Version,
VersionVersion,
Expand Down
12 changes: 4 additions & 8 deletions packages/foundry.security/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
"typecheck": "../../scripts/build_common/typecheck.sh esm"
},
"dependencies": {
"@osdk/api": "workspace:^",
"@osdk/foundry.core": "workspace:*"
},
"peerDependencies": {
"@osdk/client": "workspace:^",
"@osdk/shared.net": "workspace:^"
"@osdk/foundry.core": "workspace:*",
"@osdk/shared.client": "workspace:^",
"@osdk/shared.net.platformapi": "workspace:^"
},
"devDependencies": {
"@osdk/shared.net": "workspace:^",
"typescript": "^5.4.5"
},
"publishConfig": {
Expand All @@ -54,7 +50,7 @@
"sls": {
"dependencies": {
"com.palantir.foundry.api:api-gateway": {
"minVersion": "1.834.0",
"minVersion": "1.840.0",
"maxVersion": "1.x.x"
}
}
Expand Down
Loading

0 comments on commit cd1a098

Please sign in to comment.