@rnaga/wp-node 1.3.5 → 1.3.8
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/crud/meta.crud.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class MetaCrud extends Crud {
|
|
|
28
28
|
data: number;
|
|
29
29
|
info: undefined;
|
|
30
30
|
}>;
|
|
31
|
-
list(table: types.MetaTable, args?: Partial<z.infer<typeof val.crud.
|
|
31
|
+
list(table: types.MetaTable, args?: Partial<z.infer<typeof val.crud.metaListParams>>, options?: {
|
|
32
32
|
unserialize?: boolean;
|
|
33
33
|
}): Promise<{
|
|
34
34
|
data: ({
|
package/crud/post.crud.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare class PostCrud extends Crud {
|
|
|
37
37
|
file: string;
|
|
38
38
|
context: string;
|
|
39
39
|
ID?: number | undefined;
|
|
40
|
-
|
|
40
|
+
post_category?: number[] | undefined;
|
|
41
41
|
tax_input?: Record<string, string[] | (string | number)[] | number[]> | undefined;
|
|
42
42
|
meta_input?: Record<string, string | number | Record<string, any> | (string | number)[]> | undefined;
|
|
43
43
|
};
|
|
@@ -149,7 +149,7 @@ export declare class PostCrud extends Crud {
|
|
|
149
149
|
file: string;
|
|
150
150
|
context: string;
|
|
151
151
|
ID?: number | undefined;
|
|
152
|
-
|
|
152
|
+
post_category?: number[] | undefined;
|
|
153
153
|
tax_input?: Record<string, string[] | (string | number)[] | number[]> | undefined;
|
|
154
154
|
meta_input?: Record<string, string | number | Record<string, any> | (string | number)[]> | undefined;
|
|
155
155
|
};
|
package/crud/post.crud.js
CHANGED
|
@@ -116,10 +116,10 @@ let PostCrud = class PostCrud extends crud_1.Crud {
|
|
|
116
116
|
!(await user.can(postType?.capabilities?.publish_posts))) {
|
|
117
117
|
data.post_password = currentPost.post_password ?? "";
|
|
118
118
|
}
|
|
119
|
-
if (diffData.
|
|
119
|
+
if (diffData.post_category && diffData.post_category.length > 0) {
|
|
120
120
|
const category = await this.components.get(taxonomy_util_1.TaxonomyUtil).get("category");
|
|
121
121
|
if (!(await user.can(category.props?.capabilities?.assign_terms))) {
|
|
122
|
-
data.
|
|
122
|
+
data.post_category = currentPost.post_category ?? undefined;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
return data;
|
|
@@ -176,7 +176,7 @@ let PostCrud = class PostCrud extends crud_1.Crud {
|
|
|
176
176
|
...getData,
|
|
177
177
|
meta_input: await post.meta.props(),
|
|
178
178
|
tags_input: (await post.terms("post_tag"))?.map((tag) => tag.term_id),
|
|
179
|
-
|
|
179
|
+
post_category: (await post.terms("category"))?.map((category) => category.term_id),
|
|
180
180
|
};
|
|
181
181
|
return this.returnValue(val.trx.postUpsert.parse({ ...data, ...defaultValue }));
|
|
182
182
|
}
|
package/package.json
CHANGED
package/transactions/post.trx.js
CHANGED
|
@@ -138,7 +138,7 @@ let PostTrx = class PostTrx extends trx_1.Trx {
|
|
|
138
138
|
// Combine input with existing record
|
|
139
139
|
input = {
|
|
140
140
|
...postBefore.props,
|
|
141
|
-
|
|
141
|
+
post_category: ((await postBefore.terms("category")) ?? []).map((v) => v.term_id),
|
|
142
142
|
tags_input: ((await postBefore.terms("post_tag")) ?? []).map((v) => v.term_id),
|
|
143
143
|
...input,
|
|
144
144
|
};
|
|
@@ -184,10 +184,10 @@ let PostTrx = class PostTrx extends trx_1.Trx {
|
|
|
184
184
|
data.post_status = "inherit";
|
|
185
185
|
}
|
|
186
186
|
let postCategory = [];
|
|
187
|
-
if (Array.isArray(parsedInput.
|
|
188
|
-
postCategory = parsedInput.
|
|
187
|
+
if (Array.isArray(parsedInput.post_category)) {
|
|
188
|
+
postCategory = parsedInput.post_category.filter((v) => v > 0);
|
|
189
189
|
}
|
|
190
|
-
else if (update && !parsedInput.
|
|
190
|
+
else if (update && !parsedInput.post_category) {
|
|
191
191
|
postCategory = !postBefore
|
|
192
192
|
? []
|
|
193
193
|
: (await postBefore.terms("category"))?.map((term) => term.term_id) ??
|
|
@@ -202,7 +202,7 @@ let PostTrx = class PostTrx extends trx_1.Trx {
|
|
|
202
202
|
postCategory = [defaultCategory];
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
data.
|
|
205
|
+
data.post_category = postCategory;
|
|
206
206
|
/*
|
|
207
207
|
* Don't allow contributors to set the post slug for pending review posts.
|
|
208
208
|
*
|
|
@@ -371,7 +371,7 @@ let PostTrx = class PostTrx extends trx_1.Trx {
|
|
|
371
371
|
const taxonomyCategory = await this.taxonomyUtil.get("category");
|
|
372
372
|
if (!taxonomyCategory.isDefault &&
|
|
373
373
|
taxonomyCategory.props?.objectType == data.post_type) {
|
|
374
|
-
await this.syncCategories(post.props.ID, data.
|
|
374
|
+
await this.syncCategories(post.props.ID, data.post_category);
|
|
375
375
|
}
|
|
376
376
|
// Sync tags
|
|
377
377
|
const taxonomyPostTag = await this.taxonomyUtil.get("post_tag");
|
|
@@ -22,7 +22,7 @@ export declare const postUpsert: z.ZodObject<{
|
|
|
22
22
|
ID: z.ZodOptional<z.ZodNumber>;
|
|
23
23
|
import_id: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
24
24
|
post_status: z.ZodDefault<z.ZodString>;
|
|
25
|
-
|
|
25
|
+
post_category: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
26
26
|
comment_status: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
27
27
|
open: "open";
|
|
28
28
|
closed: "closed";
|
|
@@ -47,7 +47,7 @@ exports.postUpsert = database.wpPosts
|
|
|
47
47
|
ID: zod_1.z.number().nonnegative().optional(),
|
|
48
48
|
import_id: zod_1.z.number().nonnegative().optional().default(0),
|
|
49
49
|
post_status: zod_1.z.string().default("draft"),
|
|
50
|
-
|
|
50
|
+
post_category: zod_1.z.array(zod_1.z.number()).optional(),
|
|
51
51
|
comment_status: zod_1.z.enum(["open", "closed"]).optional().default("open"),
|
|
52
52
|
ping_status: zod_1.z.enum(["open", "closed"]).default("open"),
|
|
53
53
|
tags_input: zod_1.z
|