@palettelab/cli 0.3.25 → 0.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -267,7 +267,7 @@ Backend SDK features for app-owned data:
|
|
|
267
267
|
- `PluginContext` exposes `user_id`, `organization_id`, `plugin_id`, `permissions`, `config`, `storage`, and `ctx.db`.
|
|
268
268
|
- `ctx.repo(Model)` gives org-safe CRUD helpers for app tables.
|
|
269
269
|
- `ctx.data_rooms` gives backend access to Palette Data Rooms without importing platform internals.
|
|
270
|
-
- `ctx.has_permission("...")`
|
|
270
|
+
- `ctx.has_permission("...")`, `ctx.has_any_permission([...])`, and `ctx.has_all_permissions([...])` check declared permissions.
|
|
271
271
|
- `ctx.config_value("key")` and `ctx.require_config("key")` read app install/config values.
|
|
272
272
|
- `ctx.secret("KEY")` reads app secrets from config or environment variables.
|
|
273
273
|
- `LifecycleHooks` lets apps define install/update/enable/disable/uninstall hooks.
|
|
@@ -290,6 +290,14 @@ async def sync_invoices(ctx: PluginContext = Depends(get_plugin_context)):
|
|
|
290
290
|
folder_id=folder["id"] if folder else None,
|
|
291
291
|
)
|
|
292
292
|
content = await ctx.data_rooms.read_file_bytes(file["id"]) if file else None
|
|
293
|
+
if folder:
|
|
294
|
+
await ctx.data_rooms.upload_file(
|
|
295
|
+
room["id"],
|
|
296
|
+
"summary.txt",
|
|
297
|
+
b"Generated by my app",
|
|
298
|
+
folder_id=folder["id"],
|
|
299
|
+
content_type="text/plain",
|
|
300
|
+
)
|
|
293
301
|
return {"room": room, "folder": folder, "bytes": len(content or b"")}
|
|
294
302
|
```
|
|
295
303
|
|
|
@@ -108,3 +108,20 @@ class DataRoomsClient:
|
|
|
108
108
|
|
|
109
109
|
async def read_file_bytes(self, file_id: int) -> bytes:
|
|
110
110
|
return await self._require_service().read_file_bytes(file_id)
|
|
111
|
+
|
|
112
|
+
async def upload_file(
|
|
113
|
+
self,
|
|
114
|
+
room_id: int,
|
|
115
|
+
filename: str,
|
|
116
|
+
content: bytes,
|
|
117
|
+
*,
|
|
118
|
+
folder_id: int | None = None,
|
|
119
|
+
content_type: str | None = None,
|
|
120
|
+
) -> dict[str, Any]:
|
|
121
|
+
return await self._require_service().upload_file(
|
|
122
|
+
room_id,
|
|
123
|
+
filename,
|
|
124
|
+
content,
|
|
125
|
+
folder_id=folder_id,
|
|
126
|
+
content_type=content_type,
|
|
127
|
+
)
|
|
@@ -45,6 +45,12 @@ class PluginContext:
|
|
|
45
45
|
def has_permission(self, permission: str) -> bool:
|
|
46
46
|
return permission in self.permissions
|
|
47
47
|
|
|
48
|
+
def has_any_permission(self, permissions: list[str] | tuple[str, ...] | set[str]) -> bool:
|
|
49
|
+
return any(permission in self.permissions for permission in permissions)
|
|
50
|
+
|
|
51
|
+
def has_all_permissions(self, permissions: list[str] | tuple[str, ...] | set[str]) -> bool:
|
|
52
|
+
return all(permission in self.permissions for permission in permissions)
|
|
53
|
+
|
|
48
54
|
def config_value(self, key: str, default: Any = None) -> Any:
|
|
49
55
|
return self.config.get(key, default)
|
|
50
56
|
|