Merge pull request 'initial-setup' (#1) from initial-setup into main
Some checks failed
Test Suite / lint (push) Has been cancelled
Test Suite / test (macos-latest, 3.10) (push) Has been cancelled
Test Suite / test (macos-latest, 3.11) (push) Has been cancelled
Test Suite / test (macos-latest, 3.12) (push) Has been cancelled
Test Suite / test (macos-latest, 3.8) (push) Has been cancelled
Test Suite / test (macos-latest, 3.9) (push) Has been cancelled
Test Suite / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test Suite / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test Suite / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test Suite / test (ubuntu-latest, 3.8) (push) Has been cancelled
Test Suite / test (ubuntu-latest, 3.9) (push) Has been cancelled
Test Suite / package (push) Has been cancelled
Test Suite / test (windows-latest, 3.10) (push) Has been cancelled
Test Suite / test (windows-latest, 3.11) (push) Has been cancelled
Test Suite / test (windows-latest, 3.12) (push) Has been cancelled
Test Suite / test (windows-latest, 3.8) (push) Has been cancelled
Test Suite / test (windows-latest, 3.9) (push) Has been cancelled
Test Suite / security (push) Has been cancelled
Some checks failed
Test Suite / lint (push) Has been cancelled
Test Suite / test (macos-latest, 3.10) (push) Has been cancelled
Test Suite / test (macos-latest, 3.11) (push) Has been cancelled
Test Suite / test (macos-latest, 3.12) (push) Has been cancelled
Test Suite / test (macos-latest, 3.8) (push) Has been cancelled
Test Suite / test (macos-latest, 3.9) (push) Has been cancelled
Test Suite / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test Suite / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test Suite / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test Suite / test (ubuntu-latest, 3.8) (push) Has been cancelled
Test Suite / test (ubuntu-latest, 3.9) (push) Has been cancelled
Test Suite / package (push) Has been cancelled
Test Suite / test (windows-latest, 3.10) (push) Has been cancelled
Test Suite / test (windows-latest, 3.11) (push) Has been cancelled
Test Suite / test (windows-latest, 3.12) (push) Has been cancelled
Test Suite / test (windows-latest, 3.8) (push) Has been cancelled
Test Suite / test (windows-latest, 3.9) (push) Has been cancelled
Test Suite / security (push) Has been cancelled
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
18
.flake8
Normal file
18
.flake8
Normal file
@@ -0,0 +1,18 @@
|
||||
[flake8]
|
||||
max-line-length = 88
|
||||
select = E,W,F,C,N
|
||||
ignore = E203,E501,W503
|
||||
exclude =
|
||||
.git,
|
||||
__pycache__,
|
||||
build,
|
||||
dist,
|
||||
.eggs,
|
||||
*.egg-info,
|
||||
.venv,
|
||||
venv,
|
||||
.tox
|
||||
per-file-ignores =
|
||||
tests/*:F401,F811
|
||||
__init__.py:F401
|
||||
max-complexity = 10
|
||||
@@ -110,7 +110,7 @@ class PagesEndpoint(BaseEndpoint):
|
||||
"""
|
||||
|
||||
# Build variables object
|
||||
variables = {}
|
||||
variables: Dict[str, Any] = {}
|
||||
if limit is not None:
|
||||
variables["limit"] = limit
|
||||
if offset is not None:
|
||||
@@ -129,7 +129,7 @@ class PagesEndpoint(BaseEndpoint):
|
||||
variables["orderDirection"] = order_direction
|
||||
|
||||
# Make request with query and variables
|
||||
json_data = {"query": query}
|
||||
json_data: Dict[str, Any] = {"query": query}
|
||||
if variables:
|
||||
json_data["variables"] = variables
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from datetime import datetime
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from pydantic import BaseModel as PydanticBaseModel
|
||||
from pydantic import ConfigDict
|
||||
from pydantic import ConfigDict, field_serializer
|
||||
|
||||
|
||||
class BaseModel(PydanticBaseModel):
|
||||
@@ -26,8 +26,6 @@ class BaseModel(PydanticBaseModel):
|
||||
use_enum_values=True,
|
||||
# Allow extra fields for forward compatibility
|
||||
extra="ignore",
|
||||
# Serialize datetime as ISO format
|
||||
json_encoders={datetime: lambda v: v.isoformat() if v else None},
|
||||
)
|
||||
|
||||
def to_dict(self, exclude_none: bool = True) -> Dict[str, Any]:
|
||||
@@ -83,6 +81,11 @@ class TimestampedModel(BaseModel):
|
||||
created_at: Optional[datetime] = None
|
||||
updated_at: Optional[datetime] = None
|
||||
|
||||
@field_serializer('created_at', 'updated_at')
|
||||
def serialize_datetime(self, value: Optional[datetime]) -> Optional[str]:
|
||||
"""Serialize datetime to ISO format."""
|
||||
return value.isoformat() if value else None
|
||||
|
||||
@property
|
||||
def is_new(self) -> bool:
|
||||
"""Check if this is a new (unsaved) model."""
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import re
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import Field, validator
|
||||
from pydantic import Field, field_validator
|
||||
|
||||
from .base import BaseModel, TimestampedModel
|
||||
|
||||
@@ -37,7 +37,8 @@ class Page(TimestampedModel):
|
||||
# Editor information
|
||||
editor: Optional[str] = Field(None, description="Editor used")
|
||||
|
||||
@validator("path")
|
||||
@field_validator("path")
|
||||
@classmethod
|
||||
def validate_path(cls, v: str) -> str:
|
||||
"""Validate page path format."""
|
||||
if not v:
|
||||
@@ -52,7 +53,8 @@ class Page(TimestampedModel):
|
||||
|
||||
return v
|
||||
|
||||
@validator("title")
|
||||
@field_validator("title")
|
||||
@classmethod
|
||||
def validate_title(cls, v: str) -> str:
|
||||
"""Validate page title."""
|
||||
if not v or not v.strip():
|
||||
@@ -132,7 +134,8 @@ class PageCreate(BaseModel):
|
||||
locale: str = Field("en", description="Page locale")
|
||||
editor: str = Field("markdown", description="Editor to use")
|
||||
|
||||
@validator("path")
|
||||
@field_validator("path")
|
||||
@classmethod
|
||||
def validate_path(cls, v: str) -> str:
|
||||
"""Validate page path format."""
|
||||
if not v:
|
||||
@@ -147,7 +150,8 @@ class PageCreate(BaseModel):
|
||||
|
||||
return v
|
||||
|
||||
@validator("title")
|
||||
@field_validator("title")
|
||||
@classmethod
|
||||
def validate_title(cls, v: str) -> str:
|
||||
"""Validate page title."""
|
||||
if not v or not v.strip():
|
||||
@@ -172,7 +176,8 @@ class PageUpdate(BaseModel):
|
||||
|
||||
tags: Optional[List[str]] = Field(None, description="Page tags")
|
||||
|
||||
@validator("title")
|
||||
@field_validator("title")
|
||||
@classmethod
|
||||
def validate_title(cls, v: Optional[str]) -> Optional[str]:
|
||||
"""Validate page title if provided."""
|
||||
if v is not None:
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from wikijs import WikiJSClient
|
||||
|
||||
client = WikiJSClient(
|
||||
base_url="https://wikijs.hotserv.cloud",
|
||||
auth="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcGkiOjEsImdycCI6MSwiaWF0IjoxNTM4ODM1NTQ1LCJleHAiOjE3ODUzOTMxNDUsImF1ZCI6InVybjp3aWtpLmpzIiwiaXNzIjoidXJuOndpa2kuanMifQ.d1fCZMqS-4gR5TfcMU4CLc_mD-uyYxlUxPbxbqqdIazruKKmBLACkVEumf-RFgEatsuCQjQiU0A6E_IfwFBgqFy1g5W_Ly9st7_5k6JOHfn4shGnCrRv3FBLHOtiRUexURcXNvHxh00oEJ8IPuhmTDSpc1g5ssVeNR9oHwz8V-CIvtmP_S5NIalTVEeOXmSSfyHXK4_sMx8zbBb8tCHNt1tbhZ8Z5N--pqvWZFC_ddYZ8-kMkQo-ni1rP48WLpEngWCij6mAPKhdqLjykmIkZF_hwnfvunG7iIZpFVoUJ3uIc09GkIVa5VdpcBHD4w1rnpouWZP8FuR9aHlAL7sB3Q",
|
||||
auth="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcGkiOjEsImdycCI6MSwiaWF0IjoxNTM4ODM1NTQ1LCJleHAiOjE3ODUzOTMxNDUsImF1ZCI6InVybjp3aWtpLmpzIiwiaXNzIjoidXJuOndpa2kuanMifQ.d1fCZMqS-4gR5TfcMU4CLc_mD-uyYxlUxPbxbqqdIazruKKmBLACkVEumf-RFgEatsuCQjQiU0A6E_IfwFBgqFy1g5W_Ly9st7_5k6JOHfn4shGnCrRv3FBLHOtiRUexURcXNvHxh00oEJ8IPuhmTDSpc1g5ssVeNR9oHwz8V-CIvtmP_S5NIalTVEeOXmSSfyHXK4_sMx8zbBb8tCHNt1tbhZ8Z5N--pqvWZFC_ddYZ8-kMkQo-ni1rP48WLpEngWCij6mAPKhdqLjykmIkZF_hwnfvunG7iIZpFVoUJ3uIc09GkIVa5VdpcBHD4w1rnpouWZP8FuR9aHlAL7sB3Q"
|
||||
)
|
||||
|
||||
print("✅ Client created")
|
||||
@@ -20,5 +19,3 @@ for i, page in enumerate(pages[:5], 1):
|
||||
print(f" {i}. {page.title} (ID: {page.id})")
|
||||
client.close()
|
||||
print("✅ SDK working!")
|
||||
|
||||
print("just my test")
|
||||
|
||||
Reference in New Issue
Block a user