Skip to content

Commit

Permalink
Updates gateway versions and uses Response type for Binary Data (#1013)
Browse files Browse the repository at this point in the history
* Update to use response type

* changest
  • Loading branch information
nihalbhatnagar authored Nov 22, 2024
1 parent 0a7c747 commit 6b6c8a1
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 108 deletions.
12 changes: 12 additions & 0 deletions .changeset/tasty-rats-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@osdk/foundry-sdk-generator": patch
"@osdk/generator-converters": patch
"@osdk/cli.cmd.typescript": patch
"@osdk/shared.test": patch
"@osdk/generator": patch
"@osdk/client": patch
"@osdk/maker": patch
"@osdk/api": patch
---

Updates gateway endpoints and changes fetchContents for attachments to return a response
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ pnpm-publish-summary.json

api-docs/
temp/
tsup.config.bundled_*.mjs
tsup.config.bundled_*.mjs

vitest.workspace.ts
2 changes: 1 addition & 1 deletion etc/api.report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export interface AsyncIterArgs<Q extends ObjectOrInterfaceDefinition, K extends

// @public (undocumented)
export interface Attachment {
fetchContents(): Promise<Blob>;
fetchContents(): Promise<Response>;
// Warning: (ae-forgotten-export) The symbol "AttachmentMetadata" needs to be exported by the entry point index.d.ts
fetchMetadata(): Promise<AttachmentMetadata>;
// (undocumented)
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/object/Attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface Attachment {
/**
* Fetches actual content of attachment in Blob form
*/
fetchContents(): Promise<Blob>;
fetchContents(): Promise<Response>;
}
/**
* This interface should also accept the File object from
Expand Down
4 changes: 2 additions & 2 deletions packages/cli.cmd.typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@arethetypeswrong/cli": "^0.15.2",
"@osdk/cli.common": "workspace:~",
"@osdk/generator": "workspace:~",
"@osdk/internal.foundry.core": "2.6.0-beta.0",
"@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.0",
"@osdk/internal.foundry.core": "2.6.0-beta.1",
"@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.1",
"@osdk/shared.net": "workspace:~",
"consola": "^3.2.3",
"fast-deep-equal": "^3.1.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"@osdk/api": "workspace:~",
"@osdk/client.unstable": "workspace:*",
"@osdk/generator-converters": "workspace:*",
"@osdk/internal.foundry.core": "2.6.0-beta.0",
"@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.0",
"@osdk/internal.foundry.core": "2.6.0-beta.1",
"@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.1",
"@osdk/shared.client": "^1.0.1",
"@osdk/shared.client.impl": "workspace:~",
"@osdk/shared.client2": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/createAttachmentFromRid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function createAttachmentFromRid(
return OntologiesV2.Attachments.read(
client,
rid,
) as Promise<Blob>;
);
},
async fetchMetadata() {
const r = await OntologiesV2.Attachments.get(client, rid);
Expand Down
5 changes: 3 additions & 2 deletions packages/client/src/util/timeseriesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import type { TimeSeriesQuery } from "@osdk/api";
import { TimeseriesDurationMapping, TimeSeriesPoint } from "@osdk/api";
import type { TimeRange } from "@osdk/internal.foundry.core";
import invariant from "tiny-invariant";
import { iterateReadableStream, parseStreamedResponse } from "./streamutils.js";

export function getTimeRange(body: TimeSeriesQuery): TimeRange {
Expand Down Expand Up @@ -49,9 +50,9 @@ export function getTimeRange(body: TimeSeriesQuery): TimeRange {
export async function* asyncIterPointsHelper<
T extends number | string | GeoJSON.Point,
>(
iterator: Blob,
iterator: Response,
) {
const reader = iterator.stream().getReader();
const reader = iterator.body?.getReader()!;
for await (
const point of parseStreamedResponse(iterateReadableStream(reader))
) {
Expand Down
10 changes: 5 additions & 5 deletions packages/foundry-sdk-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"dependencies": {
"@osdk/api": "workspace:*",
"@osdk/client": "workspace:*",
"@osdk/foundry.core": "2.6.0-beta.0",
"@osdk/foundry.thirdpartyapplications": "2.6.0-beta.0",
"@osdk/foundry.core": "2.6.0-beta.1",
"@osdk/foundry.thirdpartyapplications": "2.6.0-beta.1",
"@osdk/generator": "workspace:*",
"@osdk/internal.foundry.core": "2.6.0-beta.0",
"@osdk/internal.foundry.ontologies": "2.6.0-beta.0",
"@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.0",
"@osdk/internal.foundry.core": "2.6.0-beta.1",
"@osdk/internal.foundry.ontologies": "2.6.0-beta.1",
"@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.1",
"@osdk/shared.net": "workspace:*",
"@rollup/plugin-commonjs": "28.0.0",
"@rollup/plugin-node-resolve": "15.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/generator-converters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@osdk/api": "workspace:~",
"@osdk/internal.foundry.core": "2.6.0-beta.0"
"@osdk/internal.foundry.core": "2.6.0-beta.1"
},
"devDependencies": {
"@osdk/monorepo.api-extractor": "workspace:~",
Expand Down
1 change: 1 addition & 0 deletions packages/generator-converters/src/getEditedEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function getModifiedEntityTypes(
case "deleteLink":
case "createInterfaceObject":
case "modifyInterfaceObject":
case "deleteInterfaceObject":
break;
default:
const _: never = operation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ function actionPropertyToSdkPropertyDefinition(
return { type: "object", object: parameterType.objectTypeApiName };
case "array":
return actionPropertyToSdkPropertyDefinition(parameterType.subType);
default:
throw new Error(`Unsupported action parameter type: ${parameterType}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@osdk/api": "workspace:~",
"@osdk/generator-converters": "workspace:~",
"@osdk/internal.foundry.core": "2.6.0-beta.0",
"@osdk/internal.foundry.core": "2.6.0-beta.1",
"fast-deep-equal": "^3.1.3",
"fetch-retry": "^6.0.0",
"prettier": "^3.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/maker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"devDependencies": {
"@osdk/client.unstable": "workspace:~",
"@osdk/internal.foundry.core": "2.6.0-beta.0",
"@osdk/internal.foundry.core": "2.6.0-beta.1",
"@osdk/monorepo.api-extractor": "workspace:~",
"@osdk/monorepo.tsconfig": "workspace:~",
"@osdk/monorepo.tsup": "workspace:~",
Expand Down
8 changes: 4 additions & 4 deletions packages/shared.test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
},
"dependencies": {
"@osdk/api": "workspace:~",
"@osdk/internal.foundry.core": "2.6.0-beta.0",
"@osdk/internal.foundry.geo": "2.6.0-beta.0",
"@osdk/internal.foundry.ontologies": "2.6.0-beta.0",
"@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.0",
"@osdk/internal.foundry.core": "2.6.0-beta.1",
"@osdk/internal.foundry.geo": "2.6.0-beta.1",
"@osdk/internal.foundry.ontologies": "2.6.0-beta.1",
"@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.1",
"fetch-retry": "^6.0.0",
"json-stable-stringify": "^1.1.1",
"msw": "^2.3.4",
Expand Down
18 changes: 3 additions & 15 deletions packages/shared.test/src/handlers/loadObjectsEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,7 @@ export const loadObjectsEndpoints: Array<RequestHandler> = [
attachmentContentRequest[attachmentRid];

if (getAttachmentContentResponse) {
const blob = new Blob(
[JSON.stringify(getAttachmentContentResponse)],
{ type: "application/json" },
);
return blob;
return new Response(JSON.stringify(getAttachmentContentResponse));
}

throw new OpenApiCallError(404, AttachmentNotFoundError);
Expand Down Expand Up @@ -639,11 +635,7 @@ export const loadObjectsEndpoints: Array<RequestHandler> = [
const getAttachmentContentResponse =
attachmentContentRequest[propertyName];
if (getAttachmentContentResponse) {
const blob = new Blob(
[JSON.stringify(getAttachmentContentResponse)],
{ type: "application/json" },
);
return blob;
return new Response(JSON.stringify(getAttachmentContentResponse));
}

throw new OpenApiCallError(404, AttachmentNotFoundError);
Expand Down Expand Up @@ -705,11 +697,7 @@ async function handleStreamValues(
|| req.params.ontologyApiName === defaultOntology.rid)
&& req.params.objectType === employeeObjectType.apiName
) {
const blob = new Blob(
[JSON.stringify(streamPointsResp)],
{ type: "application/json" },
);
return blob;
return new Response(JSON.stringify(streamPointsResp));
}
throw new OpenApiCallError(400, InvalidRequest("Invalid request"));
}
6 changes: 4 additions & 2 deletions packages/shared.test/src/handlers/util/handleOpenApiCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ export function handleOpenApiCall<
info as any,
);

if (result instanceof Blob) {
return new HttpResponse(result) as StrictResponse<DefaultBodyType>;
if (result instanceof Response) {
return new HttpResponse(result.body) as StrictResponse<
DefaultBodyType
>;
}
return HttpResponse.json(
result,
Expand Down
Loading

0 comments on commit 6b6c8a1

Please sign in to comment.