diff --git a/.changeset/clever-rings-yawn.md b/.changeset/clever-rings-yawn.md new file mode 100644 index 000000000..906171516 --- /dev/null +++ b/.changeset/clever-rings-yawn.md @@ -0,0 +1,6 @@ +--- +"@osdk/client.api": patch +"@osdk/client": patch +--- + +Add docs for object sets and attachments. diff --git a/etc/client.api.report.api.md b/etc/client.api.report.api.md index 96063f42c..9e6cf3b4b 100644 --- a/etc/client.api.report.api.md +++ b/etc/client.api.report.api.md @@ -127,9 +127,7 @@ export type ApplyBatchActionOptions = { // @public (undocumented) export interface Attachment { - // (undocumented) fetchContents(): Promise; - // (undocumented) fetchMetadata(): Promise; // (undocumented) rid: string; @@ -397,7 +395,7 @@ export interface InterfaceObjectSet> ext // Warning: (ae-forgotten-export) The symbol "OkResult" needs to be exported by the entry point index.d.ts // -// @public (undocumented) +// @public export function isOk(a: Result): a is OkResult; // @public (undocumented) @@ -408,13 +406,23 @@ export type LinkNames = keyof Q["links"] // @public (undocumented) export interface MinimalObjectSet extends BaseObjectSet { - // (undocumented) + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag asyncIter: () => AsyncIterableIterator>; - // (undocumented) + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag fetchPage: , R extends boolean, const A extends Augments, S extends NullabilityAdherence = NullabilityAdherenceDefault>(args?: FetchPageArgs) => Promise>; - // (undocumented) + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag fetchPageWithErrors: , R extends boolean, const A extends Augments, S extends NullabilityAdherence = NullabilityAdherenceDefault>(args?: FetchPageArgs) => Promise>>; - // (undocumented) + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag where: (clause: WhereClause) => MinimalObjectSet; } @@ -440,21 +448,27 @@ export type NumericAggregateOption = "min" | "max" | "sum" | "avg" | "approximat // @public (undocumented) export interface ObjectSet extends MinimalObjectSet { - // (undocumented) + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag aggregate: >(req: AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy) => Promise>; - // (undocumented) fetchOne: Q extends ObjectTypeDefinition ? , R extends boolean, S extends false | "throw" = NullabilityAdherenceDefault>(primaryKey: PropertyValueClientToWire[Q["primaryKeyType"]], options?: SelectArg) => Promise> : never; - // (undocumented) fetchOneWithErrors: Q extends ObjectTypeDefinition ? , R extends boolean, S extends false | "throw" = NullabilityAdherenceDefault>(primaryKey: PropertyValueClientToWire[Q["primaryKeyType"]], options?: SelectArg) => Promise>> : never; - // (undocumented) intersect: (...objectSets: ReadonlyArray>) => ObjectSet; - // (undocumented) pivotTo: >(type: L) => ObjectSet>; - // (undocumented) subtract: (...objectSets: ReadonlyArray>) => ObjectSet; - // (undocumented) union: (...objectSets: ReadonlyArray>) => ObjectSet; - // (undocumented) + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag where: (clause: WhereClause) => ObjectSet; } @@ -712,13 +726,15 @@ export interface TimeSeriesPoint { // @public (undocumented) export interface TimeSeriesProperty { - // (undocumented) + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag asyncIterPoints(query?: TimeSeriesQuery): AsyncGenerator>; - // (undocumented) + // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" + // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag getAllPoints(query?: TimeSeriesQuery): Promise>>; - // (undocumented) getFirstPoint(): Promise>; - // (undocumented) getLastPoint(): Promise>; } diff --git a/etc/client.report.api.md b/etc/client.report.api.md index 8cfffb1b0..abf86a5cf 100644 --- a/etc/client.report.api.md +++ b/etc/client.report.api.md @@ -75,7 +75,7 @@ export interface Client extends SharedClient { >(o: CheckVersionBound): QuerySignatureFromDef; } -// @public (undocumented) +// @public export function createAttachmentFromRid(client: MinimalClient, rid: string): Attachment; // @public (undocumented) diff --git a/packages/client.api/src/object/Attachment.ts b/packages/client.api/src/object/Attachment.ts index 438beba31..3c855c418 100644 --- a/packages/client.api/src/object/Attachment.ts +++ b/packages/client.api/src/object/Attachment.ts @@ -16,7 +16,13 @@ export interface Attachment { rid: string; + /** + * Fetches metadata for an attachment + */ fetchMetadata(): Promise; + /** + * Fetches actual content of attachment in Blob form + */ fetchContents(): Promise; } /** diff --git a/packages/client.api/src/object/Result.ts b/packages/client.api/src/object/Result.ts index c24fc0d03..fae3c1c51 100644 --- a/packages/client.api/src/object/Result.ts +++ b/packages/client.api/src/object/Result.ts @@ -18,10 +18,20 @@ export type ErrorResult = { error: Error; value?: never }; export type OkResult = { value: V; error?: never }; export type Result = OkResult | ErrorResult; +/** + * Check if a result was successfully received + * @param a - result wrapped value + * @returns whether a result has a value in it + */ export function isOk(a: Result): a is OkResult { return ("value" in a); } +/** + * Check if a result contains an error value + * @param a Result wrapped value + * @returns whether a result has an error in it + */ export function isError(a: Result): a is ErrorResult { return ("error" in a); } diff --git a/packages/client.api/src/objectSet/ObjectSet.ts b/packages/client.api/src/objectSet/ObjectSet.ts index cd95ce2ba..ca15c639e 100644 --- a/packages/client.api/src/objectSet/ObjectSet.ts +++ b/packages/client.api/src/objectSet/ObjectSet.ts @@ -44,6 +44,18 @@ import type { BaseObjectSet } from "./BaseObjectSet.js"; export interface MinimalObjectSet extends BaseObjectSet { + /** + * Gets a page of objects of this type, with a result wrapper + * @param args - Args to specify next page token and page size, if applicable + * @example + * const myObjs = await objectSet.fetchPage({ + $pageSize: 10, + $nextPageToken: "nextPage" + }); + const myObjsResult = myObjs.data; + + * @returns a page of objects + */ fetchPage: < L extends ObjectOrInterfacePropertyKeysFrom2, R extends boolean, @@ -53,6 +65,20 @@ export interface MinimalObjectSet args?: FetchPageArgs, ) => Promise>; + /** + * Gets a page of objects of this type, with a result wrapper + * @param args - Args to specify next page token and page size, if applicable + * @example + * const myObjs = await objectSet.fetchPage({ + $pageSize: 10, + $nextPageToken: "nextPage" + }); + + if(isOk(myObjs)){ + const myObjsResult = myObjs.value.data; + } + * @returns a page of objects, wrapped in a result wrapper + */ fetchPageWithErrors: < L extends ObjectOrInterfacePropertyKeysFrom2, R extends boolean, @@ -62,10 +88,28 @@ export interface MinimalObjectSet args?: FetchPageArgs, ) => Promise>>; + /** + * Allows you to filter an object set with a given clause + * @param clause - Takes a filter clause + * @example + * await client(Office).where({ + meetingRooms: { $contains: "Grand Central" }, + meetingRoomCapacities: { $contains: 30 }, + }); + * @returns an objectSet + */ where: ( clause: WhereClause, ) => MinimalObjectSet; + /** + * Returns an async iterator to load all objects of this type + * @example + * for await (const obj of myObjectSet.asyncIter()){ + * // Handle obj + * } + * @returns an async iterator to load all objects + */ asyncIter: () => AsyncIterableIterator>; } @@ -77,28 +121,96 @@ export interface InterfaceObjectSet> export interface ObjectSet extends MinimalObjectSet { + /** + * Aggregate on a field in an object type + * @param req - an aggregation request where you can select fields and choose how to aggregate, e.g., max, min, avg, and also choose + * whether or not you order your results. You can also specify a groupBy field to group your aggregations + * @example + * const testAggregateCountWithGroups = await client(BoundariesUsState) + .aggregate({ + $select: { + $count: "unordered", + "latitude:max": "unordered", + "latitude:min": "unordered", + "latitude:avg": "unordered", + }, + $groupBy: { + usState: "exact", + longitude: { + $fixedWidth: 10, + }, + }, + }); + + * @returns aggregation results, sorted in the groups based on the groupBy clause (if applicable) + */ aggregate: >( req: AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy, ) => Promise>; + /** + * Allows you to filter an object set with a given clause + * @param clause - Takes a filter clause + * @example + * await client(Office).where({ + meetingRooms: { $contains: "Grand Central" }, + meetingRoomCapacities: { $contains: 30 }, + }); + * @returns an objectSet + */ where: ( clause: WhereClause, ) => ObjectSet; + /** + * Unions object sets together + * @param objectSets - objectSets you want to union with + * @example + * const unionObjectSet = complexFilteredEmployeeObjectSet.union( + simpleFilteredEmployeeObjectSet, + ); + * @returns the unioned object set + */ union: ( ...objectSets: ReadonlyArray> ) => ObjectSet; + /** + * Computes the intersection of object sets + * @param objectSets - objectSets you want to intersect with + * @example + * const intersectedObjectSet = complexFilteredEmployeeObjectSet.intersect( + simpleFilteredEmployeeObjectSet, + ); + * @returns the intersected object set + */ intersect: ( ...objectSets: ReadonlyArray> ) => ObjectSet; + /** + * Computes the subtraction of object sets + * @param objectSets - objectSets you want to subtract from + * @example + * const subtractObjectSet = complexFilteredEmployeeObjectSet.subtract( + simpleFilteredEmployeeObjectSet, + ); + * @returns the subtract object set + */ subtract: ( ...objectSets: ReadonlyArray> ) => ObjectSet; + /** + * Pivots the object set over to all its linked objects of the specified type + * @param type - The linked object type you want to pivot to + * @returns an object set of the specified linked type + */ pivotTo: >(type: L) => ObjectSet>; + /** + * Fetches one object with the specified primary key, without a result wrapper + */ fetchOne: Q extends ObjectTypeDefinition ? < L extends ObjectOrInterfacePropertyKeysFrom2, R extends boolean, @@ -109,6 +221,9 @@ export interface ObjectSet ) => Promise> : never; + /** + * Fetches one object with the specified primary key, with a result wrapper + */ fetchOneWithErrors: Q extends ObjectTypeDefinition ? < L extends ObjectOrInterfacePropertyKeysFrom2, R extends boolean, diff --git a/packages/client.api/src/timeseries/timeseries.ts b/packages/client.api/src/timeseries/timeseries.ts index be8d2ffb5..e86a9e438 100644 --- a/packages/client.api/src/timeseries/timeseries.ts +++ b/packages/client.api/src/timeseries/timeseries.ts @@ -68,8 +68,36 @@ export interface TimeSeriesPoint { } export interface TimeSeriesProperty { + /** + * Queries the first point of the Timeseries + */ getFirstPoint(): Promise>; + /** + * Queries the last point of the Timeseries + */ getLastPoint(): Promise>; + /** + * Loads all points, within the given time range if that's provided + * @param query - a query representing either an absolute or relative range of time + * @example + * const points = await employee.employeeStatus?.getAllPoints({ + $after: 1, + $unit: "month", + }); + */ getAllPoints(query?: TimeSeriesQuery): Promise>>; + /** + * Returns an async iterator to load all points + * within the given time range if that's provided + * @param query - a query representing either an absolute or relative range of time + * @example + * const iterator = employee.employeeStatus?.asyncIter({ + $after: 1, + $unit: "month", + }); + for await (const point of iterator) { + // Handle time series point + } + */ asyncIterPoints(query?: TimeSeriesQuery): AsyncGenerator>; } diff --git a/packages/client/src/createAttachmentFromRid.ts b/packages/client/src/createAttachmentFromRid.ts index 4da344e79..2932354cd 100644 --- a/packages/client/src/createAttachmentFromRid.ts +++ b/packages/client/src/createAttachmentFromRid.ts @@ -18,6 +18,12 @@ import type { Attachment } from "@osdk/client.api"; import { Ontologies } from "@osdk/internal.foundry"; import type { MinimalClient } from "./MinimalClientContext.js"; +/** + * Helper function to create an attachment type from a rid + * @param client - minimal client + * @param rid - rid of attachment in Foundry + * @returns + */ export function createAttachmentFromRid( client: MinimalClient, rid: string,