Skip to content

Commit

Permalink
Release 1.0.0-rc4
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed May 24, 2023
1 parent b7044b9 commit 15b2349
Show file tree
Hide file tree
Showing 28 changed files with 349 additions and 259 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"url-join": "4.0.1",
"@types/url-join": "4.0.1",
"form-data": "4.0.0",
"js-base64": "3.7.2",
"axios": "0.27.2"
"axios": "0.27.2",
"js-base64": "3.7.2"
},
"devDependencies": {
"@types/node": "17.0.33",
Expand Down
3 changes: 2 additions & 1 deletion src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ import { Apps } from "./api/resources/apps/client/Client";

export declare namespace SquidexClient {
interface Options {
environment?: environments.SquidexEnvironment | string;
environment?: core.Supplier<environments.SquidexEnvironment | string>;
appName: string;
token: core.Supplier<core.BearerToken>;
fetcher?: core.FetchFunction;
streamingFetcher?: core.StreamingFetchFunction;
}
}

Expand Down
92 changes: 48 additions & 44 deletions src/api/resources/apps/client/Client.ts

Large diffs are not rendered by default.

74 changes: 29 additions & 45 deletions src/api/resources/assets/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ import * as environments from "../../../../environments";
import * as core from "../../../../core";
import * as Squidex from "../../..";
import * as stream from "stream";
import URLSearchParams from "@ungap/url-search-params";
import { default as URLSearchParams } from "@ungap/url-search-params";
import urlJoin from "url-join";
import * as errors from "../../../../errors";
import * as serializers from "../../../../serialization";
import * as fs from "fs";
import FormData from "form-data";
import { default as FormData } from "form-data";

export declare namespace Assets {
interface Options {
environment?: environments.SquidexEnvironment | string;
environment?: core.Supplier<environments.SquidexEnvironment | string>;
appName: string;
token: core.Supplier<core.BearerToken>;
fetcher?: core.FetchFunction;
streamingFetcher?: core.StreamingFetchFunction;
}
}

Expand Down Expand Up @@ -105,7 +106,7 @@ export class Assets {

return await (this.options.streamingFetcher ?? core.streamingFetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/assets/${this.options.appName}/${idOrSlug}/${more}`
),
method: "GET",
Expand Down Expand Up @@ -203,7 +204,10 @@ export class Assets {
}

return await (this.options.streamingFetcher ?? core.streamingFetcher)({
url: urlJoin(this.options.environment ?? environments.SquidexEnvironment.Default, `api/assets/${id}`),
url: urlJoin(
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/assets/${id}`
),
method: "GET",
headers: {
Authorization: await this._getAuthorizationHeader(),
Expand Down Expand Up @@ -239,7 +243,7 @@ export class Assets {

const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/folders`
),
method: "GET",
Expand Down Expand Up @@ -306,7 +310,7 @@ export class Assets {
public async postAssetFolder(request: Squidex.CreateAssetFolderDto): Promise<Squidex.AssetFolderDto> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/folders`
),
method: "POST",
Expand Down Expand Up @@ -382,7 +386,7 @@ export class Assets {
public async putAssetFolder(id: string, request: Squidex.RenameAssetFolderDto): Promise<Squidex.AssetFolderDto> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/folders/${id}`
),
method: "PUT",
Expand Down Expand Up @@ -458,7 +462,7 @@ export class Assets {
public async deleteAssetFolder(id: string): Promise<void> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/folders/${id}`
),
method: "DELETE",
Expand Down Expand Up @@ -531,7 +535,7 @@ export class Assets {
): Promise<Squidex.AssetFolderDto> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/folders/${id}/parent`
),
method: "PUT",
Expand Down Expand Up @@ -607,7 +611,7 @@ export class Assets {
public async getTags(): Promise<Record<string, number>> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/tags`
),
method: "GET",
Expand Down Expand Up @@ -673,7 +677,7 @@ export class Assets {
public async putTag(name: string, request: Squidex.RenameTagDto): Promise<Record<string, number>> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/tags/${name}`
),
method: "PUT",
Expand Down Expand Up @@ -779,7 +783,7 @@ export class Assets {

const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets`
),
method: "GET",
Expand Down Expand Up @@ -847,17 +851,12 @@ export class Assets {
* @throws {@link Squidex.ContentTooLargeError}
* @throws {@link Squidex.InternalServerError}
*/
public async postAsset(
file: File | fs.ReadStream,
opts?: {
onUploadProgress: (event: ProgressEvent) => void;
}
): Promise<Squidex.AssetDto> {
public async postAsset(file: File | fs.ReadStream): Promise<Squidex.AssetDto> {
const _request = new FormData();
_request.append("file", file);
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets`
),
method: "POST",
Expand All @@ -871,7 +870,6 @@ export class Assets {
contentType: "multipart/form-data; boundary=" + _request.getBoundary(),
body: _request,
timeoutMs: 60000,
onUploadProgress: opts?.onUploadProgress,
});
if (_response.ok) {
return await serializers.AssetDto.parseOrThrow(_response.body, {
Expand Down Expand Up @@ -946,7 +944,7 @@ export class Assets {
const { noTotal, noSlowTotal, body: _body } = request;
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/query`
),
method: "POST",
Expand Down Expand Up @@ -1023,7 +1021,7 @@ export class Assets {
public async getAsset(id: string): Promise<Squidex.AssetDto> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/${id}`
),
method: "GET",
Expand Down Expand Up @@ -1088,18 +1086,12 @@ export class Assets {
* @throws {@link Squidex.ContentTooLargeError}
* @throws {@link Squidex.InternalServerError}
*/
public async postUpsertAsset(
file: File | fs.ReadStream,
id: string,
opts?: {
onUploadProgress: (event: ProgressEvent) => void;
}
): Promise<Squidex.AssetDto> {
public async postUpsertAsset(file: File | fs.ReadStream, id: string): Promise<Squidex.AssetDto> {
const _request = new FormData();
_request.append("file", file);
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/${id}`
),
method: "POST",
Expand All @@ -1113,7 +1105,6 @@ export class Assets {
contentType: "multipart/form-data; boundary=" + _request.getBoundary(),
body: _request,
timeoutMs: 60000,
onUploadProgress: opts?.onUploadProgress,
});
if (_response.ok) {
return await serializers.AssetDto.parseOrThrow(_response.body, {
Expand Down Expand Up @@ -1186,7 +1177,7 @@ export class Assets {
public async putAsset(id: string, request: Squidex.AnnotateAssetDto = {}): Promise<Squidex.AssetDto> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/${id}`
),
method: "PUT",
Expand Down Expand Up @@ -1272,7 +1263,7 @@ export class Assets {

const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/${id}`
),
method: "DELETE",
Expand Down Expand Up @@ -1343,7 +1334,7 @@ export class Assets {
public async bulkUpdateAssets(request: Squidex.BulkUpdateAssetsDto = {}): Promise<Squidex.BulkResultDto[]> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/bulk`
),
method: "POST",
Expand Down Expand Up @@ -1418,18 +1409,12 @@ export class Assets {
* @throws {@link Squidex.ContentTooLargeError}
* @throws {@link Squidex.InternalServerError}
*/
public async putAssetContent(
file: File | fs.ReadStream,
id: string,
opts?: {
onUploadProgress: (event: ProgressEvent) => void;
}
): Promise<Squidex.AssetDto> {
public async putAssetContent(file: File | fs.ReadStream, id: string): Promise<Squidex.AssetDto> {
const _request = new FormData();
_request.append("file", file);
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/${id}/content`
),
method: "PUT",
Expand All @@ -1443,7 +1428,6 @@ export class Assets {
contentType: "multipart/form-data; boundary=" + _request.getBoundary(),
body: _request,
timeoutMs: 60000,
onUploadProgress: opts?.onUploadProgress,
});
if (_response.ok) {
return await serializers.AssetDto.parseOrThrow(_response.body, {
Expand Down Expand Up @@ -1516,7 +1500,7 @@ export class Assets {
public async putAssetParent(id: string, request: Squidex.MoveAssetDto = {}): Promise<Squidex.AssetDto> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/assets/${id}/parent`
),
method: "PUT",
Expand Down
28 changes: 19 additions & 9 deletions src/api/resources/backups/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import urlJoin from "url-join";
import * as errors from "../../../../errors";
import * as Squidex from "../../..";
import * as serializers from "../../../../serialization";
import URLSearchParams from "@ungap/url-search-params";
import { default as URLSearchParams } from "@ungap/url-search-params";

export declare namespace Backups {
interface Options {
environment?: environments.SquidexEnvironment | string;
environment?: core.Supplier<environments.SquidexEnvironment | string>;
appName: string;
token: core.Supplier<core.BearerToken>;
fetcher?: core.FetchFunction;
streamingFetcher?: core.StreamingFetchFunction;
}
}

Expand All @@ -26,7 +27,7 @@ export class Backups {
public async getBackupContent(id: string): Promise<stream.Readable> {
return await (this.options.streamingFetcher ?? core.streamingFetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/backups/${id}`
),
method: "GET",
Expand All @@ -53,7 +54,7 @@ export class Backups {
public async deleteBackup(id: string): Promise<void> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/backups/${id}`
),
method: "DELETE",
Expand Down Expand Up @@ -130,7 +131,10 @@ export class Backups {
}

return await (this.options.streamingFetcher ?? core.streamingFetcher)({
url: urlJoin(this.options.environment ?? environments.SquidexEnvironment.Default, `api/apps/backups/${id}`),
url: urlJoin(
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/backups/${id}`
),
method: "GET",
headers: {
Authorization: await this._getAuthorizationHeader(),
Expand All @@ -155,7 +159,7 @@ export class Backups {
public async getBackups(): Promise<Squidex.BackupJobsDto> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/backups`
),
method: "GET",
Expand Down Expand Up @@ -221,7 +225,7 @@ export class Backups {
public async postBackup(): Promise<void> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(
this.options.environment ?? environments.SquidexEnvironment.Default,
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
`api/apps/${this.options.appName}/backups`
),
method: "POST",
Expand Down Expand Up @@ -288,7 +292,10 @@ export class Backups {
*/
public async getRestoreJob(): Promise<Squidex.RestoreJobDto> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(this.options.environment ?? environments.SquidexEnvironment.Default, "api/apps/restore"),
url: urlJoin(
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
"api/apps/restore"
),
method: "GET",
headers: {
Authorization: await this._getAuthorizationHeader(),
Expand Down Expand Up @@ -348,7 +355,10 @@ export class Backups {
*/
public async postRestoreJob(request: Squidex.RestoreRequestDto): Promise<void> {
const _response = await (this.options.fetcher ?? core.fetcher)({
url: urlJoin(this.options.environment ?? environments.SquidexEnvironment.Default, "api/apps/restore"),
url: urlJoin(
(await core.Supplier.get(this.options.environment)) ?? environments.SquidexEnvironment.Default,
"api/apps/restore"
),
method: "POST",
headers: {
Authorization: await this._getAuthorizationHeader(),
Expand Down
Loading

0 comments on commit 15b2349

Please sign in to comment.