Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-markdown": "^10.1.0",
"react-router": "^7.18.2"
"react-router": "^7.18.2",
"zod": "4.6.5"
},
"devDependencies": {
"@babel/core": "^7.29.6",
Expand Down Expand Up @@ -68,9 +69,15 @@
"webpack-dev-server": "6.0.0",
"ajv": "8.20.0",
"commander": "15.0.0",
"vite": "8.3.4"
"vite": "8.3.4",
"zod": "4.6.5",
"msw": "2.15.0",
"vitest": "5.0.1",
"@vitest/coverage-v8": "5.0.1",
"happy-dom": "20.14.5"
},
"scripts": {
"prepare": "npm run build -w @pulp-ui/sdk",
"build": "NODE_ENV=production webpack --config config/build.config.js",
"cypress": "cypress open",
"cypress:chrome": "cypress run --e2e --browser chrome --headless",
Expand Down Expand Up @@ -99,7 +106,10 @@
"prettier:check": "prettier -l .",
"sort-exports": "perl -i -pe 's/^export/import/' src/**/index.ts ; npm run prettier ; perl -i -pe 's/^import/export/' src/**/index.ts",
"start": "NODE_ENV=development webpack serve --config config/start.config.js",
"test": "true",
"test": "vitest run",
"test:integration": "vitest --tags-filter=integration",
"test:unit": "vitest --tags-filter=unit",
"test:coverage": "vitest run --coverage",
"upgrade": "npx npm-check-updates -u -t minor"
},
"engines": {
Expand Down
7 changes: 5 additions & 2 deletions packages/sdk/orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export default defineConfig({
target: targetUrl,
filters: {
mode: 'include',
tags: ['Status'],
tags: ['Status', 'Login'],
},
},
output: {
client: 'fetch',
namingConvention: 'kebab-case',
mode: 'tags',
target: './src/core/core.ts',
schemas: { path: './src/core/models', splitByTags: true },
schemas: { path: './src/core/models', splitByTags: true, type: 'zod' },
indexFiles: false,
clean: true,
override: {
Expand All @@ -34,6 +34,9 @@ export default defineConfig({
...(info.description ? [info.description] : []),
...(info.version ? [`OpenAPI spec version: ${info.version}`] : []),
],
zod: {
generateReusableSchemas: true,
},
},
},
hooks: {
Expand Down
17 changes: 9 additions & 8 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@
"check-versions": "node ./scripts/check-pulp-versions.mts",
"update-versions": "node ./scripts/update-pulp-versions.mts",
"typecheck": "tsc --noEmit -p ./tsconfig.json",
"test": "vitest run",
"test:integration": "vitest --tags-filter=integration",
"test:coverage": "vitest run --coverage"
"build": "tsc -p tsconfig.build.json"
},
"devDependencies": {
"orval": "8.35.0",
"typescript": "7.0.2",
"msw": "2.15.0",
"vitest": "5.0.1",
"@vitest/coverage-v8": "5.0.1",
"happy-dom": "20.14.5"
"zod": "4.6.5"
},
"peerDependencies": {
"zod": "^4.6.5"
},
"exports": {
"./core/*": "./src/core/*.ts"
"./core/*": {
"types": "./dist/core/*.d.ts",
"default": "./dist/core/*.js"
}
}
}
2 changes: 1 addition & 1 deletion packages/sdk/pulp-versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"generatedAt": "2026-10-01T10:18:36.290Z",
"generatedAt": "2026-10-02T13:01:11.702Z",
"versions": {
"core": "3.112.0",
"hugging_face": "0.3.0",
Expand Down
115 changes: 115 additions & 0 deletions packages/sdk/src/core/login.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* Generated by orval
* Do not edit manually.
* Pulp 3 API
* Fetch, Upload, Organize, and Distribute Software Packages
* OpenAPI spec version: v3
*/
import { pulpFetch } from '../mutator/pulp-fetch.ts';
import type { LoginReadParams } from './models/login/login-read-params.zod.ts';
import type { LoginResponse } from './models/login/login-response.zod.ts';
import type { LoginUpdateResponse } from './models/login/login-update-response.zod.ts';
import type { PatchedLoginUpdate } from './models/login/patched-login-update.zod.ts';

export const getLoginReadUrl = (params?: LoginReadParams) => {
const normalizedParams = new URLSearchParams();

Object.entries(params || {}).forEach(([key, value]) => {
const explodeParameters = ['fields', 'exclude_fields'];

if (Array.isArray(value) && explodeParameters.includes(key)) {
value.forEach((v) => {
normalizedParams.append(key, v === null ? 'null' : String(v));
});
return;
}
});

const stringifiedParams = normalizedParams.toString();

return stringifiedParams.length > 0
? `/pulp/api/v3/login/?${stringifiedParams}`
: `/pulp/api/v3/login/`;
};

export const loginRead = async (
params?: LoginReadParams,
options?: Parameters<typeof pulpFetch>[1],
): Promise<LoginResponse> => {
return pulpFetch<LoginResponse>(getLoginReadUrl(params), {
...options,
method: 'GET',
});
};

export const getLoginUrl = () => {
return `/pulp/api/v3/login/`;
};

export const login = async (
options?: Parameters<typeof pulpFetch>[1],
): Promise<LoginResponse> => {
return pulpFetch<LoginResponse>(getLoginUrl(), {
...options,
method: 'POST',
});
};

export const getLoginUpdateUrl = () => {
return `/pulp/api/v3/login/`;
};

export const loginUpdate = async (
patchedLoginUpdate: PatchedLoginUpdate,
options?: Parameters<typeof pulpFetch>[1],
): Promise<LoginUpdateResponse> => {
const getHeaders = (
h?: NonNullable<RequestInit['headers']>,
): Record<string, string | readonly string[]> => {
if (!h) {
return {};
}
if (h instanceof Headers) {
return Object.fromEntries(h.entries());
}
if (Symbol.iterator in h) {
return Object.fromEntries(
Array.from(
h as Iterable<Iterable<string>>,
(entry) => Array.from(entry) as [string, string],
),
);
}
const headers: Record<string, string | readonly string[]> = {};
for (const [name, value] of Object.entries<
string | readonly string[] | undefined
>(h)) {
if (value !== undefined) {
headers[name] = value;
}
}
return headers;
};
return pulpFetch<LoginUpdateResponse>(getLoginUpdateUrl(), {
...options,
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
...getHeaders(options?.headers),
},
body: JSON.stringify(patchedLoginUpdate),
});
};

export const getLogoutUrl = () => {
return `/pulp/api/v3/login/`;
};

export const logout = async (
options?: Parameters<typeof pulpFetch>[1],
): Promise<void> => {
return pulpFetch<void>(getLogoutUrl(), {
...options,
method: 'DELETE',
});
};
15 changes: 15 additions & 0 deletions packages/sdk/src/core/models/login/login-headers.zod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Generated by orval
* Do not edit manually.
* Pulp 3 API
* Fetch, Upload, Organize, and Distribute Software Packages
* OpenAPI spec version: v3
*/
import * as zod from 'zod';

export const LoginHeaders = zod.object({
'X-Task-Diagnostics': zod.array(zod.string()).optional(),
});

export type LoginHeaders = zod.input<typeof LoginHeaders>;
export type LoginHeadersOutput = zod.output<typeof LoginHeaders>;
15 changes: 15 additions & 0 deletions packages/sdk/src/core/models/login/login-read-headers.zod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Generated by orval
* Do not edit manually.
* Pulp 3 API
* Fetch, Upload, Organize, and Distribute Software Packages
* OpenAPI spec version: v3
*/
import * as zod from 'zod';

export const LoginReadHeaders = zod.object({
'X-Task-Diagnostics': zod.array(zod.string()).optional(),
});

export type LoginReadHeaders = zod.input<typeof LoginReadHeaders>;
export type LoginReadHeadersOutput = zod.output<typeof LoginReadHeaders>;
16 changes: 16 additions & 0 deletions packages/sdk/src/core/models/login/login-read-params.zod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Generated by orval
* Do not edit manually.
* Pulp 3 API
* Fetch, Upload, Organize, and Distribute Software Packages
* OpenAPI spec version: v3
*/
import * as zod from 'zod';

export const LoginReadParams = zod.object({
fields: zod.array(zod.string()).optional(),
exclude_fields: zod.array(zod.string()).optional(),
});

export type LoginReadParams = zod.input<typeof LoginReadParams>;
export type LoginReadParamsOutput = zod.output<typeof LoginReadParams>;
17 changes: 17 additions & 0 deletions packages/sdk/src/core/models/login/login-response.zod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Generated by orval
* Do not edit manually.
* Pulp 3 API
* Fetch, Upload, Organize, and Distribute Software Packages
* OpenAPI spec version: v3
*/
import * as zod from 'zod';

export const LoginResponse = zod.object({
pulp_href: zod.url().optional(),
prn: zod.string().optional(),
username: zod.string().optional(),
});

export type LoginResponse = zod.input<typeof LoginResponse>;
export type LoginResponseOutput = zod.output<typeof LoginResponse>;
15 changes: 15 additions & 0 deletions packages/sdk/src/core/models/login/login-update-headers.zod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Generated by orval
* Do not edit manually.
* Pulp 3 API
* Fetch, Upload, Organize, and Distribute Software Packages
* OpenAPI spec version: v3
*/
import * as zod from 'zod';

export const LoginUpdateHeaders = zod.object({
'X-Task-Diagnostics': zod.array(zod.string()).optional(),
});

export type LoginUpdateHeaders = zod.input<typeof LoginUpdateHeaders>;
export type LoginUpdateHeadersOutput = zod.output<typeof LoginUpdateHeaders>;
36 changes: 36 additions & 0 deletions packages/sdk/src/core/models/login/login-update-response.zod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Generated by orval
* Do not edit manually.
* Pulp 3 API
* Fetch, Upload, Organize, and Distribute Software Packages
* OpenAPI spec version: v3
*/
import * as zod from 'zod';

export const loginUpdateResponseUsernameMax = 150;

export const loginUpdateResponseFirstNameMax = 150;

export const loginUpdateResponseLastNameMax = 150;

export const LoginUpdateResponse = zod.object({
username: zod
.string()
.max(loginUpdateResponseUsernameMax)
.optional()
.describe('150 characters or fewer. Letters, digits and @/./+/-/_ only.'),
first_name: zod
.string()
.max(loginUpdateResponseFirstNameMax)
.optional()
.describe('First name'),
last_name: zod
.string()
.max(loginUpdateResponseLastNameMax)
.optional()
.describe('Last name'),
email: zod.email().optional().describe('Email address'),
});

export type LoginUpdateResponse = zod.input<typeof LoginUpdateResponse>;
export type LoginUpdateResponseOutput = zod.output<typeof LoginUpdateResponse>;
Loading
Loading