ocean-brain 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +42 -0
- package/package.json +33 -0
- package/server/client/dist/assets/index-BBmw_0Bo.css +1 -0
- package/server/client/dist/assets/index-TKn2sngc.js +393 -0
- package/server/client/dist/assets/module-RjUF93sV.js +716 -0
- package/server/client/dist/assets/native-48B9X9Wg.js +1 -0
- package/server/client/dist/assets/note-core-DTIu0anW.js +178 -0
- package/server/client/dist/assets/note-vendor-DhbUD4OO.js +54 -0
- package/server/client/dist/fonts/Pretendard-Bold.woff +0 -0
- package/server/client/dist/fonts/Pretendard-Bold.woff2 +0 -0
- package/server/client/dist/fonts/Pretendard-Regular.woff +0 -0
- package/server/client/dist/fonts/Pretendard-Regular.woff2 +0 -0
- package/server/client/dist/icon.png +0 -0
- package/server/client/dist/index.html +19 -0
- package/server/dist/app.js +18 -0
- package/server/dist/app.js.map +1 -0
- package/server/dist/main.js +5 -0
- package/server/dist/main.js.map +1 -0
- package/server/dist/models.js +8 -0
- package/server/dist/models.js.map +1 -0
- package/server/dist/modules/auth.js +16 -0
- package/server/dist/modules/auth.js.map +1 -0
- package/server/dist/modules/graphql.js +7 -0
- package/server/dist/modules/graphql.js.map +1 -0
- package/server/dist/modules/logger.js +72 -0
- package/server/dist/modules/logger.js.map +1 -0
- package/server/dist/modules/use-async.js +13 -0
- package/server/dist/modules/use-async.js.map +1 -0
- package/server/dist/paths.js +14 -0
- package/server/dist/paths.js.map +1 -0
- package/server/dist/schema/cache/index.js +58 -0
- package/server/dist/schema/cache/index.js.map +1 -0
- package/server/dist/schema/image/index.js +88 -0
- package/server/dist/schema/image/index.js.map +1 -0
- package/server/dist/schema/index.js +30 -0
- package/server/dist/schema/index.js.map +1 -0
- package/server/dist/schema/note/index.js +400 -0
- package/server/dist/schema/note/index.js.map +1 -0
- package/server/dist/schema/placeholder/index.js +105 -0
- package/server/dist/schema/placeholder/index.js.map +1 -0
- package/server/dist/schema/reminder/index.js +161 -0
- package/server/dist/schema/reminder/index.js.map +1 -0
- package/server/dist/schema/tag/index.js +81 -0
- package/server/dist/schema/tag/index.js.map +1 -0
- package/server/dist/types/index.js +2 -0
- package/server/dist/types/index.js.map +1 -0
- package/server/dist/types/input.js +1 -0
- package/server/dist/types/input.js.map +1 -0
- package/server/dist/urls.js +8 -0
- package/server/dist/urls.js.map +1 -0
- package/server/dist/views/image.js +101 -0
- package/server/dist/views/image.js.map +1 -0
- package/server/dist/views/index.js +2 -0
- package/server/dist/views/index.js.map +1 -0
- package/server/prisma/migrations/20230521193126_0000/migration.sql +24 -0
- package/server/prisma/migrations/20240317022222_0001/migration.sql +8 -0
- package/server/prisma/migrations/20240317094153_0002/migration.sql +8 -0
- package/server/prisma/migrations/20240318110450_0003/migration.sql +21 -0
- package/server/prisma/migrations/20240414044922_0004/migration.sql +15 -0
- package/server/prisma/migrations/20241115130540_0005/migration.sql +25 -0
- package/server/prisma/migrations/20250416124833_0006/migration.sql +29 -0
- package/server/prisma/migrations/20250711131318_0007/migration.sql +12 -0
- package/server/prisma/migrations/20251024192500_0008/migration.sql +2 -0
- package/server/prisma/migrations/20251026050237_0009/migration.sql +18 -0
- package/server/prisma/migrations/migration_lock.toml +3 -0
- package/server/prisma/schema.prisma +78 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import models from "../../models.js";
|
|
2
|
+
import { gql } from "../../modules/graphql.js";
|
|
3
|
+
const reminderType = gql`
|
|
4
|
+
enum ReminderPriority {
|
|
5
|
+
low
|
|
6
|
+
medium
|
|
7
|
+
high
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type Reminder {
|
|
11
|
+
id: ID!
|
|
12
|
+
noteId: Int!
|
|
13
|
+
reminderDate: String!
|
|
14
|
+
completed: Boolean!
|
|
15
|
+
priority: ReminderPriority
|
|
16
|
+
content: String
|
|
17
|
+
createdAt: String!
|
|
18
|
+
updatedAt: String!
|
|
19
|
+
note: Note
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type Reminders {
|
|
23
|
+
totalCount: Int!
|
|
24
|
+
reminders: [Reminder!]!
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
const reminderQuery = gql`
|
|
28
|
+
extend type Query {
|
|
29
|
+
noteReminders(noteId: ID!, pagination: PaginationInput): Reminders!
|
|
30
|
+
upcomingReminders(pagination: PaginationInput): Reminders!
|
|
31
|
+
remindersInDateRange(dateRange: DateRangeInput): [Reminder!]!
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const reminderMutation = gql`
|
|
35
|
+
extend type Mutation {
|
|
36
|
+
createReminder(noteId: ID!, reminderDate: String!, priority: ReminderPriority, content: String): Reminder!
|
|
37
|
+
updateReminder(id: ID!, reminderDate: String, completed: Boolean, priority: ReminderPriority, content: String): Reminder!
|
|
38
|
+
deleteReminder(id: ID!): Boolean!
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
const reminderTypeDefs = `
|
|
42
|
+
${reminderType}
|
|
43
|
+
${reminderQuery}
|
|
44
|
+
${reminderMutation}
|
|
45
|
+
`;
|
|
46
|
+
const reminderResolvers = {
|
|
47
|
+
Query: {
|
|
48
|
+
noteReminders: async (_, {
|
|
49
|
+
noteId,
|
|
50
|
+
pagination = {
|
|
51
|
+
limit: 10,
|
|
52
|
+
offset: 0
|
|
53
|
+
}
|
|
54
|
+
}) => {
|
|
55
|
+
const where = { noteId: Number(noteId) };
|
|
56
|
+
const $reminders = models.reminder.findMany({
|
|
57
|
+
where,
|
|
58
|
+
orderBy: { reminderDate: "asc" },
|
|
59
|
+
take: Number(pagination.limit),
|
|
60
|
+
skip: Number(pagination.offset)
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
totalCount: models.reminder.count({ where }),
|
|
64
|
+
reminders: $reminders
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
upcomingReminders: async (_, {
|
|
68
|
+
pagination = {
|
|
69
|
+
limit: 10,
|
|
70
|
+
offset: 0
|
|
71
|
+
}
|
|
72
|
+
}) => {
|
|
73
|
+
const where = { completed: false };
|
|
74
|
+
const $reminders = models.reminder.findMany({
|
|
75
|
+
where,
|
|
76
|
+
orderBy: { reminderDate: "asc" },
|
|
77
|
+
take: Number(pagination.limit),
|
|
78
|
+
skip: Number(pagination.offset),
|
|
79
|
+
include: { note: true }
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
totalCount: models.reminder.count({ where }),
|
|
83
|
+
reminders: $reminders
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
remindersInDateRange: async (_, { dateRange }) => {
|
|
87
|
+
const where = {
|
|
88
|
+
reminderDate: {
|
|
89
|
+
gte: new Date(dateRange.start),
|
|
90
|
+
lt: new Date(dateRange.end)
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const $reminders = await models.reminder.findMany({
|
|
94
|
+
where,
|
|
95
|
+
orderBy: { reminderDate: "asc" },
|
|
96
|
+
include: { note: true }
|
|
97
|
+
});
|
|
98
|
+
return $reminders;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
Mutation: {
|
|
102
|
+
createReminder: async (_, {
|
|
103
|
+
noteId,
|
|
104
|
+
reminderDate,
|
|
105
|
+
priority,
|
|
106
|
+
content
|
|
107
|
+
}) => {
|
|
108
|
+
return models.reminder.create({
|
|
109
|
+
data: {
|
|
110
|
+
noteId: Number(noteId),
|
|
111
|
+
reminderDate: new Date(reminderDate),
|
|
112
|
+
completed: false,
|
|
113
|
+
priority: priority || "medium",
|
|
114
|
+
content
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
updateReminder: async (_, {
|
|
119
|
+
id,
|
|
120
|
+
reminderDate,
|
|
121
|
+
completed,
|
|
122
|
+
priority,
|
|
123
|
+
content
|
|
124
|
+
}) => {
|
|
125
|
+
const data = {};
|
|
126
|
+
if (reminderDate) {
|
|
127
|
+
data.reminderDate = new Date(reminderDate);
|
|
128
|
+
}
|
|
129
|
+
if (completed !== void 0) {
|
|
130
|
+
data.completed = completed;
|
|
131
|
+
}
|
|
132
|
+
if (priority) {
|
|
133
|
+
data.priority = priority;
|
|
134
|
+
}
|
|
135
|
+
if (content !== void 0) {
|
|
136
|
+
data.content = content;
|
|
137
|
+
}
|
|
138
|
+
return models.reminder.update({
|
|
139
|
+
where: { id: Number(id) },
|
|
140
|
+
data
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
deleteReminder: async (_, { id }) => {
|
|
144
|
+
await models.reminder.delete({ where: { id: Number(id) } });
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
Reminder: {
|
|
149
|
+
note: async (reminder) => {
|
|
150
|
+
return models.note.findUnique({ where: { id: reminder.noteId } });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
export {
|
|
155
|
+
reminderMutation,
|
|
156
|
+
reminderQuery,
|
|
157
|
+
reminderResolvers,
|
|
158
|
+
reminderType,
|
|
159
|
+
reminderTypeDefs
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/schema/reminder/index.ts"],"sourcesContent":["import type { IResolvers } from '@graphql-tools/utils';\n\nimport type { Reminder } from '~/models.js';\nimport models from '~/models.js';\nimport { gql } from '~/modules/graphql.js';\n\nimport type { Pagination } from '~/types/index.js';\n\nexport const reminderType = gql`\n enum ReminderPriority {\n low\n medium\n high\n }\n\n type Reminder {\n id: ID!\n noteId: Int!\n reminderDate: String!\n completed: Boolean!\n priority: ReminderPriority\n content: String\n createdAt: String!\n updatedAt: String!\n note: Note\n }\n\n type Reminders {\n totalCount: Int!\n reminders: [Reminder!]!\n }\n`;\n\nexport const reminderQuery = gql`\n extend type Query {\n noteReminders(noteId: ID!, pagination: PaginationInput): Reminders!\n upcomingReminders(pagination: PaginationInput): Reminders!\n remindersInDateRange(dateRange: DateRangeInput): [Reminder!]!\n }\n`;\n\nexport const reminderMutation = gql`\n extend type Mutation {\n createReminder(noteId: ID!, reminderDate: String!, priority: ReminderPriority, content: String): Reminder!\n updateReminder(id: ID!, reminderDate: String, completed: Boolean, priority: ReminderPriority, content: String): Reminder!\n deleteReminder(id: ID!): Boolean!\n }\n`;\n\nexport const reminderTypeDefs = `\n ${reminderType}\n ${reminderQuery}\n ${reminderMutation}\n`;\n\nexport const reminderResolvers: IResolvers = {\n Query: {\n noteReminders: async (_, {\n noteId,\n pagination = {\n limit: 10,\n offset: 0\n }\n }: {\n noteId: string;\n pagination: Pagination;\n }) => {\n const where = { noteId: Number(noteId) };\n\n const $reminders = models.reminder.findMany({\n where,\n orderBy: { reminderDate: 'asc' },\n take: Number(pagination.limit),\n skip: Number(pagination.offset)\n });\n\n return {\n totalCount: models.reminder.count({ where }),\n reminders: $reminders\n };\n },\n upcomingReminders: async (_, {\n pagination = {\n limit: 10,\n offset: 0\n }\n }: {\n pagination: Pagination;\n }) => {\n const where = { completed: false };\n\n const $reminders = models.reminder.findMany({\n where,\n orderBy: { reminderDate: 'asc' },\n take: Number(pagination.limit),\n skip: Number(pagination.offset),\n include: { note: true }\n });\n\n return {\n totalCount: models.reminder.count({ where }),\n reminders: $reminders\n };\n },\n remindersInDateRange: async (_, { dateRange }: {\n dateRange: {\n start: string;\n end: string;\n };\n }) => {\n const where = {\n reminderDate: {\n gte: new Date(dateRange.start),\n lt: new Date(dateRange.end)\n }\n };\n\n const $reminders = await models.reminder.findMany({\n where,\n orderBy: { reminderDate: 'asc' },\n include: { note: true }\n });\n\n return $reminders;\n }\n },\n Mutation: {\n createReminder: async (_, {\n noteId,\n reminderDate,\n priority,\n content\n }: {\n noteId: string;\n reminderDate: string;\n priority?: 'low' | 'medium' | 'high';\n content?: string;\n }) => {\n return models.reminder.create({\n data: {\n noteId: Number(noteId),\n reminderDate: new Date(reminderDate),\n completed: false,\n priority: priority || 'medium',\n content\n }\n });\n },\n updateReminder: async (_, {\n id,\n reminderDate,\n completed,\n priority,\n content\n }: {\n id: string;\n reminderDate?: string;\n completed?: boolean;\n priority?: 'low' | 'medium' | 'high';\n content?: string;\n }) => {\n const data: Partial<Reminder> = {};\n\n if (reminderDate) {\n data.reminderDate = new Date(reminderDate);\n }\n\n if (completed !== undefined) {\n data.completed = completed;\n }\n\n if (priority) {\n data.priority = priority;\n }\n\n if (content !== undefined) {\n data.content = content;\n }\n\n return models.reminder.update({\n where: { id: Number(id) },\n data\n });\n },\n deleteReminder: async (_, { id }: { id: string }) => {\n await models.reminder.delete({ where: { id: Number(id) } });\n return true;\n }\n },\n Reminder: {\n note: async (reminder) => {\n return models.note.findUnique({ where: { id: reminder.noteId } });\n }\n }\n};\n"],"mappings":"AAGA,OAAO,YAAY;AACnB,SAAS,WAAW;AAIb,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBrB,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQtB,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQzB,MAAM,mBAAmB;AAAA,MAC1B,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,gBAAgB;AAAA;AAGf,MAAM,oBAAgC;AAAA,EACzC,OAAO;AAAA,IACH,eAAe,OAAO,GAAG;AAAA,MACrB;AAAA,MACA,aAAa;AAAA,QACT,OAAO;AAAA,QACP,QAAQ;AAAA,MACZ;AAAA,IACJ,MAGM;AACF,YAAM,QAAQ,EAAE,QAAQ,OAAO,MAAM,EAAE;AAEvC,YAAM,aAAa,OAAO,SAAS,SAAS;AAAA,QACxC;AAAA,QACA,SAAS,EAAE,cAAc,MAAM;AAAA,QAC/B,MAAM,OAAO,WAAW,KAAK;AAAA,QAC7B,MAAM,OAA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A,UACX,UAAU,YAAY;AAAA,UACtB;AAAA,QACJ;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IACA,gBAAgB,OAAO,GAAG;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,MAMM;AACF,YAAM,OAA0B,CAAC;AAEjC,UAAI,cAAc;AACd,aAAK,eAAe,IAAI,KAAK,YAAY;AAAA,MAC7C;AAEA,UAAI,cAAc,QAAW;AACzB,aAAK,YAAY;AAAA,MACrB;AAEA,UAAI,UAAU;AACV,aAAK,WAAW;AAAA,MACpB;AAEA,UAAI,YAAY,QAAW;AACvB,aAAK,UAAU;AAAA,MACnB;AAEA,aAAO,OAAO,SAAS,OAAO;AAAA,QAC1B,OAAO,EAAE,IAAI,OAAO,EAAE,EAAE;AAAA,QACxB;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IACA,gBAAgB,OAAO,GAAG,EAAE,GAAG,MAAsB;AACjD,YAAM,OAAO,SAAS,OAAO,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE,EAAE,EAAE,CAAC;AAC1D,aAAO;AAAA,IACX;AAAA,EACJ;AAAA,EACA,UAAU;AAAA,IACN,MAAM,OAAO,aAAa;AACtB,aAAO,OAAO,KAAK,WAAW,EAAE,OAAO,EAAE,IAAI,SAAS,OAAO,EAAE,CAAC;AAAA,IACpE;AAAA,EACJ;AACJ;","names":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import models from "../../models.js";
|
|
2
|
+
import { gql } from "../../modules/graphql.js";
|
|
3
|
+
const tagType = gql`
|
|
4
|
+
input PaginationInput {
|
|
5
|
+
limit: Int!
|
|
6
|
+
offset: Int!
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
input SearchFilterInput {
|
|
10
|
+
query: String!
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Tag {
|
|
14
|
+
id: ID!
|
|
15
|
+
name: String!
|
|
16
|
+
createdAt: String!
|
|
17
|
+
updatedAt: String!
|
|
18
|
+
referenceCount: Int!
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type Tags {
|
|
22
|
+
totalCount: Int!
|
|
23
|
+
tags: [Tag!]!
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
const tagQuery = gql`
|
|
27
|
+
type Query {
|
|
28
|
+
allTags(searchFilter: SearchFilterInput, pagination: PaginationInput): Tags!
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const tagMutation = gql`
|
|
32
|
+
type Mutation {
|
|
33
|
+
createTag(name: String!): Tag!
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
const tagTypeDefs = `
|
|
37
|
+
${tagType}
|
|
38
|
+
${tagQuery}
|
|
39
|
+
${tagMutation}
|
|
40
|
+
`;
|
|
41
|
+
const tagResolvers = {
|
|
42
|
+
Query: {
|
|
43
|
+
allTags: async (_, {
|
|
44
|
+
searchFilter,
|
|
45
|
+
pagination
|
|
46
|
+
}) => {
|
|
47
|
+
const where = {
|
|
48
|
+
name: { contains: searchFilter.query },
|
|
49
|
+
NOT: { notes: { none: {} } }
|
|
50
|
+
};
|
|
51
|
+
const $tags = models.tag.findMany({
|
|
52
|
+
skip: pagination.offset,
|
|
53
|
+
take: pagination.limit,
|
|
54
|
+
where,
|
|
55
|
+
orderBy: { notes: { _count: "desc" } }
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
totalCount: await models.tag.count({ where }),
|
|
59
|
+
tags: await $tags
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
Mutation: {
|
|
64
|
+
createTag: async (_, { name }) => {
|
|
65
|
+
return models.tag.create({ data: { name } });
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
Tag: {
|
|
69
|
+
referenceCount: async (tag) => {
|
|
70
|
+
return models.note.count({ where: { tags: { some: { id: tag.id } } } });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
tagMutation,
|
|
76
|
+
tagQuery,
|
|
77
|
+
tagResolvers,
|
|
78
|
+
tagType,
|
|
79
|
+
tagTypeDefs
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/schema/tag/index.ts"],"sourcesContent":["import type { IResolvers } from '@graphql-tools/utils';\n\nimport models, { type Tag, type Prisma } from '~/models.js';\nimport { gql } from '~/modules/graphql.js';\nimport type { Pagination, SearchFilter } from '~/types/index.js';\n\nexport const tagType = gql`\n input PaginationInput {\n limit: Int!\n offset: Int!\n }\n\n input SearchFilterInput {\n query: String!\n }\n\n type Tag {\n id: ID!\n name: String!\n createdAt: String!\n updatedAt: String!\n referenceCount: Int!\n }\n\n type Tags {\n totalCount: Int!\n tags: [Tag!]!\n }\n`;\n\nexport const tagQuery = gql`\n type Query {\n allTags(searchFilter: SearchFilterInput, pagination: PaginationInput): Tags!\n }\n`;\n\nexport const tagMutation = gql`\n type Mutation {\n createTag(name: String!): Tag!\n }\n`;\n\nexport const tagTypeDefs = `\n ${tagType}\n ${tagQuery}\n ${tagMutation}\n`;\n\nexport const tagResolvers: IResolvers = {\n Query: {\n allTags: async (_, {\n searchFilter,\n pagination\n }: {\n searchFilter: SearchFilter;\n pagination: Pagination;\n }) => {\n const where: Prisma.TagWhereInput = {\n name: { contains: searchFilter.query },\n NOT: { notes: { none: { } } }\n };\n const $tags = models.tag.findMany({\n skip: pagination.offset,\n take: pagination.limit,\n where,\n orderBy: { notes: { _count: 'desc' } }\n });\n\n return {\n totalCount: await models.tag.count({ where }),\n tags: await $tags\n };\n }\n },\n Mutation: {\n createTag: async (_, { name }: Tag) => {\n return models.tag.create({ data: { name } });\n }\n },\n Tag: {\n referenceCount: async (tag: Tag) => {\n return models.note.count({ where: { tags: { some: { id: tag.id } } } });\n }\n }\n};\n"],"mappings":"AAEA,OAAO,YAAuC;AAC9C,SAAS,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 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { Request, Response, NextFunction } from 'express';\n\ndeclare module 'express-session' {\n interface SessionData {\n user: {\n id: number;\n name: string;\n email: string;\n createdAt: Date;\n updatedAt: Date;\n };\n }\n}\n\nexport type Controller = (req: Request, res: Response, next?: NextFunction) => Promise<void>;\n\nexport * from './input.js';\n"],"mappings":"AAgBA,cAAc;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import * as views from "./views/index.js";
|
|
3
|
+
import useAsync from "./modules/use-async.js";
|
|
4
|
+
var urls_default = Router().post("/image", useAsync(views.uploadImage)).post("/image-from-src", useAsync(views.uploadImageFromSrc));
|
|
5
|
+
export {
|
|
6
|
+
urls_default as default
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=urls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/urls.ts"],"sourcesContent":["import { Router } from 'express';\nimport * as views from './views/index.js';\nimport useAsync from './modules/use-async.js';\n\nexport default Router()\n .post('/image', useAsync(views.uploadImage))\n .post('/image-from-src', useAsync(views.uploadImageFromSrc));\n"],"mappings":"AAAA,SAAS,cAAc;AACvB,YAAY,WAAW;AACvB,OAAO,cAAc;AAErB,IAAO,eAAQ,OAAO,EACjB,KAAK,UAAU,SAAS,MAAM,WAAW,CAAC,EAC1C,KAAK,mBAAmB,SAAS,MAAM,kBAAkB,CAAC;","names":[]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import crpyto from "crypto";
|
|
4
|
+
import models from "../models.js";
|
|
5
|
+
import { paths } from "../paths.js";
|
|
6
|
+
const imageDir = paths.imageDir;
|
|
7
|
+
function ensureDirExists(dirPath) {
|
|
8
|
+
if (!fs.existsSync(dirPath)) {
|
|
9
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const uploadImage = async (req, res) => {
|
|
13
|
+
const { image } = req.body;
|
|
14
|
+
if (!image || !image.match(/data:image\/\s*(\w+);base64,/)) {
|
|
15
|
+
res.status(400).json({ error: "No image uploaded" }).end();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const [info, data] = image.split(",");
|
|
19
|
+
const hash = crpyto.createHash("sha512").update(data).digest("hex");
|
|
20
|
+
const exists = await models.image.findFirst({ where: { hash } });
|
|
21
|
+
if (exists) {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
id: exists.id,
|
|
24
|
+
url: exists.url
|
|
25
|
+
}).end();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const buffer = Buffer.from(data, "base64");
|
|
29
|
+
const currentPath = [
|
|
30
|
+
(/* @__PURE__ */ new Date()).getFullYear().toString(),
|
|
31
|
+
((/* @__PURE__ */ new Date()).getMonth() + 1).toString(),
|
|
32
|
+
(/* @__PURE__ */ new Date()).getDate().toString()
|
|
33
|
+
];
|
|
34
|
+
const targetDir = path.resolve(imageDir, ...currentPath);
|
|
35
|
+
ensureDirExists(targetDir);
|
|
36
|
+
const ext = info.split(";")[0].split("/")[1];
|
|
37
|
+
const fileName = `${Date.now()}.${ext}`;
|
|
38
|
+
fs.writeFile(path.resolve(targetDir, fileName), buffer, async (err) => {
|
|
39
|
+
if (err) {
|
|
40
|
+
res.status(500).json({ error: err }).end();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const url = "/assets/images/" + currentPath.join("/") + "/" + fileName;
|
|
44
|
+
const image2 = await models.image.create({
|
|
45
|
+
data: {
|
|
46
|
+
hash,
|
|
47
|
+
url
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
res.status(200).json({
|
|
51
|
+
id: image2.id,
|
|
52
|
+
url: image2.url
|
|
53
|
+
}).end();
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const uploadImageFromSrc = async (req, res) => {
|
|
57
|
+
const { src } = req.body;
|
|
58
|
+
const arrayBuffer = await fetch(src).then((res2) => res2.arrayBuffer());
|
|
59
|
+
const data = Buffer.from(arrayBuffer).toString("base64");
|
|
60
|
+
const hash = crpyto.createHash("sha512").update(data).digest("hex");
|
|
61
|
+
const exists = await models.image.findFirst({ where: { hash } });
|
|
62
|
+
if (exists) {
|
|
63
|
+
res.status(200).json({
|
|
64
|
+
id: exists.id,
|
|
65
|
+
url: exists.url
|
|
66
|
+
}).end();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const buffer = Buffer.from(data, "base64");
|
|
70
|
+
const currentPath = [
|
|
71
|
+
(/* @__PURE__ */ new Date()).getFullYear().toString(),
|
|
72
|
+
((/* @__PURE__ */ new Date()).getMonth() + 1).toString(),
|
|
73
|
+
(/* @__PURE__ */ new Date()).getDate().toString()
|
|
74
|
+
];
|
|
75
|
+
const targetDir = path.resolve(imageDir, ...currentPath);
|
|
76
|
+
ensureDirExists(targetDir);
|
|
77
|
+
const ext = "png";
|
|
78
|
+
const fileName = `${Date.now()}.${ext}`;
|
|
79
|
+
fs.writeFile(path.resolve(targetDir, fileName), buffer, async (err) => {
|
|
80
|
+
if (err) {
|
|
81
|
+
res.status(500).json({ error: err }).end();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const url = "/assets/images/" + currentPath.join("/") + "/" + fileName;
|
|
85
|
+
const image = await models.image.create({
|
|
86
|
+
data: {
|
|
87
|
+
hash,
|
|
88
|
+
url
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
res.status(200).json({
|
|
92
|
+
id: image.id,
|
|
93
|
+
url: image.url
|
|
94
|
+
}).end();
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
export {
|
|
98
|
+
uploadImage,
|
|
99
|
+
uploadImageFromSrc
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/views/image.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport crpyto from 'crypto';\n\nimport type { Controller } from '~/types/index.js';\nimport models from '~/models.js';\nimport { paths } from '~/paths.js';\n\nconst imageDir = paths.imageDir;\n\nfunction ensureDirExists(dirPath: string) {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n}\n\nexport const uploadImage: Controller = async (req, res) => {\n const { image } = req.body;\n\n if (!image || !image.match(/data:image\\/\\s*(\\w+);base64,/)) {\n res.status(400).json({ error: 'No image uploaded' }).end();\n return;\n }\n\n const [info, data] = image.split(',');\n\n const hash = crpyto.createHash('sha512').update(data).digest('hex');\n\n const exists = await models.image.findFirst({ where: { hash } });\n\n if (exists) {\n res.status(200).json({\n id: exists.id,\n url: exists.url\n }).end();\n return;\n }\n\n const buffer = Buffer.from(data, 'base64');\n\n const currentPath = [\n (new Date().getFullYear()).toString(),\n (new Date().getMonth() + 1).toString(),\n (new Date().getDate()).toString()\n ];\n const targetDir = path.resolve(imageDir, ...currentPath);\n ensureDirExists(targetDir);\n\n const ext = info.split(';')[0].split('/')[1];\n const fileName = `${Date.now()}.${ext}`;\n\n fs.writeFile(path.resolve(targetDir, fileName), buffer, async (err) => {\n if (err) {\n res.status(500).json({ error: err }).end();\n return;\n }\n\n const url = '/assets/images/' + currentPath.join('/') + '/' + fileName;\n const image = await models.image.create({\n data: {\n hash,\n url\n }\n });\n res.status(200).json({\n id: image.id,\n url: image.url\n }).end();\n });\n};\n\nexport const uploadImageFromSrc: Controller = async (req, res) => {\n const { src } = req.body;\n\n const arrayBuffer = await fetch(src).then(res => res.arrayBuffer());\n\n const data = Buffer.from(arrayBuffer).toString('base64');\n\n const hash = crpyto.createHash('sha512').update(data).digest('hex');\n\n const exists = await models.image.findFirst({ where: { hash } });\n\n if (exists) {\n res.status(200).json({\n id: exists.id,\n url: exists.url\n }).end();\n return;\n }\n\n const buffer = Buffer.from(data, 'base64');\n\n const currentPath = [\n (new Date().getFullYear()).toString(),\n (new Date().getMonth() + 1).toString(),\n (new Date().getDate()).toString()\n ];\n const targetDir = path.resolve(imageDir, ...currentPath);\n ensureDirExists(targetDir);\n\n const ext = 'png';\n const fileName = `${Date.now()}.${ext}`;\n\n fs.writeFile(path.resolve(targetDir, fileName), buffer, async (err) => {\n if (err) {\n res.status(500).json({ error: err }).end();\n return;\n }\n\n const url = '/assets/images/' + currentPath.join('/') + '/' + fileName;\n const image = await models.image.create({\n data: {\n hash,\n url\n }\n });\n res.status(200).json({\n id: image.id,\n url: image.url\n }).end();\n });\n};\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,YAAY;AAGnB,OAAO,YAAY;AACnB,SAAS,aAAa;AAEtB,MAAM,WAAW,MAAM;AAEvB,SAAS,gBAAgB,SAAiB;AACtC,MAAI,CAAC,GAAG,WAAW,OAAO,GAAG;AACzB,OAAG,UAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AACJ;AAEO,MAAM,cAA0B,OAAO,KAAK,QAAQ;AACvD,QAAM,EAAE,MAAM,IAAI,IAAI;AAEtB,MAAI,CAAC,SAAS,CAAC,MAAM,MAAM,8BAA8B,GAAG;AACxD,QAAI,OAAO,GAAG,EAAE,KAAK,EAAE,OAAO,oBAAoB,CAAC,EAAE,IAAI;AACzD;AAAA,EACJ;AAEA,QAAM,CAAC,MAAM,IAAI,IAAI,MAAM,MAAM,GAAG;AAEpC,QAAM,OAAO,OAAO,WAAW,QAAQ,EAAE,OAAO,IAAI,EAAE,OAAO,KAAK;AAElE,QAAM,SAAS,MAAM,OAAO,MAAM,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAE/D,MAAI,QAAQ;AACR,QAAI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":["../../src/views/index.ts"],"sourcesContent":["export * from './image.js';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "User" (
|
|
3
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
4
|
+
"email" TEXT NOT NULL,
|
|
5
|
+
"name" TEXT,
|
|
6
|
+
"password" TEXT NOT NULL,
|
|
7
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
8
|
+
"updatedAt" DATETIME NOT NULL
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
-- CreateTable
|
|
12
|
+
CREATE TABLE "Profile" (
|
|
13
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
14
|
+
"userId" INTEGER NOT NULL,
|
|
15
|
+
"bio" TEXT,
|
|
16
|
+
"avatar" TEXT,
|
|
17
|
+
CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
-- CreateIndex
|
|
21
|
+
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
|
22
|
+
|
|
23
|
+
-- CreateIndex
|
|
24
|
+
CREATE UNIQUE INDEX "Profile_userId_key" ON "Profile"("userId");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "Tag" (
|
|
3
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
4
|
+
"name" TEXT NOT NULL,
|
|
5
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
6
|
+
"updatedAt" DATETIME NOT NULL
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
-- CreateTable
|
|
10
|
+
CREATE TABLE "_NoteToTag" (
|
|
11
|
+
"A" INTEGER NOT NULL,
|
|
12
|
+
"B" INTEGER NOT NULL,
|
|
13
|
+
CONSTRAINT "_NoteToTag_A_fkey" FOREIGN KEY ("A") REFERENCES "Note" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
14
|
+
CONSTRAINT "_NoteToTag_B_fkey" FOREIGN KEY ("B") REFERENCES "Tag" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
-- CreateIndex
|
|
18
|
+
CREATE UNIQUE INDEX "_NoteToTag_AB_unique" ON "_NoteToTag"("A", "B");
|
|
19
|
+
|
|
20
|
+
-- CreateIndex
|
|
21
|
+
CREATE INDEX "_NoteToTag_B_index" ON "_NoteToTag"("B");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- RedefineTables
|
|
2
|
+
PRAGMA foreign_keys=OFF;
|
|
3
|
+
CREATE TABLE "new_Note" (
|
|
4
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
5
|
+
"title" TEXT NOT NULL,
|
|
6
|
+
"content" TEXT NOT NULL,
|
|
7
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
8
|
+
"updatedAt" DATETIME NOT NULL,
|
|
9
|
+
"pinned" BOOLEAN NOT NULL DEFAULT false
|
|
10
|
+
);
|
|
11
|
+
INSERT INTO "new_Note" ("content", "createdAt", "id", "title", "updatedAt") SELECT "content", "createdAt", "id", "title", "updatedAt" FROM "Note";
|
|
12
|
+
DROP TABLE "Note";
|
|
13
|
+
ALTER TABLE "new_Note" RENAME TO "Note";
|
|
14
|
+
PRAGMA foreign_key_check;
|
|
15
|
+
PRAGMA foreign_keys=ON;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the `Profile` table. If the table is not empty, all the data it contains will be lost.
|
|
5
|
+
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost.
|
|
6
|
+
|
|
7
|
+
*/
|
|
8
|
+
-- DropTable
|
|
9
|
+
PRAGMA foreign_keys=off;
|
|
10
|
+
DROP TABLE "Profile";
|
|
11
|
+
PRAGMA foreign_keys=on;
|
|
12
|
+
|
|
13
|
+
-- DropTable
|
|
14
|
+
PRAGMA foreign_keys=off;
|
|
15
|
+
DROP TABLE "User";
|
|
16
|
+
PRAGMA foreign_keys=on;
|
|
17
|
+
|
|
18
|
+
-- CreateTable
|
|
19
|
+
CREATE TABLE "Customization" (
|
|
20
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT DEFAULT 1,
|
|
21
|
+
"color" TEXT NOT NULL,
|
|
22
|
+
"heroBanner" TEXT NOT NULL,
|
|
23
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
24
|
+
"updatedAt" DATETIME NOT NULL
|
|
25
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
-- DropTable
|
|
2
|
+
PRAGMA foreign_keys=off;
|
|
3
|
+
DROP TABLE "Customization";
|
|
4
|
+
PRAGMA foreign_keys=on;
|
|
5
|
+
|
|
6
|
+
-- CreateTable
|
|
7
|
+
CREATE TABLE "Cache" (
|
|
8
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
9
|
+
"key" TEXT NOT NULL,
|
|
10
|
+
"value" TEXT NOT NULL,
|
|
11
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
12
|
+
"updatedAt" DATETIME NOT NULL
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
-- CreateIndex
|
|
16
|
+
CREATE UNIQUE INDEX "Cache_key_key" ON "Cache"("key");
|
|
17
|
+
|
|
18
|
+
-- CreateTable
|
|
19
|
+
CREATE TABLE "Placeholder" (
|
|
20
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
21
|
+
"name" TEXT NOT NULL,
|
|
22
|
+
"template" TEXT NOT NULL,
|
|
23
|
+
"replacement" TEXT NOT NULL,
|
|
24
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
25
|
+
"updatedAt" DATETIME NOT NULL
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
-- CreateIndex
|
|
29
|
+
CREATE UNIQUE INDEX "Placeholder_name_key" ON "Placeholder"("name");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "Reminder" (
|
|
3
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
4
|
+
"noteId" INTEGER NOT NULL,
|
|
5
|
+
"reminderDate" DATETIME NOT NULL,
|
|
6
|
+
"completed" BOOLEAN NOT NULL DEFAULT false,
|
|
7
|
+
"priority" TEXT NOT NULL DEFAULT 'medium',
|
|
8
|
+
"content" TEXT,
|
|
9
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
10
|
+
"updatedAt" DATETIME NOT NULL,
|
|
11
|
+
CONSTRAINT "Reminder_noteId_fkey" FOREIGN KEY ("noteId") REFERENCES "Note" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
12
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- RedefineTables
|
|
2
|
+
PRAGMA defer_foreign_keys=ON;
|
|
3
|
+
PRAGMA foreign_keys=OFF;
|
|
4
|
+
CREATE TABLE "new_Note" (
|
|
5
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
6
|
+
"title" TEXT NOT NULL,
|
|
7
|
+
"content" TEXT NOT NULL,
|
|
8
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
9
|
+
"updatedAt" DATETIME NOT NULL,
|
|
10
|
+
"pinned" BOOLEAN NOT NULL DEFAULT false,
|
|
11
|
+
"order" INTEGER NOT NULL DEFAULT 0,
|
|
12
|
+
"layout" TEXT NOT NULL DEFAULT 'wide'
|
|
13
|
+
);
|
|
14
|
+
INSERT INTO "new_Note" ("content", "createdAt", "id", "order", "pinned", "title", "updatedAt") SELECT "content", "createdAt", "id", "order", "pinned", "title", "updatedAt" FROM "Note";
|
|
15
|
+
DROP TABLE "Note";
|
|
16
|
+
ALTER TABLE "new_Note" RENAME TO "Note";
|
|
17
|
+
PRAGMA foreign_keys=ON;
|
|
18
|
+
PRAGMA defer_foreign_keys=OFF;
|