mirror of
https://github.com/owncloud/ocis.git
synced 2026-10-25 11:39:24 +03:00
remove-owncloudsql
2 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e1a0f3a1b2 |
[full-ci] chore: [OCISDEV-1412] remove the readOnly workaround from the libre-graph client generation (#12956)
* chore: [OCISDEV-1412] remove the readOnly workaround from the libre-graph client generation The client generation stripped every `readOnly: true` line from the spec before running the generator, because the typescript-fetch templates leave read-only fields out of the serializers they emit and a few fields oCIS does accept on write were annotated read-only. Stripping them all also unmarked the fields that genuinely are response-only. The annotations are corrected upstream now, so the generator runs on the spec as published. Everything oCIS writes is still serialized: the drive quota total, the drive type, a space image and readme, the hidden flag and remote item of a drive item, and the fields of a sharing permission. Response-only fields such as the computed quota values are now typed read-only, which the handful of places that assigned to them had to be adjusted for. * chore: [OCISDEV-1412] regenerate the libre-graph client after the driveType split drive now declares its own writable driveType while driveUpdate marks it readOnly, so updateDrive no longer accepts a value the server rejects. * fix: [OCISDEV-1412] keep the special folder id in the drive update body Setting a space image or readme patches the drive with the id of an existing item under special. driveItem.id was marked readOnly in the spec, so the generated serializer dropped it and the server skipped the entry: the request returned 200 and did nothing, which the e2e space image test caught as a timeout waiting for the image to load. The annotation is gone from the spec, and updateDrive now has tests asserting the serialized body, since neither type checking nor a mocked call notices a field that quietly disappears. * fix: [OCISDEV-1412] regenerate after splitting the drive special folder schema An update to a drive assigns its special folders by referencing existing items by id. Upstream now models that with a dedicated schema instead of reusing the response-only drive item, so the update body keeps the id while the drive item itself is read-only again. The wrapper around the generated client typed the update body as a drive rather than a drive update, which no longer holds now that the two differ in how they describe the special folders. |
||
|
|
73b26532fe |
[full-ci] chore: [OCISDEV-215] replace axios with the native fetch API in Web (#12910)
* feat(web-client): add native fetch http core
* test(web-test-helpers): replace axios mocks with fetch-shaped helpers
* refactor(web-pkg): build HttpClient on the fetch core
* refactor(web-pkg): unify ClientService interceptors on the fetch core
* refactor(web-pkg): drop axios types from useRequest
* fix(web): align error and header access with the fetch core
* refactor(web-client): move ocs onto the fetch core
* refactor(web-client): move webdav helpers onto the fetch core
* chore(web-client): regenerate graph client with typescript-fetch
* refactor(web-client): adapt graph wrappers to the fetch-based generated client
Regenerate the libre-graph client with the typescript-fetch template and
rewrite the eight facade factories against it:
- the generated APIs are classes (`new XxxApi(config)`), take a single
request-parameters object and resolve to the payload rather than an
envelope, so the wrappers no longer destructure `{ data }`
- every generated request is routed through `FetchClient` via
`Configuration.fetchApi`, keeping header injection, maintenance
detection and `HttpError`-on-non-2xx intact. Callers keep seeing
`HttpError` with `statusCode` and `data`, never `ResponseError`
- `toInitOverrides` merges our per-request headers into the generated
`RequestInit` instead of replacing them, which a plain object would do
because the runtime spreads `initOverrides` shallowly
- undeclared query parameters travel on a symbol-keyed channel, since the
runtime assembles the URL before it applies `initOverrides`
`--type-mappings=DateTime=string` keeps date-times as strings, matching
what the previous template emitted and what the app expects.
* refactor: use the generated property names for OData-annotated graph fields
The typescript-fetch template emits real JSON serializers, so annotated
fields like `@libre.graph.permissions.actions`, `@odata.id`, `@UI.Hidden`
and `@client.synchronize` are mapped to camelCase properties on the way in
and back to their wire names on the way out. The wire format is unchanged;
only the TypeScript-side names are. Reads left on the old names would have
silently resolved to `undefined`, and writes would have been dropped.
The OData `$filter` expression in FileSideBar keeps its annotated spelling,
being a query value rather than a property.
Response-only fields are now `readonly`, which the editable copies and test
fixtures built from them need to opt out of, hence `writeable()`.
* chore: drop the axios dependency
Nothing imports axios any more, so remove it from the eight manifests that
declared it and update the web-client README, whose usage examples still
instantiated an axios client.
Also applies prettier to the files touched over the course of the migration.
* fix(web-pkg): keep the axios-era surface on HttpClient
Dropping axios changed more than the transport. Four spellings that consumers
outside this repo were written against disappeared with it, and none of them had
to.
Response headers were a plain lowercased object under axios, so `headers['etag']`
was the only way to read one; a fetch `Response` exposes a `Headers`, where
`get('etag')` is. `httpHeaders` wraps the native object in a proxy that answers
both, case-insensitively, and enumerates the lowercased names — it stays a real
`Headers`, so neither spelling is a migration.
A rejected request carried its body on `error.response.data` and its status on
`error.response.status`. `HttpError` names them `data` and `statusCode`, which
this repo unifies on, but the response those shadow is reachable from outside it,
so `buildError` defines both on the response as well and keeps axios's
`Request failed with status code <n>` message. The body is read from a clone, so
callers still get an unread one.
The config `HttpClient` takes has always named the request body `data`, and web
extensions pass `data` when they issue raw WebDAV requests through
`httpAuthenticated`. Carrying the core's `body` up would have dropped those
bodies silently, so `RequestConfig` keeps `data` and `send` translates it. For
the same reason a default-responseType body that is not JSON falls back to the
raw text instead of throwing: a WebDAV multistatus answered without an explicit
`responseType: 'text'` used to arrive as a string, and a `SyntaxError` there
would turn a working request into a failing one.
`cancel()` is back, on an `AbortController` instead of a `CancelToken`. Combining
the client-wide signal with a per-request one needs a listener per request, so
`send` disposes of them once the request has settled rather than letting them
accumulate on a long-lived client.
`mockAxiosResolve` and `mockAxiosReject` stay exported from web-test-helpers as
deprecated aliases, so suites written against the axios era keep compiling.
* fix(web-client): keep read-only graph fields in request bodies
The typescript-fetch templates omit fields the spec marks `readOnly: true` from
the generated `*ToJSON` serializers. Every field of `Quota` is annotated that
way, so `updateDrive(id, { quota: { total: 500 } })` went out as
`{ quota: {} }` and quotas could no longer be changed. Seventeen other models
were affected the same way, among them `UserUpdate` and `ItemReference`.
The annotation is now stripped from the spec before generating, which is what
the axios-generated client effectively did. That also drops the `readonly`
modifiers, so the `writeable` escape hatch is no longer needed.
* fix(web-client): let graph errors keep their status and body
The generated runtime wraps whatever its `fetchApi` throws in a `FetchError`,
which buried the `HttpError` the core raises for a non-2xx response. Callers
that branch on the status saw neither `statusCode` nor `data`, so the banned
password hint on a public link never appeared and an aborted graph request
stopped looking like an abort.
Rethrowing from an `onError` middleware escapes the wrap for every graph
operation at once.
* fix(web-client): let fetch set the multipart boundary for FormData bodies
A caller-supplied `Content-Type: multipart/form-data` carries no boundary. Axios
replaced the header before sending, fetch passes it through, so the server could not
parse the body and the admin settings logo upload silently did nothing.
* fix(web): merge request headers case-insensitively, plus PR review fixes
Header names are case-insensitive, but the header layers were merged with an
object spread, where object keys are not. `Authorization` and `authorization`
both survived it, and a spec-compliant `Headers` applies a record init with
`append`, so the two were joined into `Bearer stale, Bearer fresh` instead of
the override replacing the token. The graph bridge lowercased every per-request
header name while the client-wide ones are canonically cased, which made the
collision the normal case rather than an edge one.
Merge each layer with `Headers.set()` instead, in the fetch client and in the
graph `initOverrides` bridge, which had its own copy of the same spread. The
new specs run under `@vitest-environment node`: happy-dom's `Headers` applies a
record init with `set` semantics and would hide the bug.
Also from the PR review:
- read an error body with the caller's `responseType` rather than cloning the
response, so a `blob` caller keeps getting a Blob on `error.data`
- treat any rejection on an aborted signal as an abort, since `abort(reason)`
rejects with the reason verbatim and only defaults to an `AbortError`
- share the maintenance-mode `onResponse` handler between the webdav client and
`ClientService`, with their pre-existing disagreement about clearing on an
unrelated error made explicit instead of silently unified
- pass the graph headers straight through as a `HeadersInit` and drop the
unused `httpClient` from the graph factory options
- collapse `combineSignals` onto `AbortSignal.any`
- let an abort through `getFileContents` unwrapped
- assert maintenance detection against the real `shouldResponseTriggerMaintenance`
instead of a mock, which had been hiding that a 500 is not a maintenance signal
* chore(web): drop leaked test title prefixes, document the maintenance-mode widening
* fix(web): keep graph fields the generated decoder used to lose
The typescript-fetch templates rebuild every response from the fields the
spec declares, which is what lets them rename the OData annotated fields.
Two consequences were unhandled.
A field the spec does not declare is dropped. oCIS returns `attributes` on
users, filled from OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES and displayed by the
sharing autocomplete, and the field is not part of the upstream spec. It is
now declared before generating, and the generation script fails if the spec
stops matching the line it patches, so the field cannot go missing silently.
A declared field the server omits is present holding `undefined`, so
`'accountEnabled' in user` no longer says whether the server sent it. Three
places read it that way: the login select in the user edit panel showed no
value at all, its watcher kept reporting unsaved changes, and sorting the user
list by login threw on `undefined.toString()`. The same went for
`'total' in quota`, which showed a personal quota of `?` for users without one.
|