跳到主要内容

Wiki macro types

These types are public exports of @ones-open/node-sdk; import them with import type. Node SDK WikiMacroContext locates the backend publication target. See Web SDK macro types for full frontend context.

InstallationInfo​

Installation callback data retained on the backend.

export interface InstallationInfo {
installation_id: string
shared_secret: string
ones_base_url: string
}
FieldTypeRequiredDescription
installation_idstringYesCurrent app installation ID
shared_secretstringYesBase64-encoded callback secret, never sent to the frontend
ones_base_urlstringYesONES base URL provided by the installation callback

WikiMacroContext​

Context identifying an existing macro. All fields are required; validate and retain its association with business records on the backend.

export interface WikiMacroContext {
protocolVersion: 2
appId: string
installationId: string
macroKey: string
teamId: string
documentId: string
cardUuid: string
}
FieldTypeDescription
protocolVersionLiteral 2Current macro protocol
appIdstringApp ID
installationIdstringMust equal InstallationInfo.installation_id
macroKeystringDeclared macro identifier
teamIdstringTeam containing the macro
documentIdstringCollaborative document ID, not the page ID
cardUuidstringStatic content card ID, not macro blockId

teamId and cardUuid are eight alphanumeric characters. appId, installationId, macroKey and documentId are 1–128 letters, digits, underscores or hyphens. Use runtime-provided values instead of generating identifiers. customData, scene, writable, pageId and blockId are not fields of this Node SDK type.

WikiMacroExportSpec​

export type WikiMacroExportSpec =
| { type: 'text'; data: string }
| { type: 'link'; data: { title: string; url: string } }
| { type: 'image'; data: string }
EntryFieldTypeRequiredDescription
TexttypeLiteral 'text'YesPlain text entry
TextdatastringYesPlain text without HTML parsing
LinktypeLiteral 'link'YesLink entry
Linkdata.titlestringYesLink title
Linkdata.urlstringYesValid HTTP, HTTPS or mailto URL
ImagetypeLiteral 'image'YesImage entry
ImagedatastringYesNonempty Wiki document resource ID or valid HTTPS image URL

Document resource IDs cannot contain /, backslashes, ?, # or :. HTTPS images must remain accessible in sharing, mobile and exports. Image entries do not accept additional request headers.

At most 1000 static entries are allowed. The final deduplicated resource set, including image references, allows at most 1000 items. Combined serialized UTF-8 entries and final resource references must not exceed 1 MiB.

WikiMacroResourceFile​

export interface WikiMacroResourceFile {
name: string
data: Uint8Array
}
FieldTypeRequiredDescription
namestringYesNonempty filename, at most 255 UTF-8 bytes, without separators, line breaks, null characters or double quotes
dataUint8ArrayYesBinary content, including Buffer; size above zero and at most 20 MiB

This is not a browser File and has no type, size or arrayBuffer fields. Size is determined by data.byteLength.

WikiMacroClient​

import type { WikiMacroContext, WikiMacroInstance } from '@ones-open/node-sdk'

export interface WikiMacroClient {
instance(context: WikiMacroContext): WikiMacroInstance
}

Binds synchronously; see Create a macro client and instance.

WikiMacroInstance​

import type { WikiMacroExportSpec, WikiMacroResourceFile } from '@ones-open/node-sdk'

export interface WikiMacroInstance {
uploadResource(file: WikiMacroResourceFile): Promise<string>
saveExportSpec(exportSpec: WikiMacroExportSpec[], resources: string[]): Promise<void>
}
MethodReturn valueDescription
uploadResourcePromise<string>Resource ID, not a download URL or original filename
saveExportSpecPromise<void>Confirms publication without returning context or update time

Type usage example​

import type {
InstallationInfo,
WikiMacroClient,
WikiMacroContext,
WikiMacroExportSpec,
WikiMacroInstance,
WikiMacroResourceFile,
} from '@ones-open/node-sdk'

interface MacroPublication {
installation: InstallationInfo
context: WikiMacroContext
content: WikiMacroExportSpec[]
file?: WikiMacroResourceFile
}

function bindPublication(
client: WikiMacroClient,
publication: MacroPublication,
): WikiMacroInstance {
return client.instance(publication.context)
}