@paroicms/server 1.30.0 → 1.31.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/ddl/main.ddl.sql +12 -7
- package/dist/common/child-ordering-query.d.ts +3 -3
- package/dist/common/child-ordering-query.js +11 -12
- package/dist/common/child-ordering-query.js.map +1 -1
- package/dist/common/data-format.d.ts +6 -6
- package/dist/common/data-format.js +3 -3
- package/dist/common/text-cache.d.ts +2 -2
- package/dist/common/text-cache.js +2 -2
- package/dist/context.js +1 -1
- package/dist/context.js.map +1 -1
- package/dist/helpers/special-account.helpers.d.ts +1 -1
- package/dist/models/account.model.js.map +1 -0
- package/dist/models/document.model.js.map +1 -0
- package/dist/models/fields.model.js.map +1 -0
- package/dist/{modules/core/term-flag/term-flag.model.d.ts → models/labeling.model.d.ts} +2 -2
- package/dist/{modules/core/term-flag/term-flag.model.js → models/labeling.model.js} +13 -13
- package/dist/models/labeling.model.js.map +1 -0
- package/dist/models/leaf.model.js.map +1 -0
- package/dist/models/ordered-leaf.model.d.ts +5 -0
- package/dist/{modules/core/leaf-item/leaf-item.model.js → models/ordered-leaf.model.js} +11 -16
- package/dist/models/ordered-leaf.model.js.map +1 -0
- package/dist/{modules/core/leaf-item/leaf-item.model.d.ts → models/part-leaf.model.d.ts} +2 -2
- package/dist/models/part-leaf.model.js +45 -0
- package/dist/models/part-leaf.model.js.map +1 -0
- package/dist/models/section.model.js.map +1 -0
- package/dist/modules/core/account/account.queries.d.ts +1 -1
- package/dist/modules/core/account/account.queries.js +1 -1
- package/dist/modules/core/account/account.queries.js.map +1 -1
- package/dist/modules/core/core.module.js +2 -2
- package/dist/modules/core/core.module.js.map +1 -1
- package/dist/modules/core/document/document.module.js +1 -1
- package/dist/modules/core/document/document.resolver.extend.d.ts +3 -3
- package/dist/modules/core/document/document.resolver.extend.js +9 -9
- package/dist/modules/core/document/document.resolver.extend.js.map +1 -1
- package/dist/modules/core/document/load-documents.queries.d.ts +1 -1
- package/dist/modules/core/document/load-documents.queries.js +5 -5
- package/dist/modules/core/document/load-documents.queries.js.map +1 -1
- package/dist/modules/core/document/save-documents.queries.js +12 -12
- package/dist/modules/core/document/save-documents.queries.js.map +1 -1
- package/dist/modules/core/fields/load-fields.queries.js +2 -2
- package/dist/modules/core/fields/load-fields.queries.js.map +1 -1
- package/dist/modules/core/fields/save-fields.queries.js +2 -2
- package/dist/modules/core/fields/save-fields.queries.js.map +1 -1
- package/dist/modules/core/labeling/labeling.module.d.ts +2 -0
- package/dist/modules/core/{term-flag/term-flag.module.js → labeling/labeling.module.js} +8 -8
- package/dist/modules/core/labeling/labeling.module.js.map +1 -0
- package/dist/modules/core/labeling/labeling.queries.d.ts +7 -0
- package/dist/modules/core/labeling/labeling.queries.js +58 -0
- package/dist/modules/core/labeling/labeling.queries.js.map +1 -0
- package/dist/modules/core/labeling/labeling.resolver.d.ts +5 -0
- package/dist/modules/core/{term-flag/term-flag.resolver.js → labeling/labeling.resolver.js} +15 -15
- package/dist/modules/core/labeling/labeling.resolver.js.map +1 -0
- package/dist/modules/core/{term-flag/term-flag.schema.d.ts → labeling/labeling.schema.d.ts} +1 -1
- package/dist/modules/core/{term-flag/term-flag.schema.js → labeling/labeling.schema.js} +10 -10
- package/dist/modules/core/labeling/labeling.schema.js.map +1 -0
- package/dist/modules/core/leaf/leaf.queries.d.ts +3 -3
- package/dist/modules/core/leaf/leaf.queries.js +14 -14
- package/dist/modules/core/leaf/leaf.queries.js.map +1 -1
- package/dist/modules/core/leaf/leaf.resolver.d.ts +4 -3
- package/dist/modules/core/leaf/leaf.resolver.js +22 -9
- package/dist/modules/core/leaf/leaf.resolver.js.map +1 -1
- package/dist/modules/core/leaf/ordered-leaf.queries.d.ts +7 -0
- package/dist/modules/core/leaf/ordered-leaf.queries.js +67 -0
- package/dist/modules/core/leaf/ordered-leaf.queries.js.map +1 -0
- package/dist/modules/core/part/part-leaf.queries.d.ts +9 -0
- package/dist/modules/core/part/part-leaf.queries.js +63 -0
- package/dist/modules/core/part/part-leaf.queries.js.map +1 -0
- package/dist/modules/core/part/part.queries.d.ts +1 -1
- package/dist/modules/core/part/part.queries.js +50 -44
- package/dist/modules/core/part/part.queries.js.map +1 -1
- package/dist/modules/core/part/part.resolver.d.ts +2 -2
- package/dist/modules/core/part/part.resolver.js +8 -7
- package/dist/modules/core/part/part.resolver.js.map +1 -1
- package/dist/modules/core/section/section-wrap.resolver.js +1 -1
- package/dist/modules/core/section/section-wrap.resolver.js.map +1 -1
- package/dist/modules/core/section/section.queries.d.ts +1 -5
- package/dist/modules/core/section/section.queries.js +5 -5
- package/dist/modules/core/section/section.queries.js.map +1 -1
- package/dist/modules/core/section/section.resolver.js +1 -1
- package/dist/modules/core/section/section.resolver.js.map +1 -1
- package/dist/modules/public-api/partials/partials-params.dto.d.ts +1 -1
- package/dist/modules/public-api/partials/partials-params.dto.js +2 -2
- package/dist/modules/public-api/partials/partials-params.dto.js.map +1 -1
- package/dist/modules/public-api/password-reset/password-reset.service.js +2 -2
- package/dist/modules/public-api/password-reset/password-reset.service.js.map +1 -1
- package/dist/modules/public-api/public-api-controller.d.ts +1 -1
- package/dist/modules/public-api/public-api-controller.js +7 -7
- package/dist/modules/public-api/public-api-controller.js.map +1 -1
- package/dist/modules/public-api/search-text/search-text.queries.js +20 -15
- package/dist/modules/public-api/search-text/search-text.queries.js.map +1 -1
- package/dist/modules/public-site/feed/feed-generator.js +2 -7
- package/dist/modules/public-site/feed/feed-generator.js.map +1 -1
- package/dist/modules/public-site/liquidjs-filters/info-filter.js +2 -1
- package/dist/modules/public-site/liquidjs-filters/info-filter.js.map +1 -1
- package/dist/modules/public-site/liquidjs-tags/get-docs-tag.d.ts +2 -2
- package/dist/modules/public-site/liquidjs-tags/get-docs-tag.js +42 -34
- package/dist/modules/public-site/liquidjs-tags/get-docs-tag.js.map +1 -1
- package/dist/modules/public-site/liquidjs-tags/get-paginated-docs-tag.d.ts +28 -0
- package/dist/modules/public-site/liquidjs-tags/get-paginated-docs-tag.js +82 -0
- package/dist/modules/public-site/liquidjs-tags/get-paginated-docs-tag.js.map +1 -0
- package/dist/modules/public-site/liquidjs-tags/use-image-tag.d.ts +2 -2
- package/dist/modules/public-site/public-route/make-url.js +1 -1
- package/dist/modules/public-site/public-route/make-url.js.map +1 -1
- package/dist/modules/public-site/public-route/public-route-parser.d.ts +2 -2
- package/dist/modules/public-site/public-route/public-route-parser.js +9 -9
- package/dist/modules/public-site/public-route/public-route-parser.js.map +1 -1
- package/dist/modules/public-site/public-route/raw-document-payload.js +2 -2
- package/dist/modules/public-site/public-route/raw-document-payload.js.map +1 -1
- package/dist/modules/public-site/serve-document/serve-document.js +2 -2
- package/dist/modules/public-site/serve-document/serve-document.js.map +1 -1
- package/dist/public-payload/create-doc-drop.js +23 -11
- package/dist/public-payload/create-doc-drop.js.map +1 -1
- package/dist/public-payload/create-doc-part-drop.js +2 -2
- package/dist/public-payload/create-doc-part-drop.js.map +1 -1
- package/dist/public-payload/doc-values.queries.d.ts +18 -8
- package/dist/public-payload/doc-values.queries.js +25 -17
- package/dist/public-payload/doc-values.queries.js.map +1 -1
- package/dist/public-payload/excerpt.queries.js +1 -1
- package/dist/public-payload/excerpt.queries.js.map +1 -1
- package/dist/public-payload/get-siblings.queries.js +5 -5
- package/dist/public-payload/get-siblings.queries.js.map +1 -1
- package/dist/public-payload/parts.queries.js +17 -16
- package/dist/public-payload/parts.queries.js.map +1 -1
- package/dist/public-payload/public-payload.types.d.ts +8 -2
- package/dist/public-payload/taxonomies.queries.d.ts +1 -1
- package/dist/public-payload/taxonomies.queries.js +6 -6
- package/dist/public-payload/taxonomies.queries.js.map +1 -1
- package/dist/public-payload/translations.queries.js +1 -1
- package/dist/public-payload/translations.queries.js.map +1 -1
- package/dist/site-context/create-site-context.js +7 -1
- package/dist/site-context/create-site-context.js.map +1 -1
- package/dist/site-context/db-init/ddl-migration.d.ts +1 -1
- package/dist/site-context/db-init/ddl-migration.js +21 -1
- package/dist/site-context/db-init/ddl-migration.js.map +1 -1
- package/dist/site-context/db-init/init-routing-points.js +6 -6
- package/dist/site-context/db-init/init-routing-points.js.map +1 -1
- package/dist/site-schema/common-schema-reader.js +1 -1
- package/dist/site-schema/common-schema-reader.js.map +1 -1
- package/dist/site-schema/site-schema-factory.js +13 -15
- package/dist/site-schema/site-schema-factory.js.map +1 -1
- package/dist/site-schema/site-schema-helpers.d.ts +4 -4
- package/dist/site-schema/site-schema-helpers.js +9 -9
- package/dist/site-schema/site-schema-helpers.js.map +1 -1
- package/dist/site-schema/site-schema-lib-reader.js +1 -1
- package/dist/site-schema/site-schema-lib-reader.js.map +1 -1
- package/dist/types.to.json +1 -1
- package/package.json +10 -10
- package/schema.gql +13 -12
- package/site-schema-lib/common-schema.json +1 -1
- package/site-schema-lib/{media-policies.site-schema.json → default-media-policies.site-schema.json} +1 -1
- package/site-schema-lib/{fields.site-schema.json → field-lib.site-schema.json} +1 -1
- package/site-schema-lib/lowcost.site-schema.json +15 -9
- package/site-schema-lib/lowcost.site-schema.l10n.en.json +5 -3
- package/site-schema-lib/lowcost.site-schema.l10n.fr.json +5 -3
- package/dist/modules/core/account/account.model.js.map +0 -1
- package/dist/modules/core/document/document.model.js.map +0 -1
- package/dist/modules/core/fields/fields.model.js.map +0 -1
- package/dist/modules/core/leaf/leaf.model.js.map +0 -1
- package/dist/modules/core/leaf-item/leaf-item.model.js.map +0 -1
- package/dist/modules/core/leaf-item/leaf-item.queries.d.ts +0 -9
- package/dist/modules/core/leaf-item/leaf-item.queries.js +0 -120
- package/dist/modules/core/leaf-item/leaf-item.queries.js.map +0 -1
- package/dist/modules/core/section/section.model.js.map +0 -1
- package/dist/modules/core/term-flag/term-flag.model.js.map +0 -1
- package/dist/modules/core/term-flag/term-flag.module.d.ts +0 -2
- package/dist/modules/core/term-flag/term-flag.module.js.map +0 -1
- package/dist/modules/core/term-flag/term-flag.queries.d.ts +0 -7
- package/dist/modules/core/term-flag/term-flag.queries.js +0 -44
- package/dist/modules/core/term-flag/term-flag.queries.js.map +0 -1
- package/dist/modules/core/term-flag/term-flag.resolver.d.ts +0 -5
- package/dist/modules/core/term-flag/term-flag.resolver.js.map +0 -1
- package/dist/modules/core/term-flag/term-flag.schema.js.map +0 -1
- package/site-schema-lib/gallery-page.site-schema.json +0 -19
- package/site-schema-lib/gallery-page.site-schema.l10n.en.json +0 -11
- package/site-schema-lib/gallery-page.site-schema.l10n.fr.json +0 -11
- package/site-schema-lib/portfolio.site-schema.json +0 -28
- package/site-schema-lib/portfolio.site-schema.l10n.en.json +0 -16
- package/site-schema-lib/portfolio.site-schema.l10n.fr.json +0 -16
- package/site-schema-lib/post.site-schema.json +0 -48
- package/site-schema-lib/post.site-schema.l10n.en.json +0 -28
- package/site-schema-lib/post.site-schema.l10n.fr.json +0 -27
- package/site-schema-lib/simple-pages.site-schema.json +0 -19
- package/site-schema-lib/simple-pages.site-schema.l10n.en.json +0 -11
- package/site-schema-lib/simple-pages.site-schema.l10n.fr.json +0 -11
- package/site-schema-lib/special-page.site-schema.json +0 -44
- package/site-schema-lib/special-page.site-schema.l10n.en.json +0 -16
- package/site-schema-lib/special-page.site-schema.l10n.fr.json +0 -16
- package/site-schema-lib/tour.site-schema.json +0 -70
- package/site-schema-lib/tour.site-schema.l10n.en.json +0 -37
- package/site-schema-lib/tour.site-schema.l10n.fr.json +0 -37
- /package/dist/{modules/core/account → models}/account.model.d.ts +0 -0
- /package/dist/{modules/core/account → models}/account.model.js +0 -0
- /package/dist/{modules/core/document → models}/document.model.d.ts +0 -0
- /package/dist/{modules/core/document → models}/document.model.js +0 -0
- /package/dist/{modules/core/fields → models}/fields.model.d.ts +0 -0
- /package/dist/{modules/core/fields → models}/fields.model.js +0 -0
- /package/dist/{modules/core/leaf → models}/leaf.model.d.ts +0 -0
- /package/dist/{modules/core/leaf → models}/leaf.model.js +0 -0
- /package/dist/{modules/core/section → models}/section.model.d.ts +0 -0
- /package/dist/{modules/core/section → models}/section.model.js +0 -0
- /package/site-schema-lib/{fields.site-schema.l10n.en.json → field-lib.site-schema.l10n.en.json} +0 -0
- /package/site-schema-lib/{fields.site-schema.l10n.fr.json → field-lib.site-schema.l10n.fr.json} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type DocumentSchema, type SiteSchema } from "@paroicms/anywhere-lib";
|
|
2
2
|
import type { Tracker } from "@paroicms/server-lib";
|
|
3
3
|
import type { EntityManager } from "typeorm";
|
|
4
|
+
import { LeafEntity } from "../../../models/leaf.model";
|
|
4
5
|
import type { SiteContext } from "../../../site-context/site-context.types";
|
|
5
|
-
import type {
|
|
6
|
-
import { LeafEntity } from "./leaf.model";
|
|
6
|
+
import type { LabelingObjectType } from "../labeling/labeling.schema";
|
|
7
7
|
export declare function getLeafTypeOf(siteContext: Pick<SiteContext, "cn">, leafId: string): Promise<string>;
|
|
8
8
|
export declare function getDocumentSchemaOf(siteContext: Pick<SiteContext, "cn" | "siteSchema">, leafId: string): Promise<DocumentSchema>;
|
|
9
9
|
export declare function findOneLeaf({ cn }: SiteContext, id: string): Promise<LeafEntity>;
|
|
@@ -11,7 +11,7 @@ export declare function setLeafPublishDate(siteContext: SiteContext, { leafId, p
|
|
|
11
11
|
leafId: string;
|
|
12
12
|
publishDate: Date;
|
|
13
13
|
}): Promise<void>;
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function loadLabelingTermsOf({ cn }: SiteContext, labeledId: string): Promise<LabelingObjectType[]>;
|
|
15
15
|
export declare function createLeaf(siteSchema: SiteSchema, cn: EntityManager, { parentId, depth, leafType, }: {
|
|
16
16
|
parentId?: string;
|
|
17
17
|
depth?: number;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getScheduledLeafs = exports.countLeafChildrenOf = exports.getLeafDepth = exports.createLeaf = exports.
|
|
3
|
+
exports.getScheduledLeafs = exports.countLeafChildrenOf = exports.getLeafDepth = exports.createLeaf = exports.loadLabelingTermsOf = exports.setLeafPublishDate = exports.findOneLeaf = exports.getDocumentSchemaOf = exports.getLeafTypeOf = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const data_formatters_lib_1 = require("@paroi/data-formatters-lib");
|
|
6
6
|
const anywhere_lib_1 = require("@paroicms/anywhere-lib");
|
|
7
7
|
const data_format_1 = require("../../../common/data-format");
|
|
8
8
|
const text_cache_1 = require("../../../common/text-cache");
|
|
9
9
|
const relative_id_helper_1 = require("../../../helpers/relative-id-helper");
|
|
10
|
+
const leaf_model_1 = require("../../../models/leaf.model");
|
|
10
11
|
const ddl_migration_1 = require("../../../site-context/db-init/ddl-migration");
|
|
11
|
-
const leaf_model_1 = require("./leaf.model");
|
|
12
12
|
async function getLeafTypeOf(siteContext, leafId) {
|
|
13
13
|
const row = await siteContext.cn
|
|
14
14
|
.createQueryBuilder()
|
|
15
15
|
.select("l.leafType", "leafType")
|
|
16
16
|
.from("PaLeaf", "l")
|
|
17
|
-
.
|
|
17
|
+
.andWhere("l.id = :leafId", { leafId })
|
|
18
18
|
.getRawOne();
|
|
19
19
|
if (!row)
|
|
20
20
|
throw new common_1.NotFoundException(`cannot find leaf '${leafId}'`);
|
|
@@ -45,7 +45,7 @@ async function setLeafPublishDate(siteContext, { leafId, publishDate }) {
|
|
|
45
45
|
.createQueryBuilder()
|
|
46
46
|
.select("l.publishDate", "publishDate")
|
|
47
47
|
.from("PaLeaf", "l")
|
|
48
|
-
.
|
|
48
|
+
.andWhere("l.id = :leafId", { leafId })
|
|
49
49
|
.getRawOne();
|
|
50
50
|
if (!row)
|
|
51
51
|
throw new common_1.NotFoundException(`cannot find leaf '${leafId}'`);
|
|
@@ -81,20 +81,20 @@ async function setLeafPublishDate(siteContext, { leafId, publishDate }) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
exports.setLeafPublishDate = setLeafPublishDate;
|
|
84
|
-
async function
|
|
84
|
+
async function loadLabelingTermsOf({ cn }, labeledId) {
|
|
85
85
|
const rows = await cn
|
|
86
86
|
.createQueryBuilder()
|
|
87
87
|
.select("f.lead", "lead")
|
|
88
88
|
.addSelect("f.termId", "termId")
|
|
89
89
|
.addSelect("l2.leafType", "parentLeafType")
|
|
90
|
-
.from("
|
|
90
|
+
.from("PaLabeling", "f")
|
|
91
91
|
.innerJoin("PaLeaf", "l1", "l1.id = f.termId")
|
|
92
92
|
.innerJoin("PaLeaf", "l2", "l2.id = l1.parentId")
|
|
93
|
-
.
|
|
93
|
+
.andWhere("f.labeledId = :labeledId", { labeledId })
|
|
94
94
|
.getRawMany();
|
|
95
|
-
return (0, data_formatters_lib_1.listVal)(rows, data_format_1.
|
|
95
|
+
return (0, data_formatters_lib_1.listVal)(rows, data_format_1.formatLabelingObjectType);
|
|
96
96
|
}
|
|
97
|
-
exports.
|
|
97
|
+
exports.loadLabelingTermsOf = loadLabelingTermsOf;
|
|
98
98
|
async function createLeaf(siteSchema, cn, { parentId, depth, leafType, }) {
|
|
99
99
|
const documentSchema = siteSchema.documentTypes[leafType];
|
|
100
100
|
let leafDepth = depth;
|
|
@@ -106,7 +106,7 @@ async function createLeaf(siteSchema, cn, { parentId, depth, leafType, }) {
|
|
|
106
106
|
.select("leafType", "leafType")
|
|
107
107
|
.addSelect("depth", "depth")
|
|
108
108
|
.from("PaLeaf", "l")
|
|
109
|
-
.
|
|
109
|
+
.andWhere("l.id = :parentId", { parentId })
|
|
110
110
|
.getRawOne();
|
|
111
111
|
if (!row)
|
|
112
112
|
throw new Error(`cannot find parent leaf '${parentId}'`);
|
|
@@ -161,7 +161,7 @@ async function getLeafDepth(siteContext, tracker, leafId) {
|
|
|
161
161
|
.createQueryBuilder()
|
|
162
162
|
.select("l.depth", "depth")
|
|
163
163
|
.from("PaLeaf", "l")
|
|
164
|
-
.
|
|
164
|
+
.andWhere("l.id = :leafId", { leafId })
|
|
165
165
|
.getRawOne();
|
|
166
166
|
tracker.trackAccess(ddl_migration_1.dbSchemaName, "PaLeaf", "read");
|
|
167
167
|
if (!row)
|
|
@@ -174,7 +174,7 @@ async function countLeafChildrenOf(siteContext, parendId) {
|
|
|
174
174
|
.createQueryBuilder()
|
|
175
175
|
.select("count(1)", "cnt")
|
|
176
176
|
.from("PaLeaf", "l")
|
|
177
|
-
.
|
|
177
|
+
.andWhere("l.parentId = :parendId", { parendId })
|
|
178
178
|
.getRawOne();
|
|
179
179
|
return (0, data_formatters_lib_1.nbVal)(row?.cnt);
|
|
180
180
|
}
|
|
@@ -185,7 +185,7 @@ async function getScheduledLeafs(siteContext) {
|
|
|
185
185
|
.select("l.id", "id")
|
|
186
186
|
.addSelect("l.publishDate", "publishDate")
|
|
187
187
|
.from("PaLeaf", "l")
|
|
188
|
-
.
|
|
188
|
+
.andWhere("l.publishDate > current_timestamp")
|
|
189
189
|
.getRawMany();
|
|
190
190
|
return rows.map((row) => ({
|
|
191
191
|
leafId: (0, data_formatters_lib_1.strVal)(row.id),
|
|
@@ -200,7 +200,7 @@ function isLeafTypeChildOf(siteSchema, { parentLeafType, leafType }) {
|
|
|
200
200
|
return parentSchema.children?.includes(child.leafType) ?? false;
|
|
201
201
|
}
|
|
202
202
|
for (const listType of parentSchema.partLists ?? []) {
|
|
203
|
-
if (listType.
|
|
203
|
+
if (listType.parts.includes(leafType))
|
|
204
204
|
return true;
|
|
205
205
|
}
|
|
206
206
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leaf.queries.js","sourceRoot":"","sources":["../../../../src/modules/core/leaf/leaf.queries.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AACxE,oEAAmF;AACnF,yDAMgC;AAGhC,6DAAuE;AACvE,2DAKoC;AACpC,4EAA4E;AAC5E,+EAA2E;
|
|
1
|
+
{"version":3,"file":"leaf.queries.js","sourceRoot":"","sources":["../../../../src/modules/core/leaf/leaf.queries.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AACxE,oEAAmF;AACnF,yDAMgC;AAGhC,6DAAuE;AACvE,2DAKo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;SAC7C,UAAU,EAAO,CAAC;IACrB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACxB,MAAM,EAAE,IAAA,4BAAM,EAAC,GAAG,CAAC,EAAE,CAAC;QACtB,WAAW,EAAE,IAAA,4BAAM,EAAC,GAAG,CAAC,WAAW,CAAC;KACrC,CAAC,CAAC,CAAC;AACN,CAAC;AAdD,8CAcC;AAED,SAAS,iBAAiB,CACxB,UAAsB,EACtB,EAAE,cAAc,EAAE,QAAQ,EAAgD;IAE1E,MAAM,YAAY,GAAG,IAAA,wCAAyB,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC3E,IAAI,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACjD,OAAO,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;IAClE,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,YAAY,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;QACpD,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,OAAO,IAAI,CAAC;IACrD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { GraphqlContext } from "../../graphql.types";
|
|
2
|
-
import {
|
|
2
|
+
import { LabelingObjectType } from "../labeling/labeling.schema";
|
|
3
3
|
import { LeafObjectType } from "./leaf.schema";
|
|
4
4
|
export declare class LeafResolver {
|
|
5
|
-
|
|
5
|
+
labeledBy({ fqdn }: GraphqlContext, { id }: LeafObjectType): Promise<LabelingObjectType[]>;
|
|
6
6
|
planned({ publishDate }: LeafObjectType): boolean;
|
|
7
7
|
setLeafPublishDate({ fqdn }: GraphqlContext, leafId: string, publishDate: Date): Promise<LeafObjectType>;
|
|
8
|
-
|
|
8
|
+
reorderDocuments({ fqdn }: GraphqlContext, leafIds: string[], parentLeafId: string): Promise<string[]>;
|
|
9
|
+
reorderParts({ fqdn }: GraphqlContext, leafIds: string[], parentLeafId: string, listName: string): Promise<string[]>;
|
|
9
10
|
}
|
|
@@ -18,13 +18,13 @@ const graphql_1 = require("@nestjs/graphql");
|
|
|
18
18
|
const data_format_1 = require("../../../common/data-format");
|
|
19
19
|
const site_context_1 = require("../../../site-context/site-context");
|
|
20
20
|
const jwt_auth_guard_1 = require("../auth/jwt.auth.guard");
|
|
21
|
-
const
|
|
22
|
-
const term_flag_schema_1 = require("../term-flag/term-flag.schema");
|
|
21
|
+
const labeling_schema_1 = require("../labeling/labeling.schema");
|
|
23
22
|
const leaf_queries_1 = require("./leaf.queries");
|
|
24
23
|
const leaf_schema_1 = require("./leaf.schema");
|
|
24
|
+
const ordered_leaf_queries_1 = require("./ordered-leaf.queries");
|
|
25
25
|
let LeafResolver = class LeafResolver {
|
|
26
|
-
async
|
|
27
|
-
return await (0, leaf_queries_1.
|
|
26
|
+
async labeledBy({ fqdn }, { id }) {
|
|
27
|
+
return await (0, leaf_queries_1.loadLabelingTermsOf)(await (0, site_context_1.getSiteContext)(fqdn), id);
|
|
28
28
|
}
|
|
29
29
|
planned({ publishDate }) {
|
|
30
30
|
if (!publishDate)
|
|
@@ -39,20 +39,24 @@ let LeafResolver = class LeafResolver {
|
|
|
39
39
|
});
|
|
40
40
|
return (0, data_format_1.leafEntityToObjectType)(await (0, leaf_queries_1.findOneLeaf)(siteContext, leafId));
|
|
41
41
|
}
|
|
42
|
-
async
|
|
42
|
+
async reorderDocuments({ fqdn }, leafIds, parentLeafId) {
|
|
43
43
|
const siteContext = await (0, site_context_1.getSiteContext)(fqdn);
|
|
44
|
-
return (0,
|
|
44
|
+
return (0, ordered_leaf_queries_1.reorderLeafs)(siteContext, { leafIds, parentLeafId });
|
|
45
|
+
}
|
|
46
|
+
async reorderParts({ fqdn }, leafIds, parentLeafId, listName) {
|
|
47
|
+
const siteContext = await (0, site_context_1.getSiteContext)(fqdn);
|
|
48
|
+
return (0, ordered_leaf_queries_1.reorderLeafs)(siteContext, { leafIds, parentLeafId, listName });
|
|
45
49
|
}
|
|
46
50
|
};
|
|
47
51
|
exports.LeafResolver = LeafResolver;
|
|
48
52
|
__decorate([
|
|
49
|
-
(0, graphql_1.ResolveField)(() => [
|
|
53
|
+
(0, graphql_1.ResolveField)(() => [labeling_schema_1.LabelingObjectType]),
|
|
50
54
|
__param(0, (0, graphql_1.Context)()),
|
|
51
55
|
__param(1, (0, graphql_1.Parent)()),
|
|
52
56
|
__metadata("design:type", Function),
|
|
53
57
|
__metadata("design:paramtypes", [Object, leaf_schema_1.LeafObjectType]),
|
|
54
58
|
__metadata("design:returntype", Promise)
|
|
55
|
-
], LeafResolver.prototype, "
|
|
59
|
+
], LeafResolver.prototype, "labeledBy", null);
|
|
56
60
|
__decorate([
|
|
57
61
|
(0, graphql_1.ResolveField)(() => Boolean),
|
|
58
62
|
__param(0, (0, graphql_1.Parent)()),
|
|
@@ -69,6 +73,15 @@ __decorate([
|
|
|
69
73
|
__metadata("design:paramtypes", [Object, String, Date]),
|
|
70
74
|
__metadata("design:returntype", Promise)
|
|
71
75
|
], LeafResolver.prototype, "setLeafPublishDate", null);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, graphql_1.Mutation)(() => [String]),
|
|
78
|
+
__param(0, (0, graphql_1.Context)()),
|
|
79
|
+
__param(1, (0, graphql_1.Args)("leafIds", { type: () => [String] })),
|
|
80
|
+
__param(2, (0, graphql_1.Args)("parentLeafId", { type: () => String })),
|
|
81
|
+
__metadata("design:type", Function),
|
|
82
|
+
__metadata("design:paramtypes", [Object, Array, String]),
|
|
83
|
+
__metadata("design:returntype", Promise)
|
|
84
|
+
], LeafResolver.prototype, "reorderDocuments", null);
|
|
72
85
|
__decorate([
|
|
73
86
|
(0, graphql_1.Mutation)(() => [String]),
|
|
74
87
|
__param(0, (0, graphql_1.Context)()),
|
|
@@ -78,7 +91,7 @@ __decorate([
|
|
|
78
91
|
__metadata("design:type", Function),
|
|
79
92
|
__metadata("design:paramtypes", [Object, Array, String, String]),
|
|
80
93
|
__metadata("design:returntype", Promise)
|
|
81
|
-
], LeafResolver.prototype, "
|
|
94
|
+
], LeafResolver.prototype, "reorderParts", null);
|
|
82
95
|
exports.LeafResolver = LeafResolver = __decorate([
|
|
83
96
|
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
84
97
|
(0, graphql_1.Resolver)(() => leaf_schema_1.LeafObjectType)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leaf.resolver.js","sourceRoot":"","sources":["../../../../src/modules/core/leaf/leaf.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2C;AAC3C,6CAA8F;AAC9F,6DAAqE;AACrE,qEAAoE;AAEpE,2DAAsD;AACtD,
|
|
1
|
+
{"version":3,"file":"leaf.resolver.js","sourceRoot":"","sources":["../../../../src/modules/core/leaf/leaf.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2C;AAC3C,6CAA8F;AAC9F,6DAAqE;AACrE,qEAAoE;AAEpE,2DAAsD;AACtD,iEAAiE;AACjE,iDAAsF;AACtF,+CAA+C;AAC/C,iEAAsD;AAI/C,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEjB,AAAN,KAAK,CAAC,SAAS,CACF,EAAE,IAAI,EAAkB,EAEnC,EAAE,EAAE,EAAkB;QAEtB,OAAO,MAAM,IAAA,kCAAmB,EAAC,MAAM,IAAA,6BAAc,EAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;IAGD,OAAO,CAEL,EAAE,WAAW,EAAkB;QAE/B,IAAI,CAAC,WAAW;YAAE,OAAO,KAAK,CAAC;QAC/B,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,GA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,CAqDxB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SiteContext } from "../../../site-context/site-context.types";
|
|
2
|
+
export declare function getOrderNumOf({ cn }: SiteContext, leafId: string): Promise<number | undefined>;
|
|
3
|
+
export declare function reorderLeafs(siteContext: SiteContext, { leafIds, parentLeafId, listName, }: {
|
|
4
|
+
leafIds: string[];
|
|
5
|
+
parentLeafId: string;
|
|
6
|
+
listName?: string;
|
|
7
|
+
}): Promise<string[]>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reorderLeafs = exports.getOrderNumOf = void 0;
|
|
4
|
+
const data_formatters_lib_1 = require("@paroi/data-formatters-lib");
|
|
5
|
+
const text_cache_1 = require("../../../common/text-cache");
|
|
6
|
+
const ordered_leaf_model_1 = require("../../../models/ordered-leaf.model");
|
|
7
|
+
async function getOrderNumOf({ cn }, leafId) {
|
|
8
|
+
const row = await cn
|
|
9
|
+
.createQueryBuilder()
|
|
10
|
+
.select("o.orderNum", "orderNum")
|
|
11
|
+
.from("PaOrderedLeaf", "o")
|
|
12
|
+
.andWhere("o.leafId = :leafId", { leafId })
|
|
13
|
+
.getRawOne();
|
|
14
|
+
return (0, data_formatters_lib_1.nbValOrUndef)(row?.orderNum);
|
|
15
|
+
}
|
|
16
|
+
exports.getOrderNumOf = getOrderNumOf;
|
|
17
|
+
async function reorderLeafs(siteContext, { leafIds, parentLeafId, listName, }) {
|
|
18
|
+
const { cn } = siteContext;
|
|
19
|
+
const query = cn
|
|
20
|
+
.createQueryBuilder()
|
|
21
|
+
.select("l.id", "leafId")
|
|
22
|
+
.addSelect("o.orderNum", "orderNum")
|
|
23
|
+
.from("PaLeaf", "l")
|
|
24
|
+
.innerJoin("PaOrderedLeaf", "o", "l.id = o.leafId")
|
|
25
|
+
.andWhere("l.parentId = :parentLeafId", { parentLeafId })
|
|
26
|
+
.orderBy("o.orderNum", "ASC")
|
|
27
|
+
.addOrderBy("l.id", "ASC");
|
|
28
|
+
if (listName) {
|
|
29
|
+
query.innerJoin("PaPartLeaf", "p", "p.leafId = l.id");
|
|
30
|
+
query.andWhere("p.listName = :listName", { listName });
|
|
31
|
+
}
|
|
32
|
+
const rows = await query.getRawMany();
|
|
33
|
+
const oldItems = rows.map((row) => ({
|
|
34
|
+
leafId: (0, data_formatters_lib_1.strVal)(row.leafId),
|
|
35
|
+
orderNum: (0, data_formatters_lib_1.nbVal)(row.orderNum),
|
|
36
|
+
}));
|
|
37
|
+
let orderNum = 1;
|
|
38
|
+
const newItems = [];
|
|
39
|
+
for (const leafId of leafIds) {
|
|
40
|
+
newItems.push({ leafId, orderNum });
|
|
41
|
+
++orderNum;
|
|
42
|
+
}
|
|
43
|
+
for (const item of oldItems) {
|
|
44
|
+
if (!leafIds.includes(item.leafId)) {
|
|
45
|
+
newItems.push({ leafId: item.leafId, orderNum });
|
|
46
|
+
++orderNum;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
await cn.transaction(async (tx) => {
|
|
50
|
+
const repo = tx.getRepository(ordered_leaf_model_1.OrderedLeafEntity);
|
|
51
|
+
for (const newItem of newItems) {
|
|
52
|
+
if (oldItems.find((old) => old.leafId === newItem.leafId)) {
|
|
53
|
+
await repo.update({ leafId: newItem.leafId }, { orderNum: newItem.orderNum });
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
await repo.insert({
|
|
57
|
+
leafId: newItem.leafId,
|
|
58
|
+
orderNum: newItem.orderNum,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
await (0, text_cache_1.invalidateMultipleDocumentsInCache)(siteContext, { leafId: parentLeafId });
|
|
64
|
+
return leafIds;
|
|
65
|
+
}
|
|
66
|
+
exports.reorderLeafs = reorderLeafs;
|
|
67
|
+
//# sourceMappingURL=ordered-leaf.queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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,CAAC,QAAQ,EAAE,CAAC,CAAC;YAChF,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,CAAC,MAAM,CAAC;oBAChB,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;iBAC3B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,IAAA,+CAAkC,EAAC,WAAW,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAChF,OAAO,OAAO,CAAC;AACjB,CAAC;AA7DD,oCA6DC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { QueryBuilderConnection } from "@paroicms/server-lib";
|
|
2
|
+
export declare function createPartLeaf(cn: QueryBuilderConnection, { leafId, listName, parentId, documentLeafId, isOrdered, }: {
|
|
3
|
+
leafId: string;
|
|
4
|
+
listName: string;
|
|
5
|
+
parentId: string;
|
|
6
|
+
documentLeafId: string;
|
|
7
|
+
isOrdered: boolean;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
export declare function shiftPartLeafOrdersAfterDeletion(cn: QueryBuilderConnection, leafId: string): Promise<void>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shiftPartLeafOrdersAfterDeletion = exports.createPartLeaf = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const data_formatters_lib_1 = require("@paroi/data-formatters-lib");
|
|
6
|
+
async function createPartLeaf(cn, { leafId, listName, parentId, documentLeafId, isOrdered, }) {
|
|
7
|
+
await cn
|
|
8
|
+
.createQueryBuilder()
|
|
9
|
+
.insert()
|
|
10
|
+
.into("PaPartLeaf")
|
|
11
|
+
.values({ leafId, listName, documentLeafId })
|
|
12
|
+
.execute();
|
|
13
|
+
if (isOrdered) {
|
|
14
|
+
const row = await cn
|
|
15
|
+
.createQueryBuilder()
|
|
16
|
+
.select("max(o.orderNum)", "orderNum")
|
|
17
|
+
.from("PaLeaf", "l")
|
|
18
|
+
.innerJoin("PaPartLeaf", "p", "p.leafId = l.id")
|
|
19
|
+
.innerJoin("PaOrderedLeaf", "o", "o.leafId = l.id")
|
|
20
|
+
.andWhere("l.parentId = :parentId", { parentId })
|
|
21
|
+
.andWhere("p.listName = :listName", { listName })
|
|
22
|
+
.getRawOne();
|
|
23
|
+
await cn
|
|
24
|
+
.createQueryBuilder()
|
|
25
|
+
.insert()
|
|
26
|
+
.into("PaOrderedLeaf")
|
|
27
|
+
.values({ leafId, orderNum: ((0, data_formatters_lib_1.nbValOrUndef)(row?.orderNum) ?? 0) + 1 })
|
|
28
|
+
.execute();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.createPartLeaf = createPartLeaf;
|
|
32
|
+
async function shiftPartLeafOrdersAfterDeletion(cn, leafId) {
|
|
33
|
+
const row = await cn
|
|
34
|
+
.createQueryBuilder()
|
|
35
|
+
.addSelect("l.parentId", "parentId")
|
|
36
|
+
.addSelect("p.listName", "listName")
|
|
37
|
+
.addSelect("o.orderNum", "orderNum")
|
|
38
|
+
.from("PaPartLeaf", "p")
|
|
39
|
+
.innerJoin("PaOrderedLeaf", "o", "o.leafId = p.leafId")
|
|
40
|
+
.andWhere("p.leafId = :leafId", { leafId })
|
|
41
|
+
.getRawOne();
|
|
42
|
+
if (!row)
|
|
43
|
+
throw new common_1.NotFoundException(`part-leaf '${leafId}' not found`);
|
|
44
|
+
const parentId = (0, data_formatters_lib_1.strVal)(row.parentId);
|
|
45
|
+
const listName = (0, data_formatters_lib_1.strVal)(row.listName);
|
|
46
|
+
const orderNum = (0, data_formatters_lib_1.nbVal)(row.orderNum);
|
|
47
|
+
await cn
|
|
48
|
+
.createQueryBuilder()
|
|
49
|
+
.update("PaOrderedLeaf")
|
|
50
|
+
.set({ orderNum: () => "orderNum - 1" })
|
|
51
|
+
.andWhere("PaOrderedLeaf.orderNum > :orderNum", { orderNum })
|
|
52
|
+
.andWhere(`exists (
|
|
53
|
+
select 1
|
|
54
|
+
from PaLeaf l
|
|
55
|
+
inner join PaPartLeaf p on p.leafId = l.id
|
|
56
|
+
where PaOrderedLeaf.leafId = l.id
|
|
57
|
+
and l.parentId = :parentId
|
|
58
|
+
and p.listName = :listName
|
|
59
|
+
)`, { listName, parentId })
|
|
60
|
+
.execute();
|
|
61
|
+
}
|
|
62
|
+
exports.shiftPartLeafOrdersAfterDeletion = shiftPartLeafOrdersAfterDeletion;
|
|
63
|
+
//# sourceMappingURL=part-leaf.queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"part-leaf.queries.js","sourceRoot":"","sources":["../../../../src/modules/core/part/part-leaf.queries.ts"],"names":[],"mappings":";;;AAAA,2CAAmD;AACnD,oEAAyE;AAIlE,KAAK,UAAU,cAAc,CAClC,EAA0B,EAC1B,EACE,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,SAAS,GAOV;IAED,MAAM,EAAE;SACL,kBAAkB,EAAE;SACpB,MAAM,EAAE;SACR,IAAI,CAAC,YAAY,CAAC;SAClB,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;SAC5C,OAAO,EAAE,CAAC;IAEb,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,GAAG,GAAG,MAAM,EAAE;aACjB,kBAAkB,EAAE;aACpB,MAAM,CAAC,iBAAiB,EAAE,UAAU,CAAC;aACrC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;aACnB,SAAS,CAAC,YAAY,EAAE,GAAG,EAAE,iBAAiB,CAAC;aAC/C,SAAS,CAAC,eAAe,EAAE,GAAG,EAAE,iBAAiB,CAAC;aAClD,QAAQ,CAAC,wBAAwB,EAAE,EAAE,QAAQ,EAAE,CAAC;aAChD,QAAQ,CAAC,wBAAwB,EAAE,EAAE,QAAQ,EAAE,CAAC;aAChD,SAAS,EAAO,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5D,QAAQ,CACP;;;;;;;EAOJ,EACI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CACvB;SACA,OAAO,EAAE,CAAC;AAgCf,CAAC;AAjED,4EAiEC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ParsedSectionId } from "@paroicms/anywhere-lib";
|
|
2
2
|
import type { SiteContext } from "../../../site-context/site-context.types";
|
|
3
3
|
import type { PartObjectType, PartPlaceholderObjectType } from "./part.schema";
|
|
4
|
-
export declare function createPartOnLeaf(siteContext: SiteContext,
|
|
4
|
+
export declare function createPartOnLeaf(siteContext: SiteContext, newId: ParsedSectionId): Promise<ParsedSectionId>;
|
|
5
5
|
export declare function createLeafWithPart(siteContext: SiteContext, { parentSectionId, listName, leafType, }: {
|
|
6
6
|
parentSectionId: ParsedSectionId;
|
|
7
7
|
listName: string;
|
|
@@ -7,53 +7,65 @@ const anywhere_lib_1 = require("@paroicms/anywhere-lib");
|
|
|
7
7
|
const media_handles_helpers_1 = require("../../../common/media-handles.helpers");
|
|
8
8
|
const text_cache_1 = require("../../../common/text-cache");
|
|
9
9
|
const utils_helper_1 = require("../../../helpers/utils-helper");
|
|
10
|
+
const leaf_model_1 = require("../../../models/leaf.model");
|
|
11
|
+
const section_model_1 = require("../../../models/section.model");
|
|
10
12
|
const load_documents_queries_1 = require("../document/load-documents.queries");
|
|
11
|
-
const leaf_item_queries_1 = require("../leaf-item/leaf-item.queries");
|
|
12
|
-
const leaf_model_1 = require("../leaf/leaf.model");
|
|
13
13
|
const leaf_queries_1 = require("../leaf/leaf.queries");
|
|
14
|
-
const section_model_1 = require("../section/section.model");
|
|
15
14
|
const section_queries_1 = require("../section/section.queries");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
const part_leaf_queries_1 = require("./part-leaf.queries");
|
|
16
|
+
async function createPartOnLeaf(siteContext, newId) {
|
|
17
|
+
await siteContext.cn
|
|
18
|
+
.getRepository(section_model_1.SectionEntity)
|
|
19
|
+
.save({ lang: newId.language, leafId: newId.leafId, ready: true });
|
|
20
|
+
await (0, text_cache_1.invalidateDocumentInCache)(siteContext, { parentOf: newId });
|
|
21
21
|
return newId;
|
|
22
22
|
}
|
|
23
23
|
exports.createPartOnLeaf = createPartOnLeaf;
|
|
24
24
|
async function createLeafWithPart(siteContext, { parentSectionId, listName, leafType, }) {
|
|
25
25
|
const { language, leafId: parentLeafId } = parentSectionId;
|
|
26
|
-
const
|
|
26
|
+
const row = await siteContext.cn
|
|
27
|
+
.createQueryBuilder()
|
|
28
|
+
.select("l.leafType", "leafType")
|
|
29
|
+
.addSelect("p.documentLeafId", "documentLeafId")
|
|
30
|
+
.from("PaLeaf", "l")
|
|
31
|
+
.leftJoin("PaPartLeaf", "p", "p.leafId = l.id")
|
|
32
|
+
.andWhere("l.id = :leafId", { leafId: parentLeafId })
|
|
33
|
+
.getRawOne();
|
|
34
|
+
if (!row)
|
|
35
|
+
throw new common_1.NotFoundException(`cannot find part-leaf '${parentLeafId}'`);
|
|
36
|
+
const parentLeafType = (0, data_formatters_lib_1.strVal)(row.leafType);
|
|
37
|
+
const documentLeafId = (0, data_formatters_lib_1.strValOrUndef)(row.documentLeafId) ?? parentLeafId;
|
|
27
38
|
const parentDocumentType = (0, anywhere_lib_1.getDocumentTypeByLeafType)(siteContext.siteSchema, parentLeafType);
|
|
28
39
|
const listType = parentDocumentType.partLists?.find((l) => l.listName === listName);
|
|
29
40
|
if (!listType) {
|
|
30
|
-
throw new common_1.BadRequestException(`
|
|
41
|
+
throw new common_1.BadRequestException(`unknown list '${listName}' in document type '${parentLeafType}'`);
|
|
31
42
|
}
|
|
32
|
-
if (listType.
|
|
33
|
-
const count = await
|
|
34
|
-
listName
|
|
43
|
+
if (listType.limit !== undefined) {
|
|
44
|
+
const count = await countPartsOfList(siteContext, {
|
|
45
|
+
listName,
|
|
35
46
|
parentLeafId,
|
|
36
47
|
});
|
|
37
|
-
if (count >= listType.
|
|
48
|
+
if (count >= listType.limit)
|
|
38
49
|
throw new common_1.BadRequestException("maximum parts reached");
|
|
39
50
|
}
|
|
40
|
-
if (!listType.
|
|
51
|
+
if (!listType.parts.includes(leafType)) {
|
|
41
52
|
throw new common_1.BadRequestException({
|
|
42
53
|
code: "invalid_section_type_for_this_list_name",
|
|
43
|
-
message: `Invalid sectionType leafType: '${leafType}' for listName '${
|
|
54
|
+
message: `Invalid sectionType leafType: '${leafType}' for listName '${listName}'`,
|
|
44
55
|
});
|
|
45
56
|
}
|
|
46
57
|
const newId = await siteContext.cn.transaction(async (tx) => {
|
|
47
58
|
const leaf = await (0, leaf_queries_1.createLeaf)(siteContext.siteSchema, tx, { parentId: parentLeafId, leafType });
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
const { id: leafId } = leaf;
|
|
60
|
+
await (0, part_leaf_queries_1.createPartLeaf)(tx, {
|
|
61
|
+
leafId,
|
|
62
|
+
listName,
|
|
51
63
|
parentId: parentLeafId,
|
|
64
|
+
documentLeafId,
|
|
65
|
+
isOrdered: !!listType.orderBy,
|
|
52
66
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const { id: leafId } = leaf;
|
|
56
|
-
return await createPartOnLeafWithManager({ language, leafId }, { cn: tx });
|
|
67
|
+
await tx.getRepository(section_model_1.SectionEntity).save({ lang: language, leafId, ready: true });
|
|
68
|
+
return { language, leafId };
|
|
57
69
|
});
|
|
58
70
|
await (0, text_cache_1.invalidateDocumentInCache)(siteContext, { documentId: parentSectionId });
|
|
59
71
|
return newId;
|
|
@@ -67,7 +79,7 @@ async function loadPart(siteContext, sectionId) {
|
|
|
67
79
|
.innerJoin("PaSection", "s", "s.leafId = l.id and s.lang = :language", {
|
|
68
80
|
language: sectionId.language,
|
|
69
81
|
})
|
|
70
|
-
.
|
|
82
|
+
.andWhere("l.id = :leafId", { leafId: sectionId.leafId })
|
|
71
83
|
.andWhere("not exists (select 1 from PaDocument d where d.leafId = l.id)")
|
|
72
84
|
.getRawOne();
|
|
73
85
|
if (!row)
|
|
@@ -91,12 +103,12 @@ async function deletePart(siteContext, sectionId) {
|
|
|
91
103
|
await sectionRepo.delete((0, utils_helper_1.toDbId)(sectionId));
|
|
92
104
|
const shouldDeleteLeaf = await (0, section_queries_1.isOrphanLeaf)(tx, sectionId.leafId);
|
|
93
105
|
if (shouldDeleteLeaf) {
|
|
94
|
-
await (0,
|
|
106
|
+
await (0, part_leaf_queries_1.shiftPartLeafOrdersAfterDeletion)(tx, sectionId.leafId);
|
|
95
107
|
await tx
|
|
96
108
|
.createQueryBuilder()
|
|
97
109
|
.delete()
|
|
98
110
|
.from("PaFieldVarchar")
|
|
99
|
-
.
|
|
111
|
+
.andWhere("leafId = :leafId", { leafId: sectionId.leafId })
|
|
100
112
|
.execute();
|
|
101
113
|
await tx.getRepository(leaf_model_1.LeafEntity).delete({ id: sectionId.leafId });
|
|
102
114
|
}
|
|
@@ -114,21 +126,20 @@ exports.deletePart = deletePart;
|
|
|
114
126
|
async function partsOf({ cn }, { listNames, parentId, }) {
|
|
115
127
|
const parts = await cn
|
|
116
128
|
.createQueryBuilder()
|
|
117
|
-
.
|
|
118
|
-
.addSelect("
|
|
129
|
+
.addSelect("l.id", "leafId")
|
|
130
|
+
.addSelect("l.leafType", "leafType")
|
|
131
|
+
.addSelect("o.orderNum", "orderNum")
|
|
119
132
|
.addSelect("s.lang", "language")
|
|
120
133
|
.addSelect("s.leafId", "sectionLeafId")
|
|
121
|
-
.addSelect("l.leafType", "leafType")
|
|
122
134
|
.from("PaLeaf", "l")
|
|
123
|
-
.innerJoin("
|
|
124
|
-
|
|
125
|
-
})
|
|
135
|
+
.innerJoin("PaPartLeaf", "p", "p.leafId = l.id")
|
|
136
|
+
.leftJoin("PaOrderedLeaf", "o", "o.leafId = l.id")
|
|
126
137
|
.leftJoin("PaSection", "s", "s.leafId = l.id and s.lang = :language", {
|
|
127
138
|
language: parentId.language,
|
|
128
139
|
})
|
|
129
|
-
.
|
|
130
|
-
.andWhere("
|
|
131
|
-
.orderBy("
|
|
140
|
+
.andWhere("l.parentId = :parentId", { parentId: parentId.leafId })
|
|
141
|
+
.andWhere("p.listName in (:...listNames)", { listNames })
|
|
142
|
+
.orderBy("o.orderNum", "ASC")
|
|
132
143
|
.getRawMany();
|
|
133
144
|
return parts.map((item) => {
|
|
134
145
|
if ((0, data_formatters_lib_1.strValOrUndef)(item.sectionLeafId) === undefined) {
|
|
@@ -151,19 +162,14 @@ async function partsOf({ cn }, { listNames, parentId, }) {
|
|
|
151
162
|
});
|
|
152
163
|
}
|
|
153
164
|
exports.partsOf = partsOf;
|
|
154
|
-
async function
|
|
155
|
-
await cn.getRepository(section_model_1.SectionEntity).save({ lang: language, leafId, ready: true });
|
|
156
|
-
return { language, leafId };
|
|
157
|
-
}
|
|
158
|
-
async function countLeafItemsOfList({ cn }, { listName, parentLeafId, }) {
|
|
165
|
+
async function countPartsOfList({ cn }, { listName, parentLeafId, }) {
|
|
159
166
|
const row = await cn
|
|
160
167
|
.createQueryBuilder()
|
|
161
168
|
.addSelect("count(1)", "cnt")
|
|
162
169
|
.from("PaLeaf", "l")
|
|
163
|
-
.innerJoin("
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
.where("l.parentId = :parentId", { parentId: parentLeafId })
|
|
170
|
+
.innerJoin("PaPartLeaf", "p", "p.leafId = l.id")
|
|
171
|
+
.andWhere("l.parentId = :parentId", { parentId: parentLeafId })
|
|
172
|
+
.andWhere("p.listName = :listName", { listName })
|
|
167
173
|
.getRawOne();
|
|
168
174
|
return (0, data_formatters_lib_1.nbVal)(row?.cnt);
|
|
169
175
|
}
|