Commit graph

37 commits

Author SHA1 Message Date
moson-mo
bcd808ddc1
feat(rpc): add "by" parameter - comaintainers
Add "by" parameter: comaintainers

Signed-off-by: moson-mo <mo-son@mailbox.org>
2022-11-11 11:32:39 +01:00
moson-mo
efd20ed2c7
feat(rpc): add "by" parameter - keywords
Add "by" parameter: keywords

Signed-off-by: moson-mo <mo-son@mailbox.org>
2022-11-11 11:32:31 +01:00
moson-mo
5484e68b42
feat(rpc): add "by" parameter - submitter
Add "by" parameter: submitter

Signed-off-by: moson-mo <mo-son@mailbox.org>
2022-11-11 11:32:19 +01:00
moson-mo
0583f30a53
feat(rpc): add "by" parameter - groups
Adding "by" parameter to search by "groups"

Signed-off-by: moson-mo <mo-son@mailbox.org>
2022-11-11 11:32:01 +01:00
moson-mo
50287cb066
feat(rpc): add "by" parameters - package relations
This adds new "by" search-parameters: provides, conflicts and replaces

Signed-off-by: moson-mo <mo-son@mailbox.org>
2022-11-11 11:30:44 +01:00
Leonidas Spyropoulos
9c0f8f053e
chore: rename logging.py and redis.py to avoid circular imports
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
2022-10-22 18:51:38 +01:00
Kevin Morris
17f2c05fd3
feat(rpc): add GET /rpc/v5/suggest/{arg} openapi route
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-09-12 06:50:26 -07:00
Kevin Morris
8e8b746a5b
feat(rpc): add GET /rpc/v5/search/{arg} openapi route
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-09-12 06:50:19 -07:00
Kevin Morris
df0a4a2be2
feat(rpc): add /rpc/v5/{type} openapi-compatible routes
We will be modeling future RPC implementations on an OpenAPI spec.
While this commit does not completely cohere to OpenAPI in terms
of response data, this is a good start and will allow us to cleanly
document these openapi routes in the current and future.

This commit brings in the new RPC routes:
- GET /rpc/v5/info/{pkgname}
- GET /rpc/v5/info?arg[]=pkg1&arg[]=pkg2
- POST /rpc/v5/info with JSON data `{"arg": ["pkg1", "pkg2"]}`
- GET /rpc/v5/search?arg=keywords&by=valid-by-value
- POST /rpc/v5/search with JSON data `{"by": "valid-by-value", "arg": "keywords"}`

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-09-11 19:11:18 -07:00
Joakim Saario
9c6c13b78a
style: Run pre-commit 2022-08-22 22:40:45 +02:00
Kevin Morris
801df832e5
fix(rpc): correct URLPath in package results
This was incorrectly using the particular Package record's name
to format options.snapshot_uri in order to produce URLPath.

It should, instead, use the PackageBase record's name, which
this commit resolves.

Bug reported by thomy2000

Closes #382

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-08-15 10:06:44 -07:00
Jelle van der Waa
a509e40474 fix(python): use standard dict/list type annotation
Since Python 3.9 list/dict can be used as type hint.
2022-08-02 12:06:58 +00:00
Kevin Morris
a1a88ea872
fix(rpc): suggestions should only suggest based on <keyword>%
Previously, Python code was looking for suggestions based on
`%<keyword>%`. This was inconsistent with PHP's suggestion
implementation and cause more records to be bundled with a suggestion,
along with supplying misleading suggestions.

Closes #343

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-03-08 19:00:19 -08:00
Kevin Morris
51d4b7f993
fix(rpc): limit Package results, not relationships
...This was an obvious bug in hindsight. Apologies :(

Closes #314

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-02-23 14:17:41 -08:00
Kevin Morris
3af66cafbe
fix(rpc): restore "Too Many Package Results" error
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-02-10 01:04:25 -08:00
Kevin Morris
2dfa41c9a5
feat(rpc): support POST method
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-02-07 00:49:34 -08:00
Kevin Morris
7f6c23d4cb
housekeep: centralize datetime generation
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-18 07:31:04 -08:00
Kevin Morris
43b7fdb61d
fix(rpc): display rpc doc when no query string is provided
Closes #255

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-13 22:16:13 -08:00
Kevin Morris
56bd60559c
fix(packages.search): fix default ordering & improve performance
- Use queries more closely aligned to PHP's implementation; removes
  the need for separate vote/notification queries.
- Default sort by popularity

Closes #214

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-25 11:15:20 -08:00
Kevin Morris
2fee6205a6
housekeep(fastapi): rewrite test_rpc with fixtures
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-01 00:28:36 -08:00
Kevin Morris
3efb9a57b5
change(popupdate): converted to use aurweb.db ORM
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-28 19:55:07 -08:00
Kevin Morris
ccf50cbdf5
change: rework test_rpc's TestClient usage into a fixture
This is the first step on our path to reworking the test
suite in general.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 02:30:06 -08:00
Kevin Morris
fa43f6bc3e
change(aurweb): add parallel tests and improve aurweb.db
This change utilizes pytest-xdist to perform a multiproc test
run and reworks aurweb.db's code. We no longer use a global
engine, session or Session, but we now use a memo of engines
and sessions as they are requested, based on the PYTEST_CURRENT_TEST
environment variable, which is available during testing.

Additionally, this change strips several SQLite components
out of the Python code-base.

SQLite is still compatible with PHP and sharness tests, but
not with our FastAPI implementation.

More changes:
------------
- Remove use of aurweb.db.session global in other code.
- Use new aurweb.db.name() dynamic db name function in env.py.
- Added 'addopts' to pytest.ini which utilizes multiprocessing.
    - Highly recommended to leave this be or modify `-n auto` to
      `-n {cpu_threads}` where cpu_threads is at least 2.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:34:59 -08:00
Kevin Morris
61f3cb938c
feat(rpc): support the If-None-Match request header
If the If-None-Match header is supplied with a previously
obtained ETag from the same query, a 304 Not Modified is
returned with no content.

This allows clients to completely leverage the ETag header.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-31 01:22:54 -07:00
Kevin Morris
2cc44e8f28
fix(rpc): perform regex match against callback name
Since we're in the hot path, a constant re.compiled
JSONP_EXPR is defined for checks against the callback.

Additionally, reorganized `content_type` and `content`
to avoid performing a DB query when we encounter a
regex mismatch.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-31 01:17:16 -07:00
Kevin Morris
12b4269ba8
feat(rpc): support jsonp callbacks
This change introduces alternate rendering of text/javascript
JSONP-compatible callback content. The `examples/jsonp.html`
HTML document can be used to test this functionality against
a running aurweb server.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-31 00:29:19 -07:00
Kevin Morris
05e6cfca62
feat(rpc): add msearch type handler
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-30 22:56:18 -07:00
Kevin Morris
af2f3694e7
feat(rpc): add search type handler
This commit introduces a PackageSearch-derivative class: `RPCSearch`.
This derivative modifies callback behavior of PackageSearch to
suit RPC searches, including [make|check|opt]depends `by` types.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-30 19:25:54 -07:00
Kevin Morris
9d6dbaf0ec
feat(rpc): add suggest type handler
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-30 00:36:21 -07:00
Kevin Morris
6d376fed15
feat(rpc): add ETag header with md5 hash content
The ETag header can be used for client-side caching.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 23:57:33 -07:00
Kevin Morris
65240c8343
feat(rpc): enforce ratelimiting
New configuration options:

- `[ratelimit] cache`
    - A boolean indicating whether we should use configured cache (1)
      or database (0) for ratelimiting.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 11:07:36 -07:00
Kevin Morris
7c4fb539d8
change(fastapi): rework /rpc (get)
This reworks the base implementation of the RPC to use a
class called RPC for handling of requests. Took a bit of
a different approach than PHP in terms of exposed methods,
but it does end up achieving the same goal, with one additional
error: "Request type '{type}' is not yet implemented."

For FastAPI development, we'll stick with:

- If the supplied 'type' argument has an alias mapping in
  RPC.ALIASES, we convert the type argument over to its alias
  before doing anything. Example: 'info' is aliased to 'multiinfo',
  so when a user requests type=info, it is converted to type=multiinfo.
- If the type does not exist in RPC.EXPOSED_TYPES, the following
  error is produced: "No request type/data specified."
- If the type **does** exist in RPC.EXPOSED_TYPES, but does not
  have an implemented `RPC._handle_{type}_type` function, the
  following error is produced: "Request type '{type}' is not yet
  implemented."

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-20 22:17:05 -07:00
Kevin Morris
990f4d182b
feat(rpc): add 'suggest-pkgbase' type
This feature of RPC is required to take advantage of
javascript typeahead.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-20 20:31:42 -07:00
Kevin Morris
f7818e26b5
fix(FastAPI): test_rpc.setup() should be a pytest.fixture
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-17 12:42:32 -07:00
Kevin Morris
0bbb3cc4d0
fix(FastAPI): rpc - include other fields with errors
PHP does this, we should persist the behavior here for
v=5.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-17 12:33:23 -07:00
Hunter Wittenborn
a4f5c8bef6 Fixed autopep violations in test/test_rpc.py 2021-09-16 03:20:56 -05:00
Hunter Wittenborn
c2d3dc1daf Added info and multiinfo types for /rpc 2021-09-12 02:21:55 -05:00