Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する
Commands Reference

Post Sync


The Post Sync command is used to record the initiation of an object synchronization process in the audit logs of your DID Space. This command marks the beginning of a sync operation, allowing for comprehensive tracking and auditing of data transfers.

For more details on managing audit logs, refer to the Audit Log commands. You can also List Logs or Update Sync status.

PostObjectsSyncCommand#

This command initiates an audit log entry for an application object synchronization event. It captures the essential details of the sync's start, such as source and target, and sets initial counts to zero, which can be updated later using the Put Sync command.

Parameters#

Name

Type

Description

source

string

The identifier or path of the data source for the synchronization. Must not be empty.

target

string

The identifier or path of the data target for the synchronization. Must not be empty.

metadata

Record<string, any>

Optional. A key-value pair object containing any additional information relevant to this synchronization event.

Returns#

Name

Type

Description

statusCode

number

The HTTP status code of the response (e.g., 200 for success).

statusMessage

string

The HTTP status message (e.g., "OK").

data

AuditLogModel<AuditLogAction.APP_OBJECTS_SYNC>

The audit log entry created for the synchronization initiation. This object includes actionType set to APP_OBJECTS_SYNC, and the provided source, target, and metadata, along with default values for totalCount, errorCount, successCount, size, and duration.

Example#

import { SpaceClient, PostObjectsSyncCommand } from '@did-space/client';
import { Wallet } from '@did-space/core'; // Assuming Wallet is available from @did-space/core or similar

async function postSyncLog(wallet, endpoint) {
try {
const client = new SpaceClient({ wallet, endpoint });

const command = new PostObjectsSyncCommand({
source: 'local-folder-path:/data/my-app-backup',
target: 'did-space:/app/my-app-data',
metadata: {
syncType: 'full-backup',
initiatedBy: 'user-did:xxxx',
},
});

const result = await client.send(command);

console.log('Sync initiation logged successfully:', result);
console.log('Status Code:', result.statusCode);
console.log('Audit Log Data:', result.data);
} catch (error) {
console.error('Error posting sync log:', error);
}
}

// Example usage (replace with actual wallet and endpoint)
// const myWallet = new Wallet(...);
// const didSpaceEndpoint = 'https://beta.did.space';
// postSyncLog(myWallet, didSpaceEndpoint);

This example demonstrates how to use the PostObjectsSyncCommand to record the start of a synchronization process. It specifies the source and target paths and includes custom metadata to provide more context about the sync operation. The command is then sent via the SpaceClient, and the successful audit log entry is printed.


This section explained how to initiate an object synchronization record in your DID Space audit logs. You can follow up with the Put Sync command to update the status and details of the ongoing synchronization.