@newcms/database 0.1.1 → 0.2.0
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.cjs +1527 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2695 -0
- package/dist/index.d.ts +2695 -14
- package/dist/index.js +1528 -8
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/dist/cache/index.d.ts +0 -3
- package/dist/cache/index.d.ts.map +0 -1
- package/dist/cache/index.js +0 -2
- package/dist/cache/index.js.map +0 -1
- package/dist/cache/object-cache.d.ts +0 -139
- package/dist/cache/object-cache.d.ts.map +0 -1
- package/dist/cache/object-cache.js +0 -321
- package/dist/cache/object-cache.js.map +0 -1
- package/dist/connection.d.ts +0 -18
- package/dist/connection.d.ts.map +0 -1
- package/dist/connection.js +0 -32
- package/dist/connection.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/repositories/meta-repository.d.ts +0 -71
- package/dist/repositories/meta-repository.d.ts.map +0 -1
- package/dist/repositories/meta-repository.js +0 -176
- package/dist/repositories/meta-repository.js.map +0 -1
- package/dist/repositories/options-repository.d.ts +0 -59
- package/dist/repositories/options-repository.d.ts.map +0 -1
- package/dist/repositories/options-repository.js +0 -222
- package/dist/repositories/options-repository.js.map +0 -1
- package/dist/repositories/post-repository.d.ts +0 -121
- package/dist/repositories/post-repository.d.ts.map +0 -1
- package/dist/repositories/post-repository.js +0 -241
- package/dist/repositories/post-repository.js.map +0 -1
- package/dist/repositories/revision-repository.d.ts +0 -50
- package/dist/repositories/revision-repository.d.ts.map +0 -1
- package/dist/repositories/revision-repository.js +0 -149
- package/dist/repositories/revision-repository.js.map +0 -1
- package/dist/repositories/taxonomy-repository.d.ts +0 -63
- package/dist/repositories/taxonomy-repository.d.ts.map +0 -1
- package/dist/repositories/taxonomy-repository.js +0 -268
- package/dist/repositories/taxonomy-repository.js.map +0 -1
- package/dist/schema/comments.d.ts +0 -369
- package/dist/schema/comments.d.ts.map +0 -1
- package/dist/schema/comments.js +0 -47
- package/dist/schema/comments.js.map +0 -1
- package/dist/schema/index.d.ts +0 -9
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js +0 -9
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/links.d.ts +0 -245
- package/dist/schema/links.d.ts.map +0 -1
- package/dist/schema/links.js +0 -17
- package/dist/schema/links.js.map +0 -1
- package/dist/schema/options.d.ts +0 -95
- package/dist/schema/options.d.ts.map +0 -1
- package/dist/schema/options.js +0 -12
- package/dist/schema/options.js.map +0 -1
- package/dist/schema/posts.d.ts +0 -509
- package/dist/schema/posts.d.ts.map +0 -1
- package/dist/schema/posts.js +0 -51
- package/dist/schema/posts.js.map +0 -1
- package/dist/schema/scheduled-events.d.ts +0 -156
- package/dist/schema/scheduled-events.d.ts.map +0 -1
- package/dist/schema/scheduled-events.js +0 -22
- package/dist/schema/scheduled-events.js.map +0 -1
- package/dist/schema/sessions.d.ts +0 -157
- package/dist/schema/sessions.d.ts.map +0 -1
- package/dist/schema/sessions.js +0 -26
- package/dist/schema/sessions.js.map +0 -1
- package/dist/schema/terms.d.ts +0 -343
- package/dist/schema/terms.d.ts.map +0 -1
- package/dist/schema/terms.js +0 -46
- package/dist/schema/terms.js.map +0 -1
- package/dist/schema/users.d.ts +0 -288
- package/dist/schema/users.d.ts.map +0 -1
- package/dist/schema/users.js +0 -30
- package/dist/schema/users.js.map +0 -1
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { Database } from '../connection.js';
|
|
2
|
-
import type { ObjectCache } from '../cache/object-cache.js';
|
|
3
|
-
/**
|
|
4
|
-
* Options repository — CRUD for site options with integrated Redis cache.
|
|
5
|
-
*
|
|
6
|
-
* Behaviors per spec:
|
|
7
|
-
* - Options marked as autoload=true are pre-loaded into cache together
|
|
8
|
-
* - Cache of "not found" keys prevents repeated DB misses
|
|
9
|
-
* - Complex values (objects/arrays) stored as JSONB in addition to text
|
|
10
|
-
* - Write operations invalidate cache granularly
|
|
11
|
-
*/
|
|
12
|
-
export declare class OptionsRepository {
|
|
13
|
-
private db;
|
|
14
|
-
private cache;
|
|
15
|
-
constructor(db: Database, cache: ObjectCache);
|
|
16
|
-
/**
|
|
17
|
-
* Get an option value.
|
|
18
|
-
*
|
|
19
|
-
* Lookup order:
|
|
20
|
-
* 1. Redis cache (group "options")
|
|
21
|
-
* 2. "Not found" cache (avoids repeated DB queries for missing keys)
|
|
22
|
-
* 3. Database
|
|
23
|
-
*/
|
|
24
|
-
getOption<T = string>(name: string, defaultValue?: T): Promise<T | undefined>;
|
|
25
|
-
/**
|
|
26
|
-
* Add a new option. Fails if option already exists.
|
|
27
|
-
*
|
|
28
|
-
* @returns true if the option was created
|
|
29
|
-
*/
|
|
30
|
-
addOption(name: string, value: unknown, autoload?: boolean): Promise<boolean>;
|
|
31
|
-
/**
|
|
32
|
-
* Update an existing option, or create it if it doesn't exist.
|
|
33
|
-
*
|
|
34
|
-
* @returns true if the value was changed
|
|
35
|
-
*/
|
|
36
|
-
updateOption(name: string, value: unknown, autoload?: boolean): Promise<boolean>;
|
|
37
|
-
/**
|
|
38
|
-
* Delete an option.
|
|
39
|
-
*
|
|
40
|
-
* @returns true if the option existed and was deleted
|
|
41
|
-
*/
|
|
42
|
-
deleteOption(name: string): Promise<boolean>;
|
|
43
|
-
/**
|
|
44
|
-
* Load all autoloaded options into cache at once.
|
|
45
|
-
* Called during bootstrap to pre-warm the cache.
|
|
46
|
-
*/
|
|
47
|
-
loadAutoloadedOptions(): Promise<Map<string, unknown>>;
|
|
48
|
-
/**
|
|
49
|
-
* Serialize a value for storage.
|
|
50
|
-
* Complex types (objects, arrays) are stored in both text and JSONB columns.
|
|
51
|
-
*/
|
|
52
|
-
private serializeValue;
|
|
53
|
-
/**
|
|
54
|
-
* Deserialize a value from the database row.
|
|
55
|
-
* Prefers JSONB column when available (already parsed).
|
|
56
|
-
*/
|
|
57
|
-
private deserializeValue;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=options-repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/options-repository.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAM5D;;;;;;;;GAQG;AACH,qBAAa,iBAAiB;IAE5B,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,KAAK;gBADL,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,WAAW;IAG3B;;;;;;;OAOG;IACG,SAAS,CAAC,CAAC,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IA+BnF;;;;OAIG;IACG,SAAS,CACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,QAAQ,GAAE,OAAc,GACtB,OAAO,CAAC,OAAO,CAAC;IA+BnB;;;;OAIG;IACG,YAAY,CACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,QAAQ,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,OAAO,CAAC;IA8CnB;;;;OAIG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBlD;;;OAGG;IACG,qBAAqB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAsC5D;;;OAGG;IACH,OAAO,CAAC,cAAc;IA2BtB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;CAgBxB"}
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { eq } from 'drizzle-orm';
|
|
2
|
-
import { options } from '../schema/options.js';
|
|
3
|
-
const CACHE_GROUP = 'options';
|
|
4
|
-
const AUTOLOAD_CACHE_KEY = '__autoloaded';
|
|
5
|
-
const NOT_FOUND_GROUP = 'options_nf';
|
|
6
|
-
/**
|
|
7
|
-
* Options repository — CRUD for site options with integrated Redis cache.
|
|
8
|
-
*
|
|
9
|
-
* Behaviors per spec:
|
|
10
|
-
* - Options marked as autoload=true are pre-loaded into cache together
|
|
11
|
-
* - Cache of "not found" keys prevents repeated DB misses
|
|
12
|
-
* - Complex values (objects/arrays) stored as JSONB in addition to text
|
|
13
|
-
* - Write operations invalidate cache granularly
|
|
14
|
-
*/
|
|
15
|
-
export class OptionsRepository {
|
|
16
|
-
db;
|
|
17
|
-
cache;
|
|
18
|
-
constructor(db, cache) {
|
|
19
|
-
this.db = db;
|
|
20
|
-
this.cache = cache;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Get an option value.
|
|
24
|
-
*
|
|
25
|
-
* Lookup order:
|
|
26
|
-
* 1. Redis cache (group "options")
|
|
27
|
-
* 2. "Not found" cache (avoids repeated DB queries for missing keys)
|
|
28
|
-
* 3. Database
|
|
29
|
-
*/
|
|
30
|
-
async getOption(name, defaultValue) {
|
|
31
|
-
// 1. Check cache
|
|
32
|
-
const cached = await this.cache.get(name, CACHE_GROUP);
|
|
33
|
-
if (cached !== undefined)
|
|
34
|
-
return cached;
|
|
35
|
-
// 2. Check "not found" cache
|
|
36
|
-
const isNotFound = await this.cache.get(name, NOT_FOUND_GROUP);
|
|
37
|
-
if (isNotFound !== undefined)
|
|
38
|
-
return defaultValue;
|
|
39
|
-
// 3. Query database
|
|
40
|
-
const rows = await this.db
|
|
41
|
-
.select()
|
|
42
|
-
.from(options)
|
|
43
|
-
.where(eq(options.optionName, name))
|
|
44
|
-
.limit(1);
|
|
45
|
-
if (rows.length === 0) {
|
|
46
|
-
// Cache as "not found" to avoid future DB queries
|
|
47
|
-
await this.cache.set(name, true, NOT_FOUND_GROUP, 3600);
|
|
48
|
-
return defaultValue;
|
|
49
|
-
}
|
|
50
|
-
const row = rows[0];
|
|
51
|
-
const value = this.deserializeValue(row);
|
|
52
|
-
// Cache the value
|
|
53
|
-
await this.cache.set(name, value, CACHE_GROUP);
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Add a new option. Fails if option already exists.
|
|
58
|
-
*
|
|
59
|
-
* @returns true if the option was created
|
|
60
|
-
*/
|
|
61
|
-
async addOption(name, value, autoload = true) {
|
|
62
|
-
// Check if already exists
|
|
63
|
-
const existing = await this.db
|
|
64
|
-
.select({ optionId: options.optionId })
|
|
65
|
-
.from(options)
|
|
66
|
-
.where(eq(options.optionName, name))
|
|
67
|
-
.limit(1);
|
|
68
|
-
if (existing.length > 0)
|
|
69
|
-
return false;
|
|
70
|
-
const { textValue, jsonValue } = this.serializeValue(value);
|
|
71
|
-
await this.db.insert(options).values({
|
|
72
|
-
optionName: name,
|
|
73
|
-
optionValue: textValue,
|
|
74
|
-
optionValueJson: jsonValue,
|
|
75
|
-
autoload,
|
|
76
|
-
});
|
|
77
|
-
// Update cache
|
|
78
|
-
await this.cache.set(name, value, CACHE_GROUP);
|
|
79
|
-
await this.cache.delete(name, NOT_FOUND_GROUP);
|
|
80
|
-
// Invalidate autoload cache if this is an autoloaded option
|
|
81
|
-
if (autoload) {
|
|
82
|
-
await this.cache.delete(AUTOLOAD_CACHE_KEY, CACHE_GROUP);
|
|
83
|
-
}
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Update an existing option, or create it if it doesn't exist.
|
|
88
|
-
*
|
|
89
|
-
* @returns true if the value was changed
|
|
90
|
-
*/
|
|
91
|
-
async updateOption(name, value, autoload) {
|
|
92
|
-
const { textValue, jsonValue } = this.serializeValue(value);
|
|
93
|
-
// Try to update
|
|
94
|
-
const existing = await this.db
|
|
95
|
-
.select()
|
|
96
|
-
.from(options)
|
|
97
|
-
.where(eq(options.optionName, name))
|
|
98
|
-
.limit(1);
|
|
99
|
-
if (existing.length === 0) {
|
|
100
|
-
// Option doesn't exist — create it
|
|
101
|
-
return this.addOption(name, value, autoload ?? true);
|
|
102
|
-
}
|
|
103
|
-
const row = existing[0];
|
|
104
|
-
// Check if value actually changed
|
|
105
|
-
if (row.optionValue === textValue && autoload === undefined) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
const updateData = {
|
|
109
|
-
optionValue: textValue,
|
|
110
|
-
optionValueJson: jsonValue,
|
|
111
|
-
};
|
|
112
|
-
if (autoload !== undefined) {
|
|
113
|
-
updateData['autoload'] = autoload;
|
|
114
|
-
}
|
|
115
|
-
await this.db
|
|
116
|
-
.update(options)
|
|
117
|
-
.set(updateData)
|
|
118
|
-
.where(eq(options.optionName, name));
|
|
119
|
-
// Update cache
|
|
120
|
-
await this.cache.set(name, value, CACHE_GROUP);
|
|
121
|
-
await this.cache.delete(name, NOT_FOUND_GROUP);
|
|
122
|
-
// Invalidate autoload cache
|
|
123
|
-
await this.cache.delete(AUTOLOAD_CACHE_KEY, CACHE_GROUP);
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Delete an option.
|
|
128
|
-
*
|
|
129
|
-
* @returns true if the option existed and was deleted
|
|
130
|
-
*/
|
|
131
|
-
async deleteOption(name) {
|
|
132
|
-
const result = await this.db
|
|
133
|
-
.delete(options)
|
|
134
|
-
.where(eq(options.optionName, name))
|
|
135
|
-
.returning({ optionId: options.optionId });
|
|
136
|
-
if (result.length === 0)
|
|
137
|
-
return false;
|
|
138
|
-
// Remove from cache
|
|
139
|
-
await this.cache.delete(name, CACHE_GROUP);
|
|
140
|
-
await this.cache.delete(name, NOT_FOUND_GROUP);
|
|
141
|
-
await this.cache.delete(AUTOLOAD_CACHE_KEY, CACHE_GROUP);
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Load all autoloaded options into cache at once.
|
|
146
|
-
* Called during bootstrap to pre-warm the cache.
|
|
147
|
-
*/
|
|
148
|
-
async loadAutoloadedOptions() {
|
|
149
|
-
// Check if already loaded
|
|
150
|
-
const cached = await this.cache.get(AUTOLOAD_CACHE_KEY, CACHE_GROUP);
|
|
151
|
-
if (cached) {
|
|
152
|
-
const result = new Map(Object.entries(cached));
|
|
153
|
-
// Populate individual option caches
|
|
154
|
-
for (const [key, value] of result) {
|
|
155
|
-
await this.cache.set(key, value, CACHE_GROUP);
|
|
156
|
-
}
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
// Query all autoloaded options
|
|
160
|
-
const rows = await this.db
|
|
161
|
-
.select()
|
|
162
|
-
.from(options)
|
|
163
|
-
.where(eq(options.autoload, true));
|
|
164
|
-
const result = new Map();
|
|
165
|
-
const autoloadMap = {};
|
|
166
|
-
for (const row of rows) {
|
|
167
|
-
const value = this.deserializeValue(row);
|
|
168
|
-
result.set(row.optionName, value);
|
|
169
|
-
autoloadMap[row.optionName] = value;
|
|
170
|
-
await this.cache.set(row.optionName, value, CACHE_GROUP);
|
|
171
|
-
}
|
|
172
|
-
// Cache the complete autoload map
|
|
173
|
-
await this.cache.set(AUTOLOAD_CACHE_KEY, autoloadMap, CACHE_GROUP);
|
|
174
|
-
return result;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Serialize a value for storage.
|
|
178
|
-
* Complex types (objects, arrays) are stored in both text and JSONB columns.
|
|
179
|
-
*/
|
|
180
|
-
serializeValue(value) {
|
|
181
|
-
if (value === null || value === undefined) {
|
|
182
|
-
return { textValue: '', jsonValue: null };
|
|
183
|
-
}
|
|
184
|
-
if (typeof value === 'string') {
|
|
185
|
-
// Try to detect if it's JSON
|
|
186
|
-
try {
|
|
187
|
-
const parsed = JSON.parse(value);
|
|
188
|
-
if (typeof parsed === 'object' && parsed !== null) {
|
|
189
|
-
return { textValue: value, jsonValue: parsed };
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
catch {
|
|
193
|
-
// Not JSON, store as plain text
|
|
194
|
-
}
|
|
195
|
-
return { textValue: value, jsonValue: null };
|
|
196
|
-
}
|
|
197
|
-
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
198
|
-
return { textValue: String(value), jsonValue: null };
|
|
199
|
-
}
|
|
200
|
-
// Objects and arrays → both text (JSON string) and JSONB
|
|
201
|
-
const textValue = JSON.stringify(value);
|
|
202
|
-
return { textValue, jsonValue: value };
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Deserialize a value from the database row.
|
|
206
|
-
* Prefers JSONB column when available (already parsed).
|
|
207
|
-
*/
|
|
208
|
-
deserializeValue(row) {
|
|
209
|
-
// Prefer JSONB if available
|
|
210
|
-
if (row.optionValueJson !== null && row.optionValueJson !== undefined) {
|
|
211
|
-
return row.optionValueJson;
|
|
212
|
-
}
|
|
213
|
-
// Try to parse as JSON
|
|
214
|
-
try {
|
|
215
|
-
return JSON.parse(row.optionValue);
|
|
216
|
-
}
|
|
217
|
-
catch {
|
|
218
|
-
return row.optionValue;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
//# sourceMappingURL=options-repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options-repository.js","sourceRoot":"","sources":["../../src/repositories/options-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,MAAM,WAAW,GAAG,SAAS,CAAC;AAC9B,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAC1C,MAAM,eAAe,GAAG,YAAY,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAiB;IAEpB;IACA;IAFT,YACS,EAAY,EACZ,KAAkB;QADlB,OAAE,GAAF,EAAE,CAAU;QACZ,UAAK,GAAL,KAAK,CAAa;IACxB,CAAC;IAEJ;;;;;;;OAOG;IACH,KAAK,CAAC,SAAS,CAAa,IAAY,EAAE,YAAgB;QACzD,iBAAiB;QACjB,MAAM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AAE,IAAI,EAAE,CAAC;QACtD,CAAC;QAED,yDAAyD;QACzD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACxC,CAAC;IAED;;;OAGG;IACK,gBAAgB,CAAI,GAG3B;QACA,4BAA4B;QAC5B,IAAI,GAAG,CAAC,eAAe,KAAK,IAAI,IAAI,GAAG,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACvE,OAAO,GAAG,CAAC,eAAoB,CAAC;QACjC,CAAC;QAED,uBAAuB;QACvB,IAAI,CAAC;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAM,CAAC;QACzC,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,GAAG,CAAC,WAAgB,CAAC;QAC7B,CAAC;IACF,CAAC;CACD"}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import type { Database } from '../connection.js';
|
|
2
|
-
import { MetaRepository } from './meta-repository.js';
|
|
3
|
-
export interface CreatePostInput {
|
|
4
|
-
postAuthor: number;
|
|
5
|
-
postTitle: string;
|
|
6
|
-
postContent?: string;
|
|
7
|
-
postExcerpt?: string;
|
|
8
|
-
postStatus?: string;
|
|
9
|
-
postName?: string;
|
|
10
|
-
postType?: string;
|
|
11
|
-
postParent?: number;
|
|
12
|
-
postPassword?: string;
|
|
13
|
-
commentStatus?: string;
|
|
14
|
-
pingStatus?: string;
|
|
15
|
-
postMimeType?: string;
|
|
16
|
-
menuOrder?: number;
|
|
17
|
-
guid?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface UpdatePostInput {
|
|
20
|
-
postTitle?: string;
|
|
21
|
-
postContent?: string;
|
|
22
|
-
postExcerpt?: string;
|
|
23
|
-
postStatus?: string;
|
|
24
|
-
postName?: string;
|
|
25
|
-
postType?: string;
|
|
26
|
-
postParent?: number;
|
|
27
|
-
postPassword?: string;
|
|
28
|
-
commentStatus?: string;
|
|
29
|
-
pingStatus?: string;
|
|
30
|
-
menuOrder?: number;
|
|
31
|
-
}
|
|
32
|
-
export interface PostRow {
|
|
33
|
-
id: number;
|
|
34
|
-
postAuthor: number;
|
|
35
|
-
postDate: Date;
|
|
36
|
-
postDateGmt: Date;
|
|
37
|
-
postContent: string;
|
|
38
|
-
postTitle: string;
|
|
39
|
-
postExcerpt: string;
|
|
40
|
-
postStatus: string;
|
|
41
|
-
commentStatus: string;
|
|
42
|
-
pingStatus: string;
|
|
43
|
-
postPassword: string;
|
|
44
|
-
postName: string;
|
|
45
|
-
toPing: string;
|
|
46
|
-
pinged: string;
|
|
47
|
-
postModified: Date;
|
|
48
|
-
postModifiedGmt: Date;
|
|
49
|
-
postContentFiltered: string;
|
|
50
|
-
postParent: number;
|
|
51
|
-
guid: string;
|
|
52
|
-
menuOrder: number;
|
|
53
|
-
postType: string;
|
|
54
|
-
postMimeType: string;
|
|
55
|
-
commentCount: number;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Repository for posts (all content types).
|
|
59
|
-
*
|
|
60
|
-
* Handles CRUD, slug generation, sticky posts, and provides
|
|
61
|
-
* a MetaRepository instance for post metadata operations.
|
|
62
|
-
*/
|
|
63
|
-
export declare class PostRepository {
|
|
64
|
-
private db;
|
|
65
|
-
readonly meta: MetaRepository;
|
|
66
|
-
constructor(db: Database);
|
|
67
|
-
/**
|
|
68
|
-
* Create a new post.
|
|
69
|
-
*/
|
|
70
|
-
create(input: CreatePostInput): Promise<PostRow>;
|
|
71
|
-
/**
|
|
72
|
-
* Get a post by ID.
|
|
73
|
-
*/
|
|
74
|
-
getById(id: number): Promise<PostRow | undefined>;
|
|
75
|
-
/**
|
|
76
|
-
* Get a post by slug and type.
|
|
77
|
-
*/
|
|
78
|
-
getBySlug(slug: string, postType?: string): Promise<PostRow | undefined>;
|
|
79
|
-
/**
|
|
80
|
-
* Update a post. Returns the updated row or undefined if not found.
|
|
81
|
-
*/
|
|
82
|
-
update(id: number, input: UpdatePostInput): Promise<PostRow | undefined>;
|
|
83
|
-
/**
|
|
84
|
-
* Trash a post (move to trash status, preserving original status in meta).
|
|
85
|
-
*/
|
|
86
|
-
trash(id: number): Promise<PostRow | undefined>;
|
|
87
|
-
/**
|
|
88
|
-
* Restore a trashed post to its original status.
|
|
89
|
-
*/
|
|
90
|
-
untrash(id: number): Promise<PostRow | undefined>;
|
|
91
|
-
/**
|
|
92
|
-
* Permanently delete a post and all its metadata.
|
|
93
|
-
*/
|
|
94
|
-
deletePermanently(id: number): Promise<boolean>;
|
|
95
|
-
/**
|
|
96
|
-
* Get sticky post IDs.
|
|
97
|
-
*/
|
|
98
|
-
getStickyIds(): Promise<number[]>;
|
|
99
|
-
/**
|
|
100
|
-
* Set a post as sticky or not.
|
|
101
|
-
*/
|
|
102
|
-
setSticky(id: number, sticky: boolean): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Check if a post is sticky.
|
|
105
|
-
*/
|
|
106
|
-
isSticky(id: number): Promise<boolean>;
|
|
107
|
-
/**
|
|
108
|
-
* Count posts by type and status.
|
|
109
|
-
*/
|
|
110
|
-
countByStatus(postType?: string): Promise<Record<string, number>>;
|
|
111
|
-
/**
|
|
112
|
-
* Generate a URL-safe slug from a title.
|
|
113
|
-
*/
|
|
114
|
-
private generateSlug;
|
|
115
|
-
/**
|
|
116
|
-
* Ensure a slug is unique within a post type.
|
|
117
|
-
* Appends -2, -3, etc. if needed.
|
|
118
|
-
*/
|
|
119
|
-
private ensureUniqueSlug;
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=post-repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"post-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/post-repository.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAA+C,MAAM,sBAAsB,CAA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AC,OAAO,CAAC;IAYrD;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IASvC;;OAEG;IACG,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3D;;OAEG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK5C;;OAEG;IACG,aAAa,CAClB,QAAQ,GAAE,MAAe,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAiBlC;;OAEG;IACH,OAAO,CAAC,YAAY;IAYpB;;;OAGG;YACW,gBAAgB;CAyB9B"}
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { eq, and, sql } from 'drizzle-orm';
|
|
2
|
-
import { posts, postmeta } from '../schema/index.js';
|
|
3
|
-
import { MetaRepository } from './meta-repository.js';
|
|
4
|
-
/**
|
|
5
|
-
* Repository for posts (all content types).
|
|
6
|
-
*
|
|
7
|
-
* Handles CRUD, slug generation, sticky posts, and provides
|
|
8
|
-
* a MetaRepository instance for post metadata operations.
|
|
9
|
-
*/
|
|
10
|
-
export class PostRepository {
|
|
11
|
-
db;
|
|
12
|
-
meta;
|
|
13
|
-
constructor(db) {
|
|
14
|
-
this.db = db;
|
|
15
|
-
const metaCols = {
|
|
16
|
-
metaId: postmeta.metaId,
|
|
17
|
-
objectId: postmeta.postId,
|
|
18
|
-
metaKey: postmeta.metaKey,
|
|
19
|
-
metaValue: postmeta.metaValue,
|
|
20
|
-
metaValueJson: postmeta.metaValueJson,
|
|
21
|
-
};
|
|
22
|
-
const colNames = {
|
|
23
|
-
table: 'postmeta',
|
|
24
|
-
sql: { metaId: 'meta_id', objectId: 'post_id', metaKey: 'meta_key', metaValue: 'meta_value', metaValueJson: 'meta_value_json' },
|
|
25
|
-
ts: { metaId: 'metaId', objectId: 'postId', metaKey: 'metaKey', metaValue: 'metaValue', metaValueJson: 'metaValueJson' },
|
|
26
|
-
};
|
|
27
|
-
this.meta = new MetaRepository(db, postmeta, metaCols, colNames);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Create a new post.
|
|
31
|
-
*/
|
|
32
|
-
async create(input) {
|
|
33
|
-
const postName = input.postName || this.generateSlug(input.postTitle);
|
|
34
|
-
const uniqueSlug = await this.ensureUniqueSlug(postName, input.postType ?? 'post');
|
|
35
|
-
const now = new Date();
|
|
36
|
-
const [row] = await this.db
|
|
37
|
-
.insert(posts)
|
|
38
|
-
.values({
|
|
39
|
-
postAuthor: input.postAuthor,
|
|
40
|
-
postTitle: input.postTitle,
|
|
41
|
-
postContent: input.postContent ?? '',
|
|
42
|
-
postExcerpt: input.postExcerpt ?? '',
|
|
43
|
-
postStatus: input.postStatus ?? 'draft',
|
|
44
|
-
postName: uniqueSlug,
|
|
45
|
-
postType: input.postType ?? 'post',
|
|
46
|
-
postParent: input.postParent ?? 0,
|
|
47
|
-
postPassword: input.postPassword ?? '',
|
|
48
|
-
commentStatus: input.commentStatus ?? 'open',
|
|
49
|
-
pingStatus: input.pingStatus ?? 'open',
|
|
50
|
-
postMimeType: input.postMimeType ?? '',
|
|
51
|
-
menuOrder: input.menuOrder ?? 0,
|
|
52
|
-
guid: input.guid ?? '',
|
|
53
|
-
postDate: now,
|
|
54
|
-
postDateGmt: now,
|
|
55
|
-
postModified: now,
|
|
56
|
-
postModifiedGmt: now,
|
|
57
|
-
})
|
|
58
|
-
.returning();
|
|
59
|
-
return row;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get a post by ID.
|
|
63
|
-
*/
|
|
64
|
-
async getById(id) {
|
|
65
|
-
const rows = await this.db.select().from(posts).where(eq(posts.id, id)).limit(1);
|
|
66
|
-
return rows[0];
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Get a post by slug and type.
|
|
70
|
-
*/
|
|
71
|
-
async getBySlug(slug, postType = 'post') {
|
|
72
|
-
const rows = await this.db
|
|
73
|
-
.select()
|
|
74
|
-
.from(posts)
|
|
75
|
-
.where(and(eq(posts.postName, slug), eq(posts.postType, postType)))
|
|
76
|
-
.limit(1);
|
|
77
|
-
return rows[0];
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Update a post. Returns the updated row or undefined if not found.
|
|
81
|
-
*/
|
|
82
|
-
async update(id, input) {
|
|
83
|
-
const existing = await this.getById(id);
|
|
84
|
-
if (!existing)
|
|
85
|
-
return undefined;
|
|
86
|
-
const now = new Date();
|
|
87
|
-
const updateData = {
|
|
88
|
-
postModified: now,
|
|
89
|
-
postModifiedGmt: now,
|
|
90
|
-
};
|
|
91
|
-
if (input.postTitle !== undefined)
|
|
92
|
-
updateData['postTitle'] = input.postTitle;
|
|
93
|
-
if (input.postContent !== undefined)
|
|
94
|
-
updateData['postContent'] = input.postContent;
|
|
95
|
-
if (input.postExcerpt !== undefined)
|
|
96
|
-
updateData['postExcerpt'] = input.postExcerpt;
|
|
97
|
-
if (input.postStatus !== undefined)
|
|
98
|
-
updateData['postStatus'] = input.postStatus;
|
|
99
|
-
if (input.postType !== undefined)
|
|
100
|
-
updateData['postType'] = input.postType;
|
|
101
|
-
if (input.postParent !== undefined)
|
|
102
|
-
updateData['postParent'] = input.postParent;
|
|
103
|
-
if (input.postPassword !== undefined)
|
|
104
|
-
updateData['postPassword'] = input.postPassword;
|
|
105
|
-
if (input.commentStatus !== undefined)
|
|
106
|
-
updateData['commentStatus'] = input.commentStatus;
|
|
107
|
-
if (input.pingStatus !== undefined)
|
|
108
|
-
updateData['pingStatus'] = input.pingStatus;
|
|
109
|
-
if (input.menuOrder !== undefined)
|
|
110
|
-
updateData['menuOrder'] = input.menuOrder;
|
|
111
|
-
if (input.postName !== undefined) {
|
|
112
|
-
updateData['postName'] = await this.ensureUniqueSlug(input.postName, input.postType ?? existing.postType, id);
|
|
113
|
-
}
|
|
114
|
-
const [row] = await this.db
|
|
115
|
-
.update(posts)
|
|
116
|
-
.set(updateData)
|
|
117
|
-
.where(eq(posts.id, id))
|
|
118
|
-
.returning();
|
|
119
|
-
return row;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Trash a post (move to trash status, preserving original status in meta).
|
|
123
|
-
*/
|
|
124
|
-
async trash(id) {
|
|
125
|
-
const existing = await this.getById(id);
|
|
126
|
-
if (!existing)
|
|
127
|
-
return undefined;
|
|
128
|
-
if (existing.postStatus === 'trash')
|
|
129
|
-
return existing;
|
|
130
|
-
// Save original status so it can be restored
|
|
131
|
-
await this.meta.update(id, '_trash_meta_status', existing.postStatus);
|
|
132
|
-
return this.update(id, { postStatus: 'trash' });
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Restore a trashed post to its original status.
|
|
136
|
-
*/
|
|
137
|
-
async untrash(id) {
|
|
138
|
-
const existing = await this.getById(id);
|
|
139
|
-
if (!existing || existing.postStatus !== 'trash')
|
|
140
|
-
return existing;
|
|
141
|
-
const originalStatus = await this.meta.get(id, '_trash_meta_status');
|
|
142
|
-
await this.meta.delete(id, '_trash_meta_status');
|
|
143
|
-
return this.update(id, { postStatus: originalStatus ?? 'draft' });
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Permanently delete a post and all its metadata.
|
|
147
|
-
*/
|
|
148
|
-
async deletePermanently(id) {
|
|
149
|
-
// Delete meta first (cascade should handle it but be explicit)
|
|
150
|
-
await this.meta.deleteAllForObject(id);
|
|
151
|
-
const result = await this.db
|
|
152
|
-
.delete(posts)
|
|
153
|
-
.where(eq(posts.id, id))
|
|
154
|
-
.returning({ id: posts.id });
|
|
155
|
-
return result.length > 0;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Get sticky post IDs.
|
|
159
|
-
*/
|
|
160
|
-
async getStickyIds() {
|
|
161
|
-
const rows = await this.db
|
|
162
|
-
.select({ postId: postmeta.postId })
|
|
163
|
-
.from(postmeta)
|
|
164
|
-
.where(and(eq(postmeta.metaKey, '_sticky'), eq(postmeta.metaValue, '1')));
|
|
165
|
-
return rows.map((r) => r.postId);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Set a post as sticky or not.
|
|
169
|
-
*/
|
|
170
|
-
async setSticky(id, sticky) {
|
|
171
|
-
if (sticky) {
|
|
172
|
-
await this.meta.update(id, '_sticky', '1');
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
await this.meta.delete(id, '_sticky');
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Check if a post is sticky.
|
|
180
|
-
*/
|
|
181
|
-
async isSticky(id) {
|
|
182
|
-
const value = await this.meta.get(id, '_sticky');
|
|
183
|
-
return value === '1' || value === 1;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Count posts by type and status.
|
|
187
|
-
*/
|
|
188
|
-
async countByStatus(postType = 'post') {
|
|
189
|
-
const rows = await this.db
|
|
190
|
-
.select({
|
|
191
|
-
status: posts.postStatus,
|
|
192
|
-
count: sql `count(*)::int`,
|
|
193
|
-
})
|
|
194
|
-
.from(posts)
|
|
195
|
-
.where(eq(posts.postType, postType))
|
|
196
|
-
.groupBy(posts.postStatus);
|
|
197
|
-
const result = {};
|
|
198
|
-
for (const row of rows) {
|
|
199
|
-
result[row.status] = row.count;
|
|
200
|
-
}
|
|
201
|
-
return result;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Generate a URL-safe slug from a title.
|
|
205
|
-
*/
|
|
206
|
-
generateSlug(title) {
|
|
207
|
-
return title
|
|
208
|
-
.toLowerCase()
|
|
209
|
-
.normalize('NFD')
|
|
210
|
-
.replace(/[\u0300-\u036f]/g, '') // remove diacritics
|
|
211
|
-
.replace(/[^a-z0-9_\s-]/g, '')
|
|
212
|
-
.replace(/\s+/g, '-')
|
|
213
|
-
.replace(/-+/g, '-')
|
|
214
|
-
.replace(/^-|-$/g, '')
|
|
215
|
-
.substring(0, 200);
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Ensure a slug is unique within a post type.
|
|
219
|
-
* Appends -2, -3, etc. if needed.
|
|
220
|
-
*/
|
|
221
|
-
async ensureUniqueSlug(slug, postType, excludeId) {
|
|
222
|
-
let candidate = slug;
|
|
223
|
-
let suffix = 2;
|
|
224
|
-
while (true) {
|
|
225
|
-
const conditions = [eq(posts.postName, candidate), eq(posts.postType, postType)];
|
|
226
|
-
if (excludeId !== undefined) {
|
|
227
|
-
conditions.push(sql `${posts.id} != ${excludeId}`);
|
|
228
|
-
}
|
|
229
|
-
const existing = await this.db
|
|
230
|
-
.select({ id: posts.id })
|
|
231
|
-
.from(posts)
|
|
232
|
-
.where(and(...conditions))
|
|
233
|
-
.limit(1);
|
|
234
|
-
if (existing.length === 0)
|
|
235
|
-
return candidate;
|
|
236
|
-
candidate = `${slug}-${suffix}`;
|
|
237
|
-
suffix++;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
//# sourceMappingURL=post-repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"post-repository.js","sourceRoot":"","sources":["../../src/repositories/post-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAA+C,MAAM,sBAAsB,CAAC;AA2DnG;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAGN;IAFX,IAAI,CAAiB;IAE9B,YAAoB,EAAY;QAAZ,OAAE,GAAF,EAAE,CAAU;QAC/B,MAAM,QAAQ,GAAqB;YAClC,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,QAAQ,EAAE,QAAQ,CAAC,MAAM;YACzB,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC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