Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin-types): add support for file history versions #175

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions libs/plugin-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,65 @@ export interface File extends PluginData {
exportType: 'penpot' | 'zip',
libraryExportType?: 'all' | 'merge' | 'detach'
): Promise<Uint8Array>;

/**
* Retrieves the versions for the file.
* @param `criteria.createdBy` retrieves only the versions created by the user `createdBy`.
* Requires the `content:read` permission.
*/
findVersions(criteria?: { createdBy: User }): Promise<FileVersion[]>;

/**
* Saves the current version into the versions history.
* Requires the `content:write` permission.
*/
saveVersion(label: string): Promise<FileVersion>;
}

/**
* Type defining the file version properties.
*/
export interface FileVersion {
/**
* The current label to identify the version.
*/
label: string;

/**
* The user that created the version. If not present the
* version is an autosave.
*/
readonly createdBy?: User;

/**
* The date when the version was created.
*/
readonly createdAt: Date;

/**
* If the current version has been generated automatically.
*/
readonly isAutosave: boolean;

/*
* Restores the current version and replaces the content of the active file
* for the contents of this version.
* Requires the `content:write` permission.
* Warning: Calling this will close the plugin because the workspace will reload
*/
restore(): void;

/**
* Remove the current version.
* Requires the `content:write` permission.
*/
remove(): Promise<void>;

/**
* Converts an autosave version into a permanent version.
* Requires the `content:write` permission.
*/
pin(): Promise<FileVersion>;
}

/**
Expand Down
1 change: 1 addition & 0 deletions libs/plugins-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ repairIntrinsics({
errorTaming: 'unsafe',
consoleTaming: 'unsafe',
errorTrapping: 'none',
unhandledRejectionTrapping: 'none'
});

const globalThisAny$ = globalThis as any;
Expand Down