Skip to content

Core API Reference

유용태 edited this page Jun 18, 2026 · 7 revisions

json-document Core API Reference

@interactive-os/json-document core 공개 API는 1.0부터 안정화된 surface다.

이 문서는 제품 개발자가 자주 쓰는 순서대로 API를 설명하는 레퍼런스다. 마지막에는 public entrypoint에서 import할 수 있는 runtime/type export 이름을 모두 적는다.

1.x에서는 기존 이름, result 구조, 에러 코드, 명령 의미론, 원자성, selection 의미론, clipboard 기본값, strict 동작의 하위 호환성을 유지한다.

1. 공개 import

제품 코드는 이 두 entrypoint만 공개 API로 사용한다.

import {
  createJSONDocument,
  type JSONDocument,
} from "@interactive-os/json-document";

import { useJSONDocument } from "@interactive-os/json-document/react";
  • core: @interactive-os/json-document
  • React adapter: @interactive-os/json-document/react

내부 source path import는 공개 API가 아니다.

2. 문서 만들기

가장 흔한 시작점은 createJSONDocument다.

import { z } from "zod";
import { createJSONDocument } from "@interactive-os/json-document";

const Card = z.object({
  id: z.string(),
  title: z.string().min(1),
  done: z.boolean(),
});

const doc = createJSONDocument(Card, {
  id: "card-1",
  title: "Draft",
  done: false,
}, {
  history: 100,
  selection: true,
});

공개 시그니처:

function createJSONDocument<S extends z.ZodType>(
  schema: S,
  initial: z.output<S>,
  options: JSONDocumentOptions & { trustedInitial: true },
): JSONDocument<z.output<S>>;

function createJSONDocument<S extends z.ZodType>(
  schema: S,
  initial: z.input<S>,
  options?: JSONDocumentOptions & { trustedInitial?: false | undefined },
): JSONDocument<z.output<S>>;
interface JSONDocumentOptions {
  strict?: boolean | undefined;
  onError?: (error: JSONDocumentError) => void;
  trustedInitial?: boolean | undefined;
  history?: number;
  selection?: boolean | SelectionOptions;
  onChange?: () => void;
}

trustedInitial: true는 초기값 schema parse를 건너뛴다. 호출자가 이미 검증 경계를 소유할 때만 쓴다.

3. 현재 값 읽기

doc.value는 현재 schema를 통과한 JSON 상태다.

doc.value;
doc.at("/title");
doc.exists("/title");
doc.entries("");

읽기 result:

type ReadResult =
  | { ok: true; path: Pointer; value: unknown }
  | { ok: false; code: "invalid_pointer" | "path_not_found"; reason?: string; pointer: Pointer };

type EntryKind = "root" | "object" | "array" | "record" | "primitive";

interface ReadEntry {
  key: string;
  path: Pointer;
  value: unknown;
}

type EntriesResult =
  | {
      ok: true;
      path: Pointer;
      kind: EntryKind;
      entries: ReadonlyArray<ReadEntry>;
    }
  | { ok: false; code: "invalid_pointer" | "path_not_found"; reason?: string; pointer: Pointer };

4. 검색하기

검색은 JSONPath를 받는다. 검색 결과는 JSON Pointer 목록이다.

const found = doc.find("$..cards[?(@.done==false)]");

if (found.ok) {
  for (const pointer of found.pointers) {
    doc.replace(`${pointer}/done`, true);
  }
}

검색 result:

type QueryResult =
  | { ok: true; query: string; pointers: Pointer[] }
  | { ok: false; code: "invalid_query"; reason?: string };

JSONPath는 변경 target이 아니다. 변경은 JSON Pointer로 한다.

5. 먼저 물어보고 실행하기

제품 UI는 대부분 can* -> command -> result 흐름을 쓴다.

const can = doc.canReplace("/title", "Ready");

if (can.ok) {
  doc.replace("/title", "Ready");
} else {
  can.code;
  can.reason;
  can.violations;
}

can*는 boolean이 아니다. 실패 이유를 가진 JSONCapabilityResult를 반환한다.

type JSONCapabilityResult =
  | { ok: true }
  | {
      ok: false;
      code: CapabilityErrorCode;
      reason?: string;
      pointer?: Pointer;
      violations?: ReadonlyArray<CapabilityViolation>;
    };

interface CapabilityViolation {
  path: string;
  message: string;
}

6. 값 바꾸기

가장 많이 쓰는 편집 verb는 insert, replace, delete, move, duplicate다.

doc.insert("/items/-", { id: "new", title: "New" });
doc.replace("/title", "Ready");
doc.delete("/items/0");
doc.move("/items/0", "/items/2");
doc.duplicate("/items/0", {
  rekey: { fields: ["id"], strategy: "suffix" },
});

선택이 켜져 있으면 일부 overload는 현재 selection을 기본 source로 쓴다.

doc.replace("Ready");
doc.delete();
doc.move("/items/2");
doc.duplicate();

성공한 편집은 schema 검증을 통과한 뒤 commit된다. 실패하면 state, selection, clipboard, history가 부분적으로 바뀌지 않는다.

7. 여러 변경을 한 번에 적용하기

알고 있는 여러 변경은 commit 또는 patch에 operation 배열로 넘긴다.

doc.commit([
  { op: "replace", path: "/title", value: "Ready" },
  { op: "replace", path: "/done", value: true },
], {
  label: "complete card",
  origin: "keyboard",
});

Patch type:

type JSONPatchInput = JSONPatchOperation | ReadonlyArray<JSONPatchOperation>;

type JSONPatchOperation =
  | { op: "add"; path: Pointer; value: unknown }
  | { op: "remove"; path: Pointer }
  | { op: "replace"; path: Pointer; value: unknown }
  | { op: "move"; from: Pointer; path: Pointer }
  | { op: "copy"; from: Pointer; path: Pointer }
  | { op: "test"; path: Pointer; value: unknown };

Result:

type JSONResult =
  | { ok: true }
  | {
      ok: false;
      code: ErrorCode;
      reason?: string;
      pointer?: Pointer;
    };

8. JSONDocument<T> 전체 표면

제품이 가장 많이 의존하는 중심 interface다.

interface JSONDocument<T> {
  readonly value: T;
  readonly lastPatch: ReadonlyArray<JSONPatchOperation>;
  readonly selection: SelectionState | undefined;
  readonly history: JSONDocumentHistory;
  readonly clipboard: ClipboardState<T>;
  readonly schema: SchemaState;

  patch(operations: JSONPatchInput, metadata?: JSONChangeMetadata): JSONResult;
  commit(
    operations: ReadonlyArray<JSONPatchOperation>,
    options?: JSONDocumentCommitOptions,
  ): JSONResult;

  find(jsonpath: string): QueryResult;

  insert(path: Pointer, value: unknown): JSONDocumentEditResult;
  insert(value: unknown): JSONDocumentEditResult;

  replace(path: Pointer, value: unknown): JSONDocumentEditResult;
  replace(value: unknown): JSONDocumentEditResult;

  delete(source?: SelectionSource): JSONDocumentEditResult;

  move(source: Pointer, target: Pointer): JSONDocumentEditResult;
  move(target: Pointer): JSONDocumentEditResult;

  duplicate(
    source: Pointer,
    options?: JSONDocumentDuplicateOptions,
  ): JSONDocumentDuplicateResult<T>;
  duplicate(options?: JSONDocumentDuplicateOptions): JSONDocumentDuplicateResult<T>;

  copy(source?: SelectionSource, options?: ClipboardCopyOptions): ClipboardCopyResult;
  cut(source?: SelectionSource, options?: ClipboardCutOptions): ClipboardCutResult<T>;
  paste(
    target?: JSONDocumentPasteTarget,
    options?: JSONDocumentPasteOptions,
  ): ClipboardPasteResult<T>;

  undo(): JSONCapabilityResult;
  redo(): JSONCapabilityResult;

  load(value: unknown, options?: { preserveHistory?: boolean }): JSONResult;
  reset(value?: unknown): JSONResult;

  subscribe(listener: (
    applied: ReadonlyArray<JSONPatchOperation>,
    metadata?: JSONChangeMetadata,
  ) => void): () => void;

  at(path: Pointer): ReadResult;
  exists(path: Pointer): boolean;
  query(jsonpath: string): QueryResult;
  entries(path: Pointer): EntriesResult;

  canPatch(operations: JSONPatchInput): JSONCapabilityResult;
  canFind(jsonpath: string): JSONCapabilityResult;
  canInsert(value: unknown): JSONCapabilityResult;
  canInsert(path: Pointer, value: unknown): JSONCapabilityResult;
  canReplace(value: unknown): JSONCapabilityResult;
  canReplace(path: Pointer, value: unknown): JSONCapabilityResult;
  canDelete(source?: SelectionSource): JSONCapabilityResult;
  canMove(target: Pointer): JSONCapabilityResult;
  canMove(source: Pointer, target: Pointer): JSONCapabilityResult;
  canDuplicate(source: Pointer, options?: JSONDocumentDuplicateOptions): JSONCapabilityResult;
  canDuplicate(options?: JSONDocumentDuplicateOptions): JSONCapabilityResult;
  canCopy(source?: SelectionSource): JSONCapabilityResult;
  canCut(source?: SelectionSource): JSONCapabilityResult;
  canPaste(target?: JSONDocumentPasteTarget, options?: JSONDocumentPasteOptions): JSONCapabilityResult;
  canUndo(): JSONCapabilityResult;
  canRedo(): JSONCapabilityResult;
}
type JSONDocumentEditResult =
  | JSONResult
  | Extract<JSONCapabilityResult, { ok: false }>;

9. 실패 code

앱은 reason 문자열이 아니라 code로 분기한다.

ErrorCode:

"invalid_pointer"
"path_not_found"
"move_into_self"
"schema_violation"
"test_failed"
"not_serializable"

추가 capability code:

"preflight_failed"
"discriminator_mismatch"
"rekey_failed"
"missing_new_key"
"key_conflict"
"empty_selection"
"empty_scope"
"empty_match"
"cursor_boundary"
"syntax_error"
"empty_stack"
"apply_failed"
"empty_clipboard"
"missing_length"
"multi_pointer_range"
"overlapping_ranges"
"not_string"
"point_not_in_order"

reason은 진단 문구다. 정확한 문구는 stable contract가 아니다.

10. 선택 상태

Selection은 DOM focus가 아니라 JSON document 위의 headless 주소 상태다.

doc.selection?.selectRanges(["/items/0", "/items/1"]);
doc.copy(doc.selection?.selectedSource ?? []);

Selection 기본 타입:

type SelectionMode = "single" | "multiple" | "extended";
type SelectionEdge = "before" | "after";
type SelectionAffinity = "forward" | "backward";
type SelectionType = "None" | "Caret" | "Range";
type SelectionSource = Pointer | ReadonlyArray<Pointer>;

type JSONValue =
  | string
  | number
  | boolean
  | null
  | { readonly [key: string]: JSONValue }
  | ReadonlyArray<JSONValue>;

type SelectionContext = JSONValue;

interface SelectionPointObject {
  path: Pointer;
  offset?: number;
  edge?: SelectionEdge;
  affinity?: SelectionAffinity;
}

type SelectionPoint = Pointer | SelectionPointObject;

interface SelectionRange {
  anchor: SelectionPoint;
  focus: SelectionPoint;
}

type SelectionRangeInput = SelectionPoint | SelectionRange;

interface SelectionSnap {
  selectedPointers: ReadonlyArray<Pointer>;
  selectionRanges: ReadonlyArray<SelectionRange>;
  primaryIndex: number;
  anchor: SelectionPoint | null;
  focus: SelectionPoint | null;
  context?: SelectionContext | undefined;
}

interface SelectionOptions {
  mode?: SelectionMode;
  initial?: ReadonlyArray<SelectionRangeInput>;
  context?: SelectionContext;
}

SelectionState 표면:

interface SelectionState extends SelectionSnap {
  readonly rangeCount: number;
  readonly selectedCount: number;
  readonly hasSelection: boolean;
  readonly isCollapsed: boolean;
  readonly type: SelectionType;
  readonly primaryRange: SelectionRange | null;
  readonly anchorPointer: Pointer | null;
  readonly focusPointer: Pointer | null;
  readonly selectedSource: SelectionSource | null;
  readonly primaryPointer: Pointer | null;
  readonly caret: SelectionPoint | null;
  readonly caretPointer: Pointer | null;
  readonly context: SelectionContext | undefined;

  collapse(point: SelectionPoint): void;
  setBaseAndExtent(anchor: SelectionPoint, focus: SelectionPoint): void;
  extend(point: SelectionPoint): void;
  addRange(pointOrRange: SelectionPoint | SelectionRange): void;
  removeRange(pointOrRangeOrIndex: SelectionPoint | SelectionRange | number): void;
  toggleRange(pointOrRange: SelectionPoint | SelectionRange): void;
  togglePointer(pointer: Pointer): void;

  moveCursor(direction: SelectionCursorDirection, options?: SelectionCursorOptions): SelectionCursorResult;
  extendCursor(direction: SelectionCursorDirection, options?: SelectionCursorOptions): SelectionCursorResult;
  resolveCursor(direction: SelectionCursorDirection, options?: SelectionCursorOptions): SelectionCursorResult;

  orderPrimaryRange(options?: SelectionOrderOptions): SelectionRangeOrderResult;
  orderRanges(options?: SelectionOrderOptions): SelectionRangesOrderResult;
  spansForPointer(pointer: Pointer, options?: SelectionSpanOptions): SelectionPointerSpansResult;

  textEdits(replacement: string, options?: SelectionTextEditOptions): SelectionTextEditsResult;
  textPatch(replacement: string, options?: SelectionTextEditOptions): ReplaceSelectionTextResult;
  deleteText(options?: SelectionTextDeleteOptions): DeleteSelectionTextResult;

  selectScope(options?: SelectionScopeOptions): SelectionScopeResult;
  resolveScope(options?: SelectionScopeOptions): SelectionScopeTarget;

  selectRanges(
    ranges: ReadonlyArray<SelectionRangeInput>,
    anchor?: SelectionPoint | null,
    focus?: SelectionPoint | null,
    primaryIndex?: number,
  ): void;

  setContext(context: SelectionContext): void;
  clearContext(): void;
  empty(): void;
  isSelected(pointer: Pointer): boolean;
  snapshot(): SelectionSnap;
  toJSON(): SelectionSnap;
  restore(snapshot: SelectionSnap): void;
  subscribe(listener: (snapshot: SelectionSnap, previous: SelectionSnap) => void): () => void;
}

11. 복사, 잘라내기, 붙여넣기

Clipboard는 browser clipboard가 아니라 document instance가 가진 headless buffer다.

doc.copy(["/items/0", "/items/1"]);
doc.paste("/items/-");

doc.paste("/items/-", {
  payload: { id: "external", title: "External" },
});

Clipboard 표면:

type ClipboardSource = SelectionSource;

interface JSONDocumentPasteOptions {
  payload?: unknown;
  rekey?: {
    fields: string[];
    strategy:
      | "suffix"
      | "uuid"
      | ((value: unknown, context: {
          field: string;
          existing: ReadonlySet<string>;
          attempt: number;
        }) => string);
  };
  spread?: boolean;
  trustedPayload?: boolean;
}

type JSONDocumentPasteTarget =
  | Pointer
  | { before: Pointer }
  | { after: Pointer }
  | { replace: Pointer };

interface ClipboardWriteOptions {
  source?: Pointer | null;
  sources?: ReadonlyArray<Pointer> | null;
  trustedPayload?: boolean;
  clonePayload?: boolean;
}

interface ClipboardReadOptions {
  clonePayload?: boolean;
}

interface ClipboardCopyOptions {
  clonePayload?: boolean;
}

interface ClipboardCutOptions {
  clonePayload?: boolean;
}

interface ClipboardReadOk {
  ok: true;
  payload: unknown;
  source: Pointer | null;
  sources: ReadonlyArray<Pointer> | null;
}

interface ClipboardEmpty {
  ok: false;
  code: "empty_clipboard";
  reason: string;
}

type ClipboardReadResult = ClipboardReadOk | ClipboardEmpty;

interface ClipboardMutationOk<T> {
  ok: true;
  value: T;
  applied: ReadonlyArray<JSONPatchOperation>;
}

interface ClipboardCutOk<T> extends ClipboardMutationOk<T> {
  payload: unknown;
  source: Pointer;
  sources: ReadonlyArray<Pointer>;
}

interface ClipboardState<T> {
  readonly hasData: boolean;
  readonly source: Pointer | null;
  readonly sources: ReadonlyArray<Pointer> | null;

  read(options?: ClipboardReadOptions): ClipboardReadResult;
  write(payload: unknown, options?: ClipboardWriteOptions): JSONResult;
  clear(): void;

  copy(source?: ClipboardSource, options?: ClipboardCopyOptions): ClipboardCopyResult;
  cut(source?: ClipboardSource, options?: ClipboardCutOptions): ClipboardCutResult<T>;
  paste(target?: JSONDocumentPasteTarget, options?: JSONDocumentPasteOptions): ClipboardPasteResult<T>;
}

여러 source를 copy한 뒤 array insert target에 paste하면 기본으로 펼쳐진다. 직접 payload를 넣은 paste는 spread: true를 명시해야 펼쳐진다.

12. Undo, redo, history

제품 command는 보통 top-level doc.undo()doc.redo()를 쓴다.

doc.undo();
doc.redo();
doc.history.transaction({ label: "bulk edit" }, () => {
  doc.replace("/title", "Ready");
  doc.replace("/done", true);
});

History 표면:

interface HistoryTransactionOptions {
  label?: string;
  origin?: "keyboard" | "pointer" | "programmatic" | string;
  mergeKey?: string;
}

interface JSONChangeMetadata extends HistoryTransactionOptions {
  selectionBefore?: SelectionSnap;
  selectionAfter?: SelectionSnap;
}

interface JSONDocumentCommitOptions extends HistoryTransactionOptions {
  selection?: SelectionSnap;
}

interface JSONDocumentHistory {
  readonly canUndo: boolean;
  readonly canRedo: boolean;
  readonly undoDepth: number;
  readonly redoDepth: number;

  undo(): boolean;
  redo(): boolean;
  mergeLast(options?: { mergeKey?: string }): boolean;
  transaction(fn: () => void): void;
  transaction(options: HistoryTransactionOptions, fn: () => void): void;
}

doc.undo()doc.redo()JSONCapabilityResult를 반환한다. doc.history.undo()doc.history.redo()는 lower-level control이라 boolean을 반환한다.

13. Schema 확인

Form, import review, paste guard는 doc.schema를 쓴다.

doc.schema.kind("/title");
doc.schema.describe("/items/-", "insert");
doc.schema.accepts("/title", "Ready");

Schema 표면:

interface SchemaState {
  at(path: Pointer, mode?: SchemaPathMode): SchemaQueryResult;
  kind(path: Pointer, mode?: SchemaPathMode): SchemaKindResult;
  accepts(path: Pointer, value: unknown, mode?: SchemaPathMode): JSONCapabilityResult;
  describe(path: Pointer, mode?: SchemaPathMode): SchemaDescriptionResult;
}

type SchemaPathMode = "value" | "insert";

type SchemaKind =
  | "unknown"
  | "string"
  | "number"
  | "boolean"
  | "null"
  | "literal"
  | "enum"
  | "object"
  | "array"
  | "record"
  | "union"
  | "discriminatedUnion"
  | "optional"
  | "nullable"
  | "any";

interface SchemaDescription {
  kind: SchemaKind;
  jsonSchema: unknown;
  keys?: string[];
  elementKind?: SchemaKind;
  valueKind?: SchemaKind;
  discriminator?: string;
  allowed?: unknown[];
}

type SchemaErrorCode = "invalid_pointer" | "path_not_found";

interface SchemaErrorResult {
  ok: false;
  code: SchemaErrorCode;
  reason?: string;
  pointer: Pointer;
}

type SchemaQueryResult =
  | {
      ok: true;
      path: Pointer;
      mode: SchemaPathMode;
      kind: SchemaKind;
      description: SchemaDescription;
    }
  | SchemaErrorResult;

type SchemaKindResult =
  | {
      ok: true;
      path: Pointer;
      mode: SchemaPathMode;
      kind: SchemaKind;
    }
  | SchemaErrorResult;

type SchemaDescriptionResult =
  | {
      ok: true;
      path: Pointer;
      mode: SchemaPathMode;
      description: SchemaDescription;
    }
  | SchemaErrorResult;

schema.accepts의 violation path는 schema-slot 기준이다. mutation preflight와 execution failure는 document-result 기준이다.

14. JSON Pointer helper

Adapter가 사용자 입력 path를 받을 때는 먼저 Pointer로 확인한다.

const segments = tryParsePointer(input);
if (segments === null) return;

const path = buildPointer(["items", 0, "title"]);

Pointer API:

type Pointer = string;

function parsePointer(pointer: Pointer): string[];
function tryParsePointer(pointer: Pointer): string[] | null;
function buildPointer(
  segments: ReadonlyArray<string | number>,
  options?: { uriFragment?: boolean },
): Pointer;

function escapeSegment(segment: string): string;
function unescapeSegment(segment: string): string;

function parentPointer(pointer: Pointer): Pointer | null;
function lastSegment(pointer: Pointer): string | null;
function lastSegmentIndex(pointer: Pointer): number | null;
function appendSegment(pointer: Pointer, segment: string | number): Pointer;
function withLastSegment(pointer: Pointer, segment: string | number): Pointer | null;

class PointerSyntaxError extends Error {}

Root pointer는 빈 문자열 ""이다.

15. Pointer tracking과 sibling range

Selection, annotation, id resolver adapter는 patch 이후 pointer를 추적할 수 있다.

const nextPointer = trackPointer("/items/0", doc.lastPatch);

Tracking API:

function trackPointer(
  pointer: Pointer,
  applied: ReadonlyArray<JSONPatchOperation>,
): Pointer | null;

Sibling item 선택을 parent와 index run으로 정규화할 때는 resolveSiblingRange를 쓴다.

type SiblingRangeErrorCode =
  | "empty_selection"
  | "invalid_pointer"
  | "not_array_item"
  | "mixed_parent"
  | "non_contiguous";

interface SiblingLocation {
  pointer: Pointer;
  parent: Pointer;
  index: number;
}

type SiblingRangeResult =
  | {
      ok: true;
      parent: Pointer;
      locations: ReadonlyArray<SiblingLocation>;
      contiguous: boolean;
    }
  | {
      ok: false;
      code: SiblingRangeErrorCode;
      reason: string;
      pointer?: Pointer;
    };

interface ResolveSiblingRangeOptions {
  dedupe?: boolean;
  pruneDescendants?: boolean;
  requireContiguous?: boolean;
}

function resolveSiblingRange(
  source: Pointer | ReadonlyArray<Pointer>,
  options?: ResolveSiblingRangeOptions,
): SiblingRangeResult;

resolveSiblingRange는 document state를 읽지 않는 순수 path helper다.

16. Low-level patch helper

Document instance 없이 schema와 state만으로 patch를 적용할 때 쓴다.

const result = applyPatch(Schema, state, [
  { op: "replace", path: "/title", value: "Ready" },
]);

Helper:

interface ApplyResult<S extends z.ZodTypeAny> {
  state: z.output<S>;
  result: JSONResult;
  applied: ReadonlyArray<JSONPatchOperation>;
}

function applyOperation<S extends z.ZodTypeAny>(
  schema: S,
  state: z.output<S>,
  op: JSONPatchOperation,
): ApplyResult<S>;

function applyPatch<S extends z.ZodTypeAny>(
  schema: S,
  state: z.output<S>,
  ops: ReadonlyArray<JSONPatchOperation>,
): ApplyResult<S>;

function applyPatchToTrustedState<S extends z.ZodTypeAny>(
  schema: S,
  state: z.output<S>,
  ops: ReadonlyArray<JSONPatchOperation>,
): ApplyResult<S>;

17. React

React에서는 같은 document surface를 hook으로 받는다.

import { useJSONDocument } from "@interactive-os/json-document/react";

function Editor() {
  const doc = useJSONDocument(Card, initial, {
    history: 100,
    selection: true,
  });

  return <button onClick={() => doc.replace("/title", "Ready")} />;
}

React API:

function useJSONDocument<S extends z.ZodType>(
  schema: S,
  initial: z.output<S>,
  options: JSONDocumentOptions & { trustedInitial: true },
): JSONDocument<z.output<S>>;

function useJSONDocument<S extends z.ZodType>(
  schema: S,
  initial: z.input<S>,
  options?: JSONDocumentOptions & { trustedInitial?: false | undefined },
): JSONDocument<z.output<S>>;

React API는 @interactive-os/json-document/react에만 있다. Root package는 headless다.

18. Runtime exports

아래 runtime 이름은 public entrypoint에서 제공되는 공개 export다. 1.x 범위에서는 제거, rename, 의미 변경 없이 하위 호환성을 유지한다.

JSONDocumentError
PointerSyntaxError
appendSegment
applyOperation
applyPatch
applyPatchToTrustedState
buildPointer
createJSONDocument
escapeSegment
lastSegment
lastSegmentIndex
parentPointer
parsePointer
resolveSiblingRange
trackPointer
tryParsePointer
unescapeSegment
withLastSegment
useJSONDocument

19. Type exports

아래 type 이름은 public entrypoint에서 제공되는 공개 export다. 1.x 범위에서는 제거, rename, 의미 변경 없이 하위 호환성을 유지한다.

HistoryTransactionOptions
JSONCapabilityResult
JSONChangeMetadata
JSONDocument
JSONDocumentCommitOptions
JSONDocumentDuplicateError
JSONDocumentDuplicateOptions
JSONDocumentDuplicateResult
JSONDocumentHistory
JSONDocumentOptions
JSONDocumentPasteOptions
JSONDocumentPasteTarget
JSONPatchInput
JSONPatchOperation
SelectionPoint
JSONResult
Pointer
ClipboardCopyOptions
ClipboardCopyError
ClipboardCopyOk
ClipboardCopyResult
ClipboardCutError
ClipboardCutOk
ClipboardCutOptions
ClipboardCutResult
ClipboardEmpty
ClipboardMutationOk
ClipboardPasteDiscriminatorMismatch
ClipboardPasteError
ClipboardPasteResult
ClipboardReadOk
ClipboardReadOptions
ClipboardReadResult
ClipboardState
ClipboardWriteOptions
EntriesResult
EntryKind
QueryResult
ReadEntry
ReadResult
ResolveSiblingRangeOptions
SiblingLocation
SiblingRangeErrorCode
SiblingRangeResult
SchemaDescription
SchemaDescriptionResult
SchemaErrorCode
SchemaErrorResult
SchemaKind
SchemaKindResult
SchemaPathMode
SchemaQueryResult
SchemaState
SelectionOptions
SelectionPointObject
SelectionOrderedRange
SelectionOrderedRangeEntry
SelectionAffinity
SelectionContext
SelectionCursorDirection
SelectionCursorErrorCode
SelectionCursorOptions
SelectionCursorResult
SelectionCursorTarget
SelectionDirection
SelectionEdge
SelectionMode
SelectionOrderErrorCode
SelectionOrderOptions
SelectionPointOrderResult
SelectionPointerSpan
SelectionPointerSpansResult
SelectionRange
SelectionRangeInput
SelectionRangeOrderResult
SelectionRangesOrderResult
SelectionScopeErrorCode
SelectionScopeOptions
SelectionScopeResult
SelectionScopeTarget
SelectionSnap
SelectionSource
SelectionSpanOptions
SelectionState
SelectionType
DeleteSelectionTextResult
ReplaceSelectionTextResult
SelectionTextDeleteDirection
SelectionTextDeleteOptions
SelectionTextEdit
SelectionTextEditErrorCode
SelectionTextEditOptions
SelectionTextEditsResult
ClipboardSource

예시를 읽기 쉽게 만들기 위해 본문에 나온 구조적 alias는 추가 import 대상이 아니다. 위 목록과 public entrypoint가 import 기준이다.

20. 1.x 호환성 보장

1.x에서는 이 문서의 공개 API를 제거, rename, 의미 변경하지 않는다.

호환성을 깨는 변경:

  • export 제거
  • export, type, field, method, 에러 코드 rename
  • result 구조 변경
  • 원자성 변경
  • 기본 strict 동작 변경
  • clipboard spread 기본값 변경
  • selection tracking 의미 변경
  • private module import 요구

새 API는 기존 제품이 수정 없이 계속 동작할 때만 추가한다.

labs는 이 1.x 호환성 보장 범위에 포함되지 않는다. 공식 extension package는 별도 package이며 이 core surface 위에 의존한다.

Clone this wiki locally