@newcms/database 0.1.1 → 0.3.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 +1682 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2763 -0
- package/dist/index.d.ts +2763 -14
- package/dist/index.js +1682 -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,50 +0,0 @@
|
|
|
1
|
-
import type { Database } from '../connection.js';
|
|
2
|
-
import type { PostRow } from './post-repository.js';
|
|
3
|
-
/**
|
|
4
|
-
* Repository for post revisions.
|
|
5
|
-
*
|
|
6
|
-
* Revisions are stored as posts with type='revision' and
|
|
7
|
-
* postParent pointing to the original post.
|
|
8
|
-
*/
|
|
9
|
-
export declare class RevisionRepository {
|
|
10
|
-
private db;
|
|
11
|
-
constructor(db: Database);
|
|
12
|
-
/**
|
|
13
|
-
* Create a revision snapshot of a post.
|
|
14
|
-
* Returns undefined if nothing changed since the last revision.
|
|
15
|
-
*
|
|
16
|
-
* @param post - The current state of the post (before or after update)
|
|
17
|
-
* @param authorId - The user who made the change
|
|
18
|
-
*/
|
|
19
|
-
createRevision(post: PostRow, authorId: number): Promise<PostRow | undefined>;
|
|
20
|
-
/**
|
|
21
|
-
* Get all revisions for a post, newest first.
|
|
22
|
-
*/
|
|
23
|
-
getRevisions(postId: number, limit?: number): Promise<PostRow[]>;
|
|
24
|
-
/**
|
|
25
|
-
* Get the most recent revision for a post.
|
|
26
|
-
*/
|
|
27
|
-
getLatest(postId: number): Promise<PostRow | undefined>;
|
|
28
|
-
/**
|
|
29
|
-
* Get a specific revision by ID.
|
|
30
|
-
*/
|
|
31
|
-
getById(revisionId: number): Promise<PostRow | undefined>;
|
|
32
|
-
/**
|
|
33
|
-
* Restore a post to a specific revision.
|
|
34
|
-
* Returns the updated post.
|
|
35
|
-
*/
|
|
36
|
-
restore(postId: number, revisionId: number): Promise<PostRow | undefined>;
|
|
37
|
-
/**
|
|
38
|
-
* Delete old revisions beyond the keep limit.
|
|
39
|
-
*/
|
|
40
|
-
cleanup(postId: number, keepCount: number): Promise<number>;
|
|
41
|
-
/**
|
|
42
|
-
* Count revisions for a post.
|
|
43
|
-
*/
|
|
44
|
-
count(postId: number): Promise<number>;
|
|
45
|
-
/**
|
|
46
|
-
* Check if any tracked field changed between two post states.
|
|
47
|
-
*/
|
|
48
|
-
private hasChanges;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=revision-repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"revision-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/revision-repository.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAYpD;;;;;GAKG;AACH,qBAAa,kBAAkB;IAClB,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAEhC;;;;;;OAMG;IACG,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IA6BnF;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAetE;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAK7D;;OAEG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAS/D;;;OAGG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAoB/E;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAyBjE;;OAEG;IACG,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAS5C;;OAEG;IACH,OAAO,CAAC,UAAU;CAMlB"}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { eq, and, desc, sql } from 'drizzle-orm';
|
|
2
|
-
import { posts } from '../schema/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Fields that are tracked for revision diffing.
|
|
5
|
-
* If none of these change, no revision is created.
|
|
6
|
-
*/
|
|
7
|
-
const REVISION_FIELDS = [
|
|
8
|
-
'postTitle',
|
|
9
|
-
'postContent',
|
|
10
|
-
'postExcerpt',
|
|
11
|
-
];
|
|
12
|
-
/**
|
|
13
|
-
* Repository for post revisions.
|
|
14
|
-
*
|
|
15
|
-
* Revisions are stored as posts with type='revision' and
|
|
16
|
-
* postParent pointing to the original post.
|
|
17
|
-
*/
|
|
18
|
-
export class RevisionRepository {
|
|
19
|
-
db;
|
|
20
|
-
constructor(db) {
|
|
21
|
-
this.db = db;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Create a revision snapshot of a post.
|
|
25
|
-
* Returns undefined if nothing changed since the last revision.
|
|
26
|
-
*
|
|
27
|
-
* @param post - The current state of the post (before or after update)
|
|
28
|
-
* @param authorId - The user who made the change
|
|
29
|
-
*/
|
|
30
|
-
async createRevision(post, authorId) {
|
|
31
|
-
// Check if anything actually changed
|
|
32
|
-
const lastRevision = await this.getLatest(post.id);
|
|
33
|
-
if (lastRevision && !this.hasChanges(post, lastRevision)) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
const now = new Date();
|
|
37
|
-
const [revision] = await this.db
|
|
38
|
-
.insert(posts)
|
|
39
|
-
.values({
|
|
40
|
-
postAuthor: authorId,
|
|
41
|
-
postDate: now,
|
|
42
|
-
postDateGmt: now,
|
|
43
|
-
postModified: now,
|
|
44
|
-
postModifiedGmt: now,
|
|
45
|
-
postTitle: post.postTitle,
|
|
46
|
-
postContent: post.postContent,
|
|
47
|
-
postExcerpt: post.postExcerpt,
|
|
48
|
-
postStatus: 'inherit',
|
|
49
|
-
postName: `${post.id}-revision-v1`,
|
|
50
|
-
postType: 'revision',
|
|
51
|
-
postParent: post.id,
|
|
52
|
-
})
|
|
53
|
-
.returning();
|
|
54
|
-
return revision;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Get all revisions for a post, newest first.
|
|
58
|
-
*/
|
|
59
|
-
async getRevisions(postId, limit) {
|
|
60
|
-
let query = this.db
|
|
61
|
-
.select()
|
|
62
|
-
.from(posts)
|
|
63
|
-
.where(and(eq(posts.postParent, postId), eq(posts.postType, 'revision')))
|
|
64
|
-
.orderBy(desc(posts.postDate))
|
|
65
|
-
.$dynamic();
|
|
66
|
-
if (limit !== undefined) {
|
|
67
|
-
query = query.limit(limit);
|
|
68
|
-
}
|
|
69
|
-
return (await query);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get the most recent revision for a post.
|
|
73
|
-
*/
|
|
74
|
-
async getLatest(postId) {
|
|
75
|
-
const rows = await this.getRevisions(postId, 1);
|
|
76
|
-
return rows[0];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Get a specific revision by ID.
|
|
80
|
-
*/
|
|
81
|
-
async getById(revisionId) {
|
|
82
|
-
const rows = await this.db
|
|
83
|
-
.select()
|
|
84
|
-
.from(posts)
|
|
85
|
-
.where(and(eq(posts.id, revisionId), eq(posts.postType, 'revision')))
|
|
86
|
-
.limit(1);
|
|
87
|
-
return rows[0];
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Restore a post to a specific revision.
|
|
91
|
-
* Returns the updated post.
|
|
92
|
-
*/
|
|
93
|
-
async restore(postId, revisionId) {
|
|
94
|
-
const revision = await this.getById(revisionId);
|
|
95
|
-
if (!revision || revision.postParent !== postId)
|
|
96
|
-
return undefined;
|
|
97
|
-
const now = new Date();
|
|
98
|
-
const [updated] = await this.db
|
|
99
|
-
.update(posts)
|
|
100
|
-
.set({
|
|
101
|
-
postTitle: revision.postTitle,
|
|
102
|
-
postContent: revision.postContent,
|
|
103
|
-
postExcerpt: revision.postExcerpt,
|
|
104
|
-
postModified: now,
|
|
105
|
-
postModifiedGmt: now,
|
|
106
|
-
})
|
|
107
|
-
.where(eq(posts.id, postId))
|
|
108
|
-
.returning();
|
|
109
|
-
return updated;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Delete old revisions beyond the keep limit.
|
|
113
|
-
*/
|
|
114
|
-
async cleanup(postId, keepCount) {
|
|
115
|
-
const revisions = await this.getRevisions(postId);
|
|
116
|
-
if (revisions.length <= keepCount)
|
|
117
|
-
return 0;
|
|
118
|
-
const toDelete = revisions.slice(keepCount);
|
|
119
|
-
const idsToDelete = toDelete.map((r) => r.id);
|
|
120
|
-
if (idsToDelete.length === 0)
|
|
121
|
-
return 0;
|
|
122
|
-
const result = await this.db
|
|
123
|
-
.delete(posts)
|
|
124
|
-
.where(and(sql `${posts.id} IN (${sql.join(idsToDelete.map((id) => sql `${id}`), sql `, `)})`, eq(posts.postType, 'revision')))
|
|
125
|
-
.returning({ id: posts.id });
|
|
126
|
-
return result.length;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Count revisions for a post.
|
|
130
|
-
*/
|
|
131
|
-
async count(postId) {
|
|
132
|
-
const [result] = await this.db
|
|
133
|
-
.select({ count: sql `count(*)::int` })
|
|
134
|
-
.from(posts)
|
|
135
|
-
.where(and(eq(posts.postParent, postId), eq(posts.postType, 'revision')));
|
|
136
|
-
return result.count;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Check if any tracked field changed between two post states.
|
|
140
|
-
*/
|
|
141
|
-
hasChanges(current, previous) {
|
|
142
|
-
for (const field of REVISION_FIELDS) {
|
|
143
|
-
if (current[field] !== previous[field])
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=revision-repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"revision-repository.js","sourceRoot":"","sources":["../../src/repositories/revision-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C;;;GAGG;AACH,MAAM,eAAe,GAAG;IACvB,WAAW;IACX,aAAa;IACb,aAAa;CACJ,CAAC;AAEX;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IACV;IAApB,YAAoB,EAAY;QAAZ,OAAE,GAAF,EAAE,CAAU;IAAG,CAAC;IAEpC;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAAC,IAA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AC,EAAE,KAAK,EAAE,GAAG,CAAQ,eAAe,EAAE,CAAC;aAC7C,IAAI,CAAC,KAAK,CAAC;aACX,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QAE3E,OAAO,MAAM,CAAC,KAAK,CAAC;IACrB,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,OAAgB,EAAE,QAAiB;QACrD,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;YACrC,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAC,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;QACrD,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { Database } from '../connection.js';
|
|
2
|
-
import { MetaRepository } from './meta-repository.js';
|
|
3
|
-
export interface CreateTermInput {
|
|
4
|
-
name: string;
|
|
5
|
-
slug?: string;
|
|
6
|
-
taxonomy: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
parent?: number;
|
|
9
|
-
}
|
|
10
|
-
export interface TermRow {
|
|
11
|
-
termId: number;
|
|
12
|
-
name: string;
|
|
13
|
-
slug: string;
|
|
14
|
-
termGroup: number;
|
|
15
|
-
termTaxonomyId: number;
|
|
16
|
-
taxonomy: string;
|
|
17
|
-
description: string;
|
|
18
|
-
parent: number;
|
|
19
|
-
count: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Repository for taxonomy terms (categories, tags, custom taxonomies).
|
|
23
|
-
*/
|
|
24
|
-
export declare class TaxonomyRepository {
|
|
25
|
-
private db;
|
|
26
|
-
readonly meta: MetaRepository;
|
|
27
|
-
constructor(db: Database);
|
|
28
|
-
/**
|
|
29
|
-
* Create a new term in a taxonomy.
|
|
30
|
-
*/
|
|
31
|
-
createTerm(input: CreateTermInput): Promise<TermRow>;
|
|
32
|
-
/**
|
|
33
|
-
* Get a term by ID and taxonomy.
|
|
34
|
-
*/
|
|
35
|
-
getTermById(termId: number, taxonomy: string): Promise<TermRow | undefined>;
|
|
36
|
-
/**
|
|
37
|
-
* Get a term by slug and taxonomy.
|
|
38
|
-
*/
|
|
39
|
-
getTermBySlug(slug: string, taxonomy: string): Promise<TermRow | undefined>;
|
|
40
|
-
/**
|
|
41
|
-
* Get all terms in a taxonomy.
|
|
42
|
-
*/
|
|
43
|
-
getTerms(taxonomy: string, parentId?: number): Promise<TermRow[]>;
|
|
44
|
-
/**
|
|
45
|
-
* Assign terms to an object (post).
|
|
46
|
-
*/
|
|
47
|
-
setObjectTerms(objectId: number, termTaxonomyIds: number[]): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Get terms assigned to an object.
|
|
50
|
-
*/
|
|
51
|
-
getObjectTerms(objectId: number, taxonomy?: string): Promise<TermRow[]>;
|
|
52
|
-
/**
|
|
53
|
-
* Delete a term and all its relationships.
|
|
54
|
-
*/
|
|
55
|
-
deleteTerm(termId: number, taxonomy: string): Promise<boolean>;
|
|
56
|
-
/**
|
|
57
|
-
* Recount the number of objects assigned to terms.
|
|
58
|
-
*/
|
|
59
|
-
recountTerms(termTaxonomyIds: number[]): Promise<void>;
|
|
60
|
-
private generateSlug;
|
|
61
|
-
private ensureUniqueSlug;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=taxonomy-repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"taxonomy-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/taxonomy-repository.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAOjD,OAAO,EAAE,cAAc,EAA+C,MAAM,sBAAsB,CAAC;AAEnG,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC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G;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA+BpE;;OAEG;IACG,YAAY,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAc5D,OAAO,CAAC,YAAY;YAYN,gBAAgB;CAqB9B"}
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { eq, and, sql, inArray } from 'drizzle-orm';
|
|
2
|
-
import { terms, termTaxonomy, termRelationships, termmeta, } from '../schema/index.js';
|
|
3
|
-
import { MetaRepository } from './meta-repository.js';
|
|
4
|
-
/**
|
|
5
|
-
* Repository for taxonomy terms (categories, tags, custom taxonomies).
|
|
6
|
-
*/
|
|
7
|
-
export class TaxonomyRepository {
|
|
8
|
-
db;
|
|
9
|
-
meta;
|
|
10
|
-
constructor(db) {
|
|
11
|
-
this.db = db;
|
|
12
|
-
const metaCols = {
|
|
13
|
-
metaId: termmeta.metaId,
|
|
14
|
-
objectId: termmeta.termId,
|
|
15
|
-
metaKey: termmeta.metaKey,
|
|
16
|
-
metaValue: termmeta.metaValue,
|
|
17
|
-
metaValueJson: termmeta.metaValueJson,
|
|
18
|
-
};
|
|
19
|
-
const colNames = {
|
|
20
|
-
table: 'termmeta',
|
|
21
|
-
sql: { metaId: 'meta_id', objectId: 'term_id', metaKey: 'meta_key', metaValue: 'meta_value', metaValueJson: 'meta_value_json' },
|
|
22
|
-
ts: { metaId: 'metaId', objectId: 'termId', metaKey: 'metaKey', metaValue: 'metaValue', metaValueJson: 'metaValueJson' },
|
|
23
|
-
};
|
|
24
|
-
this.meta = new MetaRepository(db, termmeta, metaCols, colNames);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Create a new term in a taxonomy.
|
|
28
|
-
*/
|
|
29
|
-
async createTerm(input) {
|
|
30
|
-
const slug = input.slug || this.generateSlug(input.name);
|
|
31
|
-
const uniqueSlug = await this.ensureUniqueSlug(slug);
|
|
32
|
-
const [term] = await this.db
|
|
33
|
-
.insert(terms)
|
|
34
|
-
.values({
|
|
35
|
-
name: input.name,
|
|
36
|
-
slug: uniqueSlug,
|
|
37
|
-
})
|
|
38
|
-
.returning();
|
|
39
|
-
const [tt] = await this.db
|
|
40
|
-
.insert(termTaxonomy)
|
|
41
|
-
.values({
|
|
42
|
-
termId: term.termId,
|
|
43
|
-
taxonomy: input.taxonomy,
|
|
44
|
-
description: input.description ?? '',
|
|
45
|
-
parent: input.parent ?? 0,
|
|
46
|
-
count: 0,
|
|
47
|
-
})
|
|
48
|
-
.returning();
|
|
49
|
-
return {
|
|
50
|
-
termId: term.termId,
|
|
51
|
-
name: term.name,
|
|
52
|
-
slug: term.slug,
|
|
53
|
-
termGroup: term.termGroup,
|
|
54
|
-
termTaxonomyId: tt.termTaxonomyId,
|
|
55
|
-
taxonomy: tt.taxonomy,
|
|
56
|
-
description: tt.description,
|
|
57
|
-
parent: tt.parent,
|
|
58
|
-
count: tt.count,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get a term by ID and taxonomy.
|
|
63
|
-
*/
|
|
64
|
-
async getTermById(termId, taxonomy) {
|
|
65
|
-
const rows = await this.db
|
|
66
|
-
.select({
|
|
67
|
-
termId: terms.termId,
|
|
68
|
-
name: terms.name,
|
|
69
|
-
slug: terms.slug,
|
|
70
|
-
termGroup: terms.termGroup,
|
|
71
|
-
termTaxonomyId: termTaxonomy.termTaxonomyId,
|
|
72
|
-
taxonomy: termTaxonomy.taxonomy,
|
|
73
|
-
description: termTaxonomy.description,
|
|
74
|
-
parent: termTaxonomy.parent,
|
|
75
|
-
count: termTaxonomy.count,
|
|
76
|
-
})
|
|
77
|
-
.from(terms)
|
|
78
|
-
.innerJoin(termTaxonomy, eq(terms.termId, termTaxonomy.termId))
|
|
79
|
-
.where(and(eq(terms.termId, termId), eq(termTaxonomy.taxonomy, taxonomy)))
|
|
80
|
-
.limit(1);
|
|
81
|
-
return rows[0];
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Get a term by slug and taxonomy.
|
|
85
|
-
*/
|
|
86
|
-
async getTermBySlug(slug, taxonomy) {
|
|
87
|
-
const rows = await this.db
|
|
88
|
-
.select({
|
|
89
|
-
termId: terms.termId,
|
|
90
|
-
name: terms.name,
|
|
91
|
-
slug: terms.slug,
|
|
92
|
-
termGroup: terms.termGroup,
|
|
93
|
-
termTaxonomyId: termTaxonomy.termTaxonomyId,
|
|
94
|
-
taxonomy: termTaxonomy.taxonomy,
|
|
95
|
-
description: termTaxonomy.description,
|
|
96
|
-
parent: termTaxonomy.parent,
|
|
97
|
-
count: termTaxonomy.count,
|
|
98
|
-
})
|
|
99
|
-
.from(terms)
|
|
100
|
-
.innerJoin(termTaxonomy, eq(terms.termId, termTaxonomy.termId))
|
|
101
|
-
.where(and(eq(terms.slug, slug), eq(termTaxonomy.taxonomy, taxonomy)))
|
|
102
|
-
.limit(1);
|
|
103
|
-
return rows[0];
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Get all terms in a taxonomy.
|
|
107
|
-
*/
|
|
108
|
-
async getTerms(taxonomy, parentId) {
|
|
109
|
-
const conditions = [eq(termTaxonomy.taxonomy, taxonomy)];
|
|
110
|
-
if (parentId !== undefined) {
|
|
111
|
-
conditions.push(eq(termTaxonomy.parent, parentId));
|
|
112
|
-
}
|
|
113
|
-
const rows = await this.db
|
|
114
|
-
.select({
|
|
115
|
-
termId: terms.termId,
|
|
116
|
-
name: terms.name,
|
|
117
|
-
slug: terms.slug,
|
|
118
|
-
termGroup: terms.termGroup,
|
|
119
|
-
termTaxonomyId: termTaxonomy.termTaxonomyId,
|
|
120
|
-
taxonomy: termTaxonomy.taxonomy,
|
|
121
|
-
description: termTaxonomy.description,
|
|
122
|
-
parent: termTaxonomy.parent,
|
|
123
|
-
count: termTaxonomy.count,
|
|
124
|
-
})
|
|
125
|
-
.from(terms)
|
|
126
|
-
.innerJoin(termTaxonomy, eq(terms.termId, termTaxonomy.termId))
|
|
127
|
-
.where(and(...conditions))
|
|
128
|
-
.orderBy(terms.name);
|
|
129
|
-
return rows;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Assign terms to an object (post).
|
|
133
|
-
*/
|
|
134
|
-
async setObjectTerms(objectId, termTaxonomyIds) {
|
|
135
|
-
// Remove existing relationships for these taxonomies
|
|
136
|
-
const existingTtIds = termTaxonomyIds.length > 0
|
|
137
|
-
? await this.db
|
|
138
|
-
.select({ taxonomy: termTaxonomy.taxonomy })
|
|
139
|
-
.from(termTaxonomy)
|
|
140
|
-
.where(inArray(termTaxonomy.termTaxonomyId, termTaxonomyIds))
|
|
141
|
-
: [];
|
|
142
|
-
const taxonomies = [...new Set(existingTtIds.map((r) => r.taxonomy))];
|
|
143
|
-
if (taxonomies.length > 0) {
|
|
144
|
-
// Get all term_taxonomy_ids for these taxonomies
|
|
145
|
-
const allTtIds = await this.db
|
|
146
|
-
.select({ termTaxonomyId: termTaxonomy.termTaxonomyId })
|
|
147
|
-
.from(termTaxonomy)
|
|
148
|
-
.where(inArray(termTaxonomy.taxonomy, taxonomies));
|
|
149
|
-
const allTtIdValues = allTtIds.map((r) => r.termTaxonomyId);
|
|
150
|
-
if (allTtIdValues.length > 0) {
|
|
151
|
-
await this.db
|
|
152
|
-
.delete(termRelationships)
|
|
153
|
-
.where(and(eq(termRelationships.objectId, objectId), inArray(termRelationships.termTaxonomyId, allTtIdValues)));
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
// Insert new relationships
|
|
157
|
-
if (termTaxonomyIds.length > 0) {
|
|
158
|
-
await this.db.insert(termRelationships).values(termTaxonomyIds.map((ttId, i) => ({
|
|
159
|
-
objectId,
|
|
160
|
-
termTaxonomyId: ttId,
|
|
161
|
-
termOrder: i,
|
|
162
|
-
}))).onConflictDoNothing();
|
|
163
|
-
}
|
|
164
|
-
// Update counts
|
|
165
|
-
await this.recountTerms(termTaxonomyIds);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Get terms assigned to an object.
|
|
169
|
-
*/
|
|
170
|
-
async getObjectTerms(objectId, taxonomy) {
|
|
171
|
-
const conditions = [eq(termRelationships.objectId, objectId)];
|
|
172
|
-
if (taxonomy) {
|
|
173
|
-
conditions.push(eq(termTaxonomy.taxonomy, taxonomy));
|
|
174
|
-
}
|
|
175
|
-
const rows = await this.db
|
|
176
|
-
.select({
|
|
177
|
-
termId: terms.termId,
|
|
178
|
-
name: terms.name,
|
|
179
|
-
slug: terms.slug,
|
|
180
|
-
termGroup: terms.termGroup,
|
|
181
|
-
termTaxonomyId: termTaxonomy.termTaxonomyId,
|
|
182
|
-
taxonomy: termTaxonomy.taxonomy,
|
|
183
|
-
description: termTaxonomy.description,
|
|
184
|
-
parent: termTaxonomy.parent,
|
|
185
|
-
count: termTaxonomy.count,
|
|
186
|
-
})
|
|
187
|
-
.from(termRelationships)
|
|
188
|
-
.innerJoin(termTaxonomy, eq(termRelationships.termTaxonomyId, termTaxonomy.termTaxonomyId))
|
|
189
|
-
.innerJoin(terms, eq(termTaxonomy.termId, terms.termId))
|
|
190
|
-
.where(and(...conditions))
|
|
191
|
-
.orderBy(termRelationships.termOrder);
|
|
192
|
-
return rows;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Delete a term and all its relationships.
|
|
196
|
-
*/
|
|
197
|
-
async deleteTerm(termId, taxonomy) {
|
|
198
|
-
const term = await this.getTermById(termId, taxonomy);
|
|
199
|
-
if (!term)
|
|
200
|
-
return false;
|
|
201
|
-
// Delete relationships
|
|
202
|
-
await this.db
|
|
203
|
-
.delete(termRelationships)
|
|
204
|
-
.where(eq(termRelationships.termTaxonomyId, term.termTaxonomyId));
|
|
205
|
-
// Delete term_taxonomy
|
|
206
|
-
await this.db
|
|
207
|
-
.delete(termTaxonomy)
|
|
208
|
-
.where(eq(termTaxonomy.termTaxonomyId, term.termTaxonomyId));
|
|
209
|
-
// Delete term (if not used by another taxonomy)
|
|
210
|
-
const otherUsages = await this.db
|
|
211
|
-
.select({ termTaxonomyId: termTaxonomy.termTaxonomyId })
|
|
212
|
-
.from(termTaxonomy)
|
|
213
|
-
.where(eq(termTaxonomy.termId, termId))
|
|
214
|
-
.limit(1);
|
|
215
|
-
if (otherUsages.length === 0) {
|
|
216
|
-
await this.db.delete(terms).where(eq(terms.termId, termId));
|
|
217
|
-
}
|
|
218
|
-
// Delete meta
|
|
219
|
-
await this.meta.deleteAllForObject(termId);
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Recount the number of objects assigned to terms.
|
|
224
|
-
*/
|
|
225
|
-
async recountTerms(termTaxonomyIds) {
|
|
226
|
-
for (const ttId of termTaxonomyIds) {
|
|
227
|
-
const [result] = await this.db
|
|
228
|
-
.select({ count: sql `count(*)::int` })
|
|
229
|
-
.from(termRelationships)
|
|
230
|
-
.where(eq(termRelationships.termTaxonomyId, ttId));
|
|
231
|
-
await this.db
|
|
232
|
-
.update(termTaxonomy)
|
|
233
|
-
.set({ count: result.count })
|
|
234
|
-
.where(eq(termTaxonomy.termTaxonomyId, ttId));
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
generateSlug(name) {
|
|
238
|
-
return name
|
|
239
|
-
.toLowerCase()
|
|
240
|
-
.normalize('NFD')
|
|
241
|
-
.replace(/[\u0300-\u036f]/g, '')
|
|
242
|
-
.replace(/[^a-z0-9_\s-]/g, '')
|
|
243
|
-
.replace(/\s+/g, '-')
|
|
244
|
-
.replace(/-+/g, '-')
|
|
245
|
-
.replace(/^-|-$/g, '')
|
|
246
|
-
.substring(0, 200);
|
|
247
|
-
}
|
|
248
|
-
async ensureUniqueSlug(slug, excludeId) {
|
|
249
|
-
let candidate = slug;
|
|
250
|
-
let suffix = 2;
|
|
251
|
-
while (true) {
|
|
252
|
-
const conditions = [eq(terms.slug, candidate)];
|
|
253
|
-
if (excludeId !== undefined) {
|
|
254
|
-
conditions.push(sql `${terms.termId} != ${excludeId}`);
|
|
255
|
-
}
|
|
256
|
-
const existing = await this.db
|
|
257
|
-
.select({ termId: terms.termId })
|
|
258
|
-
.from(terms)
|
|
259
|
-
.where(and(...conditions))
|
|
260
|
-
.limit(1);
|
|
261
|
-
if (existing.length === 0)
|
|
262
|
-
return candidate;
|
|
263
|
-
candidate = `${slug}-${suffix}`;
|
|
264
|
-
suffix++;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
//# sourceMappingURL=taxonomy-repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"taxonomy-repository.js","sourceRoot":"","sources":["../../src/repositories/taxonomy-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EACN,KAAK,EACL,YAAY,EACZ,iBAAiB,EACjB,QAAQ,GACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAA+C,MAAM,sBAAsB,CAAC;AAsBnG;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAGV;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;YAC7B,aAAa,EAAE,QAAQ,CAAC,aAAa;SACrC,CAAC;QACF,MAAM,QAAQ,GAAoB;YACjC,KAAK,EAAE,UAAU;YACjB,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE;YAC/H,EAAE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