diff --git a/src/lib/api/core/Api.ts b/src/lib/api/core/Api.ts index 15d880c..0f1eec9 100644 --- a/src/lib/api/core/Api.ts +++ b/src/lib/api/core/Api.ts @@ -22,9 +22,14 @@ import type { PluginPrincipalResp, PluginResp, PluginVersionPrincipalResp, + PluginVersionResp, ProcessorPrincipalResp, ProcessorResp, ProcessorVersionPrincipalResp, + ProcessorVersionResp, + PushPluginReq, + PushProcessorReq, + PushTemplateReq, TemplatePrincipalResp, TemplateResp, TemplateVersionPrincipalResp, @@ -336,7 +341,7 @@ export class Api< }, params: RequestParams = {}, ) => - this.request({ + this.request({ path: `/api/v${version}/Plugin/slug/${username}/${pluginName}/versions/${ver}`, method: "GET", query: query, @@ -344,6 +349,31 @@ export class Api< format: "json", ...params, }); + /** + * No description + * + * @tags Plugin + * @name VPluginSlugVersionsLatestDetail + * @request GET:/api/v{version}/Plugin/slug/{username}/{pluginName}/versions/latest + * @secure + */ + vPluginSlugVersionsLatestDetail = ( + username: string, + pluginName: string, + version: string, + query?: { + bumpDownload?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/api/v${version}/Plugin/slug/${username}/${pluginName}/versions/latest`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }); /** * No description * @@ -361,7 +391,7 @@ export class Api< version: string, params: RequestParams = {}, ) => - this.request({ + this.request({ path: `/api/v${version}/Plugin/id/${userId}/${pluginId}/versions/${ver}`, method: "GET", secure: true, @@ -393,6 +423,29 @@ export class Api< format: "json", ...params, }); + /** + * No description + * + * @tags Plugin + * @name VPluginPushCreate + * @request POST:/api/v{version}/Plugin/push/{username} + * @secure + */ + vPluginPushCreate = ( + username: string, + version: string, + data: PushPluginReq, + params: RequestParams = {}, + ) => + this.request({ + path: `/api/v${version}/Plugin/push/${username}`, + method: "POST", + body: data, + secure: true, + type: ContentType.Json, + format: "json", + ...params, + }); /** * No description * @@ -680,7 +733,7 @@ export class Api< }, params: RequestParams = {}, ) => - this.request({ + this.request({ path: `/api/v${version}/Processor/slug/${username}/${processorName}/versions/${ver}`, method: "GET", query: query, @@ -688,6 +741,31 @@ export class Api< format: "json", ...params, }); + /** + * No description + * + * @tags Processor + * @name VProcessorSlugVersionsLatestDetail + * @request GET:/api/v{version}/Processor/slug/{username}/{processorName}/versions/latest + * @secure + */ + vProcessorSlugVersionsLatestDetail = ( + username: string, + processorName: string, + version: string, + query?: { + bumpDownload?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/api/v${version}/Processor/slug/${username}/${processorName}/versions/latest`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }); /** * No description * @@ -705,7 +783,7 @@ export class Api< version: string, params: RequestParams = {}, ) => - this.request({ + this.request({ path: `/api/v${version}/Processor/id/${userId}/${processorId}/versions/${ver}`, method: "GET", secure: true, @@ -737,6 +815,29 @@ export class Api< format: "json", ...params, }); + /** + * No description + * + * @tags Processor + * @name VProcessorPushCreate + * @request POST:/api/v{version}/Processor/push/{username} + * @secure + */ + vProcessorPushCreate = ( + username: string, + version: string, + data: PushProcessorReq, + params: RequestParams = {}, + ) => + this.request({ + path: `/api/v${version}/Processor/push/${username}`, + method: "POST", + body: data, + secure: true, + type: ContentType.Json, + format: "json", + ...params, + }); /** * No description * @@ -1032,6 +1133,31 @@ export class Api< format: "json", ...params, }); + /** + * No description + * + * @tags Template + * @name VTemplateSlugVersionsLatestDetail + * @request GET:/api/v{version}/Template/slug/{username}/{templateName}/versions/latest + * @secure + */ + vTemplateSlugVersionsLatestDetail = ( + username: string, + templateName: string, + version: string, + query?: { + bumpDownload?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/api/v${version}/Template/slug/${username}/${templateName}/versions/latest`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }); /** * No description * @@ -1081,6 +1207,29 @@ export class Api< format: "json", ...params, }); + /** + * No description + * + * @tags Template + * @name VTemplatePushCreate + * @request POST:/api/v{version}/Template/push/{username} + * @secure + */ + vTemplatePushCreate = ( + username: string, + version: string, + data: PushTemplateReq, + params: RequestParams = {}, + ) => + this.request({ + path: `/api/v${version}/Template/push/${username}`, + method: "POST", + body: data, + secure: true, + type: ContentType.Json, + format: "json", + ...params, + }); /** * No description * diff --git a/src/lib/api/core/data-contracts.ts b/src/lib/api/core/data-contracts.ts index 767f93f..f3fd56f 100644 --- a/src/lib/api/core/data-contracts.ts +++ b/src/lib/api/core/data-contracts.ts @@ -22,7 +22,7 @@ export interface CreatePluginReq { export interface CreatePluginVersionReq { description?: string | null; dockerReference?: string | null; - dockerSha?: string | null; + dockerTag?: string | null; } export interface CreateProcessorReq { @@ -38,7 +38,7 @@ export interface CreateProcessorReq { export interface CreateProcessorVersionReq { description?: string | null; dockerReference?: string | null; - dockerSha?: string | null; + dockerTag?: string | null; } export interface CreateTemplateReq { @@ -54,9 +54,9 @@ export interface CreateTemplateReq { export interface CreateTemplateVersionReq { description?: string | null; blobDockerReference?: string | null; - blobDockerSha?: string | null; + blobDockerTag?: string | null; templateDockerReference?: string | null; - templateDockerSha?: string | null; + templateDockerTag?: string | null; plugins?: PluginReferenceReq[] | null; processors?: ProcessorReferenceReq[] | null; } @@ -122,6 +122,12 @@ export interface PluginVersionPrincipalResp { description?: string | null; dockerReference?: string | null; dockerSha?: string | null; + dockerTag?: string | null; +} + +export interface PluginVersionResp { + principal?: PluginVersionPrincipalResp; + plugin?: PluginPrincipalResp; } export interface ProcessorInfoResp { @@ -170,6 +176,55 @@ export interface ProcessorVersionPrincipalResp { description?: string | null; dockerReference?: string | null; dockerSha?: string | null; + dockerTag?: string | null; +} + +export interface ProcessorVersionResp { + principal?: ProcessorVersionPrincipalResp; + processor?: ProcessorPrincipalResp; +} + +export interface PushPluginReq { + name?: string | null; + project?: string | null; + source?: string | null; + email?: string | null; + tags?: string[] | null; + description?: string | null; + readme?: string | null; + versionDescription?: string | null; + dockerReference?: string | null; + dockerTag?: string | null; +} + +export interface PushProcessorReq { + name?: string | null; + project?: string | null; + source?: string | null; + email?: string | null; + tags?: string[] | null; + description?: string | null; + readme?: string | null; + versionDescription?: string | null; + dockerReference?: string | null; + dockerTag?: string | null; +} + +export interface PushTemplateReq { + name?: string | null; + project?: string | null; + source?: string | null; + email?: string | null; + tags?: string[] | null; + description?: string | null; + readme?: string | null; + versionDescription?: string | null; + blobDockerReference?: string | null; + blobDockerTag?: string | null; + templateDockerReference?: string | null; + templateDockerTag?: string | null; + plugins?: PluginReferenceReq[] | null; + processors?: ProcessorReferenceReq[] | null; } export interface TemplateInfoResp { @@ -211,6 +266,8 @@ export interface TemplateVersionPrincipalResp { blobDockerSha?: string | null; templateDockerReference?: string | null; templateDockerSha?: string | null; + blobDockerTag?: string | null; + templateDockerTag?: string | null; } export interface TemplateVersionResp { diff --git a/src/lib/api/core/http-client.ts b/src/lib/api/core/http-client.ts index 0e9d997..ca174b3 100644 --- a/src/lib/api/core/http-client.ts +++ b/src/lib/api/core/http-client.ts @@ -9,8 +9,6 @@ * --------------------------------------------------------------- */ -import { browser } from "$app/environment"; - export type QueryParamsType = Record; export type ResponseFormat = keyof Omit; @@ -70,14 +68,12 @@ export class HttpClient { private customFetch = (...fetchParams: Parameters) => fetch(...fetchParams); - private baseApiParams: RequestParams = browser - ? { - credentials: "same-origin", - headers: {}, - redirect: "follow", - referrerPolicy: "no-referrer", - } - : { headers: {} }; + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; constructor(apiConfig: ApiConfig = {}) { Object.assign(this, apiConfig); @@ -208,6 +204,7 @@ export class HttpClient { const queryString = query && this.toQueryString(query); const payloadFormatter = this.contentFormatters[type || ContentType.Json]; const responseFormat = format || requestParams.format; + return this.customFetch( `${baseUrl || this.baseUrl || ""}${path}${ queryString ? `?${queryString}` : "" @@ -233,6 +230,7 @@ export class HttpClient { const r = response as HttpResponse; r.data = null as unknown as T; r.error = null as unknown as E; + const data = !responseFormat ? r : await response[responseFormat]() diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index 978f084..cd0eaab 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -8,9 +8,10 @@ import { redirect } from "@sveltejs/kit"; import { config } from "../config/server"; export const load: LayoutServerLoad = async ({ locals, route }) => { - console.log(config); const session: Session | null = await locals.getSession(); + console.log(config); + const signIn = session?.user != null && (session.access_token == null || expired(session.access_token, new Date())); diff --git a/tsconfig.json b/tsconfig.json index 794b95b..78484a2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "allowJs": true, "checkJs": true, "esModuleInterop": true, + "isolatedModules": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "skipLibCheck": true,