Skip to content

Commit

Permalink
fix(api): fix bugs preventing builds
Browse files Browse the repository at this point in the history
  • Loading branch information
timzolleis committed Jun 6, 2024
1 parent fe2aa63 commit a14d35c
Show file tree
Hide file tree
Showing 24 changed files with 5,834 additions and 462 deletions.
16 changes: 13 additions & 3 deletions packages/procurat-node/dist/client/GeneratedProcurat.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import type { BaseHttpRequest } from "./core/BaseHttpRequest";
import type { OpenAPIConfig } from "./core/OpenAPI";
import { AddressService, CountriesService, DistrictsService, GroupsService, PersonService, RelationshipsService, ReligionsService } from "./services.gen";
import type { BaseHttpRequest } from './core/BaseHttpRequest';
import type { OpenAPIConfig } from './core/OpenAPI';
import { AddressService } from './services.gen';
import { CommunicationService } from './services.gen';
import { ContactInformationService } from './services.gen';
import { CountriesService } from './services.gen';
import { DistrictsService } from './services.gen';
import { GroupsService } from './services.gen';
import { PersonService } from './services.gen';
import { RelationshipsService } from './services.gen';
import { ReligionsService } from './services.gen';
type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
export declare class GeneratedProcurat {
readonly address: AddressService;
readonly communication: CommunicationService;
readonly contactInformation: ContactInformationService;
readonly countries: CountriesService;
readonly districts: DistrictsService;
readonly groups: GroupsService;
Expand Down
28 changes: 19 additions & 9 deletions packages/procurat-node/dist/client/GeneratedProcurat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ exports.GeneratedProcurat = void 0;
const OpenAPI_1 = require("./core/OpenAPI");
const AxiosHttpRequest_1 = require("./core/AxiosHttpRequest");
const services_gen_1 = require("./services.gen");
const services_gen_2 = require("./services.gen");
const services_gen_3 = require("./services.gen");
const services_gen_4 = require("./services.gen");
const services_gen_5 = require("./services.gen");
const services_gen_6 = require("./services.gen");
const services_gen_7 = require("./services.gen");
const services_gen_8 = require("./services.gen");
const services_gen_9 = require("./services.gen");
class GeneratedProcurat {
constructor(config, HttpRequest = AxiosHttpRequest_1.AxiosHttpRequest) {
var _a, _b, _c, _d, _e, _f, _g, _h;
this.request = new HttpRequest({
BASE: (_a = config === null || config === void 0 ? void 0 : config.BASE) !== null && _a !== void 0 ? _a : "http://localhost:8080/procurat_server_war_exploded/spring",
VERSION: (_b = config === null || config === void 0 ? void 0 : config.VERSION) !== null && _b !== void 0 ? _b : "0",
BASE: (_a = config === null || config === void 0 ? void 0 : config.BASE) !== null && _a !== void 0 ? _a : 'http://localhost:8080/procurat_server_war_exploded/spring',
VERSION: (_b = config === null || config === void 0 ? void 0 : config.VERSION) !== null && _b !== void 0 ? _b : '0',
WITH_CREDENTIALS: (_c = config === null || config === void 0 ? void 0 : config.WITH_CREDENTIALS) !== null && _c !== void 0 ? _c : false,
CREDENTIALS: (_d = config === null || config === void 0 ? void 0 : config.CREDENTIALS) !== null && _d !== void 0 ? _d : "include",
CREDENTIALS: (_d = config === null || config === void 0 ? void 0 : config.CREDENTIALS) !== null && _d !== void 0 ? _d : 'include',
TOKEN: config === null || config === void 0 ? void 0 : config.TOKEN,
USERNAME: config === null || config === void 0 ? void 0 : config.USERNAME,
PASSWORD: config === null || config === void 0 ? void 0 : config.PASSWORD,
Expand All @@ -23,12 +31,14 @@ class GeneratedProcurat {
},
});
this.address = new services_gen_1.AddressService(this.request);
this.countries = new services_gen_1.CountriesService(this.request);
this.districts = new services_gen_1.DistrictsService(this.request);
this.groups = new services_gen_1.GroupsService(this.request);
this.person = new services_gen_1.PersonService(this.request);
this.relationships = new services_gen_1.RelationshipsService(this.request);
this.religions = new services_gen_1.ReligionsService(this.request);
this.communication = new services_gen_2.CommunicationService(this.request);
this.contactInformation = new services_gen_3.ContactInformationService(this.request);
this.countries = new services_gen_4.CountriesService(this.request);
this.districts = new services_gen_5.DistrictsService(this.request);
this.groups = new services_gen_6.GroupsService(this.request);
this.person = new services_gen_7.PersonService(this.request);
this.relationships = new services_gen_8.RelationshipsService(this.request);
this.religions = new services_gen_9.ReligionsService(this.request);
}
}
exports.GeneratedProcurat = GeneratedProcurat;
4 changes: 2 additions & 2 deletions packages/procurat-node/dist/client/core/ApiError.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ApiRequestOptions } from "./ApiRequestOptions";
import type { ApiResult } from "./ApiResult";
import type { ApiRequestOptions } from './ApiRequestOptions';
import type { ApiResult } from './ApiResult';
export declare class ApiError extends Error {
readonly url: string;
readonly status: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/procurat-node/dist/client/core/ApiError.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.ApiError = void 0;
class ApiError extends Error {
constructor(request, response, message) {
super(message);
this.name = "ApiError";
this.name = 'ApiError';
this.url = response.url;
this.status = response.status;
this.statusText = response.statusText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export type ApiRequestOptions = {
readonly body?: any;
readonly mediaType?: string;
readonly responseHeader?: string;
readonly errors?: Record<number, string>;
readonly errors?: Record<number | string, string>;
};
8 changes: 4 additions & 4 deletions packages/procurat-node/dist/client/core/AxiosHttpRequest.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ApiRequestOptions } from "./ApiRequestOptions";
import { BaseHttpRequest } from "./BaseHttpRequest";
import type { CancelablePromise } from "./CancelablePromise";
import type { OpenAPIConfig } from "./OpenAPI";
import type { ApiRequestOptions } from './ApiRequestOptions';
import { BaseHttpRequest } from './BaseHttpRequest';
import type { CancelablePromise } from './CancelablePromise';
import type { OpenAPIConfig } from './OpenAPI';
export declare class AxiosHttpRequest extends BaseHttpRequest {
constructor(config: OpenAPIConfig);
/**
Expand Down
6 changes: 3 additions & 3 deletions packages/procurat-node/dist/client/core/BaseHttpRequest.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ApiRequestOptions } from "./ApiRequestOptions";
import type { CancelablePromise } from "./CancelablePromise";
import type { OpenAPIConfig } from "./OpenAPI";
import type { ApiRequestOptions } from './ApiRequestOptions';
import type { CancelablePromise } from './CancelablePromise';
import type { OpenAPIConfig } from './OpenAPI';
export declare abstract class BaseHttpRequest {
readonly config: OpenAPIConfig;
constructor(config: OpenAPIConfig);
Expand Down
6 changes: 3 additions & 3 deletions packages/procurat-node/dist/client/core/OpenAPI.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AxiosRequestConfig, AxiosResponse } from "axios";
import type { ApiRequestOptions } from "./ApiRequestOptions";
import type { AxiosRequestConfig, AxiosResponse } from 'axios';
import type { ApiRequestOptions } from './ApiRequestOptions';
type Headers = Record<string, string>;
type Middleware<T> = (value: T) => T | Promise<T>;
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
Expand All @@ -11,7 +11,7 @@ export declare class Interceptors<T> {
}
export type OpenAPIConfig = {
BASE: string;
CREDENTIALS: "include" | "omit" | "same-origin";
CREDENTIALS: 'include' | 'omit' | 'same-origin';
ENCODE_PATH?: ((path: string) => string) | undefined;
HEADERS?: Headers | Resolver<Headers> | undefined;
PASSWORD?: string | Resolver<string> | undefined;
Expand Down
6 changes: 3 additions & 3 deletions packages/procurat-node/dist/client/core/OpenAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class Interceptors {
}
exports.Interceptors = Interceptors;
exports.OpenAPI = {
BASE: "http://localhost:8080/procurat_server_war_exploded/spring",
CREDENTIALS: "include",
BASE: 'http://localhost:8080/procurat_server_war_exploded/spring',
CREDENTIALS: 'include',
ENCODE_PATH: undefined,
HEADERS: undefined,
PASSWORD: undefined,
TOKEN: undefined,
USERNAME: undefined,
VERSION: "0",
VERSION: '0',
WITH_CREDENTIALS: false,
interceptors: {
request: new Interceptors(),
Expand Down
12 changes: 6 additions & 6 deletions packages/procurat-node/dist/client/core/request.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { AxiosInstance, AxiosResponse } from "axios";
import type { ApiRequestOptions } from "./ApiRequestOptions";
import type { ApiResult } from "./ApiResult";
import type { OnCancel } from "./CancelablePromise";
import { CancelablePromise } from "./CancelablePromise";
import type { OpenAPIConfig } from "./OpenAPI";
import type { AxiosResponse, AxiosInstance } from 'axios';
import type { ApiRequestOptions } from './ApiRequestOptions';
import type { ApiResult } from './ApiResult';
import { CancelablePromise } from './CancelablePromise';
import type { OnCancel } from './CancelablePromise';
import type { OpenAPIConfig } from './OpenAPI';
export declare const isString: (value: unknown) => value is string;
export declare const isStringWithValue: (value: unknown) => value is string;
export declare const isBlob: (value: any) => value is Blob;
Expand Down
40 changes: 20 additions & 20 deletions packages/procurat-node/dist/client/core/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const axios_1 = __importDefault(require("axios"));
const ApiError_1 = require("./ApiError");
const CancelablePromise_1 = require("./CancelablePromise");
const isString = (value) => {
return typeof value === "string";
return typeof value === 'string';
};
exports.isString = isString;
const isStringWithValue = (value) => {
return (0, exports.isString)(value) && value !== "";
return (0, exports.isString)(value) && value !== '';
};
exports.isStringWithValue = isStringWithValue;
const isBlob = (value) => {
Expand All @@ -42,7 +42,7 @@ const base64 = (str) => {
}
catch (err) {
// @ts-ignore
return Buffer.from(str).toString("base64");
return Buffer.from(str).toString('base64');
}
};
exports.base64 = base64;
Expand All @@ -59,23 +59,23 @@ const getQueryString = (params) => {
append(key, value.toISOString());
}
else if (Array.isArray(value)) {
value.forEach((v) => encodePair(key, v));
value.forEach(v => encodePair(key, v));
}
else if (typeof value === "object") {
else if (typeof value === 'object') {
Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v));
}
else {
append(key, value);
}
};
Object.entries(params).forEach(([key, value]) => encodePair(key, value));
return qs.length ? `?${qs.join("&")}` : "";
return qs.length ? `?${qs.join('&')}` : '';
};
exports.getQueryString = getQueryString;
const getUrl = (config, options) => {
const encoder = config.ENCODE_PATH || encodeURI;
const path = options.url
.replace("{api-version}", config.VERSION)
.replace('{api-version}', config.VERSION)
.replace(/{(.*?)}/g, (substring, group) => {
var _a;
if ((_a = options.path) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(group)) {
Expand All @@ -101,7 +101,7 @@ const getFormData = (options) => {
.filter(([, value]) => value !== undefined && value !== null)
.forEach(([key, value]) => {
if (Array.isArray(value)) {
value.forEach((v) => process(key, v));
value.forEach(v => process(key, v));
}
else {
process(key, value);
Expand All @@ -113,7 +113,7 @@ const getFormData = (options) => {
};
exports.getFormData = getFormData;
const resolve = (options, resolver) => __awaiter(void 0, void 0, void 0, function* () {
if (typeof resolver === "function") {
if (typeof resolver === 'function') {
return resolver(options);
}
return resolver;
Expand All @@ -126,33 +126,33 @@ const getHeaders = (config, options) => __awaiter(void 0, void 0, void 0, functi
(0, exports.resolve)(options, config.PASSWORD),
(0, exports.resolve)(options, config.HEADERS),
]);
const headers = Object.entries(Object.assign(Object.assign({ Accept: "application/json" }, additionalHeaders), options.headers))
const headers = Object.entries(Object.assign(Object.assign({ Accept: 'application/json' }, additionalHeaders), options.headers))
.filter(([, value]) => value !== undefined && value !== null)
.reduce((headers, [key, value]) => (Object.assign(Object.assign({}, headers), { [key]: String(value) })), {});
if ((0, exports.isStringWithValue)(token)) {
headers["Authorization"] = `Bearer ${token}`;
headers['Authorization'] = `Bearer ${token}`;
}
if ((0, exports.isStringWithValue)(username) && (0, exports.isStringWithValue)(password)) {
const credentials = (0, exports.base64)(`${username}:${password}`);
headers["Authorization"] = `Basic ${credentials}`;
headers['Authorization'] = `Basic ${credentials}`;
}
if (options.body !== undefined) {
if (options.mediaType) {
headers["Content-Type"] = options.mediaType;
headers['Content-Type'] = options.mediaType;
}
else if ((0, exports.isBlob)(options.body)) {
headers["Content-Type"] = options.body.type || "application/octet-stream";
headers['Content-Type'] = options.body.type || 'application/octet-stream';
}
else if ((0, exports.isString)(options.body)) {
headers["Content-Type"] = "text/plain";
headers['Content-Type'] = 'text/plain';
}
else if (!(0, exports.isFormData)(options.body)) {
headers["Content-Type"] = "application/json";
headers['Content-Type'] = 'application/json';
}
}
else if (options.formData !== undefined) {
if (options.mediaType) {
headers["Content-Type"] = options.mediaType;
headers['Content-Type'] = options.mediaType;
}
}
return headers;
Expand Down Expand Up @@ -210,14 +210,14 @@ const getResponseBody = (response) => {
exports.getResponseBody = getResponseBody;
const catchErrorCodes = (options, result) => {
var _a, _b;
const errors = Object.assign({ 400: "Bad Request", 401: "Unauthorized", 402: "Payment Required", 403: "Forbidden", 404: "Not Found", 405: "Method Not Allowed", 406: "Not Acceptable", 407: "Proxy Authentication Required", 408: "Request Timeout", 409: "Conflict", 410: "Gone", 411: "Length Required", 412: "Precondition Failed", 413: "Payload Too Large", 414: "URI Too Long", 415: "Unsupported Media Type", 416: "Range Not Satisfiable", 417: "Expectation Failed", 418: "Im a teapot", 421: "Misdirected Request", 422: "Unprocessable Content", 423: "Locked", 424: "Failed Dependency", 425: "Too Early", 426: "Upgrade Required", 428: "Precondition Required", 429: "Too Many Requests", 431: "Request Header Fields Too Large", 451: "Unavailable For Legal Reasons", 500: "Internal Server Error", 501: "Not Implemented", 502: "Bad Gateway", 503: "Service Unavailable", 504: "Gateway Timeout", 505: "HTTP Version Not Supported", 506: "Variant Also Negotiates", 507: "Insufficient Storage", 508: "Loop Detected", 510: "Not Extended", 511: "Network Authentication Required" }, options.errors);
const errors = Object.assign({ 400: 'Bad Request', 401: 'Unauthorized', 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', 405: 'Method Not Allowed', 406: 'Not Acceptable', 407: 'Proxy Authentication Required', 408: 'Request Timeout', 409: 'Conflict', 410: 'Gone', 411: 'Length Required', 412: 'Precondition Failed', 413: 'Payload Too Large', 414: 'URI Too Long', 415: 'Unsupported Media Type', 416: 'Range Not Satisfiable', 417: 'Expectation Failed', 418: 'Im a teapot', 421: 'Misdirected Request', 422: 'Unprocessable Content', 423: 'Locked', 424: 'Failed Dependency', 425: 'Too Early', 426: 'Upgrade Required', 428: 'Precondition Required', 429: 'Too Many Requests', 431: 'Request Header Fields Too Large', 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', 504: 'Gateway Timeout', 505: 'HTTP Version Not Supported', 506: 'Variant Also Negotiates', 507: 'Insufficient Storage', 508: 'Loop Detected', 510: 'Not Extended', 511: 'Network Authentication Required' }, options.errors);
const error = errors[result.status];
if (error) {
throw new ApiError_1.ApiError(options, result, error);
}
if (!result.ok) {
const errorStatus = (_a = result.status) !== null && _a !== void 0 ? _a : "unknown";
const errorStatusText = (_b = result.statusText) !== null && _b !== void 0 ? _b : "unknown";
const errorStatus = (_a = result.status) !== null && _a !== void 0 ? _a : 'unknown';
const errorStatusText = (_b = result.statusText) !== null && _b !== void 0 ? _b : 'unknown';
const errorBody = (() => {
try {
return JSON.stringify(result.body, null, 2);
Expand Down
Loading

0 comments on commit a14d35c

Please sign in to comment.