mdedit-cli 0.4.12 → 0.4.14

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
@@ -22,6 +22,11 @@ mdedit auth status
22
22
  mdedit auth logout
23
23
  ```
24
24
 
25
+ Sign-in requests read and write permissions for workspaces, folders, documents, and
26
+ reviews, plus file conversion. On the consent screen, choose read-only or read and
27
+ write access for each workspace, or deselect a workspace to exclude it. You do not
28
+ need to pass `--scopes` for normal use.
29
+
25
30
  For headless and CI workflows, [create a scoped API key](https://mdedit.ai/docs/api-keys). There is no
26
31
  device-code flow, so `--no-browser` does not replace browser sign-in.
27
32
 
package/dist/index.js CHANGED
@@ -491,9 +491,9 @@ var init_dist = __esm({
491
491
  }
492
492
  return response.json();
493
493
  };
494
- getArticles = async (workspaceId, fetchers) => {
494
+ getArticles = async (workspaceId, fetchers, options) => {
495
495
  const fetchV2 = fetchers?.customFetchV2 ?? customFetchV2;
496
- const response = await fetchV2(`/workspaces/${workspaceId}/articles`);
496
+ const response = await fetchV2(`/workspaces/${workspaceId}/articles${options?.includeDeleted ? "?includeDeleted=true" : ""}`);
497
497
  if (!response.ok) {
498
498
  const errorText = await response.text();
499
499
  const looksLikeWorkspaceAccessDenied = response.status === 403 && errorText.toLowerCase().includes("access denied to workspace");
@@ -575,7 +575,7 @@ var init_dist = __esm({
575
575
  const fetchV2 = fetchers?.customFetchV2 ?? customFetchV2;
576
576
  const response = await fetchV2(
577
577
  `/workspaces/${workspaceId}/articles/${articleId}`,
578
- { method: "DELETE", headers: mutationHeaders(requestOptions) }
578
+ { method: "DELETE", headers: { ...mutationHeaders(requestOptions), ...requestOptions?.baseRevision !== void 0 ? { "If-Match": String(requestOptions.baseRevision) } : {} } }
579
579
  );
580
580
  if (!response.ok) {
581
581
  throw new errors_default(
@@ -709,7 +709,13 @@ var init_dist = __esm({
709
709
  };
710
710
  getWorkspaces = async (fetchers) => {
711
711
  const fetchV2 = fetchers?.customFetchV2 ?? customFetchV2;
712
- const response = await fetchV2("/workspaces");
712
+ let response = await fetchV2("/workspaces");
713
+ for (let attempt = 0; response.status === 503 && attempt < 45; attempt++) {
714
+ const message = await response.clone().text();
715
+ if (!message.includes("ACCOUNT_IDENTITY_RECONCILING") && !message.includes("workspace is being connected")) break;
716
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
717
+ response = await fetchV2("/workspaces");
718
+ }
713
719
  if (!response.ok) {
714
720
  throw new errors_default(
715
721
  `Error fetching workspaces. ${await response.text()}`,
@@ -807,6 +813,8 @@ var init_dist = __esm({
807
813
  }
808
814
  return {
809
815
  id,
816
+ ...typeof raw?.revision === "number" ? { revision: raw.revision } : {},
817
+ ...raw?.cloudMutationContract ? { cloudMutationContract: true } : {},
810
818
  name: name.trim(),
811
819
  parentId: parentId ?? null,
812
820
  workspaceId,
@@ -824,6 +832,7 @@ var init_dist = __esm({
824
832
  const response = await fetchV2(`/workspaces/${workspaceId}/folders`, {
825
833
  method: "POST",
826
834
  body: JSON.stringify({
835
+ operationId: folderRequest.operationId,
827
836
  folderId: folderRequest.id,
828
837
  id: folderRequest.id,
829
838
  name: folderRequest.name,
@@ -843,6 +852,8 @@ var init_dist = __esm({
843
852
  const response = await fetchV2(`/workspaces/${workspaceId}/folders/${folderId}`, {
844
853
  method: "PUT",
845
854
  body: JSON.stringify({
855
+ operationId: folderRequest.operationId,
856
+ baseRevision: folderRequest.baseRevision,
846
857
  name: folderRequest.name,
847
858
  parentId: folderRequest.parentId === null ? null : folderRequest.parentId ?? void 0
848
859
  })
@@ -887,10 +898,14 @@ var init_dist = __esm({
887
898
  }
888
899
  return normalizeFolder(await response.json());
889
900
  };
890
- deleteFolder = async (workspaceId, folderId, fetchers) => {
901
+ deleteFolder = async (workspaceId, folderId, fetchers, options) => {
891
902
  const fetchV2 = fetchers?.customFetchV2 ?? customFetchV2;
892
903
  const response = await fetchV2(`/workspaces/${workspaceId}/folders/${folderId}`, {
893
- method: "DELETE"
904
+ method: "DELETE",
905
+ headers: {
906
+ ...options?.operationId ? { "Idempotency-Key": options.operationId } : {},
907
+ ...options?.baseRevision !== void 0 ? { "If-Match": String(options.baseRevision) } : {}
908
+ }
894
909
  });
895
910
  if (!response.ok) {
896
911
  const errorText = await response.text();