Commit graph

39 commits

Author SHA1 Message Date
Akhil Narang
33dbf97db2
fix(document): don't try to overwrite name if a string is already set
This allows us to pass `name` in via API when creating documents.

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-05-05 12:24:58 +05:30
petnd
38f112f4ac
fix: Apply permlevel for update_doc endpoint in v2 API (#32135)
* fix: Only Return Allowed Fields in API Response

Apply Read Permission to the returned fields of API v2
2025-04-16 13:02:14 +02:00
Raffael Meyer
9430e3af86
fix: respect override_whitelisted_method in map_docs (#31718)
* refactor: override_whitelisted_method

* fix: respect `override_whitelisted_method` in `map_docs`

* refactor: override_whitelisted_method
2025-03-17 14:27:12 +01:00
Raffael Meyer
aade0df7bf
feat: new REST API for copy_doc (#31160)
* feat: new REST API for copy_doc

* test: copy endpoint
2025-02-07 17:46:53 +05:30
Ankush Menat
dfc6dcb6b8 Revert "perf: Avoid checking server script map (#29057)"
This reverts commit 55a55e7f7b.
2025-01-06 19:43:53 +05:30
Ankush Menat
55a55e7f7b
perf: Avoid checking server script map (#29057)
If I have to hazard a guess, 99% API calls are not server scripts, then
why check it first and pay the costs?

This PR first checks if method is a real method in python code and if
it's not found then only attempts to fetch it from server script map.

I'll revert this if I can bring the costs in acceptable limits with
client-side caching.
2025-01-06 07:40:20 +00:00
Akhil Narang
84ef6ec677
refactor: fixup with ruff 0.8.1
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-04 13:18:04 +05:30
Raffael Meyer
9208b58b6f
refactor: use doc.check_permission (#28317)
* refactor: use `doc.check_permission`

* refactor(delete_doc): check_permission_and_not_submitted
2024-11-22 10:41:24 +01:00
Ankush Menat
750b70b075
refactor: Wrap meta in v2 (#26548) 2024-05-24 06:05:09 +00:00
Ankush Menat
4dfb44d0a2 fix: assume v1 if path is not set
Old `cmd` calls will not work otherwise.
2023-10-16 18:13:50 +05:30
Ankush Menat
6fd97bcbcf fix: Add old file upload for v2 2023-10-16 18:13:50 +05:30
Ankush Menat
411819ef81 feat: v2 for message response strucutre 2023-10-16 18:13:50 +05:30
Ankush Menat
dfcb69ab21 refactor: use reportview get_count implementation
Count reported should be according to permissions
2023-10-16 18:13:50 +05:30
Ankush Menat
47538f7601 feat: doctype collection level APIs - meta, count 2023-10-16 18:13:50 +05:30
Ankush Menat
cfd3fb9341 refactor: PUT == PATCH
Correct conventions for partial updates
2023-10-16 18:13:50 +05:30
Ankush Menat
c8cd658d26 fix: add login and logout methods 2023-10-16 18:13:50 +05:30
Ankush Menat
67a5957056 fix: check for write permission if POST method 2023-10-16 18:13:50 +05:30
Ankush Menat
824229ce0a refactor: no need to cast bools manually 2023-10-16 18:13:50 +05:30
Ankush Menat
43028f51d9 refactor: simplify v2 implementations 2023-10-16 18:13:50 +05:30
Ankush Menat
7996f76ebb fix: Better delete doc for child tables 2023-10-16 18:13:50 +05:30
Ankush Menat
232f080044 feat: run_doc_method v2 2023-10-16 18:13:50 +05:30
Ankush Menat
d117e2c08b fix!: Last overriden method should be considered 2023-10-16 18:13:33 +05:30
Ankush Menat
bfb463e814 refactor!: merge handle.py
This has several breaking changes for v2:
1. No support for following methods which were implicitly present in
   default namespace.
    - run_doc_method
    - ping
    - web_logout
    - logout
    - uploadfile
    - upload_file
    - download_file
2023-10-16 18:12:53 +05:30
Ankush Menat
e63f0c895d refactor: resource => document
This lets us create three types of APIs:

- Document APIs that operate on documents
- DocType APIs that operate on collections - list, count, search
- Method APIs that are RPC calls
2023-10-16 18:12:53 +05:30
Ankush Menat
10ace97ebb fix: backward compatiblity for method calls in v1
Preserves complete path just like before. This broke oauth as oauth code
was expecting 4th part in path even though it's never been supported in
API methods
2023-10-16 18:12:53 +05:30
Ankush Menat
985c897c95 refactor: simplify request form data 2023-10-16 18:12:53 +05:30
Ankush Menat
825692128f chore: separate out v1 and v2
Any common utils end up becoming a problem, duplicating code here is
better than coupling potentially breaking behaviour
2023-10-16 18:12:53 +05:30
Ankush Menat
275f16060a fix: route ambiguitities and / in name
v1 and v2:
- Use path convertor to consume entire document which MIGHT contain `/`
- Drop string convertor, as it's the default
- Dont merge slashes - avoid consuming something that's part of name

v2:
- `SI/BLAH/BLAH/submit` is not simple to parse without ambiguitity
- `SI/BLAH/BLAH/method/submit` removes ambiguitity for 99.99% cases.
2023-10-16 18:12:53 +05:30
Ankush Menat
627b777a9c refactor!: manual creation of response
This contains minor breaking change where `delete` API call now returns `OK` in `data` key instead of `message`.
2023-10-16 18:12:53 +05:30
Ankush Menat
b57ca948ab refactor: common API methods to utils 2023-10-16 18:12:53 +05:30
Ankush Menat
8ce6426c75 refactor: Drop frappe.local for proxies 2023-10-16 18:12:53 +05:30
Ankush Menat
f9e120c104 refactor: remove unnessary manual commits 2023-10-16 18:12:53 +05:30
Ankush Menat
b6b4b98c0f refactor(APIv2): message -> data 2023-10-16 18:12:53 +05:30
Ankush Menat
26b3f6ae96 fix: pass on custom responses as is without any post processing 2023-10-16 18:12:53 +05:30
Ankush Menat
e0f87dc4e1 refactor!: move OAuth and token auth code to auth.py
This doesn't belong in api.py
2023-10-16 18:12:53 +05:30
Ankush Menat
b064d12440 feat: Shorthand for whitelisted function call in controllers
```diff
- GET /api/method/frappe.core.doctype.user.user.get_timezones
+ GET /api/method/User/get_timezones
```
2023-10-16 18:12:53 +05:30
Ankush Menat
5f32952b30 feat(APIv2): Execute doc method using API
e.g. `POST /api/v2/resource/Sales Order/SO-0001/submit`
2023-10-16 18:12:53 +05:30
Ankush Menat
1b51914a83 refactor: create two API versions 2023-10-16 18:12:53 +05:30
Ankush Menat
5af6624cce refactor: Use werkzeug router for API routing 2023-10-16 18:12:53 +05:30