feat(properties): prepare property commands before execution
Build and Push Docker Container / build-and-push (push) Successful in 4m28s
Build and Push Docker Container / build-and-push (push) Successful in 4m28s
- Create missing note files before running property:set. - Default date-only datetime values to midnight. - Keep property names out of path authorization checks. - Split policy, vault, daily note, and command target helpers. - Split n8n node args, description, output, and API response helpers. - Split API tests by auth, command, daily note, and property behavior. - Bump API and n8n node versions.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from pathlib import Path
|
||||
|
||||
from app.config import DEFAULT_VAULT_NAME, REGISTERED_VAULTS
|
||||
from app.command_target import CommandTarget
|
||||
|
||||
def vault_for_path(path:Path) -> str|None:
|
||||
resolved = path.resolve()
|
||||
best_name:str|None = None
|
||||
best_len = -1
|
||||
|
||||
for name, vault_path in REGISTERED_VAULTS.items():
|
||||
root = Path(vault_path).resolve()
|
||||
try:
|
||||
resolved.relative_to(root)
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
root_len = len(str(root))
|
||||
if root_len > best_len:
|
||||
best_name = name
|
||||
best_len = root_len
|
||||
|
||||
return best_name
|
||||
|
||||
def vault_root_for_target(target:CommandTarget, cwd:Path) -> Path:
|
||||
if target.vault and target.vault in REGISTERED_VAULTS:
|
||||
return Path(REGISTERED_VAULTS[target.vault]).resolve()
|
||||
|
||||
vault_name = vault_for_path(cwd) or DEFAULT_VAULT_NAME
|
||||
return Path(REGISTERED_VAULTS.get(vault_name, cwd)).resolve()
|
||||
Reference in New Issue
Block a user