Files
Docwell/Phone-App/lib/api/generated/models.dart
T
tajniak81andClaude Opus 5.5 ba394b8fac Finish Phase 0: lint, codegen, contributor docs and the two remaining spikes
Repository basics:
- CONTRIBUTING.md and CODE_OF_CONDUCT.md (Contributor Covenant 2.1)
- SPDX AGPL-3.0-or-later headers on all hand-written sources, checked in CI
- golangci-lint (shared .golangci.yml), ESLint and Prettier, all run in CI

API codegen from api/openapi.yaml (npm run generate, drift fails CI):
- Go types via oapi-codegen in Server/internal/api
- a contract test that the router and the spec list the same routes
- Dart models via Phone-App/tool/generate_api.dart; the app uses them

Spike: shared Tiptap editor in a Flutter WebView (ADR-4)
- @docwell/editor-bridge builds the editor into one HTML page with a
  versioned JSON protocol; Phone-App hosts it with webview_flutter and a
  native toolbar. Integration test passes on an Android API 35 emulator.
- flutter_inappwebview dropped: its Android plugin fails on AGP 9.

Spike: Wails v3 desktop (ADR-11)
- system tray, docwell:// deep links (page and space only) with
  single-instance hand-off, and the built-in updater with a required
  ed25519 signing key. Verified on Windows.
- regenerated build assets register the scheme and drop template
  placeholders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 16:11:07 +01:00

966 lines
22 KiB
Dart

// SPDX-License-Identifier: AGPL-3.0-or-later
// Code generated by tool/generate_api.dart from api/openapi.yaml. DO NOT EDIT.
// ignore_for_file: constant_identifier_names
class ApiError {
const ApiError({required this.error, this.message, this.fields, this.mfaId});
factory ApiError.fromJson(Map<String, dynamic> json) => ApiError(
error: json['error'] as String,
message: json['message'] == null ? null : json['message'] as String,
fields: json['fields'] == null
? null
: (json['fields'] as Map<String, dynamic>).map(
(k, e) => MapEntry(k, e as String),
),
mfaId: json['mfaId'] == null ? null : json['mfaId'] as String,
);
/// invalid_json, validation, invalid_credentials, mfa_required, unauthorized, forbidden, account_disabled, signup_disabled, domain_not_allowed, invalid_token, invalid, not_found, conflict, internal
final String error;
/// Human-readable explanation
final String? message;
final Map<String, String>? fields;
final String? mfaId;
Map<String, dynamic> toJson() => {
'error': error,
'message': ?message,
'fields': ?fields,
'mfaId': ?mfaId,
};
}
/// Instance role. admin manages their own organization; superadmin manages everything.
enum Role {
user('user'),
admin('admin'),
superadmin('superadmin');
const Role(this.value);
final String value;
static Role fromJson(String value) => values.firstWhere(
(e) => e.value == value,
orElse: () => throw FormatException('unknown Role', value),
);
String toJson() => value;
}
enum WorkspaceRole {
owner('owner'),
admin('admin'),
member('member'),
guest('guest');
const WorkspaceRole(this.value);
final String value;
static WorkspaceRole fromJson(String value) => values.firstWhere(
(e) => e.value == value,
orElse: () => throw FormatException('unknown WorkspaceRole', value),
);
String toJson() => value;
}
enum UserStatus {
active('active'),
invited('invited'),
disabled('disabled');
const UserStatus(this.value);
final String value;
static UserStatus fromJson(String value) => values.firstWhere(
(e) => e.value == value,
orElse: () => throw FormatException('unknown UserStatus', value),
);
String toJson() => value;
}
class User {
const User({
required this.id,
required this.email,
required this.name,
required this.avatar,
required this.locale,
required this.theme,
required this.status,
required this.verified,
required this.created,
required this.role,
required this.organization,
required this.organizationName,
});
factory User.fromJson(Map<String, dynamic> json) => User(
id: json['id'] as String,
email: json['email'] as String,
name: json['name'] as String,
avatar: json['avatar'] as String,
locale: json['locale'] as String,
theme: json['theme'] as String,
status: UserStatus.fromJson(json['status'] as String),
verified: json['verified'] as bool,
created: json['created'] as String,
role: Role.fromJson(json['role'] as String),
organization: json['organization'] as String,
organizationName: json['organizationName'] as String,
);
final String id;
final String email;
final String name;
final String avatar;
final String locale;
final String theme;
final UserStatus status;
final bool verified;
final String created;
final Role role;
/// Organization id
final String organization;
final String organizationName;
Map<String, dynamic> toJson() => {
'id': id,
'email': email,
'name': name,
'avatar': avatar,
'locale': locale,
'theme': theme,
'status': status.toJson(),
'verified': verified,
'created': created,
'role': role.toJson(),
'organization': organization,
'organizationName': organizationName,
};
}
class CreateUserRequest {
const CreateUserRequest({
required this.email,
required this.password,
required this.name,
this.role,
this.organization,
});
factory CreateUserRequest.fromJson(Map<String, dynamic> json) =>
CreateUserRequest(
email: json['email'] as String,
password: json['password'] as String,
name: json['name'] as String,
role: json['role'] == null
? null
: Role.fromJson(json['role'] as String),
organization: json['organization'] == null
? null
: json['organization'] as String,
);
final String email;
final String password;
final String name;
final Role? role;
/// Superadmins only; admins always create in their own
final String? organization;
Map<String, dynamic> toJson() => {
'email': email,
'password': password,
'name': name,
'role': ?role?.toJson(),
'organization': ?organization,
};
}
enum UpdateUserRequestStatus {
active('active'),
invited('invited'),
disabled('disabled');
const UpdateUserRequestStatus(this.value);
final String value;
static UpdateUserRequestStatus fromJson(String value) => values.firstWhere(
(e) => e.value == value,
orElse: () =>
throw FormatException('unknown UpdateUserRequestStatus', value),
);
String toJson() => value;
}
class UpdateUserRequest {
const UpdateUserRequest({
this.email,
this.name,
this.role,
this.password,
this.status,
this.verified,
this.organization,
});
factory UpdateUserRequest.fromJson(Map<String, dynamic> json) =>
UpdateUserRequest(
email: json['email'] == null ? null : json['email'] as String,
name: json['name'] == null ? null : json['name'] as String,
role: json['role'] == null
? null
: Role.fromJson(json['role'] as String),
password: json['password'] == null ? null : json['password'] as String,
status: json['status'] == null
? null
: UpdateUserRequestStatus.fromJson(json['status'] as String),
verified: json['verified'] == null ? null : json['verified'] as bool,
organization: json['organization'] == null
? null
: json['organization'] as String,
);
final String? email;
final String? name;
final Role? role;
final String? password;
final UpdateUserRequestStatus? status;
final bool? verified;
/// Superadmins only; empty string detaches
final String? organization;
Map<String, dynamic> toJson() => {
'email': ?email,
'name': ?name,
'role': ?role?.toJson(),
'password': ?password,
'status': ?status?.toJson(),
'verified': ?verified,
'organization': ?organization,
};
}
class NameRequest {
const NameRequest({required this.name});
factory NameRequest.fromJson(Map<String, dynamic> json) =>
NameRequest(name: json['name'] as String);
final String name;
Map<String, dynamic> toJson() => {'name': name};
}
class Organization {
const Organization({
required this.id,
required this.name,
required this.created,
required this.members,
required this.workspaces,
});
factory Organization.fromJson(Map<String, dynamic> json) => Organization(
id: json['id'] as String,
name: json['name'] as String,
created: json['created'] as String,
members: (json['members'] as num).toInt(),
workspaces: (json['workspaces'] as num).toInt(),
);
final String id;
final String name;
final String created;
final int members;
final int workspaces;
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'created': created,
'members': members,
'workspaces': workspaces,
};
}
class Workspace {
const Workspace({
required this.id,
required this.name,
required this.slug,
required this.organization,
required this.organizationName,
required this.role,
required this.created,
});
factory Workspace.fromJson(Map<String, dynamic> json) => Workspace(
id: json['id'] as String,
name: json['name'] as String,
slug: json['slug'] as String,
organization: json['organization'] as String,
organizationName: json['organizationName'] as String,
role: WorkspaceRole.fromJson(json['role'] as String),
created: json['created'] as String,
);
final String id;
final String name;
final String slug;
final String organization;
final String organizationName;
final WorkspaceRole role;
final String created;
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'slug': slug,
'organization': organization,
'organizationName': organizationName,
'role': role.toJson(),
'created': created,
};
}
class WorkspaceMemberUser {
const WorkspaceMemberUser({
required this.id,
required this.email,
required this.name,
});
factory WorkspaceMemberUser.fromJson(Map<String, dynamic> json) =>
WorkspaceMemberUser(
id: json['id'] as String,
email: json['email'] as String,
name: json['name'] as String,
);
final String id;
final String email;
final String name;
Map<String, dynamic> toJson() => {'id': id, 'email': email, 'name': name};
}
class WorkspaceMember {
const WorkspaceMember({required this.user, required this.role});
factory WorkspaceMember.fromJson(Map<String, dynamic> json) =>
WorkspaceMember(
user: WorkspaceMemberUser.fromJson(
json['user'] as Map<String, dynamic>,
),
role: WorkspaceRole.fromJson(json['role'] as String),
);
final WorkspaceMemberUser user;
final WorkspaceRole role;
Map<String, dynamic> toJson() => {
'user': user.toJson(),
'role': role.toJson(),
};
}
enum SpaceRole {
admin('admin'),
editor('editor'),
commenter('commenter'),
viewer('viewer');
const SpaceRole(this.value);
final String value;
static SpaceRole fromJson(String value) => values.firstWhere(
(e) => e.value == value,
orElse: () => throw FormatException('unknown SpaceRole', value),
);
String toJson() => value;
}
/// Role that workspace members (not guests) get in an open space without an explicit role.
enum SpaceDefaultRole {
editor('editor'),
commenter('commenter'),
viewer('viewer');
const SpaceDefaultRole(this.value);
final String value;
static SpaceDefaultRole fromJson(String value) => values.firstWhere(
(e) => e.value == value,
orElse: () => throw FormatException('unknown SpaceDefaultRole', value),
);
String toJson() => value;
}
/// open - every workspace member gets the default role; private - explicit members only.
enum SpaceVisibility {
open('open'),
private('private');
const SpaceVisibility(this.value);
final String value;
static SpaceVisibility fromJson(String value) => values.firstWhere(
(e) => e.value == value,
orElse: () => throw FormatException('unknown SpaceVisibility', value),
);
String toJson() => value;
}
class Space {
const Space({
required this.id,
required this.workspace,
required this.name,
required this.slug,
required this.icon,
required this.description,
required this.visibility,
required this.defaultRole,
required this.role,
required this.created,
});
factory Space.fromJson(Map<String, dynamic> json) => Space(
id: json['id'] as String,
workspace: json['workspace'] as String,
name: json['name'] as String,
slug: json['slug'] as String,
icon: json['icon'] as String,
description: json['description'] as String,
visibility: SpaceVisibility.fromJson(json['visibility'] as String),
defaultRole: SpaceDefaultRole.fromJson(json['defaultRole'] as String),
role: SpaceRole.fromJson(json['role'] as String),
created: json['created'] as String,
);
final String id;
final String workspace;
final String name;
final String slug;
final String icon;
final String description;
final SpaceVisibility visibility;
final SpaceDefaultRole defaultRole;
final SpaceRole role;
final String created;
Map<String, dynamic> toJson() => {
'id': id,
'workspace': workspace,
'name': name,
'slug': slug,
'icon': icon,
'description': description,
'visibility': visibility.toJson(),
'defaultRole': defaultRole.toJson(),
'role': role.toJson(),
'created': created,
};
}
class SpaceMemberUser {
const SpaceMemberUser({
required this.id,
required this.email,
required this.name,
});
factory SpaceMemberUser.fromJson(Map<String, dynamic> json) =>
SpaceMemberUser(
id: json['id'] as String,
email: json['email'] as String,
name: json['name'] as String,
);
final String id;
final String email;
final String name;
Map<String, dynamic> toJson() => {'id': id, 'email': email, 'name': name};
}
class SpaceMember {
const SpaceMember({required this.user, required this.role});
factory SpaceMember.fromJson(Map<String, dynamic> json) => SpaceMember(
user: SpaceMemberUser.fromJson(json['user'] as Map<String, dynamic>),
role: SpaceRole.fromJson(json['role'] as String),
);
final SpaceMemberUser user;
final SpaceRole role;
Map<String, dynamic> toJson() => {
'user': user.toJson(),
'role': role.toJson(),
};
}
class PageNode {
const PageNode({
required this.id,
required this.parent,
required this.title,
required this.icon,
required this.position,
required this.updated,
});
factory PageNode.fromJson(Map<String, dynamic> json) => PageNode(
id: json['id'] as String,
parent: json['parent'] as String,
title: json['title'] as String,
icon: json['icon'] as String,
position: json['position'] as String,
updated: json['updated'] as String,
);
final String id;
/// Parent page id; empty at the top level
final String parent;
final String title;
final String icon;
/// Fractional sort key among siblings
final String position;
final String updated;
Map<String, dynamic> toJson() => {
'id': id,
'parent': parent,
'title': title,
'icon': icon,
'position': position,
'updated': updated,
};
}
class PageRef {
const PageRef({required this.id, required this.title, required this.icon});
factory PageRef.fromJson(Map<String, dynamic> json) => PageRef(
id: json['id'] as String,
title: json['title'] as String,
icon: json['icon'] as String,
);
final String id;
final String title;
final String icon;
Map<String, dynamic> toJson() => {'id': id, 'title': title, 'icon': icon};
}
class Page {
const Page({
required this.id,
required this.workspace,
required this.space,
required this.parent,
required this.title,
required this.icon,
required this.created,
required this.updated,
required this.deletedAt,
required this.inTrash,
required this.ancestors,
required this.role,
});
factory Page.fromJson(Map<String, dynamic> json) => Page(
id: json['id'] as String,
workspace: json['workspace'] as String,
space: json['space'] as String,
parent: json['parent'] as String,
title: json['title'] as String,
icon: json['icon'] as String,
created: json['created'] as String,
updated: json['updated'] as String,
deletedAt: json['deletedAt'] as String,
inTrash: json['inTrash'] as bool,
ancestors: (json['ancestors'] as List)
.map((e) => PageRef.fromJson(e as Map<String, dynamic>))
.toList(),
role: SpaceRole.fromJson(json['role'] as String),
);
final String id;
final String workspace;
final String space;
final String parent;
final String title;
final String icon;
final String created;
final String updated;
/// When the page itself was trashed; empty otherwise
final String deletedAt;
/// The page or one of its ancestors is in the trash
final bool inTrash;
/// Root first
final List<PageRef> ancestors;
final SpaceRole role;
Map<String, dynamic> toJson() => {
'id': id,
'workspace': workspace,
'space': space,
'parent': parent,
'title': title,
'icon': icon,
'created': created,
'updated': updated,
'deletedAt': deletedAt,
'inTrash': inTrash,
'ancestors': ancestors.map((e) => e.toJson()).toList(),
'role': role.toJson(),
};
}
class PageContent {
const PageContent({required this.content, required this.updated});
factory PageContent.fromJson(Map<String, dynamic> json) => PageContent(
content: json['content'] == null
? null
: json['content'] as Map<String, dynamic>,
updated: json['updated'] as String,
);
/// Tiptap JSON with type "doc"; null for a page that was never edited
final Map<String, dynamic>? content;
final String updated;
Map<String, dynamic> toJson() => {'content': content, 'updated': updated};
}
class PageVersion {
const PageVersion({
required this.id,
required this.author,
required this.label,
required this.created,
});
factory PageVersion.fromJson(Map<String, dynamic> json) => PageVersion(
id: json['id'] as String,
author: json['author'] as String,
label: json['label'] as String,
created: json['created'] as String,
);
final String id;
/// Name (or email) of the last person who edited before it was taken
final String author;
final String label;
final String created;
Map<String, dynamic> toJson() => {
'id': id,
'author': author,
'label': label,
'created': created,
};
}
class TrashedPage {
const TrashedPage({
required this.id,
required this.title,
required this.icon,
required this.deletedAt,
});
factory TrashedPage.fromJson(Map<String, dynamic> json) => TrashedPage(
id: json['id'] as String,
title: json['title'] as String,
icon: json['icon'] as String,
deletedAt: json['deletedAt'] as String,
);
final String id;
final String title;
final String icon;
final String deletedAt;
Map<String, dynamic> toJson() => {
'id': id,
'title': title,
'icon': icon,
'deletedAt': deletedAt,
};
}
class Session {
const Session({required this.token, required this.user});
factory Session.fromJson(Map<String, dynamic> json) => Session(
token: json['token'] as String,
user: User.fromJson(json['user'] as Map<String, dynamic>),
);
final String token;
final User user;
Map<String, dynamic> toJson() => {'token': token, 'user': user.toJson()};
}
class UserList {
const UserList({
required this.items,
required this.page,
required this.perPage,
required this.totalItems,
});
factory UserList.fromJson(Map<String, dynamic> json) => UserList(
items: (json['items'] as List)
.map((e) => User.fromJson(e as Map<String, dynamic>))
.toList(),
page: (json['page'] as num).toInt(),
perPage: (json['perPage'] as num).toInt(),
totalItems: (json['totalItems'] as num).toInt(),
);
final List<User> items;
final int page;
final int perPage;
final int totalItems;
Map<String, dynamic> toJson() => {
'items': items.map((e) => e.toJson()).toList(),
'page': page,
'perPage': perPage,
'totalItems': totalItems,
};
}
class AuthMethods {
const AuthMethods({
required this.password,
required this.otp,
required this.mfa,
required this.oauth2,
required this.signup,
});
factory AuthMethods.fromJson(Map<String, dynamic> json) => AuthMethods(
password: json['password'] as bool,
otp: json['otp'] as bool,
mfa: json['mfa'] as bool,
oauth2: (json['oauth2'] as List).map((e) => e as String).toList(),
signup: json['signup'] as bool,
);
final bool password;
final bool otp;
final bool mfa;
final List<String> oauth2;
final bool signup;
Map<String, dynamic> toJson() => {
'password': password,
'otp': otp,
'mfa': mfa,
'oauth2': oauth2.map((e) => e).toList(),
'signup': signup,
};
}
class SignupRequest {
const SignupRequest({
required this.email,
required this.password,
required this.name,
});
factory SignupRequest.fromJson(Map<String, dynamic> json) => SignupRequest(
email: json['email'] as String,
password: json['password'] as String,
name: json['name'] as String,
);
final String email;
final String password;
final String name;
Map<String, dynamic> toJson() => {
'email': email,
'password': password,
'name': name,
};
}
class LoginRequest {
const LoginRequest({required this.email, required this.password, this.mfaId});
factory LoginRequest.fromJson(Map<String, dynamic> json) => LoginRequest(
email: json['email'] as String,
password: json['password'] as String,
mfaId: json['mfaId'] == null ? null : json['mfaId'] as String,
);
final String email;
final String password;
final String? mfaId;
Map<String, dynamic> toJson() => {
'email': email,
'password': password,
'mfaId': ?mfaId,
};
}
class EmailRequest {
const EmailRequest({required this.email});
factory EmailRequest.fromJson(Map<String, dynamic> json) =>
EmailRequest(email: json['email'] as String);
final String email;
Map<String, dynamic> toJson() => {'email': email};
}
enum StatusStatus {
ok('ok'),
unavailable('unavailable');
const StatusStatus(this.value);
final String value;
static StatusStatus fromJson(String value) => values.firstWhere(
(e) => e.value == value,
orElse: () => throw FormatException('unknown StatusStatus', value),
);
String toJson() => value;
}
class Status {
const Status({required this.status, this.db});
factory Status.fromJson(Map<String, dynamic> json) => Status(
status: StatusStatus.fromJson(json['status'] as String),
db: json['db'] == null ? null : json['db'] as String,
);
final StatusStatus status;
final String? db;
Map<String, dynamic> toJson() => {'status': status.toJson(), 'db': ?db};
}
class Version {
const Version({required this.name, required this.version});
factory Version.fromJson(Map<String, dynamic> json) =>
Version(name: json['name'] as String, version: json['version'] as String);
final String name;
final String version;
Map<String, dynamic> toJson() => {'name': name, 'version': version};
}