1
import {
2
	ModelInit,
3
	MutableModel,
4
	PersistentModelConstructor,
5
} from '@aws-amplify/datastore';
6

7 1
import { initSchema, NonModelTypeConstructor } from '../src/index';
8 1
import { newSchema } from './schema';
9

10
declare class BlogModel {
11
	readonly id: string;
12
	readonly name: string;
13
	readonly posts?: PostModel[];
14
	readonly owner: BlogOwnerModel;
15
	constructor(init: ModelInit<BlogModel>);
16
	static copyOf(
17
		source: BlogModel,
18
		mutator: (draft: MutableModel<BlogModel>) => MutableModel<BlogModel> | void
19
	): BlogModel;
20
}
21

22
declare class PostModel {
23
	readonly id: string;
24
	readonly title: string;
25
	readonly blog?: BlogModel;
26
	readonly reference?: PostModel;
27
	readonly comments?: CommentModel[];
28
	readonly authors?: PostAuthorJoinModel[];
29
	readonly metadata?: PostMetadataType;
30
	constructor(init: ModelInit<PostModel>);
31
	static copyOf(
32
		source: PostModel,
33
		mutator: (draft: MutableModel<PostModel>) => MutableModel<PostModel> | void
34
	): PostModel;
35
}
36

37
declare class PostMetadataType {
38
	readonly rating: number;
39
	readonly tags?: string[];
40
	readonly nested?: NestedType;
41
	constructor(init: ModelInit<PostMetadataType>);
42
}
43

44
declare class NestedType {
45
	readonly aField: string;
46
	constructor(init: ModelInit<NestedType>);
47
}
48

49
declare class CommentModel {
50
	readonly id: string;
51
	readonly content?: string;
52
	readonly post?: PostModel;
53
	constructor(init: ModelInit<CommentModel>);
54
	static copyOf(
55
		source: CommentModel,
56
		mutator: (
57
			draft: MutableModel<CommentModel>
58
		) => MutableModel<CommentModel> | void
59
	): CommentModel;
60
}
61

62
declare class PostAuthorJoinModel {
63
	readonly id: string;
64
	readonly author?: AuthorModel;
65
	readonly post?: PostModel;
66
	constructor(init: ModelInit<PostAuthorJoinModel>);
67
	static copyOf(
68
		source: PostAuthorJoinModel,
69
		mutator: (
70
			draft: MutableModel<PostAuthorJoinModel>
71
		) => MutableModel<PostAuthorJoinModel> | void
72
	): PostAuthorJoinModel;
73
}
74

75
declare class AuthorModel {
76
	readonly id: string;
77
	readonly name: string;
78
	readonly posts?: PostAuthorJoinModel[];
79
	constructor(init: ModelInit<AuthorModel>);
80
	static copyOf(
81
		source: AuthorModel,
82
		mutator: (
83
			draft: MutableModel<AuthorModel>
84
		) => MutableModel<AuthorModel> | void
85
	): AuthorModel;
86
}
87

88
declare class BlogOwnerModel {
89
	readonly name: string;
90
	readonly id: string;
91
	readonly blog?: BlogModel;
92
	constructor(init: ModelInit<BlogOwnerModel>);
93
	static copyOf(
94
		source: BlogOwnerModel,
95
		mutator: (
96
			draft: MutableModel<BlogOwnerModel>
97
		) => MutableModel<BlogOwnerModel> | void
98
	): BlogOwnerModel;
99
}
100

101
declare class PersonModel {
102
	readonly id: string;
103
	readonly firstName: string;
104
	readonly lastName: string;
105
	readonly username?: string;
106
}
107

108 1
const {
109 1
	Author,
110 1
	Post,
111 1
	Comment,
112 1
	Blog,
113 1
	BlogOwner,
114 1
	PostAuthorJoin,
115 1
	Person,
116 1
	PostMetadata,
117 1
	Nested,
118
} = initSchema(newSchema) as {
119
	Author: PersistentModelConstructor<AuthorModel>;
120
	Post: PersistentModelConstructor<PostModel>;
121
	Comment: PersistentModelConstructor<CommentModel>;
122
	Blog: PersistentModelConstructor<BlogModel>;
123
	BlogOwner: PersistentModelConstructor<BlogOwnerModel>;
124
	PostAuthorJoin: PersistentModelConstructor<PostAuthorJoinModel>;
125
	Person: PersistentModelConstructor<PersonModel>;
126
	PostMetadata: NonModelTypeConstructor<PostMetadataType>;
127
	Nested: NonModelTypeConstructor<NestedType>;
128
};
129 1
``;
130
export {
131 1
	Author,
132 1
	Post,
133 1
	Comment,
134 1
	Blog,
135 1
	BlogOwner,
136 1
	PostAuthorJoin,
137 1
	Person,
138 1
	PostMetadata,
139 1
	Nested,
140
};

Read our documentation on viewing source code .

Loading