npm run generate stopped at NewApiToken (an allOf of ApiToken and the token), so the phone app's models missed the sign-in and security schemas. allOf parts are now merged into one class, keeping the inline types of the schema they come from (NewApiToken.scope is an ApiTokenScope). Enum values with dots become camelCase names (page.created -> pageCreated) and "*" becomes all, for WebhookEvent. The regenerated models add the OAuth, TOTP, API token, audit log and webhook types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3222 lines
75 KiB
Dart
3222 lines
75 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,
|
|
this.challenge,
|
|
});
|
|
|
|
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,
|
|
challenge: json['challenge'] == null ? null : json['challenge'] as String,
|
|
);
|
|
|
|
/// invalid_json, validation, invalid_credentials, mfa_required, totp_required (with challenge), invalid_code, 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;
|
|
|
|
/// With totp_required; send it to /api/v1/auth/totp/verify
|
|
final String? challenge;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'error': error,
|
|
'message': ?message,
|
|
'fields': ?fields,
|
|
'mfaId': ?mfaId,
|
|
'challenge': ?challenge,
|
|
};
|
|
}
|
|
|
|
/// 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,
|
|
this.totp,
|
|
});
|
|
|
|
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,
|
|
totp: json['totp'] == null ? null : json['totp'] as bool,
|
|
);
|
|
|
|
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;
|
|
|
|
/// Signs in with an authenticator app too
|
|
final bool? totp;
|
|
|
|
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,
|
|
'totp': ?totp,
|
|
};
|
|
}
|
|
|
|
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.limited,
|
|
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: SpaceCallerRole.fromJson(json['role'] as String),
|
|
limited: json['limited'] as bool,
|
|
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 SpaceCallerRole role;
|
|
|
|
/// The caller cannot open the space itself and sees only pages shared with them
|
|
final bool limited;
|
|
|
|
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(),
|
|
'limited': limited,
|
|
'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.restricted,
|
|
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,
|
|
restricted: json['restricted'] as bool,
|
|
updated: json['updated'] as String,
|
|
);
|
|
|
|
final String id;
|
|
|
|
/// Parent page id; empty at the top level. In a page tree, a page whose parent the caller cannot open hangs from its nearest visible ancestor.
|
|
final String parent;
|
|
|
|
final String title;
|
|
|
|
final String icon;
|
|
|
|
/// Fractional sort key among siblings
|
|
final String position;
|
|
|
|
/// This page itself is restricted
|
|
final bool restricted;
|
|
|
|
final String updated;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'parent': parent,
|
|
'title': title,
|
|
'icon': icon,
|
|
'position': position,
|
|
'restricted': restricted,
|
|
'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,
|
|
required this.restricted,
|
|
required this.isTemplate,
|
|
required this.favorite,
|
|
});
|
|
|
|
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),
|
|
restricted: json['restricted'] as bool,
|
|
isTemplate: json['isTemplate'] as bool,
|
|
favorite: json['favorite'] as bool,
|
|
);
|
|
|
|
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; pages the caller cannot open are left out
|
|
final List<PageRef> ancestors;
|
|
|
|
/// The caller's role on this page
|
|
final SpaceRole role;
|
|
|
|
/// The page or one of its ancestors is restricted
|
|
final bool restricted;
|
|
|
|
/// Offered as a template for new pages
|
|
final bool isTemplate;
|
|
|
|
/// In the caller's favorites
|
|
final bool favorite;
|
|
|
|
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(),
|
|
'restricted': restricted,
|
|
'isTemplate': isTemplate,
|
|
'favorite': favorite,
|
|
};
|
|
}
|
|
|
|
enum PageGrantRole {
|
|
editor('editor'),
|
|
commenter('commenter'),
|
|
viewer('viewer');
|
|
|
|
const PageGrantRole(this.value);
|
|
final String value;
|
|
|
|
static PageGrantRole fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () => throw FormatException('unknown PageGrantRole', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
/// The caller's space role; empty when they see only pages shared with them
|
|
enum SpaceCallerRole {
|
|
admin('admin'),
|
|
editor('editor'),
|
|
commenter('commenter'),
|
|
viewer('viewer'),
|
|
none('');
|
|
|
|
const SpaceCallerRole(this.value);
|
|
final String value;
|
|
|
|
static SpaceCallerRole fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () => throw FormatException('unknown SpaceCallerRole', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
enum PageGrantType {
|
|
user('user'),
|
|
group('group');
|
|
|
|
const PageGrantType(this.value);
|
|
final String value;
|
|
|
|
static PageGrantType fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () => throw FormatException('unknown PageGrantType', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
class PageGrant {
|
|
const PageGrant({
|
|
required this.type,
|
|
required this.id,
|
|
required this.name,
|
|
required this.email,
|
|
required this.role,
|
|
required this.page,
|
|
required this.inherited,
|
|
});
|
|
|
|
factory PageGrant.fromJson(Map<String, dynamic> json) => PageGrant(
|
|
type: PageGrantType.fromJson(json['type'] as String),
|
|
id: json['id'] as String,
|
|
name: json['name'] as String,
|
|
email: json['email'] as String,
|
|
role: PageGrantRole.fromJson(json['role'] as String),
|
|
page: PageRef.fromJson(json['page'] as Map<String, dynamic>),
|
|
inherited: json['inherited'] as bool,
|
|
);
|
|
|
|
final PageGrantType type;
|
|
|
|
final String id;
|
|
|
|
final String name;
|
|
|
|
/// Empty for groups
|
|
final String email;
|
|
|
|
final PageGrantRole role;
|
|
|
|
/// Where the grant was made
|
|
final PageRef page;
|
|
|
|
/// Granted on an ancestor
|
|
final bool inherited;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'type': type.toJson(),
|
|
'id': id,
|
|
'name': name,
|
|
'email': email,
|
|
'role': role.toJson(),
|
|
'page': page.toJson(),
|
|
'inherited': inherited,
|
|
};
|
|
}
|
|
|
|
class PageInvite {
|
|
const PageInvite({
|
|
required this.id,
|
|
required this.email,
|
|
required this.role,
|
|
required this.expires,
|
|
});
|
|
|
|
factory PageInvite.fromJson(Map<String, dynamic> json) => PageInvite(
|
|
id: json['id'] as String,
|
|
email: json['email'] as String,
|
|
role: PageGrantRole.fromJson(json['role'] as String),
|
|
expires: json['expires'] as String,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String email;
|
|
|
|
final PageGrantRole role;
|
|
|
|
final String expires;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'email': email,
|
|
'role': role.toJson(),
|
|
'expires': expires,
|
|
};
|
|
}
|
|
|
|
class PageAccess {
|
|
const PageAccess({
|
|
required this.restricted,
|
|
required this.inheritedFrom,
|
|
required this.grants,
|
|
required this.invites,
|
|
required this.role,
|
|
required this.canManage,
|
|
required this.canInvite,
|
|
});
|
|
|
|
factory PageAccess.fromJson(Map<String, dynamic> json) => PageAccess(
|
|
restricted: json['restricted'] as bool,
|
|
inheritedFrom: json['inheritedFrom'] == null
|
|
? null
|
|
: PageRef.fromJson(json['inheritedFrom'] as Map<String, dynamic>),
|
|
grants: (json['grants'] as List)
|
|
.map((e) => PageGrant.fromJson(e as Map<String, dynamic>))
|
|
.toList(),
|
|
invites: (json['invites'] as List)
|
|
.map((e) => PageInvite.fromJson(e as Map<String, dynamic>))
|
|
.toList(),
|
|
role: SpaceRole.fromJson(json['role'] as String),
|
|
canManage: json['canManage'] as bool,
|
|
canInvite: json['canInvite'] as bool,
|
|
);
|
|
|
|
/// The page or an ancestor is restricted; space members then see it only through grants
|
|
final bool restricted;
|
|
|
|
/// The restricted ancestor, when the restriction comes from one
|
|
final PageRef? inheritedFrom;
|
|
|
|
/// This page's grants first
|
|
final List<PageGrant> grants;
|
|
|
|
/// Pending guest invites for this page (editors only)
|
|
final List<PageInvite> invites;
|
|
|
|
/// The caller's role on this page
|
|
final SpaceRole role;
|
|
|
|
final bool canManage;
|
|
|
|
/// May share with people outside the workspace
|
|
final bool canInvite;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'restricted': restricted,
|
|
'inheritedFrom': inheritedFrom?.toJson(),
|
|
'grants': grants.map((e) => e.toJson()).toList(),
|
|
'invites': invites.map((e) => e.toJson()).toList(),
|
|
'role': role.toJson(),
|
|
'canManage': canManage,
|
|
'canInvite': canInvite,
|
|
};
|
|
}
|
|
|
|
class SharePageResult {
|
|
const SharePageResult({required this.access, required this.invite});
|
|
|
|
factory SharePageResult.fromJson(Map<String, dynamic> json) =>
|
|
SharePageResult(
|
|
access: PageAccess.fromJson(json['access'] as Map<String, dynamic>),
|
|
invite: json['invite'] == null
|
|
? null
|
|
: Invite.fromJson(json['invite'] as Map<String, dynamic>),
|
|
);
|
|
|
|
final PageAccess access;
|
|
|
|
/// Set when the person was invited as a guest; the grant is made when they accept
|
|
final Invite? invite;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'access': access.toJson(),
|
|
'invite': invite?.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 AuthMethodsProviders {
|
|
const AuthMethodsProviders({required this.name, required this.displayName});
|
|
|
|
factory AuthMethodsProviders.fromJson(Map<String, dynamic> json) =>
|
|
AuthMethodsProviders(
|
|
name: json['name'] as String,
|
|
displayName: json['displayName'] as String,
|
|
);
|
|
|
|
final String name;
|
|
|
|
final String displayName;
|
|
|
|
Map<String, dynamic> toJson() => {'name': name, 'displayName': displayName};
|
|
}
|
|
|
|
class AuthMethods {
|
|
const AuthMethods({
|
|
required this.password,
|
|
required this.otp,
|
|
required this.mfa,
|
|
required this.oauth2,
|
|
required this.providers,
|
|
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(),
|
|
providers: (json['providers'] as List)
|
|
.map((e) => AuthMethodsProviders.fromJson(e as Map<String, dynamic>))
|
|
.toList(),
|
|
signup: json['signup'] as bool,
|
|
);
|
|
|
|
final bool password;
|
|
|
|
final bool otp;
|
|
|
|
final bool mfa;
|
|
|
|
final List<String> oauth2;
|
|
|
|
final List<AuthMethodsProviders> providers;
|
|
|
|
final bool signup;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'password': password,
|
|
'otp': otp,
|
|
'mfa': mfa,
|
|
'oauth2': oauth2.map((e) => e).toList(),
|
|
'providers': providers.map((e) => e.toJson()).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};
|
|
}
|
|
|
|
class PublicSettings {
|
|
const PublicSettings({
|
|
required this.appName,
|
|
required this.accentColor,
|
|
required this.logo,
|
|
required this.signup,
|
|
required this.magicLink,
|
|
});
|
|
|
|
factory PublicSettings.fromJson(Map<String, dynamic> json) => PublicSettings(
|
|
appName: json['appName'] as String,
|
|
accentColor: json['accentColor'] as String,
|
|
logo: json['logo'] as String,
|
|
signup: json['signup'] as bool,
|
|
magicLink: json['magicLink'] as bool,
|
|
);
|
|
|
|
final String appName;
|
|
|
|
/// #rrggbb, or empty for the default
|
|
final String accentColor;
|
|
|
|
/// A data URL
|
|
final String logo;
|
|
|
|
/// Self-service signup is open
|
|
final bool signup;
|
|
|
|
/// Sign-in links by email are enabled
|
|
final bool magicLink;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'appName': appName,
|
|
'accentColor': accentColor,
|
|
'logo': logo,
|
|
'signup': signup,
|
|
'magicLink': magicLink,
|
|
};
|
|
}
|
|
|
|
class SignupSettings {
|
|
const SignupSettings({required this.enabled, required this.domains});
|
|
|
|
factory SignupSettings.fromJson(Map<String, dynamic> json) => SignupSettings(
|
|
enabled: json['enabled'] as bool,
|
|
domains: (json['domains'] as List).map((e) => e as String).toList(),
|
|
);
|
|
|
|
final bool enabled;
|
|
|
|
/// Allowed email domains; empty allows all
|
|
final List<String> domains;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'enabled': enabled,
|
|
'domains': domains.map((e) => e).toList(),
|
|
};
|
|
}
|
|
|
|
class BrandingSettings {
|
|
const BrandingSettings({
|
|
required this.appName,
|
|
required this.accentColor,
|
|
required this.logo,
|
|
});
|
|
|
|
factory BrandingSettings.fromJson(Map<String, dynamic> json) =>
|
|
BrandingSettings(
|
|
appName: json['appName'] as String,
|
|
accentColor: json['accentColor'] as String,
|
|
logo: json['logo'] as String,
|
|
);
|
|
|
|
final String appName;
|
|
|
|
final String accentColor;
|
|
|
|
/// data:image/(png|jpeg|webp|svg+xml);base64,..., at most 256 KB
|
|
final String logo;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'appName': appName,
|
|
'accentColor': accentColor,
|
|
'logo': logo,
|
|
};
|
|
}
|
|
|
|
class SmtpSettings {
|
|
const SmtpSettings({
|
|
required this.enabled,
|
|
required this.host,
|
|
required this.port,
|
|
required this.username,
|
|
this.password,
|
|
required this.passwordSet,
|
|
required this.tls,
|
|
required this.senderName,
|
|
required this.senderAddress,
|
|
});
|
|
|
|
factory SmtpSettings.fromJson(Map<String, dynamic> json) => SmtpSettings(
|
|
enabled: json['enabled'] as bool,
|
|
host: json['host'] as String,
|
|
port: (json['port'] as num).toInt(),
|
|
username: json['username'] as String,
|
|
password: json['password'] == null ? null : json['password'] as String,
|
|
passwordSet: json['passwordSet'] as bool,
|
|
tls: json['tls'] as bool,
|
|
senderName: json['senderName'] as String,
|
|
senderAddress: json['senderAddress'] as String,
|
|
);
|
|
|
|
final bool enabled;
|
|
|
|
final String host;
|
|
|
|
final int port;
|
|
|
|
final String username;
|
|
|
|
/// Leave out to keep the stored password
|
|
final String? password;
|
|
|
|
final bool passwordSet;
|
|
|
|
final bool tls;
|
|
|
|
final String senderName;
|
|
|
|
final String senderAddress;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'enabled': enabled,
|
|
'host': host,
|
|
'port': port,
|
|
'username': username,
|
|
'password': ?password,
|
|
'passwordSet': passwordSet,
|
|
'tls': tls,
|
|
'senderName': senderName,
|
|
'senderAddress': senderAddress,
|
|
};
|
|
}
|
|
|
|
class StorageSettings {
|
|
const StorageSettings({
|
|
required this.s3,
|
|
required this.bucket,
|
|
required this.region,
|
|
required this.endpoint,
|
|
required this.accessKey,
|
|
this.secret,
|
|
required this.secretSet,
|
|
required this.forcePathStyle,
|
|
});
|
|
|
|
factory StorageSettings.fromJson(Map<String, dynamic> json) =>
|
|
StorageSettings(
|
|
s3: json['s3'] as bool,
|
|
bucket: json['bucket'] as String,
|
|
region: json['region'] as String,
|
|
endpoint: json['endpoint'] as String,
|
|
accessKey: json['accessKey'] as String,
|
|
secret: json['secret'] == null ? null : json['secret'] as String,
|
|
secretSet: json['secretSet'] as bool,
|
|
forcePathStyle: json['forcePathStyle'] as bool,
|
|
);
|
|
|
|
/// false stores files on docwell-db's disk
|
|
final bool s3;
|
|
|
|
final String bucket;
|
|
|
|
final String region;
|
|
|
|
final String endpoint;
|
|
|
|
final String accessKey;
|
|
|
|
/// Leave out to keep the stored secret
|
|
final String? secret;
|
|
|
|
final bool secretSet;
|
|
|
|
final bool forcePathStyle;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
's3': s3,
|
|
'bucket': bucket,
|
|
'region': region,
|
|
'endpoint': endpoint,
|
|
'accessKey': accessKey,
|
|
'secret': ?secret,
|
|
'secretSet': secretSet,
|
|
'forcePathStyle': forcePathStyle,
|
|
};
|
|
}
|
|
|
|
class InstanceSettings {
|
|
const InstanceSettings({
|
|
required this.signup,
|
|
required this.auth,
|
|
required this.branding,
|
|
required this.smtp,
|
|
required this.storage,
|
|
});
|
|
|
|
factory InstanceSettings.fromJson(Map<String, dynamic> json) =>
|
|
InstanceSettings(
|
|
signup: SignupSettings.fromJson(json['signup'] as Map<String, dynamic>),
|
|
auth: AuthSettings.fromJson(json['auth'] as Map<String, dynamic>),
|
|
branding: BrandingSettings.fromJson(
|
|
json['branding'] as Map<String, dynamic>,
|
|
),
|
|
smtp: SmtpSettings.fromJson(json['smtp'] as Map<String, dynamic>),
|
|
storage: StorageSettings.fromJson(
|
|
json['storage'] as Map<String, dynamic>,
|
|
),
|
|
);
|
|
|
|
final SignupSettings signup;
|
|
|
|
final AuthSettings auth;
|
|
|
|
final BrandingSettings branding;
|
|
|
|
final SmtpSettings smtp;
|
|
|
|
final StorageSettings storage;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'signup': signup.toJson(),
|
|
'auth': auth.toJson(),
|
|
'branding': branding.toJson(),
|
|
'smtp': smtp.toJson(),
|
|
'storage': storage.toJson(),
|
|
};
|
|
}
|
|
|
|
class InstanceSettingsUpdate {
|
|
const InstanceSettingsUpdate({
|
|
this.signup,
|
|
this.auth,
|
|
this.branding,
|
|
this.smtp,
|
|
this.storage,
|
|
});
|
|
|
|
factory InstanceSettingsUpdate.fromJson(Map<String, dynamic> json) =>
|
|
InstanceSettingsUpdate(
|
|
signup: json['signup'] == null
|
|
? null
|
|
: SignupSettings.fromJson(json['signup'] as Map<String, dynamic>),
|
|
auth: json['auth'] == null
|
|
? null
|
|
: AuthSettings.fromJson(json['auth'] as Map<String, dynamic>),
|
|
branding: json['branding'] == null
|
|
? null
|
|
: BrandingSettings.fromJson(
|
|
json['branding'] as Map<String, dynamic>,
|
|
),
|
|
smtp: json['smtp'] == null
|
|
? null
|
|
: SmtpSettings.fromJson(json['smtp'] as Map<String, dynamic>),
|
|
storage: json['storage'] == null
|
|
? null
|
|
: StorageSettings.fromJson(json['storage'] as Map<String, dynamic>),
|
|
);
|
|
|
|
final SignupSettings? signup;
|
|
|
|
final AuthSettings? auth;
|
|
|
|
final BrandingSettings? branding;
|
|
|
|
final SmtpSettings? smtp;
|
|
|
|
final StorageSettings? storage;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'signup': ?signup?.toJson(),
|
|
'auth': ?auth?.toJson(),
|
|
'branding': ?branding?.toJson(),
|
|
'smtp': ?smtp?.toJson(),
|
|
'storage': ?storage?.toJson(),
|
|
};
|
|
}
|
|
|
|
class OAuthStart {
|
|
const OAuthStart({required this.url, required this.state});
|
|
|
|
factory OAuthStart.fromJson(Map<String, dynamic> json) =>
|
|
OAuthStart(url: json['url'] as String, state: json['state'] as String);
|
|
|
|
final String url;
|
|
|
|
final String state;
|
|
|
|
Map<String, dynamic> toJson() => {'url': url, 'state': state};
|
|
}
|
|
|
|
class TotpStatus {
|
|
const TotpStatus({required this.enabled, required this.recoveryCodesLeft});
|
|
|
|
factory TotpStatus.fromJson(Map<String, dynamic> json) => TotpStatus(
|
|
enabled: json['enabled'] as bool,
|
|
recoveryCodesLeft: (json['recoveryCodesLeft'] as num).toInt(),
|
|
);
|
|
|
|
final bool enabled;
|
|
|
|
final int recoveryCodesLeft;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'enabled': enabled,
|
|
'recoveryCodesLeft': recoveryCodesLeft,
|
|
};
|
|
}
|
|
|
|
class TotpSetup {
|
|
const TotpSetup({required this.secret, required this.url, required this.qr});
|
|
|
|
factory TotpSetup.fromJson(Map<String, dynamic> json) => TotpSetup(
|
|
secret: json['secret'] as String,
|
|
url: json['url'] as String,
|
|
qr: json['qr'] as String,
|
|
);
|
|
|
|
/// For typing into the app by hand
|
|
final String secret;
|
|
|
|
/// The otpauth:// address
|
|
final String url;
|
|
|
|
/// PNG data URL of the QR code
|
|
final String qr;
|
|
|
|
Map<String, dynamic> toJson() => {'secret': secret, 'url': url, 'qr': qr};
|
|
}
|
|
|
|
enum ApiTokenScope {
|
|
read('read'),
|
|
write('write');
|
|
|
|
const ApiTokenScope(this.value);
|
|
final String value;
|
|
|
|
static ApiTokenScope fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () => throw FormatException('unknown ApiTokenScope', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
/// In admin listings
|
|
class ApiTokenUser {
|
|
const ApiTokenUser({
|
|
required this.id,
|
|
required this.email,
|
|
required this.name,
|
|
});
|
|
|
|
factory ApiTokenUser.fromJson(Map<String, dynamic> json) => ApiTokenUser(
|
|
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 ApiToken {
|
|
const ApiToken({
|
|
required this.id,
|
|
required this.name,
|
|
required this.prefix,
|
|
required this.scope,
|
|
required this.lastUsed,
|
|
required this.expires,
|
|
required this.created,
|
|
this.user,
|
|
});
|
|
|
|
factory ApiToken.fromJson(Map<String, dynamic> json) => ApiToken(
|
|
id: json['id'] as String,
|
|
name: json['name'] as String,
|
|
prefix: json['prefix'] as String,
|
|
scope: ApiTokenScope.fromJson(json['scope'] as String),
|
|
lastUsed: json['lastUsed'] as String,
|
|
expires: json['expires'] as String,
|
|
created: json['created'] as String,
|
|
user: json['user'] == null
|
|
? null
|
|
: ApiTokenUser.fromJson(json['user'] as Map<String, dynamic>),
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String name;
|
|
|
|
/// The token's first characters
|
|
final String prefix;
|
|
|
|
final ApiTokenScope scope;
|
|
|
|
final String lastUsed;
|
|
|
|
/// Empty when it never expires
|
|
final String expires;
|
|
|
|
final String created;
|
|
|
|
/// In admin listings
|
|
final ApiTokenUser? user;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'name': name,
|
|
'prefix': prefix,
|
|
'scope': scope.toJson(),
|
|
'lastUsed': lastUsed,
|
|
'expires': expires,
|
|
'created': created,
|
|
'user': ?user?.toJson(),
|
|
};
|
|
}
|
|
|
|
class NewApiToken {
|
|
const NewApiToken({
|
|
required this.id,
|
|
required this.name,
|
|
required this.prefix,
|
|
required this.scope,
|
|
required this.lastUsed,
|
|
required this.expires,
|
|
required this.created,
|
|
this.user,
|
|
required this.token,
|
|
});
|
|
|
|
factory NewApiToken.fromJson(Map<String, dynamic> json) => NewApiToken(
|
|
id: json['id'] as String,
|
|
name: json['name'] as String,
|
|
prefix: json['prefix'] as String,
|
|
scope: ApiTokenScope.fromJson(json['scope'] as String),
|
|
lastUsed: json['lastUsed'] as String,
|
|
expires: json['expires'] as String,
|
|
created: json['created'] as String,
|
|
user: json['user'] == null
|
|
? null
|
|
: ApiTokenUser.fromJson(json['user'] as Map<String, dynamic>),
|
|
token: json['token'] as String,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String name;
|
|
|
|
/// The token's first characters
|
|
final String prefix;
|
|
|
|
final ApiTokenScope scope;
|
|
|
|
final String lastUsed;
|
|
|
|
/// Empty when it never expires
|
|
final String expires;
|
|
|
|
final String created;
|
|
|
|
/// In admin listings
|
|
final ApiTokenUser? user;
|
|
|
|
/// The token; it is not shown again
|
|
final String token;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'name': name,
|
|
'prefix': prefix,
|
|
'scope': scope.toJson(),
|
|
'lastUsed': lastUsed,
|
|
'expires': expires,
|
|
'created': created,
|
|
'user': ?user?.toJson(),
|
|
'token': token,
|
|
};
|
|
}
|
|
|
|
class AuditEntry {
|
|
const AuditEntry({
|
|
required this.id,
|
|
required this.created,
|
|
required this.action,
|
|
required this.actorId,
|
|
required this.actorEmail,
|
|
required this.targetType,
|
|
required this.targetId,
|
|
required this.status,
|
|
required this.ip,
|
|
required this.userAgent,
|
|
required this.meta,
|
|
});
|
|
|
|
factory AuditEntry.fromJson(Map<String, dynamic> json) => AuditEntry(
|
|
id: json['id'] as String,
|
|
created: json['created'] as String,
|
|
action: json['action'] as String,
|
|
actorId: json['actorId'] as String,
|
|
actorEmail: json['actorEmail'] as String,
|
|
targetType: json['targetType'] as String,
|
|
targetId: json['targetId'] as String,
|
|
status: (json['status'] as num).toInt(),
|
|
ip: json['ip'] as String,
|
|
userAgent: json['userAgent'] as String,
|
|
meta: json['meta'] == null ? null : json['meta'] as Map<String, dynamic>,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String created;
|
|
|
|
/// A sign-in step ("auth.login", "auth.login.failed") or the route of a change ("PATCH /pages/{id}")
|
|
final String action;
|
|
|
|
final String actorId;
|
|
|
|
final String actorEmail;
|
|
|
|
final String targetType;
|
|
|
|
final String targetId;
|
|
|
|
final int status;
|
|
|
|
final String ip;
|
|
|
|
final String userAgent;
|
|
|
|
final Map<String, dynamic>? meta;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'created': created,
|
|
'action': action,
|
|
'actorId': actorId,
|
|
'actorEmail': actorEmail,
|
|
'targetType': targetType,
|
|
'targetId': targetId,
|
|
'status': status,
|
|
'ip': ip,
|
|
'userAgent': userAgent,
|
|
'meta': meta,
|
|
};
|
|
}
|
|
|
|
class AuditPage {
|
|
const AuditPage({
|
|
required this.items,
|
|
required this.total,
|
|
required this.page,
|
|
});
|
|
|
|
factory AuditPage.fromJson(Map<String, dynamic> json) => AuditPage(
|
|
items: (json['items'] as List)
|
|
.map((e) => AuditEntry.fromJson(e as Map<String, dynamic>))
|
|
.toList(),
|
|
total: (json['total'] as num).toInt(),
|
|
page: (json['page'] as num).toInt(),
|
|
);
|
|
|
|
final List<AuditEntry> items;
|
|
|
|
final int total;
|
|
|
|
final int page;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'items': items.map((e) => e.toJson()).toList(),
|
|
'total': total,
|
|
'page': page,
|
|
};
|
|
}
|
|
|
|
enum WebhookEvent {
|
|
all('*'),
|
|
pageCreated('page.created'),
|
|
pageUpdated('page.updated'),
|
|
pageMoved('page.moved'),
|
|
pageTrashed('page.trashed'),
|
|
pageRestored('page.restored'),
|
|
pageDeleted('page.deleted'),
|
|
commentCreated('comment.created'),
|
|
commentResolved('comment.resolved'),
|
|
spaceCreated('space.created'),
|
|
spaceDeleted('space.deleted');
|
|
|
|
const WebhookEvent(this.value);
|
|
final String value;
|
|
|
|
static WebhookEvent fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () => throw FormatException('unknown WebhookEvent', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
class Webhook {
|
|
const Webhook({
|
|
required this.id,
|
|
required this.name,
|
|
required this.url,
|
|
required this.events,
|
|
required this.active,
|
|
this.secret,
|
|
required this.created,
|
|
});
|
|
|
|
factory Webhook.fromJson(Map<String, dynamic> json) => Webhook(
|
|
id: json['id'] as String,
|
|
name: json['name'] as String,
|
|
url: json['url'] as String,
|
|
events: (json['events'] as List)
|
|
.map((e) => WebhookEvent.fromJson(e as String))
|
|
.toList(),
|
|
active: json['active'] as bool,
|
|
secret: json['secret'] == null ? null : json['secret'] as String,
|
|
created: json['created'] as String,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String name;
|
|
|
|
final String url;
|
|
|
|
final List<WebhookEvent> events;
|
|
|
|
final bool active;
|
|
|
|
/// Only when just created
|
|
final String? secret;
|
|
|
|
final String created;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'name': name,
|
|
'url': url,
|
|
'events': events.map((e) => e.toJson()).toList(),
|
|
'active': active,
|
|
'secret': ?secret,
|
|
'created': created,
|
|
};
|
|
}
|
|
|
|
class WebhookInput {
|
|
const WebhookInput({this.name, this.url, this.events, this.active});
|
|
|
|
factory WebhookInput.fromJson(Map<String, dynamic> json) => WebhookInput(
|
|
name: json['name'] == null ? null : json['name'] as String,
|
|
url: json['url'] == null ? null : json['url'] as String,
|
|
events: json['events'] == null
|
|
? null
|
|
: (json['events'] as List)
|
|
.map((e) => WebhookEvent.fromJson(e as String))
|
|
.toList(),
|
|
active: json['active'] == null ? null : json['active'] as bool,
|
|
);
|
|
|
|
final String? name;
|
|
|
|
final String? url;
|
|
|
|
/// Defaults to all ("*")
|
|
final List<WebhookEvent>? events;
|
|
|
|
final bool? active;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'name': ?name,
|
|
'url': ?url,
|
|
'events': ?events?.map((e) => e.toJson()).toList(),
|
|
'active': ?active,
|
|
};
|
|
}
|
|
|
|
enum WebhookDeliveryStatus {
|
|
pending('pending'),
|
|
success('success'),
|
|
failed('failed');
|
|
|
|
const WebhookDeliveryStatus(this.value);
|
|
final String value;
|
|
|
|
static WebhookDeliveryStatus fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () => throw FormatException('unknown WebhookDeliveryStatus', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
class WebhookDelivery {
|
|
const WebhookDelivery({
|
|
required this.id,
|
|
required this.event,
|
|
required this.deliveryId,
|
|
required this.status,
|
|
required this.attempts,
|
|
required this.responseCode,
|
|
required this.error,
|
|
required this.durationMs,
|
|
required this.created,
|
|
});
|
|
|
|
factory WebhookDelivery.fromJson(Map<String, dynamic> json) =>
|
|
WebhookDelivery(
|
|
id: json['id'] as String,
|
|
event: json['event'] as String,
|
|
deliveryId: json['deliveryId'] as String,
|
|
status: WebhookDeliveryStatus.fromJson(json['status'] as String),
|
|
attempts: (json['attempts'] as num).toInt(),
|
|
responseCode: (json['responseCode'] as num).toInt(),
|
|
error: json['error'] as String,
|
|
durationMs: (json['durationMs'] as num).toInt(),
|
|
created: json['created'] as String,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String event;
|
|
|
|
/// The payload's id (X-Docwell-Delivery)
|
|
final String deliveryId;
|
|
|
|
final WebhookDeliveryStatus status;
|
|
|
|
final int attempts;
|
|
|
|
final int responseCode;
|
|
|
|
final String error;
|
|
|
|
final int durationMs;
|
|
|
|
final String created;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'event': event,
|
|
'deliveryId': deliveryId,
|
|
'status': status.toJson(),
|
|
'attempts': attempts,
|
|
'responseCode': responseCode,
|
|
'error': error,
|
|
'durationMs': durationMs,
|
|
'created': created,
|
|
};
|
|
}
|
|
|
|
enum OAuthProviderSettingsName {
|
|
google('google'),
|
|
github('github'),
|
|
microsoft('microsoft'),
|
|
oidc('oidc');
|
|
|
|
const OAuthProviderSettingsName(this.value);
|
|
final String value;
|
|
|
|
static OAuthProviderSettingsName fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () =>
|
|
throw FormatException('unknown OAuthProviderSettingsName', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
class OAuthProviderSettings {
|
|
const OAuthProviderSettings({
|
|
required this.name,
|
|
required this.clientId,
|
|
this.clientSecret,
|
|
required this.displayName,
|
|
required this.authUrl,
|
|
required this.tokenUrl,
|
|
required this.userInfoUrl,
|
|
});
|
|
|
|
factory OAuthProviderSettings.fromJson(Map<String, dynamic> json) =>
|
|
OAuthProviderSettings(
|
|
name: OAuthProviderSettingsName.fromJson(json['name'] as String),
|
|
clientId: json['clientId'] as String,
|
|
clientSecret: json['clientSecret'] == null
|
|
? null
|
|
: json['clientSecret'] as String,
|
|
displayName: json['displayName'] as String,
|
|
authUrl: json['authUrl'] as String,
|
|
tokenUrl: json['tokenUrl'] as String,
|
|
userInfoUrl: json['userInfoUrl'] as String,
|
|
);
|
|
|
|
final OAuthProviderSettingsName name;
|
|
|
|
final String clientId;
|
|
|
|
/// Write-only; leave out to keep the stored one
|
|
final String? clientSecret;
|
|
|
|
final String displayName;
|
|
|
|
/// OpenID Connect only
|
|
final String authUrl;
|
|
|
|
/// OpenID Connect only
|
|
final String tokenUrl;
|
|
|
|
/// OpenID Connect only
|
|
final String userInfoUrl;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'name': name.toJson(),
|
|
'clientId': clientId,
|
|
'clientSecret': ?clientSecret,
|
|
'displayName': displayName,
|
|
'authUrl': authUrl,
|
|
'tokenUrl': tokenUrl,
|
|
'userInfoUrl': userInfoUrl,
|
|
};
|
|
}
|
|
|
|
class AuthSettings {
|
|
const AuthSettings({
|
|
required this.magicLink,
|
|
required this.oauth2,
|
|
this.callbackUrl,
|
|
});
|
|
|
|
factory AuthSettings.fromJson(Map<String, dynamic> json) => AuthSettings(
|
|
magicLink: json['magicLink'] as bool,
|
|
oauth2: (json['oauth2'] as List)
|
|
.map((e) => OAuthProviderSettings.fromJson(e as Map<String, dynamic>))
|
|
.toList(),
|
|
callbackUrl: json['callbackUrl'] == null
|
|
? null
|
|
: json['callbackUrl'] as String,
|
|
);
|
|
|
|
/// Email a one-time sign-in link and code
|
|
final bool magicLink;
|
|
|
|
/// Sign-in providers; saving replaces the list (leave it out to keep it)
|
|
final List<OAuthProviderSettings> oauth2;
|
|
|
|
/// Read-only: the address to register with each provider
|
|
final String? callbackUrl;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'magicLink': magicLink,
|
|
'oauth2': oauth2.map((e) => e.toJson()).toList(),
|
|
'callbackUrl': ?callbackUrl,
|
|
};
|
|
}
|
|
|
|
enum InviteStatus {
|
|
pending('pending'),
|
|
expired('expired'),
|
|
added('added');
|
|
|
|
const InviteStatus(this.value);
|
|
final String value;
|
|
|
|
static InviteStatus fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () => throw FormatException('unknown InviteStatus', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
class Invite {
|
|
const Invite({
|
|
required this.id,
|
|
required this.email,
|
|
required this.organization,
|
|
required this.organizationName,
|
|
required this.role,
|
|
required this.workspace,
|
|
required this.workspaceName,
|
|
required this.workspaceRole,
|
|
required this.invitedBy,
|
|
required this.expires,
|
|
required this.created,
|
|
required this.status,
|
|
this.link,
|
|
required this.mailed,
|
|
});
|
|
|
|
factory Invite.fromJson(Map<String, dynamic> json) => Invite(
|
|
id: json['id'] as String,
|
|
email: json['email'] as String,
|
|
organization: json['organization'] as String,
|
|
organizationName: json['organizationName'] as String,
|
|
role: Role.fromJson(json['role'] as String),
|
|
workspace: json['workspace'] as String,
|
|
workspaceName: json['workspaceName'] as String,
|
|
workspaceRole: json['workspaceRole'] as String,
|
|
invitedBy: json['invitedBy'] as String,
|
|
expires: json['expires'] as String,
|
|
created: json['created'] as String,
|
|
status: InviteStatus.fromJson(json['status'] as String),
|
|
link: json['link'] == null ? null : json['link'] as String,
|
|
mailed: json['mailed'] as bool,
|
|
);
|
|
|
|
/// Empty when status is added
|
|
final String id;
|
|
|
|
final String email;
|
|
|
|
final String organization;
|
|
|
|
final String organizationName;
|
|
|
|
final Role role;
|
|
|
|
final String workspace;
|
|
|
|
final String workspaceName;
|
|
|
|
/// A workspace role
|
|
final String workspaceRole;
|
|
|
|
/// Inviter's name
|
|
final String invitedBy;
|
|
|
|
final String expires;
|
|
|
|
final String created;
|
|
|
|
final InviteStatus status;
|
|
|
|
/// Only when just created or resent
|
|
final String? link;
|
|
|
|
/// The email was handed to the mail server
|
|
final bool mailed;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'email': email,
|
|
'organization': organization,
|
|
'organizationName': organizationName,
|
|
'role': role.toJson(),
|
|
'workspace': workspace,
|
|
'workspaceName': workspaceName,
|
|
'workspaceRole': workspaceRole,
|
|
'invitedBy': invitedBy,
|
|
'expires': expires,
|
|
'created': created,
|
|
'status': status.toJson(),
|
|
'link': ?link,
|
|
'mailed': mailed,
|
|
};
|
|
}
|
|
|
|
class CreateInviteRequest {
|
|
const CreateInviteRequest({
|
|
required this.email,
|
|
this.role,
|
|
this.organization,
|
|
this.workspace,
|
|
this.workspaceRole,
|
|
});
|
|
|
|
factory CreateInviteRequest.fromJson(
|
|
Map<String, dynamic> json,
|
|
) => CreateInviteRequest(
|
|
email: json['email'] as String,
|
|
role: json['role'] == null ? null : Role.fromJson(json['role'] as String),
|
|
organization: json['organization'] == null
|
|
? null
|
|
: json['organization'] as String,
|
|
workspace: json['workspace'] == null ? null : json['workspace'] as String,
|
|
workspaceRole: json['workspaceRole'] == null
|
|
? null
|
|
: WorkspaceRole.fromJson(json['workspaceRole'] as String),
|
|
);
|
|
|
|
final String email;
|
|
|
|
final Role? role;
|
|
|
|
/// Superadmins only; admins always invite into their own
|
|
final String? organization;
|
|
|
|
/// Makes this a workspace invite
|
|
final String? workspace;
|
|
|
|
final WorkspaceRole? workspaceRole;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'email': email,
|
|
'role': ?role?.toJson(),
|
|
'organization': ?organization,
|
|
'workspace': ?workspace,
|
|
'workspaceRole': ?workspaceRole?.toJson(),
|
|
};
|
|
}
|
|
|
|
class InviteInfo {
|
|
const InviteInfo({
|
|
required this.email,
|
|
required this.organizationName,
|
|
required this.workspaceName,
|
|
required this.invitedBy,
|
|
required this.expires,
|
|
required this.hasAccount,
|
|
});
|
|
|
|
factory InviteInfo.fromJson(Map<String, dynamic> json) => InviteInfo(
|
|
email: json['email'] as String,
|
|
organizationName: json['organizationName'] as String,
|
|
workspaceName: json['workspaceName'] as String,
|
|
invitedBy: json['invitedBy'] as String,
|
|
expires: json['expires'] as String,
|
|
hasAccount: json['hasAccount'] as bool,
|
|
);
|
|
|
|
final String email;
|
|
|
|
final String organizationName;
|
|
|
|
final String workspaceName;
|
|
|
|
final String invitedBy;
|
|
|
|
final String expires;
|
|
|
|
/// Sign in to accept instead of signing up
|
|
final bool hasAccount;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'email': email,
|
|
'organizationName': organizationName,
|
|
'workspaceName': workspaceName,
|
|
'invitedBy': invitedBy,
|
|
'expires': expires,
|
|
'hasAccount': hasAccount,
|
|
};
|
|
}
|
|
|
|
class MemberUser {
|
|
const MemberUser({required this.id, required this.email, required this.name});
|
|
|
|
factory MemberUser.fromJson(Map<String, dynamic> json) => MemberUser(
|
|
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 Group {
|
|
const Group({
|
|
required this.id,
|
|
required this.workspace,
|
|
required this.name,
|
|
required this.description,
|
|
required this.members,
|
|
required this.created,
|
|
});
|
|
|
|
factory Group.fromJson(Map<String, dynamic> json) => Group(
|
|
id: json['id'] as String,
|
|
workspace: json['workspace'] as String,
|
|
name: json['name'] as String,
|
|
description: json['description'] as String,
|
|
members: (json['members'] as num).toInt(),
|
|
created: json['created'] as String,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String workspace;
|
|
|
|
final String name;
|
|
|
|
final String description;
|
|
|
|
final int members;
|
|
|
|
final String created;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'workspace': workspace,
|
|
'name': name,
|
|
'description': description,
|
|
'members': members,
|
|
'created': created,
|
|
};
|
|
}
|
|
|
|
class GroupRequest {
|
|
const GroupRequest({this.name, this.description});
|
|
|
|
factory GroupRequest.fromJson(Map<String, dynamic> json) => GroupRequest(
|
|
name: json['name'] == null ? null : json['name'] as String,
|
|
description: json['description'] == null
|
|
? null
|
|
: json['description'] as String,
|
|
);
|
|
|
|
final String? name;
|
|
|
|
final String? description;
|
|
|
|
Map<String, dynamic> toJson() => {'name': ?name, 'description': ?description};
|
|
}
|
|
|
|
class SpaceGroupGroup {
|
|
const SpaceGroupGroup({required this.id, required this.name});
|
|
|
|
factory SpaceGroupGroup.fromJson(Map<String, dynamic> json) =>
|
|
SpaceGroupGroup(id: json['id'] as String, name: json['name'] as String);
|
|
|
|
final String id;
|
|
|
|
final String name;
|
|
|
|
Map<String, dynamic> toJson() => {'id': id, 'name': name};
|
|
}
|
|
|
|
class SpaceGroup {
|
|
const SpaceGroup({required this.group, required this.role});
|
|
|
|
factory SpaceGroup.fromJson(Map<String, dynamic> json) => SpaceGroup(
|
|
group: SpaceGroupGroup.fromJson(json['group'] as Map<String, dynamic>),
|
|
role: SpaceRole.fromJson(json['role'] as String),
|
|
);
|
|
|
|
final SpaceGroupGroup group;
|
|
|
|
final SpaceRole role;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'group': group.toJson(),
|
|
'role': role.toJson(),
|
|
};
|
|
}
|
|
|
|
class PageItem {
|
|
const PageItem({
|
|
required this.id,
|
|
required this.title,
|
|
required this.icon,
|
|
required this.space,
|
|
required this.spaceName,
|
|
required this.at,
|
|
});
|
|
|
|
factory PageItem.fromJson(Map<String, dynamic> json) => PageItem(
|
|
id: json['id'] as String,
|
|
title: json['title'] as String,
|
|
icon: json['icon'] as String,
|
|
space: json['space'] as String,
|
|
spaceName: json['spaceName'] as String,
|
|
at: json['at'] as String,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String title;
|
|
|
|
final String icon;
|
|
|
|
final String space;
|
|
|
|
final String spaceName;
|
|
|
|
/// When it was favorited
|
|
final String at;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'title': title,
|
|
'icon': icon,
|
|
'space': space,
|
|
'spaceName': spaceName,
|
|
'at': at,
|
|
};
|
|
}
|
|
|
|
class Attachment {
|
|
const Attachment({
|
|
required this.id,
|
|
required this.page,
|
|
required this.name,
|
|
required this.mime,
|
|
required this.size,
|
|
required this.url,
|
|
required this.created,
|
|
});
|
|
|
|
factory Attachment.fromJson(Map<String, dynamic> json) => Attachment(
|
|
id: json['id'] as String,
|
|
page: json['page'] as String,
|
|
name: json['name'] as String,
|
|
mime: json['mime'] as String,
|
|
size: (json['size'] as num).toInt(),
|
|
url: json['url'] as String,
|
|
created: json['created'] as String,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String page;
|
|
|
|
final String name;
|
|
|
|
/// Detected from the content
|
|
final String mime;
|
|
|
|
/// Bytes
|
|
final int size;
|
|
|
|
/// API path, e.g. /api/v1/files/abc
|
|
final String url;
|
|
|
|
final String created;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'page': page,
|
|
'name': name,
|
|
'mime': mime,
|
|
'size': size,
|
|
'url': url,
|
|
'created': created,
|
|
};
|
|
}
|
|
|
|
class SearchHit {
|
|
const SearchHit({
|
|
required this.id,
|
|
required this.title,
|
|
required this.icon,
|
|
required this.space,
|
|
required this.spaceName,
|
|
required this.snippet,
|
|
required this.highlights,
|
|
required this.updated,
|
|
});
|
|
|
|
factory SearchHit.fromJson(Map<String, dynamic> json) => SearchHit(
|
|
id: json['id'] as String,
|
|
title: json['title'] as String,
|
|
icon: json['icon'] as String,
|
|
space: json['space'] as String,
|
|
spaceName: json['spaceName'] as String,
|
|
snippet: json['snippet'] as String,
|
|
highlights: (json['highlights'] as List)
|
|
.map((e) => (e as List).map((e) => (e as num).toInt()).toList())
|
|
.toList(),
|
|
updated: json['updated'] as String,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String title;
|
|
|
|
final String icon;
|
|
|
|
final String space;
|
|
|
|
final String spaceName;
|
|
|
|
/// Plain text around the first match
|
|
final String snippet;
|
|
|
|
/// [start, end) character offsets of matches in snippet
|
|
final List<List<int>> highlights;
|
|
|
|
final String updated;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'title': title,
|
|
'icon': icon,
|
|
'space': space,
|
|
'spaceName': spaceName,
|
|
'snippet': snippet,
|
|
'highlights': highlights.map((e) => e.map((e) => e).toList()).toList(),
|
|
'updated': updated,
|
|
};
|
|
}
|
|
|
|
class SearchResult {
|
|
const SearchResult({required this.items, required this.total});
|
|
|
|
factory SearchResult.fromJson(Map<String, dynamic> json) => SearchResult(
|
|
items: (json['items'] as List)
|
|
.map((e) => SearchHit.fromJson(e as Map<String, dynamic>))
|
|
.toList(),
|
|
total: (json['total'] as num).toInt(),
|
|
);
|
|
|
|
final List<SearchHit> items;
|
|
|
|
final int total;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'items': items.map((e) => e.toJson()).toList(),
|
|
'total': total,
|
|
};
|
|
}
|
|
|
|
class ShareLink {
|
|
const ShareLink({
|
|
required this.token,
|
|
required this.url,
|
|
required this.includeSubpages,
|
|
required this.created,
|
|
});
|
|
|
|
factory ShareLink.fromJson(Map<String, dynamic> json) => ShareLink(
|
|
token: json['token'] as String,
|
|
url: json['url'] as String,
|
|
includeSubpages: json['includeSubpages'] as bool,
|
|
created: json['created'] as String,
|
|
);
|
|
|
|
final String token;
|
|
|
|
/// The link on docwell-web (DOCWELL_WEB_URL/share/`<token>`)
|
|
final String url;
|
|
|
|
final bool includeSubpages;
|
|
|
|
final String created;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'token': token,
|
|
'url': url,
|
|
'includeSubpages': includeSubpages,
|
|
'created': created,
|
|
};
|
|
}
|
|
|
|
class SharedPage {
|
|
const SharedPage({
|
|
required this.id,
|
|
required this.title,
|
|
required this.icon,
|
|
required this.updated,
|
|
required this.content,
|
|
required this.root,
|
|
required this.pages,
|
|
});
|
|
|
|
factory SharedPage.fromJson(Map<String, dynamic> json) => SharedPage(
|
|
id: json['id'] as String,
|
|
title: json['title'] as String,
|
|
icon: json['icon'] as String,
|
|
updated: json['updated'] as String,
|
|
content: json['content'] == null
|
|
? null
|
|
: json['content'] as Map<String, dynamic>,
|
|
root: PageRef.fromJson(json['root'] as Map<String, dynamic>),
|
|
pages: (json['pages'] as List)
|
|
.map((e) => PageNode.fromJson(e as Map<String, dynamic>))
|
|
.toList(),
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String title;
|
|
|
|
final String icon;
|
|
|
|
final String updated;
|
|
|
|
/// Tiptap JSON; files load from /api/v1/share/{token}/files/{fileId}
|
|
final Map<String, dynamic>? content;
|
|
|
|
final PageRef root;
|
|
|
|
/// Pages under the shared page
|
|
final List<PageNode> pages;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'title': title,
|
|
'icon': icon,
|
|
'updated': updated,
|
|
'content': content,
|
|
'root': root.toJson(),
|
|
'pages': pages.map((e) => e.toJson()).toList(),
|
|
};
|
|
}
|
|
|
|
class Comment {
|
|
const Comment({
|
|
required this.id,
|
|
required this.parent,
|
|
required this.page,
|
|
required this.author,
|
|
required this.body,
|
|
required this.quote,
|
|
required this.anchor,
|
|
required this.created,
|
|
required this.editedAt,
|
|
required this.resolvedAt,
|
|
required this.resolvedBy,
|
|
required this.reactions,
|
|
required this.canEdit,
|
|
required this.canDelete,
|
|
required this.canResolve,
|
|
});
|
|
|
|
factory Comment.fromJson(Map<String, dynamic> json) => Comment(
|
|
id: json['id'] as String,
|
|
parent: json['parent'] as String,
|
|
page: json['page'] as String,
|
|
author: MemberUser.fromJson(json['author'] as Map<String, dynamic>),
|
|
body: json['body'] as String,
|
|
quote: json['quote'] as String,
|
|
anchor: json['anchor'] == null
|
|
? null
|
|
: json['anchor'] as Map<String, dynamic>,
|
|
created: json['created'] as String,
|
|
editedAt: json['editedAt'] as String,
|
|
resolvedAt: json['resolvedAt'] as String,
|
|
resolvedBy: json['resolvedBy'] == null
|
|
? null
|
|
: MemberUser.fromJson(json['resolvedBy'] as Map<String, dynamic>),
|
|
reactions: (json['reactions'] as List)
|
|
.map((e) => Reaction.fromJson(e as Map<String, dynamic>))
|
|
.toList(),
|
|
canEdit: json['canEdit'] as bool,
|
|
canDelete: json['canDelete'] as bool,
|
|
canResolve: json['canResolve'] as bool,
|
|
);
|
|
|
|
final String id;
|
|
|
|
/// The thread's first comment for a reply; empty for a thread
|
|
final String parent;
|
|
|
|
final String page;
|
|
|
|
final MemberUser author;
|
|
|
|
final String body;
|
|
|
|
final String quote;
|
|
|
|
/// As sent when the comment was created; null when there was none
|
|
final Map<String, dynamic>? anchor;
|
|
|
|
final String created;
|
|
|
|
/// Empty when never edited
|
|
final String editedAt;
|
|
|
|
/// Empty unless the thread is resolved
|
|
final String resolvedAt;
|
|
|
|
final MemberUser? resolvedBy;
|
|
|
|
/// Most used first
|
|
final List<Reaction> reactions;
|
|
|
|
final bool canEdit;
|
|
|
|
final bool canDelete;
|
|
|
|
/// A thread the caller may resolve or reopen
|
|
final bool canResolve;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'parent': parent,
|
|
'page': page,
|
|
'author': author.toJson(),
|
|
'body': body,
|
|
'quote': quote,
|
|
'anchor': anchor,
|
|
'created': created,
|
|
'editedAt': editedAt,
|
|
'resolvedAt': resolvedAt,
|
|
'resolvedBy': resolvedBy?.toJson(),
|
|
'reactions': reactions.map((e) => e.toJson()).toList(),
|
|
'canEdit': canEdit,
|
|
'canDelete': canDelete,
|
|
'canResolve': canResolve,
|
|
};
|
|
}
|
|
|
|
class Reaction {
|
|
const Reaction({
|
|
required this.emoji,
|
|
required this.count,
|
|
required this.mine,
|
|
required this.people,
|
|
});
|
|
|
|
factory Reaction.fromJson(Map<String, dynamic> json) => Reaction(
|
|
emoji: json['emoji'] as String,
|
|
count: (json['count'] as num).toInt(),
|
|
mine: json['mine'] as bool,
|
|
people: (json['people'] as List).map((e) => e as String).toList(),
|
|
);
|
|
|
|
final String emoji;
|
|
|
|
final int count;
|
|
|
|
final bool mine;
|
|
|
|
/// Names of the people who reacted
|
|
final List<String> people;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'emoji': emoji,
|
|
'count': count,
|
|
'mine': mine,
|
|
'people': people.map((e) => e).toList(),
|
|
};
|
|
}
|
|
|
|
class Template {
|
|
const Template({
|
|
required this.id,
|
|
required this.title,
|
|
required this.icon,
|
|
required this.space,
|
|
required this.spaceName,
|
|
});
|
|
|
|
factory Template.fromJson(Map<String, dynamic> json) => Template(
|
|
id: json['id'] as String,
|
|
title: json['title'] as String,
|
|
icon: json['icon'] as String,
|
|
space: json['space'] as String,
|
|
spaceName: json['spaceName'] as String,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final String title;
|
|
|
|
final String icon;
|
|
|
|
final String space;
|
|
|
|
final String spaceName;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'title': title,
|
|
'icon': icon,
|
|
'space': space,
|
|
'spaceName': spaceName,
|
|
};
|
|
}
|
|
|
|
class WatchState {
|
|
const WatchState({required this.watching});
|
|
|
|
factory WatchState.fromJson(Map<String, dynamic> json) =>
|
|
WatchState(watching: json['watching'] as bool);
|
|
|
|
final bool watching;
|
|
|
|
Map<String, dynamic> toJson() => {'watching': watching};
|
|
}
|
|
|
|
enum NotificationType {
|
|
comment('comment'),
|
|
reply('reply'),
|
|
mention('mention'),
|
|
share('share'),
|
|
resolved('resolved');
|
|
|
|
const NotificationType(this.value);
|
|
final String value;
|
|
|
|
static NotificationType fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () => throw FormatException('unknown NotificationType', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
class Notification {
|
|
const Notification({
|
|
required this.id,
|
|
required this.type,
|
|
required this.workspace,
|
|
required this.page,
|
|
required this.comment,
|
|
required this.actor,
|
|
required this.excerpt,
|
|
required this.created,
|
|
required this.read,
|
|
});
|
|
|
|
factory Notification.fromJson(Map<String, dynamic> json) => Notification(
|
|
id: json['id'] as String,
|
|
type: NotificationType.fromJson(json['type'] as String),
|
|
workspace: json['workspace'] as String,
|
|
page: json['page'] == null
|
|
? null
|
|
: PageRef.fromJson(json['page'] as Map<String, dynamic>),
|
|
comment: json['comment'] as String,
|
|
actor: json['actor'] == null
|
|
? null
|
|
: MemberUser.fromJson(json['actor'] as Map<String, dynamic>),
|
|
excerpt: json['excerpt'] as String,
|
|
created: json['created'] as String,
|
|
read: json['read'] as bool,
|
|
);
|
|
|
|
final String id;
|
|
|
|
final NotificationType type;
|
|
|
|
final String workspace;
|
|
|
|
/// Null when the page is gone or the caller lost access to it
|
|
final PageRef? page;
|
|
|
|
/// The comment it is about
|
|
final String comment;
|
|
|
|
final MemberUser? actor;
|
|
|
|
final String excerpt;
|
|
|
|
final String created;
|
|
|
|
final bool read;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'type': type.toJson(),
|
|
'workspace': workspace,
|
|
'page': page?.toJson(),
|
|
'comment': comment,
|
|
'actor': actor?.toJson(),
|
|
'excerpt': excerpt,
|
|
'created': created,
|
|
'read': read,
|
|
};
|
|
}
|
|
|
|
class NotificationList {
|
|
const NotificationList({required this.items, required this.unread});
|
|
|
|
factory NotificationList.fromJson(Map<String, dynamic> json) =>
|
|
NotificationList(
|
|
items: (json['items'] as List)
|
|
.map((e) => Notification.fromJson(e as Map<String, dynamic>))
|
|
.toList(),
|
|
unread: (json['unread'] as num).toInt(),
|
|
);
|
|
|
|
final List<Notification> items;
|
|
|
|
final int unread;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'items': items.map((e) => e.toJson()).toList(),
|
|
'unread': unread,
|
|
};
|
|
}
|
|
|
|
/// Unread notifications by email every few minutes
|
|
enum NotificationSettingsEmail {
|
|
digest('digest'),
|
|
off('off');
|
|
|
|
const NotificationSettingsEmail(this.value);
|
|
final String value;
|
|
|
|
static NotificationSettingsEmail fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () =>
|
|
throw FormatException('unknown NotificationSettingsEmail', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
class NotificationSettings {
|
|
const NotificationSettings({required this.email});
|
|
|
|
factory NotificationSettings.fromJson(Map<String, dynamic> json) =>
|
|
NotificationSettings(
|
|
email: NotificationSettingsEmail.fromJson(json['email'] as String),
|
|
);
|
|
|
|
/// Unread notifications by email every few minutes
|
|
final NotificationSettingsEmail email;
|
|
|
|
Map<String, dynamic> toJson() => {'email': email.toJson()};
|
|
}
|
|
|
|
enum AdminStatsScope {
|
|
instance('instance'),
|
|
organization('organization');
|
|
|
|
const AdminStatsScope(this.value);
|
|
final String value;
|
|
|
|
static AdminStatsScope fromJson(String value) => values.firstWhere(
|
|
(e) => e.value == value,
|
|
orElse: () => throw FormatException('unknown AdminStatsScope', value),
|
|
);
|
|
|
|
String toJson() => value;
|
|
}
|
|
|
|
class AdminStats {
|
|
const AdminStats({
|
|
required this.scope,
|
|
required this.users,
|
|
required this.organizations,
|
|
required this.workspaces,
|
|
required this.spaces,
|
|
required this.pages,
|
|
required this.attachments,
|
|
required this.storageBytes,
|
|
required this.rooms,
|
|
required this.editors,
|
|
required this.indexed,
|
|
});
|
|
|
|
factory AdminStats.fromJson(Map<String, dynamic> json) => AdminStats(
|
|
scope: AdminStatsScope.fromJson(json['scope'] as String),
|
|
users: (json['users'] as num).toInt(),
|
|
organizations: (json['organizations'] as num).toInt(),
|
|
workspaces: (json['workspaces'] as num).toInt(),
|
|
spaces: (json['spaces'] as num).toInt(),
|
|
pages: (json['pages'] as num).toInt(),
|
|
attachments: (json['attachments'] as num).toInt(),
|
|
storageBytes: (json['storageBytes'] as num).toInt(),
|
|
rooms: (json['rooms'] as num).toInt(),
|
|
editors: (json['editors'] as num).toInt(),
|
|
indexed: (json['indexed'] as num).toInt(),
|
|
);
|
|
|
|
final AdminStatsScope scope;
|
|
|
|
final int users;
|
|
|
|
final int organizations;
|
|
|
|
final int workspaces;
|
|
|
|
final int spaces;
|
|
|
|
/// Pages outside the trash
|
|
final int pages;
|
|
|
|
final int attachments;
|
|
|
|
/// Total size of attachments
|
|
final int storageBytes;
|
|
|
|
/// Pages open for editing now (instance scope only)
|
|
final int rooms;
|
|
|
|
/// People connected to those pages (instance scope only)
|
|
final int editors;
|
|
|
|
/// Pages in the search index (instance scope only)
|
|
final int indexed;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'scope': scope.toJson(),
|
|
'users': users,
|
|
'organizations': organizations,
|
|
'workspaces': workspaces,
|
|
'spaces': spaces,
|
|
'pages': pages,
|
|
'attachments': attachments,
|
|
'storageBytes': storageBytes,
|
|
'rooms': rooms,
|
|
'editors': editors,
|
|
'indexed': indexed,
|
|
};
|
|
}
|
|
|
|
class AdminHealthDatabase {
|
|
const AdminHealthDatabase({
|
|
required this.ok,
|
|
required this.latencyMs,
|
|
this.error,
|
|
});
|
|
|
|
factory AdminHealthDatabase.fromJson(Map<String, dynamic> json) =>
|
|
AdminHealthDatabase(
|
|
ok: json['ok'] as bool,
|
|
latencyMs: (json['latencyMs'] as num).toInt(),
|
|
error: json['error'] == null ? null : json['error'] as String,
|
|
);
|
|
|
|
final bool ok;
|
|
|
|
final int latencyMs;
|
|
|
|
final String? error;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'ok': ok,
|
|
'latencyMs': latencyMs,
|
|
'error': ?error,
|
|
};
|
|
}
|
|
|
|
class AdminHealth {
|
|
const AdminHealth({
|
|
required this.version,
|
|
required this.goVersion,
|
|
required this.started,
|
|
required this.uptimeSeconds,
|
|
required this.database,
|
|
required this.goroutines,
|
|
required this.memoryMb,
|
|
});
|
|
|
|
factory AdminHealth.fromJson(Map<String, dynamic> json) => AdminHealth(
|
|
version: json['version'] as String,
|
|
goVersion: json['goVersion'] as String,
|
|
started: json['started'] as String,
|
|
uptimeSeconds: (json['uptimeSeconds'] as num).toInt(),
|
|
database: AdminHealthDatabase.fromJson(
|
|
json['database'] as Map<String, dynamic>,
|
|
),
|
|
goroutines: (json['goroutines'] as num).toInt(),
|
|
memoryMb: (json['memoryMb'] as num).toInt(),
|
|
);
|
|
|
|
final String version;
|
|
|
|
final String goVersion;
|
|
|
|
final String started;
|
|
|
|
final int uptimeSeconds;
|
|
|
|
final AdminHealthDatabase database;
|
|
|
|
final int goroutines;
|
|
|
|
final int memoryMb;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'version': version,
|
|
'goVersion': goVersion,
|
|
'started': started,
|
|
'uptimeSeconds': uptimeSeconds,
|
|
'database': database.toJson(),
|
|
'goroutines': goroutines,
|
|
'memoryMb': memoryMb,
|
|
};
|
|
}
|
|
|
|
class Job {
|
|
const Job({
|
|
required this.name,
|
|
required this.description,
|
|
required this.every,
|
|
required this.runnable,
|
|
required this.running,
|
|
required this.runs,
|
|
required this.failures,
|
|
required this.lastStarted,
|
|
required this.lastDurationMs,
|
|
required this.lastError,
|
|
});
|
|
|
|
factory Job.fromJson(Map<String, dynamic> json) => Job(
|
|
name: json['name'] as String,
|
|
description: json['description'] as String,
|
|
every: json['every'] as String,
|
|
runnable: json['runnable'] as bool,
|
|
running: json['running'] as bool,
|
|
runs: (json['runs'] as num).toInt(),
|
|
failures: (json['failures'] as num).toInt(),
|
|
lastStarted: json['lastStarted'] as String,
|
|
lastDurationMs: (json['lastDurationMs'] as num).toInt(),
|
|
lastError: json['lastError'] as String,
|
|
);
|
|
|
|
final String name;
|
|
|
|
final String description;
|
|
|
|
/// How often it runs on its own (Go duration); empty when only on demand
|
|
final String every;
|
|
|
|
/// Can be started by hand
|
|
final bool runnable;
|
|
|
|
final bool running;
|
|
|
|
/// Runs since the server started
|
|
final int runs;
|
|
|
|
final int failures;
|
|
|
|
/// RFC 3339; empty before the first run
|
|
final String lastStarted;
|
|
|
|
final int lastDurationMs;
|
|
|
|
final String lastError;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'name': name,
|
|
'description': description,
|
|
'every': every,
|
|
'runnable': runnable,
|
|
'running': running,
|
|
'runs': runs,
|
|
'failures': failures,
|
|
'lastStarted': lastStarted,
|
|
'lastDurationMs': lastDurationMs,
|
|
'lastError': lastError,
|
|
};
|
|
}
|
|
|
|
class Backup {
|
|
const Backup({required this.key, required this.size, required this.modified});
|
|
|
|
factory Backup.fromJson(Map<String, dynamic> json) => Backup(
|
|
key: json['key'] as String,
|
|
size: (json['size'] as num).toInt(),
|
|
modified: json['modified'] as String,
|
|
);
|
|
|
|
final String key;
|
|
|
|
final int size;
|
|
|
|
final String modified;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'key': key,
|
|
'size': size,
|
|
'modified': modified,
|
|
};
|
|
}
|