@seliseblocks/cli-os 0.2.11 → 0.2.12

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.
Files changed (47) hide show
  1. package/AI_USAGE_GUIDE.md +551 -560
  2. package/README.md +171 -173
  3. package/dist/commands/auth/refresh.js +21 -2
  4. package/dist/commands/mfa/generate.js +7 -4
  5. package/dist/commands/mfa/method-set.js +13 -4
  6. package/dist/commands/mfa/totp-enable.d.ts +3 -3
  7. package/dist/commands/mfa/totp-enable.js +4 -4
  8. package/dist/commands/mfa/verify.js +4 -2
  9. package/dist/commands/projects/create.js +110 -16
  10. package/dist/index.js +696 -703
  11. package/package.json +2 -2
  12. package/dist/commands/sdk/client.d.ts +0 -1
  13. package/dist/commands/sdk/client.js +0 -99
  14. package/dist/commands/skill/add.d.ts +0 -1
  15. package/dist/commands/skill/add.js +0 -19
  16. package/dist/commands/skill/list.d.ts +0 -1
  17. package/dist/commands/skill/list.js +0 -15
  18. package/dist/commands/skill/show.d.ts +0 -1
  19. package/dist/commands/skill/show.js +0 -15
  20. package/dist/lib/skills.d.ts +0 -17
  21. package/dist/lib/skills.js +0 -69
  22. package/dist/skills/blocks-data-gateway-configuration/SKILL.md +0 -204
  23. package/dist/skills/blocks-data-gateway-crud/SKILL.md +0 -223
  24. package/dist/skills/blocks-data-storage/SKILL.md +0 -253
  25. package/dist/skills/blocks-data-storage/flows/object-management.md +0 -124
  26. package/dist/skills/blocks-frontend-local-https/SKILL.md +0 -100
  27. package/dist/skills/blocks-iam-access-control/SKILL.md +0 -49
  28. package/dist/skills/blocks-iam-access-control/flows/feature-gating.md +0 -38
  29. package/dist/skills/blocks-iam-access-control/flows/manage-roles-permissions.md +0 -110
  30. package/dist/skills/blocks-iam-account/SKILL.md +0 -169
  31. package/dist/skills/blocks-iam-mfa/SKILL.md +0 -124
  32. package/dist/skills/blocks-iam-organizations/SKILL.md +0 -43
  33. package/dist/skills/blocks-iam-organizations/flows/admin-mutations.md +0 -89
  34. package/dist/skills/blocks-iam-organizations/flows/read-and-switch.md +0 -57
  35. package/dist/skills/blocks-iam-sso-oidc-configuration/SKILL.md +0 -105
  36. package/dist/skills/blocks-iam-sso-oidc-implementation/SKILL.md +0 -80
  37. package/dist/skills/blocks-iam-users/SKILL.md +0 -131
  38. package/dist/skills/blocks-localization-configuration/SKILL.md +0 -149
  39. package/dist/skills/blocks-localization-implementation/SKILL.md +0 -63
  40. package/dist/skills/blocks-mail/SKILL.md +0 -95
  41. package/dist/skills/blocks-notification/SKILL.md +0 -69
  42. package/dist/skills/blocks-notifier/SKILL.md +0 -107
  43. package/dist/skills/blocks-onboarding/SKILL.md +0 -77
  44. package/dist/skills/blocks-release-deployment/SKILL.md +0 -81
  45. package/dist/skills/blocks-secrets/SKILL.md +0 -81
  46. package/dist/skills/blocks-storage-configuration/SKILL.md +0 -93
  47. package/dist/skills/lint.mjs +0 -168
@@ -1,223 +0,0 @@
1
- ---
2
- name: blocks-data-gateway-crud
3
- description: "Implement create/read/update/delete against a SELISE Blocks project's runtime Data Gateway using the @seliseblocks/client SDK. Use data.collection(schemaName) for straightforward per-item CRUD, data.graphql() for joins or custom query shapes, and data.schemas.*/data.validations.* for schema/validation metadata. Shows how to wire CRUD into the React 18 + Vite + TanStack Query app that blocks new web scaffolds. Use whenever the user wants to read or write actual records through a Blocks Data schema from app code."
4
- ---
5
-
6
- # Blocks Data - Gateway CRUD
7
-
8
- Once a schema exists and has been reloaded via the blocks-data-gateway-configuration skill, the Data Gateway exposes runtime records through GraphQL. This skill shows how to use the generated app's shared `@seliseblocks/client` instance for CRUD. Do not use raw `fetch` or `curl` against Blocks APIs from app code.
9
-
10
- Prerequisite: a project selected via `blocks use` and an app scaffolded with `blocks new web <name> ...`. If either is missing, run the blocks-onboarding skill first.
11
-
12
- ## Use the Existing Client
13
-
14
- The scaffold creates one `createBlocksClient()` call in `src/lib/blocks/client.ts`:
15
-
16
- ```ts
17
- import { createBlocksClient } from "@seliseblocks/client";
18
- import { blocksConfig } from "./config";
19
- import { getValidAccessToken } from "./auth";
20
-
21
- export const blocksClient = createBlocksClient({
22
- accessToken: () => getValidAccessToken(),
23
- apiUrl: blocksConfig.apiUrl,
24
- appDomain: blocksConfig.appDomain,
25
- oidc: { clientId: blocksConfig.oidcClientId, scope: blocksConfig.oidcScope, url: blocksConfig.oidcUrl },
26
- xBlocksKey: blocksConfig.xBlocksKey
27
- });
28
- ```
29
-
30
- Import that existing instance from feature code. Do not create a second client.
31
-
32
- - `xBlocksKey` is the project's public tenant key from `VITE_BLOCKS_X_BLOCKS_KEY`.
33
- - The SDK does not add `ProjectKey` to runtime Data calls.
34
- - The HTTP client sends `credentials: "include"` so hosted-login session cookies are included.
35
- - Never use the CLI's impersonation token or project token in browser code.
36
-
37
- ## Preferred CRUD Helper
38
-
39
- Use `blocksClient.data.collection<T>(schemaName, options)` for normal CRUD. Pass the schema name, not the collection name. For a schema named `Product` with collection `Products`, pass `"Product"`.
40
-
41
- ```ts
42
- const products = blocksClient.data.collection<Product>("Product", {
43
- fields: ["name", "price", "status"]
44
- });
45
-
46
- products.list({ pageNo: 1, pageSize: 20 });
47
- products.get(itemId);
48
- products.create(payload);
49
- products.update(itemId, payload);
50
- products.delete(itemId);
51
- ```
52
-
53
- What the helper does:
54
-
55
- - `list` and `get` call `query getProducts($input: DynamicQueryInput)`.
56
- - `create` calls `mutation insertProduct($input: ProductInsertInput!)`.
57
- - `update` calls `mutation updateProduct($filter: String, $input: ProductUpdateInput!)`.
58
- - `delete` calls `mutation deleteProduct($filter: String, $input: ProductDeleteInput!)`.
59
- - `get`, `update`, and `delete` address records by `ItemId`.
60
- - `fields` controls the GraphQL selection for returned items; `ItemId` is always selected.
61
-
62
- `list` accepts paging plus optional GraphQL dynamic input values:
63
-
64
- ```ts
65
- await products.list({
66
- pageNo: 1,
67
- pageSize: 20,
68
- filter: { status: "Active" },
69
- sort: { name: 1 }
70
- });
71
- ```
72
-
73
- For search, only send filters that the schema/runtime actually supports. If unsure, start with simple paging and client-side filtering, or inspect the schema first.
74
-
75
- ## Product Example
76
-
77
- ```ts
78
- // src/features/products/productsApi.ts
79
- import { blocksClient } from "../../lib/blocks/client";
80
-
81
- export type Product = Record<string, unknown> & {
82
- itemId?: string;
83
- id?: string;
84
- name?: string;
85
- price?: number;
86
- status?: string;
87
- };
88
-
89
- export type ProductInput = { name: string; price: number; status: string };
90
-
91
- const products = blocksClient.data.collection<Product>("Product", {
92
- fields: ["name", "price", "status"]
93
- });
94
-
95
- export async function listProducts({ page, pageSize }: { page: number; pageSize: number }) {
96
- const response = await products.list({ pageNo: page, pageSize });
97
- return normalizeProductList(response);
98
- }
99
-
100
- export function createProduct(input: ProductInput) {
101
- return products.create(input);
102
- }
103
-
104
- export function updateProduct(product: Product) {
105
- return products.update(productId(product), product);
106
- }
107
-
108
- export function deleteProduct(product: Product) {
109
- return products.delete(productId(product));
110
- }
111
-
112
- function productId(product: Product): string {
113
- const id = product.itemId ?? product.id;
114
- if (!id) throw new Error("Product item id is missing.");
115
- return String(id);
116
- }
117
-
118
- function normalizeProductList(response: unknown): { items: Product[]; totalCount: number } {
119
- const record = response as {
120
- data?: {
121
- getProducts?: { items?: Product[]; totalCount?: number };
122
- items?: Product[];
123
- totalCount?: number;
124
- };
125
- items?: Product[];
126
- totalCount?: number;
127
- };
128
- const gateway = record.data?.getProducts;
129
- const items = gateway?.items ?? record.data?.items ?? record.items ?? [];
130
- return { items, totalCount: gateway?.totalCount ?? record.data?.totalCount ?? record.totalCount ?? items.length };
131
- }
132
- ```
133
-
134
- ```ts
135
- // src/features/products/useProducts.ts
136
- import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
137
- import { createProduct, deleteProduct, listProducts, updateProduct } from "./productsApi";
138
- import type { Product, ProductInput } from "./productsApi";
139
-
140
- export function useProductsQuery(page: number, pageSize: number) {
141
- return useQuery({
142
- queryKey: ["products", page, pageSize],
143
- queryFn: () => listProducts({ page, pageSize })
144
- });
145
- }
146
-
147
- export function useProductMutations() {
148
- const queryClient = useQueryClient();
149
- const invalidate = () => queryClient.invalidateQueries({ queryKey: ["products"] });
150
-
151
- return {
152
- create: useMutation({ mutationFn: (input: ProductInput) => createProduct(input), onSuccess: invalidate }),
153
- update: useMutation({ mutationFn: (product: Product) => updateProduct(product), onSuccess: invalidate }),
154
- remove: useMutation({ mutationFn: (product: Product) => deleteProduct(product), onSuccess: invalidate })
155
- };
156
- }
157
- ```
158
-
159
- ## When to Use `data.graphql()`
160
-
161
- Use `data.graphql({ query, variables, operationName })` when the collection helper is too small:
162
-
163
- - joins across schemas;
164
- - custom nested selections;
165
- - generated `where`, `order`, or `paging` arguments;
166
- - bulk operations such as `insertManyProduct`.
167
-
168
- Example:
169
-
170
- ```ts
171
- const result = await blocksClient.data.graphql({
172
- operationName: "getProducts",
173
- query: `
174
- query getProducts($input: DynamicQueryInput) {
175
- getProducts(input: $input) {
176
- items { ItemId name price status }
177
- totalCount
178
- }
179
- }
180
- `,
181
- variables: { input: { pageNo: 1, pageSize: 20 } }
182
- });
183
- ```
184
-
185
- ## Schema Metadata
186
-
187
- Use `data.schemas.*` when building dynamic UI:
188
-
189
- - `data.schemas.list(options)` or `data.schemas.get(schemaName)` for discovery;
190
- - `data.schemas.infoByName(schemaName)` for field-level metadata;
191
- - `data.schemas.info()` for general schema info;
192
- - `data.schemas.aggregation(options)` for summary views;
193
- - `data.schemas.getById(id)` when you already have the schema id.
194
-
195
- Use `data.validations.*` to read field-level validation rules at runtime (e.g. to drive client-side form validation from the same rules the backend enforces):
196
-
197
- - `data.validations.list(options)` for all rules, with optional schema/field/paging filters;
198
- - `data.validations.bySchemaId(schemaId)` for every rule on one schema;
199
- - `data.validations.bySchemaAndField({ schemaId, fieldName })` for one field's rule;
200
- - `data.validations.getById(id)` when you already have the validation id.
201
-
202
- Validation rules are authored and saved separately via `blocks data validation save` (see the blocks-data-gateway-configuration skill); this SDK namespace only reads them.
203
-
204
- ## Gotchas
205
-
206
- - Pass schema name, not collection name: `Product`, not `Products`.
207
- - Generated query names pluralize by naive concatenation -- literally appending `s`, not English pluralization: `getProducts`, but `Company` -> `getCompanys`, not `getCompanies`. Never guess a pluralized name; read it from the schema's `querySchema` field (via `data.schemas.get`/`getByName` or `blocks data schema get <id>`) and use `get${querySchema}`.
208
- - Generated mutation names stay singular: `insertProduct`, `updateProduct`, `deleteProduct`. Bulk variants follow the same pattern but are not listed in `mutationSchemas`: `insertManyProduct`, `updateManyProduct`, `deleteManyProduct`.
209
- - Dynamic item selections use schema field names such as `ItemId`, `name`, `price`.
210
- - Mutation response fields are lower camel case: `acknowledged`, `itemId`, `message`, `totalImpactedData`.
211
- - If GraphQL says the field does not exist, the schema probably has not been created or reloaded.
212
- - Keep one `blocksClient` per app.
213
-
214
- ## Prompt Routing
215
-
216
- ```text
217
- Wire create/read/update/delete for Product into my React app -> this skill
218
- Build a paged table of Orders in the dashboard -> this skill
219
- I need a GraphQL query that joins Orders with Customer details -> this skill, data.graphql
220
- Build a dynamic form from my schema's field metadata -> this skill, data.schemas.infoByName
221
- Create a Product schema with title/price and reload it -> blocks-data-gateway-configuration
222
- Upload a PDF and get a download link -> blocks-data-storage
223
- ```
@@ -1,253 +0,0 @@
1
- ---
2
- name: blocks-data-storage
3
- description: "Build file and document-management features on SELISE Blocks Data: upload/download, directory trees, cursor-paginated browsing and search, file versions, rename/move/copy, soft delete/trash/restore, sharing, access policies, and inheritance. Use for attachments, file browsers, folders, shared files, permissions, or version history. Use 'blocks data files *' for terminal/admin work and @seliseblocks/client data.files/data.directories/data.objects for app code."
4
- ---
5
-
6
- # Blocks Data — Storage
7
-
8
- Treat storage as one permission-aware object tree containing **directories** and **files**. Uploading a new file now creates the file object in that tree; there is no second DMS registration step.
9
-
10
- Use:
11
-
12
- - **`blocks data files *`** for supported terminal/admin operations.
13
- - **`@seliseblocks/client`** for app code. Use the shared `blocksClient` created by blocks-onboarding.
14
- - **blocks-storage-configuration** only to manage the named provider configuration used by `configurationName`.
15
-
16
- Select a project first with `blocks use <tenantId>`. If login/project state or the shared client setup is unknown, use blocks-onboarding before this skill.
17
-
18
- Store the returned `fileId` in a Data record when attaching a file to domain data. Use blocks-data-gateway-crud for the record mutation.
19
-
20
- ## Choose the surface
21
-
22
- The current CLI and SDK follow the backend's file, directory, and object resource groups.
23
-
24
- ```bash
25
- blocks --version
26
- blocks data files --help
27
- ```
28
-
29
- - Use `blocks data files *` for terminal/admin work and inspect `blocks --help` for exact flags.
30
- - Use `blocksClient.data.files` for bytes, metadata, versions, and file operations.
31
- - Use `blocksClient.data.directories` for directory create/get/update/delete/move.
32
- - Use `blocksClient.data.objects` for browse/search/trash/shared/restore/share/access/inheritance.
33
-
34
- Legacy `data.dms.*`, `dms-upload`, `dms-list`, `create-folder`, and `delete-folder` wrappers are retired. Uploads need no registration call.
35
-
36
- ## Upload a new file
37
-
38
- Choose one path from the project's storage configuration.
39
-
40
- | Provider category | Sequence |
41
- |---|---|
42
- | Cloud object storage | request a pre-signed URL, then PUT the bytes to it |
43
- | Local/SFTP storage | send one authenticated multipart upload |
44
-
45
- Both paths create the file object and initial version directly. Do not call `dms-upload` afterward.
46
-
47
- ### Cloud upload from the CLI
48
-
49
- Prefer the composed command. It previews and confirms both metadata creation and the provider PUT:
50
-
51
- ```bash
52
- blocks data files upload --file ./invoice.pdf --parent-id <directoryId> \
53
- --configuration-name Default --access-modifier Private --dry-run --json
54
- blocks data files upload --file ./invoice.pdf --parent-id <directoryId> \
55
- --configuration-name Default --access-modifier Private --yes --json
56
- ```
57
-
58
- Use the two explicit commands only when the intermediate upload URL is required:
59
-
60
- ```bash
61
- blocks data files presigned-upload-url \
62
- --name invoice.pdf \
63
- --parent-directory-id <directoryId> \
64
- --configuration-name Default \
65
- --access-modifier Private \
66
- --dry-run --json
67
- blocks data files presigned-upload-url \
68
- --name invoice.pdf \
69
- --parent-directory-id <directoryId> \
70
- --configuration-name Default \
71
- --access-modifier Private \
72
- --yes --json
73
-
74
- blocks data files upload-to-url \
75
- --url "<uploadUrl>" \
76
- --file ./invoice.pdf \
77
- --content-type application/pdf \
78
- --dry-run --json
79
- blocks data files upload-to-url \
80
- --url "<uploadUrl>" \
81
- --file ./invoice.pdf \
82
- --content-type application/pdf \
83
- --yes --json
84
- ```
85
-
86
- The presign response contains `uploadUrl`, `fileId`, and `isSuccess`. The first call creates the file metadata/version; the PUT fills its object-storage key. Handle PUT failure explicitly because it can leave metadata for missing bytes.
87
-
88
- When `parentDirectoryId` is empty, the cloud upload resolves `moduleName` to that module's default directory. The backend default is module value `8` (`Default_Construct`), but pass the intended module or a concrete directory id instead of relying on that default.
89
-
90
- ### Cloud upload from app code
91
-
92
- ```ts
93
- const presign = await blocksClient.data.files.presignedUploadUrl({
94
- name: "invoice.pdf",
95
- parentDirectoryId: directoryId,
96
- configurationName: "Default",
97
- accessModifier: "Private",
98
- tags: "invoice,2026",
99
- });
100
-
101
- if (!presign || typeof presign !== "object") {
102
- throw new Error("Unexpected upload response");
103
- }
104
-
105
- const result = presign as {
106
- uploadUrl: string;
107
- fileId: string;
108
- isSuccess: boolean;
109
- errors?: Record<string, string>;
110
- };
111
-
112
- if (!result.isSuccess) throw new Error(JSON.stringify(result.errors));
113
-
114
- await blocksClient.data.files.uploadToUrl({
115
- url: result.uploadUrl,
116
- body: file,
117
- contentType: file.type || "application/octet-stream",
118
- });
119
- ```
120
-
121
- `uploadToUrl` is provider-direct and sends no bearer token or `x-blocks-key`. The SDK adds Azure's `x-ms-blob-type: Blockblob` header unless overridden; ensure that header matches the signed provider policy.
122
-
123
- ### Local-storage upload
124
-
125
- ```bash
126
- blocks data files upload-to-local-storage \
127
- --file ./invoice.pdf \
128
- --parent-directory-id <directoryId> \
129
- --configuration-name Default \
130
- --access-modifier Private \
131
- --dry-run --json
132
- blocks data files upload-to-local-storage \
133
- --file ./invoice.pdf \
134
- --parent-directory-id <directoryId> \
135
- --configuration-name Default \
136
- --access-modifier Private \
137
- --yes --json
138
- ```
139
-
140
- ```ts
141
- const uploaded = await blocksClient.data.files.uploadToLocalStorage({
142
- name: file.name,
143
- file,
144
- parentDirectoryId: directoryId,
145
- configurationName: "Default",
146
- accessModifier: "Private",
147
- tags: ["invoice", "2026"],
148
- });
149
- ```
150
-
151
- This call creates the file object and uploads version 1 in one request. Unlike cloud presign, an empty local `parentDirectoryId` stays at the top level; it is not resolved through `moduleName`.
152
-
153
- ## Add a file version
154
-
155
- Supplying an existing `itemId` to either upload flow creates another version after the caller passes the file's Edit check. For cloud storage, the dedicated command/method returns another pre-signed URL:
156
-
157
- ```bash
158
- blocks data files versions <fileId> --limit 25 --json
159
- blocks data files create-version <fileId> --configuration-name Default --dry-run --json
160
- blocks data files create-version <fileId> --configuration-name Default --yes --json
161
- ```
162
-
163
- ```ts
164
- const history = await blocksClient.data.files.versions({ fileId, limit: 25 });
165
- const next = await blocksClient.data.files.createVersion({ fileId, configurationName: "Default" });
166
- ```
167
-
168
- Version history is newest-first and cursor-paginated. Use the returned opaque `nextCursor`; the current backend uses the last version number internally, but callers must not construct cursors. Limits are 1–100, default 25.
169
-
170
- ## Read and download
171
-
172
- ```bash
173
- blocks data files get <fileId> --configuration-name Default --json
174
- blocks data files get <fileId> --version <versionNo> --configuration-name Default --json
175
- blocks data files get-many <fileId...> --configuration-name Default --json
176
- ```
177
-
178
- ```ts
179
- const file = await blocksClient.data.files.get(fileId, {
180
- configurationName: "Default",
181
- version: 2,
182
- });
183
- ```
184
-
185
- The response includes a download URL plus metadata. Download requires the caller's Download permission. Access-denied reads may deliberately look like missing resources so clients cannot probe hidden object ids.
186
-
187
- ## Directory and object workflows
188
-
189
- For browsing, directories, search, move/copy/rename, trash, sharing, and ACL behavior, read [flows/object-management.md](flows/object-management.md).
190
-
191
- ## Update custom metadata
192
-
193
- ```bash
194
- blocks data files update-additional-info <fileId> \
195
- --additional-properties '{"status":"reviewed"}' \
196
- --dry-run --json
197
- blocks data files update-additional-info <fileId> \
198
- --additional-properties '{"status":"reviewed"}' \
199
- --yes --json
200
- ```
201
-
202
- This updates `additionalProperties`; it does not rename, move, tag, or version the file.
203
-
204
- ## Delete safely
205
-
206
- Deletion now distinguishes trash from permanent removal:
207
-
208
- - `permanent: false` archives the file or directory so it can be restored.
209
- - `permanent: true` removes it for good.
210
- - The backend default is **`true`** when `permanent` is omitted.
211
-
212
- The CLI defaults to safe soft deletion. Add `--permanent` only after explicit approval.
213
-
214
- ```bash
215
- blocks data files delete <fileId> --dry-run --json
216
- blocks data files delete <fileId> --yes --json
217
- blocks data files delete <fileId> --permanent --dry-run --json
218
- ```
219
-
220
- In app code, send the choice explicitly: `blocksClient.data.files.delete({ fileId, permanent: false })`.
221
-
222
- ## Permission model
223
-
224
- Every storage request passes two checks:
225
-
226
- 1. The endpoint permission permits that class of action.
227
- 2. The object ACL permits the action on that specific file/directory.
228
-
229
- Capabilities are ordered: `View`, `Download`, `Edit`, `Delete`, `Manage`, `Owner`. Higher capabilities imply lower ones. Directory children inherit ancestor access while `inheritsParentAccess` is true. New files inherit from their directory.
230
-
231
- Do not infer permission from a visible button or endpoint grant. Render actions from each object's returned `permissions` flags and still handle 403/404 races.
232
-
233
- ## Gotchas
234
-
235
- - Upload now creates the visible file object; legacy DMS registration is wrong and may fail after the bytes were successfully PUT.
236
- - Cloud presign creates metadata before the provider PUT. Treat the two steps as a recoverable workflow and surface partial failure.
237
- - A name must contain an allowed extension. Directories may restrict extensions.
238
- - Names are unique within a directory. File move/copy can fail on a name conflict or extension policy.
239
- - `Private` is the safe default. Use `Public` only when unauthenticated download is intended.
240
- - `configurationName` selects an existing provider record; it does not configure storage.
241
- - Most legacy file SDK methods return `Promise<unknown>`; validate responses at the boundary.
242
- - Never send Blocks auth headers to a pre-signed provider URL.
243
- - Never use a raw API call to work around a missing CLI/SDK wrapper; update the client surface first.
244
-
245
- ## Example triggers
246
-
247
- - "Upload this PDF into the Contracts folder."
248
- - "Build a file browser with folders and search."
249
- - "Show files shared with the current user."
250
- - "Move this file to trash and let users restore it."
251
- - "Add version history and upload a replacement version."
252
- - "Share this directory with a role and let its children inherit access."
253
- - "Move, copy, or rename a file."
@@ -1,124 +0,0 @@
1
- # Object management
2
-
3
- Use `blocks data files *` from a terminal and `blocksClient.data.directories` / `blocksClient.data.objects` / `blocksClient.data.files` in app code. Do not fall back to legacy `data.dms.*` helpers or raw HTTP.
4
-
5
- ## Browse a directory
6
-
7
- Use the current `get-objects` operation with:
8
-
9
- - `parentDirectoryId` for a concrete directory, or `moduleName` to resolve a module's default directory when no parent id is supplied.
10
- - `cursor` from the previous response and `limit` from 1–200 (default 50).
11
- - `type: "directory" | "file"` to narrow results.
12
- - `search` for name filtering within that parent.
13
-
14
- The result contains `items`, `nextCursor`, `hasMore`, and `totalChildCount`. Each item has a lowercase `type` discriminator and permission flags. Continue while `hasMore` using `nextCursor`; access filtering can produce a short page even when more results remain.
15
-
16
- Use `search-objects` for a case-insensitive name search across descendants. Pass `query`, optional `directoryId`, optional type, cursor, and limit. Search text is treated literally rather than as a regular expression.
17
-
18
- ```bash
19
- blocks data files list --parent-id <directoryId> --type file --limit 50 --json
20
- blocks data files search invoice --directory-id <directoryId> --json
21
- ```
22
-
23
- ```ts
24
- const page = await blocksClient.data.objects.list({ parentDirectoryId, limit: 50 });
25
- const matches = await blocksClient.data.objects.search({ query: "invoice", directoryId });
26
- ```
27
-
28
- ## Manage directories
29
-
30
- - **Create:** provide `name`, an existing `parentDirectoryId`, optional `description`, `configurationName`, and `allowedFileExtensions`. If the parent is empty but `moduleName` is present, the backend resolves the module default. Creating a true root uses a separate owner-only capability and should not be a normal app action.
31
- - **Read details:** get one directory by `directoryId`. The response includes path, ancestors, child counts, size, extension rules, inheritance, timestamps, and permissions.
32
- - **Update:** provide `directoryId` and optional `name`/`description`. Default directories cannot be renamed.
33
- - **Move:** provide `directoryId` and `targetDirectoryId`; an empty target means top level. Moving into self/descendants is rejected. Default directories cannot move.
34
- - **Delete:** send `permanent: false` for trash. Permanent deletion requires an empty directory. Default directories cannot be deleted.
35
-
36
- Directory names must be 1–255 characters, trimmed, not `.`/`..`, and contain no slash or backslash. Descriptions are limited to 2,000 characters.
37
-
38
- ```bash
39
- blocks data files directory-create Contracts --parent-id <directoryId> \
40
- --allowed-extensions pdf,docx --dry-run --json
41
- blocks data files directory-get <directoryId> --json
42
- blocks data files directory-update <directoryId> --name Agreements --dry-run --json
43
- blocks data files directory-move <directoryId> --target-directory-id <targetId> --dry-run --json
44
- blocks data files directory-delete <directoryId> --dry-run --json
45
- ```
46
-
47
- Use the matching `blocksClient.data.directories.create/get/update/move/delete` methods in app code.
48
-
49
- ## Manage files
50
-
51
- - **Rename:** needs Edit and a unique name in the current directory.
52
- - **Move:** needs Delete on the source file and Edit on the target directory. Stored bytes and versions stay in place.
53
- - **Copy:** needs View on the source and Edit on the target. The new file gets a new id; version rows reference the same immutable stored bytes. It inherits from the target. Set `copyAccessPolicies` only when the user intends to duplicate direct policy entries.
54
- - **Versions:** list newest-first with a cursor and limit 1–100. Creating a cloud version returns `versionNo` and `uploadUrl`; PUT the bytes to that URL without Blocks auth headers.
55
-
56
- Move/copy reject a target name collision and a file extension disallowed by the target directory.
57
-
58
- ```bash
59
- blocks data files rename <fileId> --name final.pdf --dry-run --json
60
- blocks data files move <fileId> --target-directory-id <targetId> --dry-run --json
61
- blocks data files copy <fileId> --target-directory-id <targetId> --dry-run --json
62
- ```
63
-
64
- Use `blocksClient.data.files.rename`, `.move`, and `.copy` in app code.
65
-
66
- ## Trash and restore
67
-
68
- Use soft delete (`permanent: false`) to archive an item. List archived files/directories with `get-trash`, optionally filtering by type and paging with cursor/limit. Restore with `restore-from-trash`; permanently purge an archived item with `delete-from-trash` only after explicit approval.
69
-
70
- Restore returns the item to its original parent. Reads and mutations remain ACL-filtered while the item is archived.
71
-
72
- ```bash
73
- blocks data files trash --type file --json
74
- blocks data files restore <resourceId> --dry-run --json
75
- blocks data files purge <resourceId> --dry-run --json
76
- ```
77
-
78
- Use `blocksClient.data.objects.trash`, `.restore`, and `.deleteFromTrash` in app code.
79
-
80
- ## Shared objects
81
-
82
- Use `get-shared-objects` for live items shared with the caller. It is cursor-paginated and may be filtered by `directory`/`file`. Owned objects are excluded. Direct or inherited allow entries for the current user, role, or organization qualify as shares.
83
-
84
- Use `share-object` for the common allow-only action. Provide:
85
-
86
- - `resourceId`
87
- - `resourceType`: `Directory` or `File`
88
- - `principalType`: `User`, `Role`, `Organization`, or `Everyone`
89
- - `principalId` for every type except `Everyone`
90
- - `permission`: `View`, `Download`, `Edit`, `Delete`, `Manage`, or `Owner`
91
- - optional future `expiresAt`
92
-
93
- Sharing requires Manage on the resource.
94
-
95
- ```bash
96
- blocks data files shared --json
97
- blocks data files share <resourceId> --resource-type Directory \
98
- --principal-type Role --principal-id editors --permission Edit --dry-run --json
99
- ```
100
-
101
- Use `blocksClient.data.objects.shared` and `.share` in app code.
102
-
103
- ## Advanced access policies
104
-
105
- Use the policy operations only for an access-management UI:
106
-
107
- - `get-access-policies` lists direct entries on a resource.
108
- - `grant-access` adds Allow or Deny with optional priority and expiry.
109
- - `update-access-policy` replaces an entry and requires its `policyItemId`.
110
- - `revoke-access-policy` removes an entry by `resourceId` and `policyItemId`.
111
- - `resolve-access` returns the caller's `canView`, `canDownload`, `canEdit`, `canDelete`, `canManage`, and `canOwner` flags.
112
- - `toggle-inheritance` changes whether ancestors participate in resolution.
113
-
114
- Enums are JSON strings, not guessed numeric values. Priority must be non-negative and expiry must be in the future.
115
-
116
- Policy guardrails:
117
-
118
- - Manage is required to change access.
119
- - A Deny aimed at the resource owner is rejected.
120
- - Turning inheritance off is rejected until the resource has a direct Allow entry, preventing an orphaned resource.
121
- - The request model for access-policy listing contains `includeInherited`, but the current controller does not use it; do not promise inherited entries in that response. Use `resolve-access` for effective permissions.
122
- - Object reads may return 404 instead of 403 to avoid revealing hidden ids.
123
-
124
- CLI access commands are `access-list`, `access-grant`, `access-update`, `access-revoke`, `access-resolve`, and `inheritance`. Their SDK equivalents are under `blocksClient.data.objects`.