@doist/comms-cli 1.3.2 → 1.5.0
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/CHANGELOG.md +12 -0
- package/README.md +5 -3
- package/dist/commands/auth/helpers.d.ts +2 -0
- package/dist/commands/auth/helpers.d.ts.map +1 -1
- package/dist/commands/auth/helpers.js +52 -0
- package/dist/commands/auth/helpers.js.map +1 -1
- package/dist/commands/auth/login.d.ts.map +1 -1
- package/dist/commands/auth/login.js +13 -4
- package/dist/commands/auth/login.js.map +1 -1
- package/dist/commands/auth/status.d.ts +5 -8
- package/dist/commands/auth/status.d.ts.map +1 -1
- package/dist/commands/auth/status.js +28 -22
- package/dist/commands/auth/status.js.map +1 -1
- package/dist/commands/channel/delete.d.ts.map +1 -1
- package/dist/commands/channel/delete.js +1 -13
- package/dist/commands/channel/delete.js.map +1 -1
- package/dist/commands/config/view.d.ts.map +1 -1
- package/dist/commands/config/view.js +7 -1
- package/dist/commands/config/view.js.map +1 -1
- package/dist/commands/conversation/helpers.d.ts +3 -1
- package/dist/commands/conversation/helpers.d.ts.map +1 -1
- package/dist/commands/conversation/index.d.ts.map +1 -1
- package/dist/commands/conversation/index.js +4 -1
- package/dist/commands/conversation/index.js.map +1 -1
- package/dist/commands/conversation/reply.d.ts.map +1 -1
- package/dist/commands/conversation/reply.js +29 -6
- package/dist/commands/conversation/reply.js.map +1 -1
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/thread/create.d.ts +1 -0
- package/dist/commands/thread/create.d.ts.map +1 -1
- package/dist/commands/thread/create.js +24 -6
- package/dist/commands/thread/create.js.map +1 -1
- package/dist/commands/thread/index.d.ts.map +1 -1
- package/dist/commands/thread/index.js +8 -2
- package/dist/commands/thread/index.js.map +1 -1
- package/dist/commands/thread/reply.d.ts +1 -0
- package/dist/commands/thread/reply.d.ts.map +1 -1
- package/dist/commands/thread/reply.js +37 -10
- package/dist/commands/thread/reply.js.map +1 -1
- package/dist/commands/view.d.ts.map +1 -1
- package/dist/commands/view.js +2 -7
- package/dist/commands/view.js.map +1 -1
- package/dist/lib/api.d.ts +4 -1
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +21 -7
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/attachments.d.ts +20 -0
- package/dist/lib/attachments.d.ts.map +1 -0
- package/dist/lib/attachments.js +45 -0
- package/dist/lib/attachments.js.map +1 -0
- package/dist/lib/auth-pages.d.ts.map +1 -1
- package/dist/lib/auth-pages.js +173 -302
- package/dist/lib/auth-pages.js.map +1 -1
- package/dist/lib/auth-provider.d.ts +41 -18
- package/dist/lib/auth-provider.d.ts.map +1 -1
- package/dist/lib/auth-provider.js +368 -78
- package/dist/lib/auth-provider.js.map +1 -1
- package/dist/lib/auth.d.ts +12 -1
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +41 -10
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/comms-account.d.ts +6 -0
- package/dist/lib/comms-account.d.ts.map +1 -1
- package/dist/lib/comms-account.js +6 -0
- package/dist/lib/comms-account.js.map +1 -1
- package/dist/lib/config.d.ts +14 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +76 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/errors.d.ts +8 -1
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +25 -9
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/local-file.d.ts +29 -0
- package/dist/lib/local-file.d.ts.map +1 -0
- package/dist/lib/local-file.js +48 -0
- package/dist/lib/local-file.js.map +1 -0
- package/dist/lib/options.d.ts +5 -0
- package/dist/lib/options.d.ts.map +1 -1
- package/dist/lib/options.js +7 -1
- package/dist/lib/options.js.map +1 -1
- package/dist/lib/refs.d.ts +2 -0
- package/dist/lib/refs.d.ts.map +1 -1
- package/dist/lib/refs.js +62 -26
- package/dist/lib/refs.js.map +1 -1
- package/dist/lib/search-api.d.ts.map +1 -1
- package/dist/lib/search-api.js +8 -4
- package/dist/lib/search-api.js.map +1 -1
- package/dist/lib/skills/content.d.ts +1 -1
- package/dist/lib/skills/content.d.ts.map +1 -1
- package/dist/lib/skills/content.js +9 -2
- package/dist/lib/skills/content.js.map +1 -1
- package/dist/lib/user-records.js +27 -0
- package/dist/lib/user-records.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getCommsClient } from './api.js';
|
|
2
|
+
import { openLocalFileAsBlob } from './local-file.js';
|
|
3
|
+
/** Max attachments uploaded at once — bounds socket/file-descriptor pressure. */
|
|
4
|
+
const MAX_UPLOAD_CONCURRENCY = 4;
|
|
5
|
+
/**
|
|
6
|
+
* Map `items` through `fn` with at most `limit` in flight at a time, preserving
|
|
7
|
+
* input order in the returned array.
|
|
8
|
+
*/
|
|
9
|
+
async function mapWithConcurrency(items, limit, fn) {
|
|
10
|
+
const results = Array.from({ length: items.length });
|
|
11
|
+
let cursor = 0;
|
|
12
|
+
const worker = async () => {
|
|
13
|
+
while (cursor < items.length) {
|
|
14
|
+
const index = cursor++;
|
|
15
|
+
results[index] = await fn(items[index], index);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
19
|
+
return results;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Validate that every path exists and is readable, without uploading anything.
|
|
23
|
+
* Used by `--dry-run` so the preview fails on a bad path exactly as a real run
|
|
24
|
+
* would. Throws `FILE_NOT_FOUND` / `FILE_READ_ERROR` on the first bad path.
|
|
25
|
+
*/
|
|
26
|
+
export async function validateAttachmentFiles(files) {
|
|
27
|
+
await Promise.all(files.map((file) => openLocalFileAsBlob({ file })));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Upload one or more local files and return the created {@link Attachment}s,
|
|
31
|
+
* ready to splice into the `attachments` array of `comments.createComment`,
|
|
32
|
+
* `conversationMessages.createMessage`, or `threads.createThread`.
|
|
33
|
+
*
|
|
34
|
+
* All paths are validated (existence + readability) up front, before any
|
|
35
|
+
* upload starts, so a bad path fails fast without leaving a partial set of
|
|
36
|
+
* uploaded-but-unreferenced attachments behind. Uploads then run with bounded
|
|
37
|
+
* concurrency while the returned array preserves the input order.
|
|
38
|
+
*/
|
|
39
|
+
export async function uploadAttachments(files) {
|
|
40
|
+
// Validate every path first so a bad one fails before we upload anything.
|
|
41
|
+
const opened = await Promise.all(files.map((file) => openLocalFileAsBlob({ file })));
|
|
42
|
+
const client = await getCommsClient();
|
|
43
|
+
return mapWithConcurrency(opened, MAX_UPLOAD_CONCURRENCY, ({ blob, fileName }) => client.attachments.upload({ file: blob, fileName }));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../src/lib/attachments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,iFAAiF;AACjF,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEhC;;;GAGG;AACH,KAAK,UAAU,kBAAkB,CAC7B,KAAmB,EACnB,KAAa,EACb,EAA0C;IAE1C,MAAM,OAAO,GAAQ,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IACzD,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,MAAM,MAAM,GAAG,KAAK,IAAI,EAAE;QACtB,OAAO,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,MAAM,EAAE,CAAA;YACtB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAA;QAClD,CAAC;IACL,CAAC,CAAA;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAA;IAChF,OAAO,OAAO,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,KAAe;IACzD,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,mBAAmB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACzE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,KAAe;IACnD,0EAA0E;IAC1E,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,mBAAmB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IAEpF,MAAM,MAAM,GAAG,MAAM,cAAc,EAAE,CAAA;IACrC,OAAO,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAC7E,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CACtD,CAAA;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-pages.d.ts","sourceRoot":"","sources":["../../src/lib/auth-pages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth-pages.d.ts","sourceRoot":"","sources":["../../src/lib/auth-pages.ts"],"names":[],"mappings":"AA6JA,wBAAgB,aAAa,IAAI,MAAM,CAqTtC;AAED,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CA8GxD"}
|