@superdoc-dev/sdk 1.0.0-alpha.25 → 1.0.0-alpha.27

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.
@@ -1,13 +1,25 @@
1
1
  /* eslint-disable */
2
2
  // Auto-generated by packages/sdk/codegen/src/generate-node.mjs
3
3
  import { CONTRACT } from './contract.js';
4
+ /** Extract a string value from a CLI response envelope like `{ document, text: "..." }`. */
5
+ function unwrapStringEnvelope(value, key) {
6
+ if (typeof value === "string")
7
+ return value;
8
+ if (typeof value === "object" && value !== null) {
9
+ const extracted = value[key];
10
+ if (typeof extracted === "string")
11
+ return extracted;
12
+ }
13
+ return value;
14
+ }
4
15
  export function createDocApi(runtime) {
5
16
  return {
6
17
  find: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.find"], params, options),
7
18
  getNode: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.getNode"], params, options),
8
19
  getNodeById: (params, options) => runtime.invoke(CONTRACT.operations["doc.getNodeById"], params, options),
9
- getText: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.getText"], params, options),
10
- getMarkdown: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.getMarkdown"], params, options),
20
+ getText: async (params = {}, options) => unwrapStringEnvelope(await runtime.invoke(CONTRACT.operations["doc.getText"], params, options), "text"),
21
+ getMarkdown: async (params = {}, options) => unwrapStringEnvelope(await runtime.invoke(CONTRACT.operations["doc.getMarkdown"], params, options), "markdown"),
22
+ getHtml: async (params = {}, options) => unwrapStringEnvelope(await runtime.invoke(CONTRACT.operations["doc.getHtml"], params, options), "html"),
11
23
  info: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.info"], params, options),
12
24
  insert: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.insert"], params, options),
13
25
  replace: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.replace"], params, options),