Skip to content

Commit

Permalink
Add check-api for @osdk/client (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericanderson authored Jul 18, 2024
1 parent fee51a3 commit ddeb76f
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .changeset/weak-flies-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
61 changes: 52 additions & 9 deletions .monorepolint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ const DELETE_SCRIPT_ENTRY = { options: [undefined], fixValue: undefined };
const nonStandardPackages = [
"@osdk/examples.*",
"@osdk/foundry-sdk-generator",
"@osdk/monorepo.*",
"@osdk/monorepo.*", // internal monorepo packages
"@osdk/e2e.sandbox.*", // sandboxes for manual e2e testing
"@osdk/e2e.generated.*", // generated sdks for e2e testing
"@osdk/shared.client",
"@osdk/create-app.template.*",
"@osdk/monorepo.cspell",
"@osdk/shared.client", // hand written package that only exposes a symbol
"@osdk/create-app.template.*", // template packages for create-app
"@osdk/tests.*",
];

// Any package that is in the dependency chain of `legacy-client` needs to be in this list
const legacyPackages = [
"@osdk/api",
"@osdk/gateway",
Expand All @@ -56,10 +56,9 @@ const legacyPackages = [
const esmOnlyPackages = [
"@osdk/cli.*",
"@osdk/cli",
"@osdk/client.*",
"@osdk/client",
"@osdk/client.api",
"@osdk/client.unstable",
"@osdk/client.unstable.osw",
"@osdk/create-app.template-packager",
"@osdk/create-app",
"@osdk/example-generator",
"@osdk/foundry.*",
Expand All @@ -73,11 +72,14 @@ const esmOnlyPackages = [
"@osdk/shared.net.platformapi",
"@osdk/tool.release",
"@osdk/version-updater",
"@osdk/client.test.ontology",
"@osdk/create-app.template-packager",
// "@osdk/examples.*", but they have their own config cause they are nonstandard
];

const checkApiPackages = [
"@osdk/client",
"@osdk/client.api",
];

/**
* We don't want to allow `workspace:^` in our dependencies because our current release branch
* strategy only allows for patch changes in the release branch and minors elsewhere.
Expand Down Expand Up @@ -514,6 +516,8 @@ NOTE: DO NOT EDIT THIS README BY HAND. It is generated by monorepolint.
skipTsconfigReferences: true,
}),

...rulesForPackagesWithChecKApiTask(),

packageEntry({
options: {
entries: {
Expand Down Expand Up @@ -602,3 +606,42 @@ package you do so at your own risk.
}),
],
};

/**
* Rules for packages that do api checks / docs generation
* @returns {import("@monorepolint/config").RuleModule<any>[]}
*/
function rulesForPackagesWithChecKApiTask() {
return [
packageScript({
includePackages: checkApiPackages,
options: {
scripts: {
"check-api": "api-extractor run --verbose --local",
},
},
}),
requireDependency({
includePackages: checkApiPackages,
options: {
devDependencies: {
"@osdk/monorepo.api-extractor": "workspace:~",
"@microsoft/api-documenter": "^7.25.3",
"@microsoft/api-extractor": "^7.47.0",
},
},
}),
fileContents({
includePackages: checkApiPackages,
options: {
file: "api-extractor.json",
template: `{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "@osdk/monorepo.api-extractor/base.json",
"mainEntryPointFilePath": "<projectFolder>/build/esm/index.d.ts"
}
`,
},
}),
];
}
File renamed without changes.
121 changes: 121 additions & 0 deletions etc/client.report.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
## API Report File for "@osdk/client"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts

import type { ActionDefinition } from '@osdk/api';
import { ActionEditResponse } from '@osdk/client.api';
import { ActionReturnTypeForOptions } from '@osdk/client.api';
import type { ActionSignatureFromDef } from '@osdk/client.api';
import { ActionValidationResponse } from '@osdk/client.api';
import { ApplyActionOptions } from '@osdk/client.api';
import { ApplyBatchActionOptions } from '@osdk/client.api';
import type { Attachment } from '@osdk/client.api';
import type { GreaterThan } from 'type-fest';
import type { GreaterThanOrEqual } from 'type-fest';
import type { InterfaceDefinition } from '@osdk/api';
import { InterfaceObjectSet } from '@osdk/client.api';
import type { IsEqual } from 'type-fest';
import type { LessThan } from 'type-fest';
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';
import { OsdkObject } from '@osdk/client.api';
import { PageResult } from '@osdk/client.api';
import { PalantirApiError } from '@osdk/shared.net.errors';
import type { QueryDefinition } from '@osdk/api';
import type { QuerySignatureFromDef } from '@osdk/client.api';
import type { SharedClient } from '@osdk/shared.client';
import { SharedClientContext } from '@osdk/shared.client';
import type { VersionBound } from '@osdk/api';
import { WhereClause } from '@osdk/client.api';

export { ActionEditResponse }

export { ActionReturnTypeForOptions }

// @public (undocumented)
export class ActionValidationError extends Error {
constructor(validation: ActionValidationResponse);
// (undocumented)
validation: ActionValidationResponse;
}

export { ActionValidationResponse }

export { ApplyActionOptions }

export { ApplyBatchActionOptions }

// Warning: (ae-forgotten-export) The symbol "MinimalClient" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export interface Client extends SharedClient<MinimalClient> {
// Warning: (ae-forgotten-export) The symbol "CheckVersionBound" needs to be exported by the entry point index.d.ts
//
// (undocumented)
<Q extends (ObjectTypeDefinition<any, any> & VersionBound<any>)>(o: CheckVersionBound<Q>): ObjectSet<Q>;
// (undocumented)
<Q extends ActionDefinition<any, any, any>>(o: CheckVersionBound<Q>): ActionSignatureFromDef<Q>;
// (undocumented)
<Q extends QueryDefinition<any, any>>(o: CheckVersionBound<Q>): QuerySignatureFromDef<Q>;
}

// @public (undocumented)
export function createAttachmentFromRid(client: MinimalClient, rid: string): Attachment;

// @public (undocumented)
export const createClient: (baseUrl: string, ontologyRid: string | Promise<string>, tokenProvider: () => Promise<string>, options?: {
logger?: Logger;
} | undefined, fetchFn?: typeof fetch | undefined) => Client;

// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
//
// @public
export function createPlatformClient(baseUrl: string, tokenProvider: () => Promise<string>, options?: undefined, fetchFn?: typeof globalThis.fetch): SharedClientContext;

export { InterfaceObjectSet }

// @public (undocumented)
export function isOk(result: ResultOrError<any>): result is {
type: "ok";
};

export { NOOP }

export { ObjectSet }

export { Osdk }

export { OsdkActionParameters }

export { OsdkObject }

export { PageResult }

export { PalantirApiError }

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

export { WhereClause }

// (No @packageDocumentation comment for this package)

```
2 changes: 1 addition & 1 deletion packages/client.api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
}
},
"scripts": {
"api-checker": "api-extractor run --verbose --local",
"api-docs": "api-documenter markdown -i build/api-extractor --output-folder api-docs",
"check-api": "api-extractor run --verbose --local",
"check-attw": "../../scripts/build_common/check-attw.sh esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
Expand Down
5 changes: 5 additions & 0 deletions packages/client/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "@osdk/monorepo.api-extractor/base.json",
"mainEntryPointFilePath": "<projectFolder>/build/esm/index.d.ts"
}
3 changes: 3 additions & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
}
},
"scripts": {
"check-api": "api-extractor run --verbose --local",
"check-attw": "../../scripts/build_common/check-attw.sh esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
Expand Down Expand Up @@ -57,6 +58,8 @@
}
},
"devDependencies": {
"@microsoft/api-documenter": "^7.25.3",
"@microsoft/api-extractor": "^7.47.0",
"@osdk/client.test.ontology": "workspace:~",
"@osdk/internal.foundry": "workspace:~",
"@osdk/monorepo.api-extractor": "workspace:~",
Expand Down
2 changes: 1 addition & 1 deletion packages/monorepo.api-extractor/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"apiReport": {
"enabled": true,
"reportFileName": "<unscopedPackageName>.report.api.md",
"reportFolder": "<projectFolder>/etc/",
"reportFolder": "<projectFolder>/../../etc/",
"reportTempFolder": "<projectFolder>/build/api-extractor/"
},

Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,23 @@
"inputs": ["tsup.mjs"]
},

"api-checker": {
"check-api": {
"outputLogs": "new-only",
"inputs": ["api-extractor.json", "build/esm/**/*", "api-extractor.json"],
"outputs": ["etc/*.report.api.md", "build/api-extractor/**/*"],
"dependsOn": ["typecheck", "@osdk/monorepo.api-extractor#api-checker"]
"dependsOn": ["typecheck", "@osdk/monorepo.api-extractor#check-api"]
},

// Doesn't do anything, just a virtual task to depend on the base.json file
"@osdk/monorepo.api-extractor#api-checker": {
"@osdk/monorepo.api-extractor#check-api": {
"inputs": ["base.json"]
},

"api-docs": {
"outputLogs": "new-only",
"inputs": ["temp/**/*"],
"outputs": ["api-docs/**/*"],
"dependsOn": ["api-checker"]
"dependsOn": ["check-api"]
},

"postVersioning": {
Expand Down Expand Up @@ -176,7 +176,7 @@
"typecheck",
"test",
"check-attw",
"api-checker",
"check-api",
"check-spelling"
]
}
Expand Down

0 comments on commit ddeb76f

Please sign in to comment.