@seliseblocks/cli-os 0.2.2 → 0.2.4
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/AI_USAGE_GUIDE.md +20 -15
- package/README.md +5 -5
- package/dist/commands/auth/idp/create.d.ts +7 -0
- package/dist/commands/auth/idp/create.js +22 -3
- package/dist/commands/auth/idp/update.d.ts +7 -0
- package/dist/commands/auth/idp/update.js +22 -3
- package/dist/commands/data/files/delete.js +5 -4
- package/dist/commands/data/files/get-many.js +1 -1
- package/dist/commands/data/files/get.js +1 -1
- package/dist/commands/data/files/info.js +1 -1
- package/dist/commands/data/files/object-tree.d.ts +23 -0
- package/dist/commands/data/files/object-tree.js +238 -0
- package/dist/commands/data/files/presigned-upload-url.js +9 -2
- package/dist/commands/data/files/update-additional-info.js +2 -2
- package/dist/commands/data/files/upload-to-local-storage.js +2 -2
- package/dist/commands/data/files/upload.d.ts +2 -4
- package/dist/commands/data/files/upload.js +14 -28
- package/dist/commands/new/web.js +4 -0
- package/dist/index.js +100 -42
- package/dist/skills/blocks-data-storage/SKILL.md +194 -102
- package/dist/skills/blocks-data-storage/flows/object-management.md +124 -0
- package/dist/skills/blocks-iam-sso-oidc-configuration/SKILL.md +25 -9
- package/dist/skills/blocks-onboarding/SKILL.md +2 -2
- package/dist/skills/blocks-storage-configuration/SKILL.md +93 -93
- package/package.json +1 -1
- package/dist/commands/data/files/create-folder.d.ts +0 -1
- package/dist/commands/data/files/create-folder.js +0 -34
- package/dist/commands/data/files/delete-folder.d.ts +0 -1
- package/dist/commands/data/files/delete-folder.js +0 -25
- package/dist/commands/data/files/dms-list.d.ts +0 -1
- package/dist/commands/data/files/dms-list.js +0 -27
- package/dist/commands/data/files/dms-upload.d.ts +0 -6
- package/dist/commands/data/files/dms-upload.js +0 -41
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: blocks-storage-configuration
|
|
3
|
-
description: "Configure which storage provider (Azure Blob, S3, or local
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Blocks Storage — Configuration
|
|
7
|
-
|
|
8
|
-
This skill manages the **storage configuration record itself** — which cloud provider (or local
|
|
9
|
-
|
|
10
|
-
**CLI-only, no SDK path.** There is no `@seliseblocks/client` method for reading or writing a storage configuration's own fields
|
|
11
|
-
|
|
12
|
-
**Prerequisite:** a project is selected (`blocks use <tenantId>`). If login/project state is unknown, run the blocks-onboarding skill first.
|
|
13
|
-
|
|
14
|
-
## Command family
|
|
15
|
-
|
|
16
|
-
All four commands require an **impersonated project token** — there is no account-token path for this surface, consistent with other project-scoped admin commands (`secrets *`, `data config *`, etc.).
|
|
17
|
-
|
|
18
|
-
| Command | Notes |
|
|
19
|
-
|---|---|
|
|
20
|
-
| `blocks storage config list` | No parameters beyond the selected project. Read-only. |
|
|
21
|
-
| `blocks storage config get <name>` | `<name>` (positional) or `--name` (required if no positional arg). Read-only. |
|
|
22
|
-
| `blocks storage config save` | Upsert — create or update a configuration. Mutating. |
|
|
23
|
-
| `blocks storage config delete <name>` | `<name>` (positional) or `--name` (required if no positional arg). Mutating. |
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
blocks storage config list --json
|
|
27
|
-
blocks storage config get Default --json
|
|
28
|
-
blocks storage config get --name Default --json
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## `storage config save` — fields
|
|
32
|
-
|
|
33
|
-
`save` builds its request body from `--body`/`--file` (a raw JSON object, spread first) merged with these convenience flags (later, so they win if both are given):
|
|
34
|
-
|
|
35
|
-
| Flag | Body field |
|
|
36
|
-
|---|---|
|
|
37
|
-
| `--name` | `name` |
|
|
38
|
-
| `--item-id` | `itemId` |
|
|
39
|
-
| `--strategy` | `storageStrategy` |
|
|
40
|
-
| `--host` | `host` |
|
|
41
|
-
| `--port` | `port` |
|
|
42
|
-
| `--region-endpoint` | `cloudStorageRegionEndPoint` |
|
|
43
|
-
| `--connection-string` | `connectionString` |
|
|
44
|
-
| `--access-key` | `accessKey` |
|
|
45
|
-
| `--secret-key` | `secretKey` |
|
|
46
|
-
| `--username` | `userName` |
|
|
47
|
-
| `--password` | `password` |
|
|
48
|
-
| `--remote-base-path` | `remoteBasePath` |
|
|
49
|
-
| `--update` (boolean) | `updateRequest` |
|
|
50
|
-
|
|
51
|
-
Unset flags are dropped (`compact`), so they never overwrite fields already present in a `--body`/`--file` payload. `save` is a create-or-update in one command, not two separate verbs — pass `--item-id` (and typically `--update`) when modifying an existing configuration, omit it to create a new one.
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
blocks storage config save --name Default --strategy AzureBlob \
|
|
55
|
-
--host mystorageaccount.blob.core.windows.net --region-endpoint eu-west-1 \
|
|
56
|
-
--access-key <key> --secret-key <secret> --dry-run --json
|
|
57
|
-
blocks storage config save --name Default --strategy AzureBlob \
|
|
58
|
-
--host mystorageaccount.blob.core.windows.net --region-endpoint eu-west-1 \
|
|
59
|
-
--access-key <key> --secret-key <secret> --yes --json
|
|
60
|
-
|
|
61
|
-
# Update an existing configuration
|
|
62
|
-
blocks storage config save --item-id <id> --update --connection-string "<new connection string>" --dry-run --json
|
|
63
|
-
blocks storage config save --item-id <id> --update --connection-string "<new connection string>" --yes --json
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## `--dry-run` before `--yes` — always
|
|
67
|
-
|
|
68
|
-
Both mutating commands (`save`, `delete`) follow the standard `blocks` mutation discipline: `--dry-run` prints what would be sent and returns without calling the API; `--yes` skips the interactive confirmation prompt and sends the request for real. Omitting both drops into an interactive "Type 'yes' to continue" prompt — not viable in a scripted/agent context, so always pass one or the other explicitly.
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
blocks storage config delete Default --dry-run --json
|
|
72
|
-
blocks storage config delete Default --yes --json
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
`save`'s dry-run output redacts secret-shaped fields before printing (`accessKey`, `connectionString`, `password`, `secretKey` become `"***"`) — this redaction is **dry-run-preview only**, it does not change what's actually sent when you run with `--yes`, and it doesn't apply to `get`/`list` responses (see Gotchas).
|
|
76
|
-
|
|
77
|
-
## Gotchas
|
|
78
|
-
|
|
79
|
-
- **`get`/`list` are not redacted.** Only `save --dry-run`'s own preview output redacts `accessKey`/`connectionString`/`password`/`secretKey`. If a `get`/`list` response ever echoes credential fields back, treat that output as sensitive — don't paste it into logs, tickets, or chat verbatim.
|
|
80
|
-
- **`save` is upsert, not separate create/update commands.** Whether a call creates or updates is determined by whether `--item-id` is present, not by a different command name.
|
|
81
|
-
- **This is provider configuration, not
|
|
82
|
-
- **No positional-or-flag ambiguity trap:** `get`/`delete` accept the configuration name as either the first positional argument or `--name`; only one is required, not both.
|
|
83
|
-
- **Impersonated project token only.** Like `secrets *` and `data config *`, none of these four commands run against the account token — a project must be selected first (`blocks use <tenantId>`).
|
|
84
|
-
|
|
85
|
-
## Example trigger prompts
|
|
86
|
-
|
|
87
|
-
- "Set up Azure Blob storage for this project." → `storage config save --strategy AzureBlob ...`.
|
|
88
|
-
- "What storage configurations exist on this project?" → `storage config list`.
|
|
89
|
-
- "Show me the `Default` storage configuration." → `storage config get Default`.
|
|
90
|
-
- "Rotate the access key on our storage config." → `storage config save --item-id <id> --update --access-key <new key> ...`.
|
|
91
|
-
- "Switch this project to local storage." → `storage config save --strategy <local strategy value> --host ... --port ...` (confirm the exact strategy value expected by the project rather than guessing).
|
|
92
|
-
- "Delete this storage configuration, we don't use it anymore." → `storage config delete <name>`.
|
|
93
|
-
- "How do I actually upload a file once storage is configured?" → hand off to **blocks-data-storage**, not this skill.
|
|
1
|
+
---
|
|
2
|
+
name: blocks-storage-configuration
|
|
3
|
+
description: "Configure which storage provider (Azure Blob, S3-compatible object storage, or local/SFTP storage) backs a SELISE Blocks project's file object tree: named configurations with host, port, credentials, region/endpoint or connection string, and strategy, via the blocks CLI ('storage config get/list/save/delete'). CLI-only, project-scoped admin surface. Use to create, inspect, rotate, switch, or delete provider configurations; file/directory/object operations belong to blocks-data-storage."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Blocks Storage — Configuration
|
|
7
|
+
|
|
8
|
+
This skill manages the **storage configuration record itself** — which cloud provider (or local/SFTP storage) a named configuration points at, and the connection details needed to reach it. It does not upload, download, browse, share, version, move, or trash objects; those runtime concerns belong to blocks-data-storage.
|
|
9
|
+
|
|
10
|
+
**CLI-only, no SDK path.** There is no `@seliseblocks/client` method for reading or writing a storage configuration's own fields. Runtime storage calls select an existing record by `configurationName`. If the user wants to manipulate a file/directory or its access policies, hand off to blocks-data-storage.
|
|
11
|
+
|
|
12
|
+
**Prerequisite:** a project is selected (`blocks use <tenantId>`). If login/project state is unknown, run the blocks-onboarding skill first.
|
|
13
|
+
|
|
14
|
+
## Command family
|
|
15
|
+
|
|
16
|
+
All four commands require an **impersonated project token** — there is no account-token path for this surface, consistent with other project-scoped admin commands (`secrets *`, `data config *`, etc.).
|
|
17
|
+
|
|
18
|
+
| Command | Notes |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `blocks storage config list` | No parameters beyond the selected project. Read-only. |
|
|
21
|
+
| `blocks storage config get <name>` | `<name>` (positional) or `--name` (required if no positional arg). Read-only. |
|
|
22
|
+
| `blocks storage config save` | Upsert — create or update a configuration. Mutating. |
|
|
23
|
+
| `blocks storage config delete <name>` | `<name>` (positional) or `--name` (required if no positional arg). Mutating. |
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
blocks storage config list --json
|
|
27
|
+
blocks storage config get Default --json
|
|
28
|
+
blocks storage config get --name Default --json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## `storage config save` — fields
|
|
32
|
+
|
|
33
|
+
`save` builds its request body from `--body`/`--file` (a raw JSON object, spread first) merged with these convenience flags (later, so they win if both are given):
|
|
34
|
+
|
|
35
|
+
| Flag | Body field |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `--name` | `name` |
|
|
38
|
+
| `--item-id` | `itemId` |
|
|
39
|
+
| `--strategy` | `storageStrategy` |
|
|
40
|
+
| `--host` | `host` |
|
|
41
|
+
| `--port` | `port` |
|
|
42
|
+
| `--region-endpoint` | `cloudStorageRegionEndPoint` |
|
|
43
|
+
| `--connection-string` | `connectionString` |
|
|
44
|
+
| `--access-key` | `accessKey` |
|
|
45
|
+
| `--secret-key` | `secretKey` |
|
|
46
|
+
| `--username` | `userName` |
|
|
47
|
+
| `--password` | `password` |
|
|
48
|
+
| `--remote-base-path` | `remoteBasePath` |
|
|
49
|
+
| `--update` (boolean) | `updateRequest` |
|
|
50
|
+
|
|
51
|
+
Unset flags are dropped (`compact`), so they never overwrite fields already present in a `--body`/`--file` payload. `save` is a create-or-update in one command, not two separate verbs — pass `--item-id` (and typically `--update`) when modifying an existing configuration, omit it to create a new one.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
blocks storage config save --name Default --strategy AzureBlob \
|
|
55
|
+
--host mystorageaccount.blob.core.windows.net --region-endpoint eu-west-1 \
|
|
56
|
+
--access-key <key> --secret-key <secret> --dry-run --json
|
|
57
|
+
blocks storage config save --name Default --strategy AzureBlob \
|
|
58
|
+
--host mystorageaccount.blob.core.windows.net --region-endpoint eu-west-1 \
|
|
59
|
+
--access-key <key> --secret-key <secret> --yes --json
|
|
60
|
+
|
|
61
|
+
# Update an existing configuration
|
|
62
|
+
blocks storage config save --item-id <id> --update --connection-string "<new connection string>" --dry-run --json
|
|
63
|
+
blocks storage config save --item-id <id> --update --connection-string "<new connection string>" --yes --json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## `--dry-run` before `--yes` — always
|
|
67
|
+
|
|
68
|
+
Both mutating commands (`save`, `delete`) follow the standard `blocks` mutation discipline: `--dry-run` prints what would be sent and returns without calling the API; `--yes` skips the interactive confirmation prompt and sends the request for real. Omitting both drops into an interactive "Type 'yes' to continue" prompt — not viable in a scripted/agent context, so always pass one or the other explicitly.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
blocks storage config delete Default --dry-run --json
|
|
72
|
+
blocks storage config delete Default --yes --json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`save`'s dry-run output redacts secret-shaped fields before printing (`accessKey`, `connectionString`, `password`, `secretKey` become `"***"`) — this redaction is **dry-run-preview only**, it does not change what's actually sent when you run with `--yes`, and it doesn't apply to `get`/`list` responses (see Gotchas).
|
|
76
|
+
|
|
77
|
+
## Gotchas
|
|
78
|
+
|
|
79
|
+
- **`get`/`list` are not redacted.** Only `save --dry-run`'s own preview output redacts `accessKey`/`connectionString`/`password`/`secretKey`. If a `get`/`list` response ever echoes credential fields back, treat that output as sensitive — don't paste it into logs, tickets, or chat verbatim.
|
|
80
|
+
- **`save` is upsert, not separate create/update commands.** Whether a call creates or updates is determined by whether `--item-id` is present, not by a different command name.
|
|
81
|
+
- **This is provider configuration, not object management.** `blocks storage config *` never touches file bytes, directory hierarchy, versions, trash, sharing, or ACLs. Those belong to **blocks-data-storage**, using a `configurationName` that a storage config already defines.
|
|
82
|
+
- **No positional-or-flag ambiguity trap:** `get`/`delete` accept the configuration name as either the first positional argument or `--name`; only one is required, not both.
|
|
83
|
+
- **Impersonated project token only.** Like `secrets *` and `data config *`, none of these four commands run against the account token — a project must be selected first (`blocks use <tenantId>`).
|
|
84
|
+
|
|
85
|
+
## Example trigger prompts
|
|
86
|
+
|
|
87
|
+
- "Set up Azure Blob storage for this project." → `storage config save --strategy AzureBlob ...`.
|
|
88
|
+
- "What storage configurations exist on this project?" → `storage config list`.
|
|
89
|
+
- "Show me the `Default` storage configuration." → `storage config get Default`.
|
|
90
|
+
- "Rotate the access key on our storage config." → `storage config save --item-id <id> --update --access-key <new key> ...`.
|
|
91
|
+
- "Switch this project to local storage." → `storage config save --strategy <local strategy value> --host ... --port ...` (confirm the exact strategy value expected by the project rather than guessing).
|
|
92
|
+
- "Delete this storage configuration, we don't use it anymore." → `storage config delete <name>`.
|
|
93
|
+
- "How do I actually upload a file once storage is configured?" → hand off to **blocks-data-storage**, not this skill.
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function dataFilesCreateFolder(argv: string[]): Promise<void>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { booleanFlag, stringFlag } from "../../../lib/args.js";
|
|
2
|
-
import { blocksRequest } from "../../../lib/api.js";
|
|
3
|
-
import { confirmMutation } from "../../../lib/confirm.js";
|
|
4
|
-
import { compact, jsonBodyFlag, listFlag } from "../../../lib/json-flag.js";
|
|
5
|
-
import { writeOutput } from "../../../lib/output.js";
|
|
6
|
-
import { requestContext } from "../../../lib/request-context.js";
|
|
7
|
-
import { parseCommand, selectedProject } from "../../../lib/workspace.js";
|
|
8
|
-
export async function dataFilesCreateFolder(argv) {
|
|
9
|
-
const { args, flags } = parseCommand(argv);
|
|
10
|
-
const artifactName = args[0] || stringFlag(flags, "name", { required: true });
|
|
11
|
-
const body = {
|
|
12
|
-
...(await jsonBodyFlag(flags)),
|
|
13
|
-
...compact({
|
|
14
|
-
artifactName,
|
|
15
|
-
configurationName: stringFlag(flags, "configuration-name") || undefined,
|
|
16
|
-
description: stringFlag(flags, "description") || undefined,
|
|
17
|
-
parentId: stringFlag(flags, "parent-id"),
|
|
18
|
-
tags: listFlag(flags, "tags")
|
|
19
|
-
})
|
|
20
|
-
};
|
|
21
|
-
if (booleanFlag(flags, "dry-run")) {
|
|
22
|
-
writeOutput({ dryRun: true, endpoint: "/data/v4/Files/CreateFolder", request: body }, flags);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
await confirmMutation(flags, `Create DMS folder '${artifactName}'.`);
|
|
26
|
-
const projectKey = await selectedProject(flags);
|
|
27
|
-
const result = await blocksRequest("/data/v4/Files/CreateFolder", {
|
|
28
|
-
body,
|
|
29
|
-
impersonatedProjectAuth: true,
|
|
30
|
-
...requestContext(flags),
|
|
31
|
-
projectTenantId: projectKey
|
|
32
|
-
});
|
|
33
|
-
writeOutput(result, flags);
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function dataFilesDeleteFolder(argv: string[]): Promise<void>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { booleanFlag, stringFlag } from "../../../lib/args.js";
|
|
2
|
-
import { blocksRequest } from "../../../lib/api.js";
|
|
3
|
-
import { confirmMutation } from "../../../lib/confirm.js";
|
|
4
|
-
import { compact } from "../../../lib/json-flag.js";
|
|
5
|
-
import { writeOutput } from "../../../lib/output.js";
|
|
6
|
-
import { requestContext } from "../../../lib/request-context.js";
|
|
7
|
-
import { parseCommand, selectedProject } from "../../../lib/workspace.js";
|
|
8
|
-
export async function dataFilesDeleteFolder(argv) {
|
|
9
|
-
const { args, flags } = parseCommand(argv);
|
|
10
|
-
const folderId = args[0] || stringFlag(flags, "folder-id", { required: true });
|
|
11
|
-
const body = { folderId, ...compact({ configurationName: stringFlag(flags, "configuration-name") || undefined }) };
|
|
12
|
-
if (booleanFlag(flags, "dry-run")) {
|
|
13
|
-
writeOutput({ dryRun: true, endpoint: "/data/v4/Files/DeleteFolder", request: body }, flags);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
await confirmMutation(flags, `Delete DMS folder '${folderId}'.`);
|
|
17
|
-
const projectKey = await selectedProject(flags);
|
|
18
|
-
const result = await blocksRequest("/data/v4/Files/DeleteFolder", {
|
|
19
|
-
body,
|
|
20
|
-
impersonatedProjectAuth: true,
|
|
21
|
-
...requestContext(flags),
|
|
22
|
-
projectTenantId: projectKey
|
|
23
|
-
});
|
|
24
|
-
writeOutput(result, flags);
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function dataFilesDmsList(argv: string[]): Promise<void>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { integerFlag, stringFlag } from "../../../lib/args.js";
|
|
2
|
-
import { blocksRequest } from "../../../lib/api.js";
|
|
3
|
-
import { compact } from "../../../lib/json-flag.js";
|
|
4
|
-
import { writeOutput } from "../../../lib/output.js";
|
|
5
|
-
import { requestContext } from "../../../lib/request-context.js";
|
|
6
|
-
import { parseCommand, selectedProject } from "../../../lib/workspace.js";
|
|
7
|
-
export async function dataFilesDmsList(argv) {
|
|
8
|
-
const { flags } = parseCommand(argv);
|
|
9
|
-
const body = {
|
|
10
|
-
parentId: stringFlag(flags, "parent-id"),
|
|
11
|
-
take: integerFlag(flags, "take", 20),
|
|
12
|
-
...compact({
|
|
13
|
-
configurationName: stringFlag(flags, "configuration-name") || undefined,
|
|
14
|
-
moduleName: stringFlag(flags, "module-name") || undefined,
|
|
15
|
-
searchKey: stringFlag(flags, "search") || undefined,
|
|
16
|
-
skip: integerFlag(flags, "skip", 0) || undefined
|
|
17
|
-
})
|
|
18
|
-
};
|
|
19
|
-
const projectKey = await selectedProject(flags);
|
|
20
|
-
const result = await blocksRequest("/data/v4/Files/GetDmsFileAndFolder", {
|
|
21
|
-
body,
|
|
22
|
-
impersonatedProjectAuth: true,
|
|
23
|
-
...requestContext(flags),
|
|
24
|
-
projectTenantId: projectKey
|
|
25
|
-
});
|
|
26
|
-
writeOutput(result, flags);
|
|
27
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registers an already-uploaded file (via presigned-upload-url/upload-to-url or
|
|
3
|
-
* upload-to-local-storage) so it shows up in a DMS folder. `--file-storage-id` covers the
|
|
4
|
-
* common single-file case; pass --body/--file with an `upload` array to register several at once.
|
|
5
|
-
*/
|
|
6
|
-
export declare function dataFilesDmsUpload(argv: string[]): Promise<void>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { booleanFlag, stringFlag } from "../../../lib/args.js";
|
|
2
|
-
import { blocksRequest } from "../../../lib/api.js";
|
|
3
|
-
import { confirmMutation } from "../../../lib/confirm.js";
|
|
4
|
-
import { compact, jsonBodyFlag, listFlag } from "../../../lib/json-flag.js";
|
|
5
|
-
import { writeOutput } from "../../../lib/output.js";
|
|
6
|
-
import { requestContext } from "../../../lib/request-context.js";
|
|
7
|
-
import { parseCommand, selectedProject } from "../../../lib/workspace.js";
|
|
8
|
-
/**
|
|
9
|
-
* Registers an already-uploaded file (via presigned-upload-url/upload-to-url or
|
|
10
|
-
* upload-to-local-storage) so it shows up in a DMS folder. `--file-storage-id` covers the
|
|
11
|
-
* common single-file case; pass --body/--file with an `upload` array to register several at once.
|
|
12
|
-
*/
|
|
13
|
-
export async function dataFilesDmsUpload(argv) {
|
|
14
|
-
const { flags } = parseCommand(argv);
|
|
15
|
-
const fileStorageId = stringFlag(flags, "file-storage-id");
|
|
16
|
-
const body = await jsonBodyFlag(flags);
|
|
17
|
-
if (fileStorageId) {
|
|
18
|
-
body.upload = [compact({
|
|
19
|
-
artifactName: stringFlag(flags, "artifact-name") || undefined,
|
|
20
|
-
fileStorageId,
|
|
21
|
-
parentId: stringFlag(flags, "parent-id"),
|
|
22
|
-
tags: listFlag(flags, "tags")
|
|
23
|
-
})];
|
|
24
|
-
}
|
|
25
|
-
if (!Array.isArray(body.upload) || !body.upload.length) {
|
|
26
|
-
throw new Error("Provide --file-storage-id (with --artifact-name) or an 'upload' array via --body/--file.");
|
|
27
|
-
}
|
|
28
|
-
if (booleanFlag(flags, "dry-run")) {
|
|
29
|
-
writeOutput({ dryRun: true, endpoint: "/data/v4/Files/UploadFile", request: body }, flags);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
await confirmMutation(flags, `Register ${body.upload.length} file(s) into DMS.`);
|
|
33
|
-
const projectKey = await selectedProject(flags);
|
|
34
|
-
const result = await blocksRequest("/data/v4/Files/UploadFile", {
|
|
35
|
-
body,
|
|
36
|
-
impersonatedProjectAuth: true,
|
|
37
|
-
...requestContext(flags),
|
|
38
|
-
projectTenantId: projectKey
|
|
39
|
-
});
|
|
40
|
-
writeOutput(result, flags);
|
|
41
|
-
}
|