diff --git a/kiota-compatibility-guidelines.md b/kiota-compatibility-guidelines.md new file mode 100644 index 0000000..3969521 --- /dev/null +++ b/kiota-compatibility-guidelines.md @@ -0,0 +1,77 @@ +Here’s a concise **English version** of the essential Kiota-compatibility guidelines, suitable for giving to another AI agent or automated generator: + +--- + +## 🧩 **Kiota Compatibility Guidelines for NestJS Swagger APIs** + +**Goal:** Ensure the OpenAPI spec generated by NestJS Swagger can be fully parsed by Kiota without losing endpoints or models. + +--- + +### βœ… 1. OpenAPI Version + +* Use **OpenAPI 3.0.x** (Kiota doesn’t support 3.1). +* Avoid non-standard or experimental extensions. + +--- + +### βœ… 2. Request & Response Schemas + +* Always define a **schema** for every request and 2XX response. +* Use `application/json` as the single content type. +* Avoid multiple response formats per endpoint. +* Empty 204 responses β†’ no `type`, only `description`. + +--- + +### βœ… 3. Error Handling + +* Define object-type **error schemas** for 4XX/5XX responses. +* Avoid array-type root errors (`[{message}]` β†’ `{ errors: [...] }`). +* Kiota maps errors to typed exceptions only if schema exists. + +--- + +### βœ… 4. Models & Polymorphism + +* Use **`allOf` + `discriminator`** for inheritance. +* Avoid `oneOf`/`anyOf` unless you add a `discriminator` and reference named components. +* Never use anonymous inline schemas or `type: any`. + +--- + +### βœ… 5. Query & Header Parameters + +* Define query params individually (`@ApiQuery` per field). +* Avoid `deepObject` style; use simple `form` style. +* Enums in queries become **strings** in Kiota. +* Kiota does **not** auto-generate custom header fields β€” document required headers. + +--- + +### βœ… 6. Authentication + +* Use standard `Bearer`, `OAuth2`, or `openIdConnect` security schemes. +* Include `openIdConnectUrl` or token endpoint if applicable. +* Apply `@ApiBearerAuth()` on secured endpoints. + +--- + +### βœ… 7. File Uploads + +* Prefer JSON metadata + binary file upload separately. +* If multipart is required, use Kiota form-serialization packages (`@microsoft/kiota-serialization-form`). + +--- + +### βœ… 8. Validation & Generation + +* Check for Kiota CLI warnings (`kiota generate --log-level info`). +* Verify all endpoints produce request builders. +* Re-generate after Swagger or Kiota updates. + +--- + +**Outcome:** Following these rules ensures every NestJS API route and model is fully generated by Kiota’s TypeScript client without loss of fidelity. + +--- diff --git a/kiota-generate.ps1 b/kiota-generate.ps1 index f9648b3..5270809 100755 --- a/kiota-generate.ps1 +++ b/kiota-generate.ps1 @@ -1,4 +1,4 @@ $ENDPOINT = "https://wiki.dahyeon.us/v1" # $ENDPOINT = "https://dev.dahyeon.us/v1" -kiota generate --openapi $ENDPOINT/api-yaml --language Typescript --output ./src/kiota --clean-output \ No newline at end of file +kiota generate --openapi $ENDPOINT/api-yaml --language Typescript --output ./src/kiota --clean-output --clear-cache \ No newline at end of file diff --git a/src/entities/page/api.ts b/src/entities/page/api.ts index 764cbcd..55e0071 100644 --- a/src/entities/page/api.ts +++ b/src/entities/page/api.ts @@ -1,28 +1,68 @@ import type { Page, CreatePageData, UpdatePageData } from './types'; import type { ApiClient } from '../../kiota/apiClient'; -import type { PageResponseDto, CreatePageDto, UpdatePageDto } from '../../kiota/models'; +import type { PageResponseDto } from '../../kiota/models'; +import type { PagePostRequestBody } from '../../kiota/v1/page'; +import type { WithPagePutRequestBody } from '../../kiota/v1/page/item'; import type { Guid } from '@microsoft/kiota-abstractions'; /** * Convert PageResponseDto to local Page type */ function mapPageResponseToPage(dto: PageResponseDto): Page { - // Handle content - it comes as a string from the server despite the Kiota type + // The API now returns these fields as object types due to Kiota limitations + // We need to extract the actual values from the serialized objects const content = (dto.content as any) || ''; const contentStr = typeof content === 'string' ? content : ''; - // Handle parentPageId - it comes as a Guid/string from the server despite the Kiota type const parentPageId = (dto.parentPageId as any); - const parentIdStr = parentPageId?.toString() || null; + + // Check if parentPageId is a valid GUID string or object with a value + let parentIdStr: string | null = null; + if (parentPageId) { + if (typeof parentPageId === 'string') { + parentIdStr = parentPageId; + } else if (typeof parentPageId === 'object') { + // Try multiple ways to extract the GUID + const keys = Object.keys(parentPageId); + if (keys.length === 0) { + // Empty object means null + parentIdStr = null; + } else { + // Try to find the actual GUID value + // Check common property names first + const guidValue = parentPageId.value || + parentPageId.id || + parentPageId.guid || + parentPageId[keys[0]]; // Use first key if exists + + if (typeof guidValue === 'string' && guidValue !== '[object Object]') { + parentIdStr = guidValue; + } else { + // Last resort: check if the object itself can be converted to a valid GUID + const strValue = parentPageId.toString(); + parentIdStr = strValue !== '[object Object]' ? strValue : null; + } + } + } + } + + const createdAt = (dto.createdAt as any); + const createdAtStr = createdAt ? (typeof createdAt === 'string' ? createdAt : new Date().toISOString()) : new Date().toISOString(); + + const updatedAt = (dto.updatedAt as any); + const updatedAtStr = updatedAt ? (typeof updatedAt === 'string' ? updatedAt : new Date().toISOString()) : new Date().toISOString(); + + const sortOrder = (dto.sortOrder as any); + const sortOrderNum = sortOrder ? (typeof sortOrder === 'number' ? sortOrder : undefined) : undefined; return { id: dto.pageId?.toString() || '', title: dto.title || '', content: contentStr, parentId: parentIdStr, - order: dto.sortOrder || undefined, - createdAt: dto.createdAt?.toISOString() || new Date().toISOString(), - updatedAt: dto.updatedAt?.toISOString() || new Date().toISOString(), + order: sortOrderNum, + createdAt: createdAtStr, + updatedAt: updatedAtStr, }; } @@ -34,11 +74,11 @@ export async function getPages(apiClient: ApiClient, spaceId?: string): Promise< queryParameters: spaceId ? { spaceId: spaceId as Guid } : undefined, }); - if (!response) { + if (!response || !response.pages) { return []; } - return response.map(mapPageResponseToPage); + return response.pages.map(mapPageResponseToPage); } /** @@ -52,21 +92,15 @@ export async function getPage(apiClient: ApiClient, pageId: string): Promise { - const createDto: CreatePageDto = { + const requestBody: PagePostRequestBody = { title: data.title, content: data.content, parentPageId: data.parentId as Guid | null | undefined, sortOrder: data.order, spaceId: spaceId as Guid, - userId: userId as Guid, }; - const response = await apiClient.v1.page.post(createDto); + const response = await apiClient.v1.page.post(requestBody); if (!response) { throw new Error('Failed to create page'); @@ -109,16 +141,16 @@ export async function createPage( export async function updatePage( apiClient: ApiClient, pageId: string, - data: UpdatePageData, - userId: string + data: UpdatePageData ): Promise { - const updateDto: UpdatePageDto = { + const requestBody: WithPagePutRequestBody = { title: data.title, content: data.content, - userId: userId as Guid, + parentPageId: data.parentId as Guid | null | undefined, + sortOrder: data.order, }; - const response = await apiClient.v1.page.byPageId(pageId as Guid).put(updateDto); + const response = await apiClient.v1.page.byPageId(pageId as Guid).put(requestBody); if (!response) { throw new Error(`Failed to update page ${pageId}`); @@ -132,10 +164,7 @@ export async function updatePage( */ export async function deletePage( apiClient: ApiClient, - pageId: string, - userId: string + pageId: string ): Promise { - await apiClient.v1.page.byPageId(pageId as Guid).delete({ - userId: userId as Guid, - }); + await apiClient.v1.page.byPageId(pageId as Guid).delete(); } diff --git a/src/entities/page/types.ts b/src/entities/page/types.ts index 9aeb9de..583d44c 100644 --- a/src/entities/page/types.ts +++ b/src/entities/page/types.ts @@ -18,4 +18,6 @@ export interface CreatePageData { export interface UpdatePageData { title: string; content: string; + parentId?: string | null; + order?: number; } diff --git a/src/kiota/kiota-lock.json b/src/kiota/kiota-lock.json index 2284c1f..a393afd 100644 --- a/src/kiota/kiota-lock.json +++ b/src/kiota/kiota-lock.json @@ -1,5 +1,5 @@ { - "descriptionHash": "C64A91036F62D15D93162E3F7F5EE01034379FC42298C27FCC2D9B38675AD428119460B568D89EC1A9B819B52FD11892B94DEC504EE319DD5FDEA1A4032450A4", + "descriptionHash": "A4E87469774A711C65C7C38D1FFF5D2AE8A03EB6DCF7EAAF17C32D88B642FB38D172697FBC5C22F9955B0487E7AC11061A94CA71B0C1479B601A4292AA1F7090", "descriptionLocation": "https://wiki.dahyeon.us/v1/api-yaml", "lockFileVersion": "1.0.0", "kiotaVersion": "1.28.0", diff --git a/src/kiota/models/index.ts b/src/kiota/models/index.ts index fb40bd5..1aad956 100644 --- a/src/kiota/models/index.ts +++ b/src/kiota/models/index.ts @@ -34,20 +34,20 @@ export function createDeleteSpaceResponseDtoFromDiscriminatorValue(parseNode: Pa /** * Creates a new instance of the appropriate class based on discriminator value * @param parseNode The parse node to use to read the discriminator value and create the object - * @returns {PageResponseDto_content} + * @returns {ErrorResponseDto} */ // @ts-ignore -export function createPageResponseDto_contentFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record void>) { - return deserializeIntoPageResponseDto_content; +export function createErrorResponseDtoFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record void>) { + return deserializeIntoErrorResponseDto; } /** * Creates a new instance of the appropriate class based on discriminator value * @param parseNode The parse node to use to read the discriminator value and create the object - * @returns {PageResponseDto_parentPageId} + * @returns {PageListResponseDto} */ // @ts-ignore -export function createPageResponseDto_parentPageIdFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record void>) { - return deserializeIntoPageResponseDto_parentPageId; +export function createPageListResponseDtoFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record void>) { + return deserializeIntoPageListResponseDto; } /** * Creates a new instance of the appropriate class based on discriminator value @@ -94,24 +94,6 @@ export function createSpaceStatisticsDto_statisticsFromDiscriminatorValue(parseN export function createSpaceStatisticsDtoFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record void>) { return deserializeIntoSpaceStatisticsDto; } -/** - * Creates a new instance of the appropriate class based on discriminator value - * @param parseNode The parse node to use to read the discriminator value and create the object - * @returns {TokenInfoDto_description} - */ -// @ts-ignore -export function createTokenInfoDto_descriptionFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record void>) { - return deserializeIntoTokenInfoDto_description; -} -/** - * Creates a new instance of the appropriate class based on discriminator value - * @param parseNode The parse node to use to read the discriminator value and create the object - * @returns {TokenInfoDto_expiresAt} - */ -// @ts-ignore -export function createTokenInfoDto_expiresAtFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record void>) { - return deserializeIntoTokenInfoDto_expiresAt; -} /** * Creates a new instance of the appropriate class based on discriminator value * @param parseNode The parse node to use to read the discriminator value and create the object @@ -201,6 +183,30 @@ export function deserializeIntoDeleteSpaceResponseDto(deleteSpaceResponseDto: Pa "spaceId": n => { deleteSpaceResponseDto.spaceId = n.getGuidValue(); }, } } +/** + * The deserialization information for the current model + * @param ErrorResponseDto The instance to deserialize into. + * @returns {Record void>} + */ +// @ts-ignore +export function deserializeIntoErrorResponseDto(errorResponseDto: Partial | undefined = {}) : Record void> { + return { + "error": n => { errorResponseDto.errorEscaped = n.getStringValue(); }, + "message": n => { errorResponseDto.messageEscaped = n.getStringValue(); }, + "statusCode": n => { errorResponseDto.statusCode = n.getNumberValue(); }, + } +} +/** + * The deserialization information for the current model + * @param PageListResponseDto The instance to deserialize into. + * @returns {Record void>} + */ +// @ts-ignore +export function deserializeIntoPageListResponseDto(pageListResponseDto: Partial | undefined = {}) : Record void> { + return { + "pages": n => { pageListResponseDto.pages = n.getCollectionOfObjectValues(createPageResponseDtoFromDiscriminatorValue); }, + } +} /** * The deserialization information for the current model * @param PageResponseDto The instance to deserialize into. @@ -209,12 +215,12 @@ export function deserializeIntoDeleteSpaceResponseDto(deleteSpaceResponseDto: Pa // @ts-ignore export function deserializeIntoPageResponseDto(pageResponseDto: Partial | undefined = {}) : Record void> { return { - "content": n => { pageResponseDto.content = n.getObjectValue(createPageResponseDto_contentFromDiscriminatorValue); }, + "content": n => { pageResponseDto.content = n.getStringValue(); }, "createdAt": n => { pageResponseDto.createdAt = n.getDateValue(); }, "createdByUserId": n => { pageResponseDto.createdByUserId = n.getGuidValue(); }, "isDeleted": n => { pageResponseDto.isDeleted = n.getBooleanValue(); }, "pageId": n => { pageResponseDto.pageId = n.getGuidValue(); }, - "parentPageId": n => { pageResponseDto.parentPageId = n.getObjectValue(createPageResponseDto_parentPageIdFromDiscriminatorValue); }, + "parentPageId": n => { pageResponseDto.parentPageId = n.getGuidValue(); }, "sortOrder": n => { pageResponseDto.sortOrder = n.getNumberValue(); }, "spaceId": n => { pageResponseDto.spaceId = n.getGuidValue(); }, "title": n => { pageResponseDto.title = n.getStringValue(); }, @@ -222,26 +228,6 @@ export function deserializeIntoPageResponseDto(pageResponseDto: Partial { pageResponseDto.updatedByUserId = n.getGuidValue(); }, } } -/** - * The deserialization information for the current model - * @param PageResponseDto_content The instance to deserialize into. - * @returns {Record void>} - */ -// @ts-ignore -export function deserializeIntoPageResponseDto_content(pageResponseDto_content: Partial | undefined = {}) : Record void> { - return { - } -} -/** - * The deserialization information for the current model - * @param PageResponseDto_parentPageId The instance to deserialize into. - * @returns {Record void>} - */ -// @ts-ignore -export function deserializeIntoPageResponseDto_parentPageId(pageResponseDto_parentPageId: Partial | undefined = {}) : Record void> { - return { - } -} /** * The deserialization information for the current model * @param SpaceResponseDto The instance to deserialize into. @@ -299,32 +285,12 @@ export function deserializeIntoSpaceStatisticsDto_statistics(spaceStatisticsDto_ export function deserializeIntoTokenInfoDto(tokenInfoDto: Partial | undefined = {}) : Record void> { return { "createdAt": n => { tokenInfoDto.createdAt = n.getDateValue(); }, - "description": n => { tokenInfoDto.description = n.getObjectValue(createTokenInfoDto_descriptionFromDiscriminatorValue); }, - "expiresAt": n => { tokenInfoDto.expiresAt = n.getObjectValue(createTokenInfoDto_expiresAtFromDiscriminatorValue); }, + "description": n => { tokenInfoDto.description = n.getStringValue(); }, + "expiresAt": n => { tokenInfoDto.expiresAt = n.getDateValue(); }, "tokenId": n => { tokenInfoDto.tokenId = n.getGuidValue(); }, "tokenValue": n => { tokenInfoDto.tokenValue = n.getStringValue(); }, } } -/** - * The deserialization information for the current model - * @param TokenInfoDto_description The instance to deserialize into. - * @returns {Record void>} - */ -// @ts-ignore -export function deserializeIntoTokenInfoDto_description(tokenInfoDto_description: Partial | undefined = {}) : Record void> { - return { - } -} -/** - * The deserialization information for the current model - * @param TokenInfoDto_expiresAt The instance to deserialize into. - * @returns {Record void>} - */ -// @ts-ignore -export function deserializeIntoTokenInfoDto_expiresAt(tokenInfoDto_expiresAt: Partial | undefined = {}) : Record void> { - return { - } -} /** * The deserialization information for the current model * @param TokenPermissionsDto The instance to deserialize into. @@ -337,11 +303,31 @@ export function deserializeIntoTokenPermissionsDto(tokenPermissionsDto: Partial< "spaceIds": n => { tokenPermissionsDto.spaceIds = n.getCollectionOfPrimitiveValues(); }, } } +export interface ErrorResponseDto extends AdditionalDataHolder, ApiError, Parsable { + /** + * μ—λŸ¬ 상세 정보 + */ + errorEscaped?: string | null; + /** + * μ—λŸ¬ λ©”μ‹œμ§€ + */ + messageEscaped?: string | null; + /** + * HTTP μƒνƒœ μ½”λ“œ + */ + statusCode?: number | null; +} +export interface PageListResponseDto extends AdditionalDataHolder, ApiError, Parsable { + /** + * νŽ˜μ΄μ§€ λͺ©λ‘ + */ + pages?: PageResponseDto[] | null; +} export interface PageResponseDto extends AdditionalDataHolder, ApiError, Parsable { /** * νŽ˜μ΄μ§€ λ‚΄μš© */ - content?: PageResponseDto_content | null; + content?: string | null; /** * 생성 μ‹œκ°„ */ @@ -361,7 +347,7 @@ export interface PageResponseDto extends AdditionalDataHolder, ApiError, Parsabl /** * λΆ€λͺ¨ νŽ˜μ΄μ§€ ID */ - parentPageId?: PageResponseDto_parentPageId | null; + parentPageId?: Guid | null; /** * μ •λ ¬ μˆœμ„œ */ @@ -383,16 +369,6 @@ export interface PageResponseDto extends AdditionalDataHolder, ApiError, Parsabl */ updatedByUserId?: Guid | null; } -/** - * νŽ˜μ΄μ§€ λ‚΄μš© - */ -export interface PageResponseDto_content extends AdditionalDataHolder, Parsable { -} -/** - * λΆ€λͺ¨ νŽ˜μ΄μ§€ ID - */ -export interface PageResponseDto_parentPageId extends AdditionalDataHolder, Parsable { -} /** * Serializes information the current object * @param CreateTokenResponseDto The instance to serialize from. @@ -433,6 +409,32 @@ export function serializeDeleteSpaceResponseDto(writer: SerializationWriter, del writer.writeGuidValue("spaceId", deleteSpaceResponseDto.spaceId); writer.writeAdditionalData(deleteSpaceResponseDto.additionalData); } +/** + * Serializes information the current object + * @param ErrorResponseDto The instance to serialize from. + * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. + * @param writer Serialization writer to use to serialize this model + */ +// @ts-ignore +export function serializeErrorResponseDto(writer: SerializationWriter, errorResponseDto: Partial | undefined | null = {}, isSerializingDerivedType: boolean = false) : void { + if (!errorResponseDto || isSerializingDerivedType) { return; } + writer.writeStringValue("error", errorResponseDto.errorEscaped); + writer.writeStringValue("message", errorResponseDto.messageEscaped); + writer.writeNumberValue("statusCode", errorResponseDto.statusCode); + writer.writeAdditionalData(errorResponseDto.additionalData); +} +/** + * Serializes information the current object + * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. + * @param PageListResponseDto The instance to serialize from. + * @param writer Serialization writer to use to serialize this model + */ +// @ts-ignore +export function serializePageListResponseDto(writer: SerializationWriter, pageListResponseDto: Partial | undefined | null = {}, isSerializingDerivedType: boolean = false) : void { + if (!pageListResponseDto || isSerializingDerivedType) { return; } + writer.writeCollectionOfObjectValues("pages", pageListResponseDto.pages, serializePageResponseDto); + writer.writeAdditionalData(pageListResponseDto.additionalData); +} /** * Serializes information the current object * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. @@ -442,12 +444,12 @@ export function serializeDeleteSpaceResponseDto(writer: SerializationWriter, del // @ts-ignore export function serializePageResponseDto(writer: SerializationWriter, pageResponseDto: Partial | undefined | null = {}, isSerializingDerivedType: boolean = false) : void { if (!pageResponseDto || isSerializingDerivedType) { return; } - writer.writeObjectValue("content", pageResponseDto.content, serializePageResponseDto_content); + writer.writeStringValue("content", pageResponseDto.content); writer.writeDateValue("createdAt", pageResponseDto.createdAt); writer.writeGuidValue("createdByUserId", pageResponseDto.createdByUserId); writer.writeBooleanValue("isDeleted", pageResponseDto.isDeleted); writer.writeGuidValue("pageId", pageResponseDto.pageId); - writer.writeObjectValue("parentPageId", pageResponseDto.parentPageId, serializePageResponseDto_parentPageId); + writer.writeGuidValue("parentPageId", pageResponseDto.parentPageId); writer.writeNumberValue("sortOrder", pageResponseDto.sortOrder); writer.writeGuidValue("spaceId", pageResponseDto.spaceId); writer.writeStringValue("title", pageResponseDto.title); @@ -455,28 +457,6 @@ export function serializePageResponseDto(writer: SerializationWriter, pageRespon writer.writeGuidValue("updatedByUserId", pageResponseDto.updatedByUserId); writer.writeAdditionalData(pageResponseDto.additionalData); } -/** - * Serializes information the current object - * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. - * @param PageResponseDto_content The instance to serialize from. - * @param writer Serialization writer to use to serialize this model - */ -// @ts-ignore -export function serializePageResponseDto_content(writer: SerializationWriter, pageResponseDto_content: Partial | undefined | null = {}, isSerializingDerivedType: boolean = false) : void { - if (!pageResponseDto_content || isSerializingDerivedType) { return; } - writer.writeAdditionalData(pageResponseDto_content.additionalData); -} -/** - * Serializes information the current object - * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. - * @param PageResponseDto_parentPageId The instance to serialize from. - * @param writer Serialization writer to use to serialize this model - */ -// @ts-ignore -export function serializePageResponseDto_parentPageId(writer: SerializationWriter, pageResponseDto_parentPageId: Partial | undefined | null = {}, isSerializingDerivedType: boolean = false) : void { - if (!pageResponseDto_parentPageId || isSerializingDerivedType) { return; } - writer.writeAdditionalData(pageResponseDto_parentPageId.additionalData); -} /** * Serializes information the current object * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. @@ -539,34 +519,12 @@ export function serializeSpaceStatisticsDto_statistics(writer: SerializationWrit export function serializeTokenInfoDto(writer: SerializationWriter, tokenInfoDto: Partial | undefined | null = {}, isSerializingDerivedType: boolean = false) : void { if (!tokenInfoDto || isSerializingDerivedType) { return; } writer.writeDateValue("createdAt", tokenInfoDto.createdAt); - writer.writeObjectValue("description", tokenInfoDto.description, serializeTokenInfoDto_description); - writer.writeObjectValue("expiresAt", tokenInfoDto.expiresAt, serializeTokenInfoDto_expiresAt); + writer.writeStringValue("description", tokenInfoDto.description); + writer.writeDateValue("expiresAt", tokenInfoDto.expiresAt); writer.writeGuidValue("tokenId", tokenInfoDto.tokenId); writer.writeStringValue("tokenValue", tokenInfoDto.tokenValue); writer.writeAdditionalData(tokenInfoDto.additionalData); } -/** - * Serializes information the current object - * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. - * @param TokenInfoDto_description The instance to serialize from. - * @param writer Serialization writer to use to serialize this model - */ -// @ts-ignore -export function serializeTokenInfoDto_description(writer: SerializationWriter, tokenInfoDto_description: Partial | undefined | null = {}, isSerializingDerivedType: boolean = false) : void { - if (!tokenInfoDto_description || isSerializingDerivedType) { return; } - writer.writeAdditionalData(tokenInfoDto_description.additionalData); -} -/** - * Serializes information the current object - * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. - * @param TokenInfoDto_expiresAt The instance to serialize from. - * @param writer Serialization writer to use to serialize this model - */ -// @ts-ignore -export function serializeTokenInfoDto_expiresAt(writer: SerializationWriter, tokenInfoDto_expiresAt: Partial | undefined | null = {}, isSerializingDerivedType: boolean = false) : void { - if (!tokenInfoDto_expiresAt || isSerializingDerivedType) { return; } - writer.writeAdditionalData(tokenInfoDto_expiresAt.additionalData); -} /** * Serializes information the current object * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. @@ -634,11 +592,11 @@ export interface TokenInfoDto extends AdditionalDataHolder, Parsable { /** * 토큰 μ„€λͺ… */ - description?: TokenInfoDto_description | null; + description?: string | null; /** * 만료 μ‹œκ°„ */ - expiresAt?: TokenInfoDto_expiresAt | null; + expiresAt?: Date | null; /** * 토큰 ID */ @@ -648,16 +606,6 @@ export interface TokenInfoDto extends AdditionalDataHolder, Parsable { */ tokenValue?: string | null; } -/** - * 토큰 μ„€λͺ… - */ -export interface TokenInfoDto_description extends AdditionalDataHolder, Parsable { -} -/** - * 만료 μ‹œκ°„ - */ -export interface TokenInfoDto_expiresAt extends AdditionalDataHolder, Parsable { -} export interface TokenPermissionsDto extends AdditionalDataHolder, Parsable { /** * κΆŒν•œμ΄ λΆ€μ—¬λœ νŽ˜μ΄μ§€ ID λͺ©λ‘ diff --git a/src/kiota/v1/account/index.ts b/src/kiota/v1/account/index.ts index cb13ed9..e1451bf 100644 --- a/src/kiota/v1/account/index.ts +++ b/src/kiota/v1/account/index.ts @@ -15,11 +15,13 @@ export interface AccountRequestBuilder extends BaseRequestBuilder} + * @returns {Promise} */ - get(requestConfiguration?: RequestConfiguration | undefined) : Promise; + get(requestConfiguration?: RequestConfiguration | undefined) : Promise; /** + * ν˜„μž¬ λ‘œκ·ΈμΈν•œ μ‚¬μš©μžμ˜ 계정 정보 쑰회 * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. * @returns {RequestInformation} */ @@ -45,7 +47,7 @@ export const AccountRequestBuilderRequestsMetadata: RequestsMetadata = { uriTemplate: AccountRequestBuilderUriTemplate, responseBodyContentType: "application/json", adapterMethodName: "sendPrimitive", - responseBodyFactory: "ArrayBuffer", + responseBodyFactory: "string", }, }; /* tslint:enable */ diff --git a/src/kiota/v1/account/signin/index.ts b/src/kiota/v1/account/signin/index.ts index 73dd88b..00cb1ef 100644 --- a/src/kiota/v1/account/signin/index.ts +++ b/src/kiota/v1/account/signin/index.ts @@ -9,11 +9,13 @@ import { type BaseRequestBuilder, type Parsable, type ParsableFactory, type Requ */ export interface SigninRequestBuilder extends BaseRequestBuilder { /** + * μ‚¬μš©μž 둜그인 * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. - * @returns {Promise} + * @returns {Promise} */ - get(requestConfiguration?: RequestConfiguration | undefined) : Promise; + get(requestConfiguration?: RequestConfiguration | undefined) : Promise; /** + * μ‚¬μš©μž 둜그인 * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. * @returns {RequestInformation} */ @@ -31,7 +33,7 @@ export const SigninRequestBuilderRequestsMetadata: RequestsMetadata = { uriTemplate: SigninRequestBuilderUriTemplate, responseBodyContentType: "application/json", adapterMethodName: "sendPrimitive", - responseBodyFactory: "ArrayBuffer", + responseBodyFactory: "string", }, }; /* tslint:enable */ diff --git a/src/kiota/v1/image/index.ts b/src/kiota/v1/image/index.ts index a5b0032..d7a94e4 100644 --- a/src/kiota/v1/image/index.ts +++ b/src/kiota/v1/image/index.ts @@ -2,22 +2,26 @@ /* eslint-disable */ // Generated by Microsoft Kiota // @ts-ignore -import { type BaseRequestBuilder, type Parsable, type ParsableFactory, type RequestConfiguration, type RequestInformation, type RequestsMetadata } from '@microsoft/kiota-abstractions'; +import { MultipartBody, serializeMultipartBody, type BaseRequestBuilder, type Parsable, type ParsableFactory, type RequestConfiguration, type RequestInformation, type RequestsMetadata } from '@microsoft/kiota-abstractions'; /** * Builds and executes requests for operations under /v1/image */ export interface ImageRequestBuilder extends BaseRequestBuilder { /** + * 이미지 νŒŒμΌμ„ μ—…λ‘œλ“œν•©λ‹ˆλ‹€ + * @param body The request body * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. - * @returns {Promise} + * @returns {Promise} */ - post(requestConfiguration?: RequestConfiguration | undefined) : Promise; + post(body: MultipartBody, requestConfiguration?: RequestConfiguration | undefined) : Promise; /** + * 이미지 νŒŒμΌμ„ μ—…λ‘œλ“œν•©λ‹ˆλ‹€ + * @param body The request body * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. * @returns {RequestInformation} */ - toPostRequestInformation(requestConfiguration?: RequestConfiguration | undefined) : RequestInformation; + toPostRequestInformation(body: MultipartBody, requestConfiguration?: RequestConfiguration | undefined) : RequestInformation; } /** * Uri template for the request builder. @@ -31,7 +35,10 @@ export const ImageRequestBuilderRequestsMetadata: RequestsMetadata = { uriTemplate: ImageRequestBuilderUriTemplate, responseBodyContentType: "application/json", adapterMethodName: "sendPrimitive", - responseBodyFactory: "ArrayBuffer", + responseBodyFactory: "string", + requestBodyContentType: "multipart/form-data", + requestBodySerializer: serializeMultipartBody, + requestInformationContentSetMethod: "setContentFromParsable", }, }; /* tslint:enable */ diff --git a/src/kiota/v1/index.ts b/src/kiota/v1/index.ts index 553ba0a..53b94b8 100644 --- a/src/kiota/v1/index.ts +++ b/src/kiota/v1/index.ts @@ -33,11 +33,13 @@ export interface V1RequestBuilder extends BaseRequestBuilder { */ get space(): SpaceRequestBuilder; /** + * μ„œλ²„ μƒνƒœ 확인 * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. - * @returns {Promise} + * @returns {Promise} */ - get(requestConfiguration?: RequestConfiguration | undefined) : Promise; + get(requestConfiguration?: RequestConfiguration | undefined) : Promise; /** + * μ„œλ²„ μƒνƒœ 확인 * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. * @returns {RequestInformation} */ @@ -75,7 +77,7 @@ export const V1RequestBuilderRequestsMetadata: RequestsMetadata = { uriTemplate: V1RequestBuilderUriTemplate, responseBodyContentType: "application/json", adapterMethodName: "sendPrimitive", - responseBodyFactory: "ArrayBuffer", + responseBodyFactory: "string", }, }; /* tslint:enable */ diff --git a/src/kiota/v1/page/index.ts b/src/kiota/v1/page/index.ts index f97b8f1..c0171e4 100644 --- a/src/kiota/v1/page/index.ts +++ b/src/kiota/v1/page/index.ts @@ -2,32 +2,14 @@ /* eslint-disable */ // Generated by Microsoft Kiota // @ts-ignore -import { createPageResponseDtoFromDiscriminatorValue, serializePageResponseDto, type PageResponseDto } from '../../models/index.js'; +import { createErrorResponseDtoFromDiscriminatorValue, createPageListResponseDtoFromDiscriminatorValue, createPageResponseDtoFromDiscriminatorValue, serializePageResponseDto, type ErrorResponseDto, type PageListResponseDto, type PageResponseDto } from '../../models/index.js'; // @ts-ignore import { type WithPageItemRequestBuilder, WithPageItemRequestBuilderRequestsMetadata } from './item/index.js'; // @ts-ignore import { TemporaryAccessTokenRequestBuilderRequestsMetadata, type TemporaryAccessTokenRequestBuilder } from './temporaryAccessToken/index.js'; // @ts-ignore -import { type AdditionalDataHolder, type ApiError, type BaseRequestBuilder, type Guid, type KeysToExcludeForNavigationMetadata, type NavigationMetadata, type Parsable, type ParsableFactory, type ParseNode, type RequestConfiguration, type RequestInformation, type RequestsMetadata, type SerializationWriter } from '@microsoft/kiota-abstractions'; +import { type AdditionalDataHolder, type BaseRequestBuilder, type Guid, type KeysToExcludeForNavigationMetadata, type NavigationMetadata, type Parsable, type ParsableFactory, type ParseNode, type RequestConfiguration, type RequestInformation, type RequestsMetadata, type SerializationWriter } from '@microsoft/kiota-abstractions'; -/** - * Creates a new instance of the appropriate class based on discriminator value - * @param parseNode The parse node to use to read the discriminator value and create the object - * @returns {Page4XXError} - */ -// @ts-ignore -export function createPage4XXErrorFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record void>) { - return deserializeIntoPage4XXError; -} -/** - * Creates a new instance of the appropriate class based on discriminator value - * @param parseNode The parse node to use to read the discriminator value and create the object - * @returns {Page5XXError} - */ -// @ts-ignore -export function createPage5XXErrorFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record void>) { - return deserializeIntoPage5XXError; -} /** * Creates a new instance of the appropriate class based on discriminator value * @param parseNode The parse node to use to read the discriminator value and create the object @@ -37,26 +19,6 @@ export function createPage5XXErrorFromDiscriminatorValue(parseNode: ParseNode | export function createPagePostRequestBodyFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record void>) { return deserializeIntoPagePostRequestBody; } -/** - * The deserialization information for the current model - * @param Page4XXError The instance to deserialize into. - * @returns {Record void>} - */ -// @ts-ignore -export function deserializeIntoPage4XXError(page4XXError: Partial | undefined = {}) : Record void> { - return { - } -} -/** - * The deserialization information for the current model - * @param Page5XXError The instance to deserialize into. - * @returns {Record void>} - */ -// @ts-ignore -export function deserializeIntoPage5XXError(page5XXError: Partial | undefined = {}) : Record void> { - return { - } -} /** * The deserialization information for the current model * @param PagePostRequestBody The instance to deserialize into. @@ -72,10 +34,6 @@ export function deserializeIntoPagePostRequestBody(pagePostRequestBody: Partial< "title": n => { pagePostRequestBody.title = n.getStringValue(); }, } } -export interface Page4XXError extends AdditionalDataHolder, ApiError, Parsable { -} -export interface Page5XXError extends AdditionalDataHolder, ApiError, Parsable { -} export interface PagePostRequestBody extends AdditionalDataHolder, Parsable { /** * νŽ˜μ΄μ§€ λ‚΄μš© (Markdown) @@ -115,16 +73,20 @@ export interface PageRequestBuilder extends BaseRequestBuilder} - * @throws {Page4XXError} error when the service returns a 4XX status code - * @throws {Page5XXError} error when the service returns a 5XX status code + * @returns {Promise} + * @throws {ErrorResponseDto} error when the service returns a 400 status code + * @throws {ErrorResponseDto} error when the service returns a 404 status code + * @throws {PageListResponseDto} error when the service returns a 4XX or 5XX status code */ - get(requestConfiguration?: RequestConfiguration | undefined) : Promise; + get(requestConfiguration?: RequestConfiguration | undefined) : Promise; /** * μƒˆλ‘œμš΄ νŽ˜μ΄μ§€λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€. 슀페이슀 λ‚΄μ—μ„œ 계측 ꡬ쑰λ₯Ό κ°€μ§ˆ 수 μžˆμŠ΅λ‹ˆλ‹€. (인증 ν•„μš”) * @param body The request body * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. * @returns {Promise} + * @throws {ErrorResponseDto} error when the service returns a 400 status code + * @throws {ErrorResponseDto} error when the service returns a 401 status code + * @throws {ErrorResponseDto} error when the service returns a 404 status code * @throws {PageResponseDto} error when the service returns a 4XX or 5XX status code */ post(body: PagePostRequestBody, requestConfiguration?: RequestConfiguration | undefined) : Promise; @@ -155,28 +117,6 @@ export interface PageRequestBuilderGetQueryParameters { */ spaceId?: Guid; } -/** - * Serializes information the current object - * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. - * @param Page4XXError The instance to serialize from. - * @param writer Serialization writer to use to serialize this model - */ -// @ts-ignore -export function serializePage4XXError(writer: SerializationWriter, page4XXError: Partial | undefined | null = {}, isSerializingDerivedType: boolean = false) : void { - if (!page4XXError || isSerializingDerivedType) { return; } - writer.writeAdditionalData(page4XXError.additionalData); -} -/** - * Serializes information the current object - * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. - * @param Page5XXError The instance to serialize from. - * @param writer Serialization writer to use to serialize this model - */ -// @ts-ignore -export function serializePage5XXError(writer: SerializationWriter, page5XXError: Partial | undefined | null = {}, isSerializingDerivedType: boolean = false) : void { - if (!page5XXError || isSerializingDerivedType) { return; } - writer.writeAdditionalData(page5XXError.additionalData); -} /** * Serializes information the current object * @param isSerializingDerivedType A boolean indicating whether the serialization is for a derived type. @@ -217,16 +157,20 @@ export const PageRequestBuilderRequestsMetadata: RequestsMetadata = { uriTemplate: PageRequestBuilderUriTemplate, responseBodyContentType: "application/json", errorMappings: { - _4XX: createPage4XXErrorFromDiscriminatorValue as ParsableFactory, - _5XX: createPage5XXErrorFromDiscriminatorValue as ParsableFactory, + 400: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, + 404: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, + XXX: createPageListResponseDtoFromDiscriminatorValue as ParsableFactory, }, - adapterMethodName: "sendCollection", - responseBodyFactory: createPageResponseDtoFromDiscriminatorValue, + adapterMethodName: "send", + responseBodyFactory: createPageListResponseDtoFromDiscriminatorValue, }, post: { uriTemplate: PageRequestBuilderUriTemplate, responseBodyContentType: "application/json", errorMappings: { + 400: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, + 401: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, + 404: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, XXX: createPageResponseDtoFromDiscriminatorValue as ParsableFactory, }, adapterMethodName: "send", diff --git a/src/kiota/v1/page/item/index.ts b/src/kiota/v1/page/item/index.ts index 2b20c97..2210ae9 100644 --- a/src/kiota/v1/page/item/index.ts +++ b/src/kiota/v1/page/item/index.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // Generated by Microsoft Kiota // @ts-ignore -import { createDeleteResponseDtoFromDiscriminatorValue, createPageResponseDtoFromDiscriminatorValue, serializePageResponseDto, type DeleteResponseDto, type PageResponseDto } from '../../../models/index.js'; +import { createDeleteResponseDtoFromDiscriminatorValue, createErrorResponseDtoFromDiscriminatorValue, createPageResponseDtoFromDiscriminatorValue, serializePageResponseDto, type DeleteResponseDto, type ErrorResponseDto, type PageResponseDto } from '../../../models/index.js'; // @ts-ignore import { type AdditionalDataHolder, type BaseRequestBuilder, type Guid, type Parsable, type ParsableFactory, type ParseNode, type RequestConfiguration, type RequestInformation, type RequestsMetadata, type SerializationWriter } from '@microsoft/kiota-abstractions'; @@ -52,6 +52,8 @@ export interface WithPageItemRequestBuilder extends BaseRequestBuilder} + * @throws {ErrorResponseDto} error when the service returns a 401 status code + * @throws {ErrorResponseDto} error when the service returns a 404 status code * @throws {DeleteResponseDto} error when the service returns a 4XX or 5XX status code */ delete(requestConfiguration?: RequestConfiguration | undefined) : Promise; @@ -60,6 +62,9 @@ export interface WithPageItemRequestBuilder extends BaseRequestBuilder} + * @throws {ErrorResponseDto} error when the service returns a 400 status code + * @throws {ErrorResponseDto} error when the service returns a 401 status code + * @throws {ErrorResponseDto} error when the service returns a 404 status code * @throws {PageResponseDto} error when the service returns a 4XX or 5XX status code */ put(body: WithPagePutRequestBody, requestConfiguration?: RequestConfiguration | undefined) : Promise; @@ -107,6 +112,8 @@ export const WithPageItemRequestBuilderRequestsMetadata: RequestsMetadata = { uriTemplate: WithPageItemRequestBuilderUriTemplate, responseBodyContentType: "application/json", errorMappings: { + 401: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, + 404: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, XXX: createDeleteResponseDtoFromDiscriminatorValue as ParsableFactory, }, adapterMethodName: "send", @@ -116,6 +123,9 @@ export const WithPageItemRequestBuilderRequestsMetadata: RequestsMetadata = { uriTemplate: WithPageItemRequestBuilderUriTemplate, responseBodyContentType: "application/json", errorMappings: { + 400: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, + 401: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, + 404: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, XXX: createPageResponseDtoFromDiscriminatorValue as ParsableFactory, }, adapterMethodName: "send", diff --git a/src/kiota/v1/page/temporaryAccessToken/index.ts b/src/kiota/v1/page/temporaryAccessToken/index.ts index b1f41f3..ffc1e15 100644 --- a/src/kiota/v1/page/temporaryAccessToken/index.ts +++ b/src/kiota/v1/page/temporaryAccessToken/index.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // Generated by Microsoft Kiota // @ts-ignore -import { createCreateTokenResponseDtoFromDiscriminatorValue, createDeleteResponseDtoFromDiscriminatorValue, serializeCreateTokenResponseDto, serializeDeleteResponseDto, type CreateTokenResponseDto, type DeleteResponseDto } from '../../../models/index.js'; +import { createCreateTokenResponseDtoFromDiscriminatorValue, createDeleteResponseDtoFromDiscriminatorValue, createErrorResponseDtoFromDiscriminatorValue, serializeCreateTokenResponseDto, serializeDeleteResponseDto, type CreateTokenResponseDto, type DeleteResponseDto, type ErrorResponseDto } from '../../../models/index.js'; // @ts-ignore import { type AdditionalDataHolder, type BaseRequestBuilder, type Guid, type Parsable, type ParsableFactory, type ParseNode, type RequestConfiguration, type RequestInformation, type RequestsMetadata, type SerializationWriter } from '@microsoft/kiota-abstractions'; @@ -109,6 +109,8 @@ export interface TemporaryAccessTokenRequestBuilder extends BaseRequestBuilder} + * @throws {ErrorResponseDto} error when the service returns a 401 status code + * @throws {ErrorResponseDto} error when the service returns a 404 status code * @throws {DeleteResponseDto} error when the service returns a 4XX or 5XX status code */ delete(body: TemporaryAccessTokenDeleteRequestBody, requestConfiguration?: RequestConfiguration | undefined) : Promise; @@ -117,6 +119,9 @@ export interface TemporaryAccessTokenRequestBuilder extends BaseRequestBuilder} + * @throws {ErrorResponseDto} error when the service returns a 400 status code + * @throws {ErrorResponseDto} error when the service returns a 401 status code + * @throws {ErrorResponseDto} error when the service returns a 404 status code * @throws {CreateTokenResponseDto} error when the service returns a 4XX or 5XX status code */ post(body: TemporaryAccessTokenPostRequestBody, requestConfiguration?: RequestConfiguration | undefined) : Promise; @@ -147,6 +152,8 @@ export const TemporaryAccessTokenRequestBuilderRequestsMetadata: RequestsMetadat uriTemplate: TemporaryAccessTokenRequestBuilderUriTemplate, responseBodyContentType: "application/json", errorMappings: { + 401: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, + 404: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, XXX: createDeleteResponseDtoFromDiscriminatorValue as ParsableFactory, }, adapterMethodName: "send", @@ -159,6 +166,9 @@ export const TemporaryAccessTokenRequestBuilderRequestsMetadata: RequestsMetadat uriTemplate: TemporaryAccessTokenRequestBuilderUriTemplate, responseBodyContentType: "application/json", errorMappings: { + 400: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, + 401: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, + 404: createErrorResponseDtoFromDiscriminatorValue as ParsableFactory, XXX: createCreateTokenResponseDtoFromDiscriminatorValue as ParsableFactory, }, adapterMethodName: "send", diff --git a/src/pages/PageDetailPage.tsx b/src/pages/PageDetailPage.tsx index c305d15..b288752 100644 --- a/src/pages/PageDetailPage.tsx +++ b/src/pages/PageDetailPage.tsx @@ -8,7 +8,7 @@ import { LexicalViewer } from '../shared/LexicalViewer'; import * as AlertDialog from '@radix-ui/react-alert-dialog'; import { Pencil1Icon, TrashIcon } from '@radix-ui/react-icons'; import { useState } from 'react'; -import { useApiClient, useUserId } from '../shared/hooks/useApiClient'; +import { useApiClient } from '../shared/hooks/useApiClient'; function PageDetailContent() { const { spaceKey, id } = useParams<{ spaceKey: string; id: string }>(); @@ -16,7 +16,6 @@ function PageDetailContent() { const queryClient = useQueryClient(); const [showDeleteDialog, setShowDeleteDialog] = useState(false); const apiClient = useApiClient(); - const userId = useUserId(); const { data: page, isLoading, error } = useQuery({ queryKey: ['page', id], @@ -26,8 +25,7 @@ function PageDetailContent() { const deleteMutation = useMutation({ mutationFn: () => { - if (!userId) throw new Error('User not authenticated'); - return deletePage(apiClient, id!, userId); + return deletePage(apiClient, id!); }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['pages'] }); diff --git a/src/pages/PageEditPage.tsx b/src/pages/PageEditPage.tsx index 5664496..635672e 100644 --- a/src/pages/PageEditPage.tsx +++ b/src/pages/PageEditPage.tsx @@ -1,19 +1,20 @@ -import { useParams, useNavigate } from 'react-router-dom'; +import { useParams, useNavigate, useSearchParams } from 'react-router-dom'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { getPage, createPage, updatePage } from '../entities/page'; import { getSpaceByKey } from '../entities/space'; import { PageForm } from '../features/page'; import { Layout } from '../shared/Layout'; import { Breadcrumb } from '../shared/Breadcrumb'; -import { useApiClient, useUserId } from '../shared/hooks/useApiClient'; +import { useApiClient } from '../shared/hooks/useApiClient'; export function PageEditPage() { const { spaceKey, id } = useParams<{ spaceKey: string; id: string }>(); + const [searchParams] = useSearchParams(); const navigate = useNavigate(); const queryClient = useQueryClient(); const isNew = !id; const apiClient = useApiClient(); - const userId = useUserId(); + const parentId = searchParams.get('parentId'); const { data: space } = useQuery({ queryKey: ['space', spaceKey], @@ -27,11 +28,16 @@ export function PageEditPage() { enabled: !isNew, }); + const { data: parentPage } = useQuery({ + queryKey: ['page', parentId], + queryFn: () => getPage(apiClient, parentId!), + enabled: !!parentId && isNew, + }); + const createMutation = useMutation({ mutationFn: (data: { title: string; content: string }) => { - if (!userId) throw new Error('User not authenticated'); if (!space?.id) throw new Error('Space not found'); - return createPage(apiClient, data, userId, space.id); + return createPage(apiClient, { ...data, parentId: parentId || undefined }, space.id); }, onSuccess: (newPage) => { queryClient.invalidateQueries({ queryKey: ['pages', space?.id] }); @@ -41,8 +47,7 @@ export function PageEditPage() { const updateMutation = useMutation({ mutationFn: (data: { title: string; content: string }) => { - if (!userId) throw new Error('User not authenticated'); - return updatePage(apiClient, id!, data, userId); + return updatePage(apiClient, id!, data); }, onSuccess: (updatedPage) => { queryClient.setQueryData(['page', id], updatedPage); @@ -81,13 +86,14 @@ export function PageEditPage() { items={[ { label: 'Spaces', path: '/' }, { label: space?.name || spaceKey || '', path: `/spaces/${spaceKey}` }, + ...(parentPage ? [{ label: parentPage.title, path: `/spaces/${spaceKey}/pages/${parentPage.id}` }] : []), { label: isNew ? 'μƒˆ νŽ˜μ΄μ§€ λ§Œλ“€κΈ°' : page?.title || 'νŽΈμ§‘' }, ]} />

- {isNew ? 'μƒˆ νŽ˜μ΄μ§€ λ§Œλ“€κΈ°' : 'νŽ˜μ΄μ§€ νŽΈμ§‘'} + {isNew ? (parentPage ? `"${parentPage.title}"의 ν•˜μœ„ νŽ˜μ΄μ§€ λ§Œλ“€κΈ°` : 'μƒˆ νŽ˜μ΄μ§€ λ§Œλ“€κΈ°') : 'νŽ˜μ΄μ§€ νŽΈμ§‘'}

(); return (
@@ -52,9 +53,11 @@ export function Layout({ children, showSidebar = true, rightSidebar }: LayoutPro Learn - - μƒˆ νŽ˜μ΄μ§€ - + {spaceKey && ( + + μƒˆ νŽ˜μ΄μ§€ + + )}
diff --git a/src/shared/LeftSidebar.tsx b/src/shared/LeftSidebar.tsx index 2161097..b539abd 100644 --- a/src/shared/LeftSidebar.tsx +++ b/src/shared/LeftSidebar.tsx @@ -1,8 +1,10 @@ import { useState } from 'react'; -import { Link, useLocation } from 'react-router-dom'; +import { Link, useLocation, useParams, useNavigate } from 'react-router-dom'; import { useQuery } from '@tanstack/react-query'; import { getPages, type Page } from '../entities/page'; -import { MagnifyingGlassIcon, FileTextIcon, PlusIcon, ChevronRightIcon, ChevronDownIcon } from '@radix-ui/react-icons'; +import { getSpaceByKey } from '../entities/space'; +import { useApiClient } from './hooks/useApiClient'; +import { MagnifyingGlassIcon, FileTextIcon, PlusIcon, ChevronRightIcon, ChevronDownIcon, DotsHorizontalIcon } from '@radix-ui/react-icons'; interface TreeNodeProps { page: Page; @@ -10,13 +12,16 @@ interface TreeNodeProps { allPages: Page[]; searchQuery: string; level: number; + spaceKey: string; onLinkClick: () => void; } -function TreeNode({ page, children, allPages, searchQuery, level, onLinkClick }: TreeNodeProps) { +function TreeNode({ page, children, allPages, searchQuery, level, spaceKey, onLinkClick }: TreeNodeProps) { const location = useLocation(); + const navigate = useNavigate(); const [isExpanded, setIsExpanded] = useState(true); - const isActive = location.pathname === `/pages/${page.id}`; + const [isHovered, setIsHovered] = useState(false); + const isActive = location.pathname === `/spaces/${spaceKey}/pages/${page.id}`; const hasChildren = children.length > 0; const matchesSearch = searchQuery === '' || page.title.toLowerCase().includes(searchQuery.toLowerCase()); @@ -25,36 +30,74 @@ function TreeNode({ page, children, allPages, searchQuery, level, onLinkClick }: return null; } + const handleAddSubPage = (e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + // Navigate to new page creation with parent page ID + navigate(`/spaces/${spaceKey}/pages/new?parentId=${page.id}`); + }; + + const handleMenuClick = (e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + // TODO: Show context menu + }; + return (
-
- {hasChildren && ( +
setIsHovered(true)} + onMouseLeave={() => setIsHovered(false)} + > +
- )} - {!hasChildren &&
} - - - - {page.title} - + + + + {page.title} + +
+ + {/* Action buttons - fixed on the right side, shown on hover */} +
+ + +
{hasChildren && isExpanded && ( @@ -69,6 +112,7 @@ function TreeNode({ page, children, allPages, searchQuery, level, onLinkClick }: allPages={allPages} searchQuery={searchQuery} level={level + 1} + spaceKey={spaceKey} onLinkClick={onLinkClick} /> ); @@ -86,9 +130,21 @@ interface LeftSidebarProps { export function LeftSidebar({ isMobileOpen, onMobileClose }: LeftSidebarProps) { const [searchQuery, setSearchQuery] = useState(''); - const { data: pages = [] } = useQuery({ - queryKey: ['pages'], - queryFn: getPages, + const { spaceKey } = useParams<{ spaceKey: string }>(); + const apiClient = useApiClient(); + + // Get space info to fetch its pages + const { data: space, isLoading: isLoadingSpace, error: spaceError } = useQuery({ + queryKey: ['space', spaceKey], + queryFn: () => getSpaceByKey(apiClient, spaceKey!), + enabled: !!spaceKey, + }); + + // Fetch pages for the current space + const { data: pages = [], isLoading: isLoadingPages, error: pagesError } = useQuery({ + queryKey: ['pages', space?.id], + queryFn: () => getPages(apiClient, space!.id), + enabled: !!space?.id, }); // Build tree structure @@ -137,31 +193,48 @@ export function LeftSidebar({ isMobileOpen, onMobileClose }: LeftSidebarProps) { {/* Navigation */}