@paroicms/internal-anywhere-lib 1.17.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/README.md +9 -0
- package/dist-cjs/constants.d.ts +1 -0
- package/dist-cjs/constants.js +5 -0
- package/dist-cjs/constants.js.map +1 -0
- package/dist-cjs/index.d.ts +6 -0
- package/dist-cjs/index.js +23 -0
- package/dist-cjs/index.js.map +1 -0
- package/dist-cjs/number-localization.d.ts +6 -0
- package/dist-cjs/number-localization.js +29 -0
- package/dist-cjs/number-localization.js.map +1 -0
- package/dist-cjs/parts.helper.d.ts +2 -0
- package/dist-cjs/parts.helper.js +48 -0
- package/dist-cjs/parts.helper.js.map +1 -0
- package/dist-cjs/site-schema-helpers.d.ts +19 -0
- package/dist-cjs/site-schema-helpers.js +87 -0
- package/dist-cjs/site-schema-helpers.js.map +1 -0
- package/dist-cjs/time-with-unit.helpers.d.ts +6 -0
- package/dist-cjs/time-with-unit.helpers.js +19 -0
- package/dist-cjs/time-with-unit.helpers.js.map +1 -0
- package/dist-cjs/url-helpers.d.ts +1 -0
- package/dist-cjs/url-helpers.js +17 -0
- package/dist-cjs/url-helpers.js.map +1 -0
- package/dist-mjs/constants.d.ts +1 -0
- package/dist-mjs/constants.js +2 -0
- package/dist-mjs/constants.js.map +1 -0
- package/dist-mjs/index.d.ts +6 -0
- package/dist-mjs/index.js +7 -0
- package/dist-mjs/index.js.map +1 -0
- package/dist-mjs/number-localization.d.ts +6 -0
- package/dist-mjs/number-localization.js +25 -0
- package/dist-mjs/number-localization.js.map +1 -0
- package/dist-mjs/parts.helper.d.ts +2 -0
- package/dist-mjs/parts.helper.js +44 -0
- package/dist-mjs/parts.helper.js.map +1 -0
- package/dist-mjs/site-schema-helpers.d.ts +19 -0
- package/dist-mjs/site-schema-helpers.js +72 -0
- package/dist-mjs/site-schema-helpers.js.map +1 -0
- package/dist-mjs/time-with-unit.helpers.d.ts +6 -0
- package/dist-mjs/time-with-unit.helpers.js +14 -0
- package/dist-mjs/time-with-unit.helpers.js.map +1 -0
- package/dist-mjs/url-helpers.d.ts +1 -0
- package/dist-mjs/url-helpers.js +13 -0
- package/dist-mjs/url-helpers.js.map +1 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @paroicms/internal-anywhere-lib
|
|
2
|
+
|
|
3
|
+
This is an internal package.
|
|
4
|
+
|
|
5
|
+
This package is part of [ParoiCMS](https://www.npmjs.com/package/@paroicms/server).
|
|
6
|
+
|
|
7
|
+
## License
|
|
8
|
+
|
|
9
|
+
Released under the [MIT license](https://gitlab.com/paroi/opensource/paroicms/-/blob/main/LICENSE.md).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PART_DEFAULT_LIST_NAME = "subParts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./number-localization"), exports);
|
|
19
|
+
__exportStar(require("./parts.helper"), exports);
|
|
20
|
+
__exportStar(require("./site-schema-helpers"), exports);
|
|
21
|
+
__exportStar(require("./time-with-unit.helpers"), exports);
|
|
22
|
+
__exportStar(require("./url-helpers"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,wDAAsC;AACtC,iDAA+B;AAC/B,wDAAsC;AACtC,2DAAyC;AACzC,gDAA8B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NumberLocalization = void 0;
|
|
4
|
+
class NumberLocalization {
|
|
5
|
+
#numberFormat;
|
|
6
|
+
constructor(locale) {
|
|
7
|
+
this.#numberFormat = new Intl.NumberFormat(locale, {
|
|
8
|
+
minimumFractionDigits: 0,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
parse(val) {
|
|
12
|
+
const parts = this.#numberFormat.formatToParts(1234.5);
|
|
13
|
+
const group = parts.find((d) => d.type === "group")?.value;
|
|
14
|
+
const decimal = parts.find((d) => d.type === "decimal")?.value;
|
|
15
|
+
if (!group)
|
|
16
|
+
throw new Error("group not found");
|
|
17
|
+
if (!decimal)
|
|
18
|
+
throw new Error("group not found");
|
|
19
|
+
return val
|
|
20
|
+
.trim()
|
|
21
|
+
.replace(new RegExp(group, "g"), "")
|
|
22
|
+
.replace(decimal === "." ? /\./ : new RegExp(decimal), ".");
|
|
23
|
+
}
|
|
24
|
+
format(val) {
|
|
25
|
+
return this.#numberFormat.format(val);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.NumberLocalization = NumberLocalization;
|
|
29
|
+
//# sourceMappingURL=number-localization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-localization.js","sourceRoot":"","sources":["../src/number-localization.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAkB;IAC7B,aAAa,CAAoB;IAEjC,YAAY,MAAc;QACxB,IAAI,CAAC,aAAa,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YACjD,qBAAqB,EAAE,CAAC;SACzB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAW;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,EAAE,KAAK,CAAC;QAC3D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,EAAE,KAAK,CAAC;QAE/D,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAEjD,OAAO,GAAG;aACP,IAAI,EAAE;aACN,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;aACnC,OAAO,CAAC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACF;AA1BD,gDA0BC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortParts = void 0;
|
|
4
|
+
const data_formatters_lib_1 = require("@paroi/data-formatters-lib");
|
|
5
|
+
function sortParts(listType, list) {
|
|
6
|
+
if (listType.orderBy === "manual") {
|
|
7
|
+
list.sort((a, b) => {
|
|
8
|
+
if (a.orderNum === b.orderNum)
|
|
9
|
+
return 0;
|
|
10
|
+
if (a.orderNum === undefined)
|
|
11
|
+
return -1;
|
|
12
|
+
if (b.orderNum === undefined)
|
|
13
|
+
return 1;
|
|
14
|
+
return a.orderNum - b.orderNum;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else if (includesOrderBy(listType.orderBy, ["publishDate", "desc"])) {
|
|
18
|
+
list.sort((a, b) => {
|
|
19
|
+
if ("publishDate" in a && "publishDate" in b) {
|
|
20
|
+
if (a.publishDate === b.publishDate) {
|
|
21
|
+
if ((0, data_formatters_lib_1.nbVal)(a.leafId) > (0, data_formatters_lib_1.nbVal)(b.leafId))
|
|
22
|
+
return -1;
|
|
23
|
+
return 1;
|
|
24
|
+
}
|
|
25
|
+
return new Date(b.publishDate).getTime() - new Date(a.publishDate).getTime();
|
|
26
|
+
}
|
|
27
|
+
return 0;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else if (includesOrderBy(listType.orderBy, ["publishDate", "asc"])) {
|
|
31
|
+
list.sort((a, b) => {
|
|
32
|
+
if ("publishDate" in a && "publishDate" in b) {
|
|
33
|
+
if (a.publishDate === b.publishDate) {
|
|
34
|
+
if ((0, data_formatters_lib_1.nbVal)(a.leafId) > (0, data_formatters_lib_1.nbVal)(b.leafId))
|
|
35
|
+
return -1;
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
return new Date(a.publishDate).getTime() - new Date(b.publishDate).getTime();
|
|
39
|
+
}
|
|
40
|
+
return 0;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.sortParts = sortParts;
|
|
45
|
+
function includesOrderBy(orderBy, valueToCheck) {
|
|
46
|
+
return orderBy.some((item) => item[0] === valueToCheck[0] && item[1] === valueToCheck[1]);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=parts.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.helper.js","sourceRoot":"","sources":["../src/parts.helper.ts"],"names":[],"mappings":";;;AAAA,oEAAmD;AAGnD,SAAgB,SAAS,CAAC,QAAoB,EAAE,IAAW;IACzD,IAAI,QAAQ,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAClC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACjB,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;gBAAE,OAAO,CAAC,CAAC;YACxC,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS;gBAAE,OAAO,CAAC,CAAC,CAAC;YACxC,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS;gBAAE,OAAO,CAAC,CAAC;YACvC,OAAO,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;QACtE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACjB,IAAI,aAAa,IAAI,CAAC,IAAI,aAAa,IAAI,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;oBACpC,IAAI,IAAA,2BAAK,EAAC,CAAC,CAAC,MAAM,CAAC,GAAG,IAAA,2BAAK,EAAC,CAAC,CAAC,MAAM,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,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClassicDocumentSchema, DocumentSchema, FTextFieldType, FieldType, LeafSchema, PartSchema, RoutingPointDocumentSchema, SiteSchema } from "@paroicms/public-anywhere-lib";
|
|
2
|
+
export declare function getDocumentTypeByLeafType(siteSchema: SiteSchema, leafType: string): DocumentSchema;
|
|
3
|
+
export declare function getPartTypeByLeafType(siteSchema: SiteSchema, leafType: string): PartSchema;
|
|
4
|
+
export declare function getRoutingPointDocumentTypes(siteSchema: SiteSchema): RoutingPointDocumentSchema[];
|
|
5
|
+
export declare function getClassicDocumentTypes(siteSchema: SiteSchema): ClassicDocumentSchema[];
|
|
6
|
+
export declare function classicChildDocumentTypesOf(siteSchema: SiteSchema, parentLeafType: string): ClassicDocumentSchema[];
|
|
7
|
+
export declare function getDocumentTypeByBoDirName({ boDirName, siteSchema, }: {
|
|
8
|
+
boDirName: string;
|
|
9
|
+
siteSchema: SiteSchema;
|
|
10
|
+
}): DocumentSchema | undefined;
|
|
11
|
+
export declare function getParentDocumentTypeOf({ leafType, siteSchema, }: {
|
|
12
|
+
leafType: string;
|
|
13
|
+
siteSchema: SiteSchema;
|
|
14
|
+
}): DocumentSchema;
|
|
15
|
+
export declare function getLeafSchema(siteSchema: SiteSchema, leafType: string): LeafSchema;
|
|
16
|
+
export declare function getMediaLimitPerDocument(siteSchema: SiteSchema, documentType: DocumentSchema): number | undefined;
|
|
17
|
+
export declare function getMediaLimitPerPart(siteSchema: SiteSchema, partType: PartSchema): number | undefined;
|
|
18
|
+
export declare function isFTextFieldType(fieldType: FieldType): fieldType is FTextFieldType;
|
|
19
|
+
export declare function documentTypeHasData(documentType: DocumentSchema): boolean;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.documentTypeHasData = exports.isFTextFieldType = exports.getMediaLimitPerPart = exports.getMediaLimitPerDocument = exports.getLeafSchema = exports.getParentDocumentTypeOf = exports.getDocumentTypeByBoDirName = exports.classicChildDocumentTypesOf = exports.getClassicDocumentTypes = exports.getRoutingPointDocumentTypes = exports.getPartTypeByLeafType = exports.getDocumentTypeByLeafType = void 0;
|
|
4
|
+
function getDocumentTypeByLeafType(siteSchema, leafType) {
|
|
5
|
+
const documentType = siteSchema.documentTypes[leafType];
|
|
6
|
+
if (!documentType)
|
|
7
|
+
throw new Error(`Unknown documentType for leafType '${leafType}'`);
|
|
8
|
+
return documentType;
|
|
9
|
+
}
|
|
10
|
+
exports.getDocumentTypeByLeafType = getDocumentTypeByLeafType;
|
|
11
|
+
function getPartTypeByLeafType(siteSchema, leafType) {
|
|
12
|
+
const partType = siteSchema.partTypes[leafType];
|
|
13
|
+
if (!partType)
|
|
14
|
+
throw new Error(`Unknown partType for leafType '${leafType}'`);
|
|
15
|
+
return partType;
|
|
16
|
+
}
|
|
17
|
+
exports.getPartTypeByLeafType = getPartTypeByLeafType;
|
|
18
|
+
function getRoutingPointDocumentTypes(siteSchema) {
|
|
19
|
+
return Object.values(siteSchema.documentTypes).filter((item) => item.kind === "routingPoint");
|
|
20
|
+
}
|
|
21
|
+
exports.getRoutingPointDocumentTypes = getRoutingPointDocumentTypes;
|
|
22
|
+
function getClassicDocumentTypes(siteSchema) {
|
|
23
|
+
return Object.values(siteSchema.documentTypes).filter((item) => item.kind === "classic");
|
|
24
|
+
}
|
|
25
|
+
exports.getClassicDocumentTypes = getClassicDocumentTypes;
|
|
26
|
+
function classicChildDocumentTypesOf(siteSchema, parentLeafType) {
|
|
27
|
+
const found = [];
|
|
28
|
+
const parent = getDocumentTypeByLeafType(siteSchema, parentLeafType);
|
|
29
|
+
for (const child of parent.children ?? []) {
|
|
30
|
+
const documentType = getDocumentTypeByLeafType(siteSchema, child);
|
|
31
|
+
if (documentType.kind !== "routingPoint") {
|
|
32
|
+
found.push(documentType);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return found;
|
|
36
|
+
}
|
|
37
|
+
exports.classicChildDocumentTypesOf = classicChildDocumentTypesOf;
|
|
38
|
+
function getDocumentTypeByBoDirName({ boDirName, siteSchema, }) {
|
|
39
|
+
const found = Object.values(siteSchema.documentTypes).find((item) => item.boDirName === boDirName);
|
|
40
|
+
return found;
|
|
41
|
+
}
|
|
42
|
+
exports.getDocumentTypeByBoDirName = getDocumentTypeByBoDirName;
|
|
43
|
+
function getParentDocumentTypeOf({ leafType, siteSchema, }) {
|
|
44
|
+
const foundDocumentType = Object.values(siteSchema.documentTypes).find((item) => item.children?.includes(leafType));
|
|
45
|
+
if (!foundDocumentType)
|
|
46
|
+
throw new Error(`Unknown parent documentType of leafType:'${leafType}'`);
|
|
47
|
+
return foundDocumentType;
|
|
48
|
+
}
|
|
49
|
+
exports.getParentDocumentTypeOf = getParentDocumentTypeOf;
|
|
50
|
+
function getLeafSchema(siteSchema, leafType) {
|
|
51
|
+
if (leafType === siteSchema.site.leafType)
|
|
52
|
+
return siteSchema.site;
|
|
53
|
+
const type = siteSchema.documentTypes[leafType] ?? siteSchema.partTypes[leafType];
|
|
54
|
+
if (!type)
|
|
55
|
+
throw new Error(`unknown leaf-type '${leafType}'`);
|
|
56
|
+
return type;
|
|
57
|
+
}
|
|
58
|
+
exports.getLeafSchema = getLeafSchema;
|
|
59
|
+
function getMediaLimitPerDocument(siteSchema, documentType) {
|
|
60
|
+
const policyName = documentType.mediaPolicy;
|
|
61
|
+
if (policyName) {
|
|
62
|
+
const val = siteSchema.mediaPolicies[policyName].mediaLimitPerDocument;
|
|
63
|
+
if (val !== undefined)
|
|
64
|
+
return val;
|
|
65
|
+
}
|
|
66
|
+
return siteSchema.mediaPolicies.default.mediaLimitPerDocument;
|
|
67
|
+
}
|
|
68
|
+
exports.getMediaLimitPerDocument = getMediaLimitPerDocument;
|
|
69
|
+
function getMediaLimitPerPart(siteSchema, partType) {
|
|
70
|
+
const policyName = partType.mediaPolicy;
|
|
71
|
+
if (policyName) {
|
|
72
|
+
const val = siteSchema.mediaPolicies[policyName].mediaLimitPerPart;
|
|
73
|
+
if (val !== undefined)
|
|
74
|
+
return val;
|
|
75
|
+
}
|
|
76
|
+
return siteSchema.mediaPolicies.default.mediaLimitPerPart;
|
|
77
|
+
}
|
|
78
|
+
exports.getMediaLimitPerPart = getMediaLimitPerPart;
|
|
79
|
+
function isFTextFieldType(fieldType) {
|
|
80
|
+
return fieldType.dataType === "quillDelta" || fieldType.dataType === "html";
|
|
81
|
+
}
|
|
82
|
+
exports.isFTextFieldType = isFTextFieldType;
|
|
83
|
+
function documentTypeHasData(documentType) {
|
|
84
|
+
return documentType.kind !== "routingPoint" || !documentType.redirectTo;
|
|
85
|
+
}
|
|
86
|
+
exports.documentTypeHasData = documentTypeHasData;
|
|
87
|
+
//# sourceMappingURL=site-schema-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-schema-helpers.js","sourceRoot":"","sources":["../src/site-schema-helpers.ts"],"names":[],"mappings":";;;AAWA,SAAgB,yBAAyB,CAAC,UAAsB,EAAE,QAAgB;IAChF,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACxD,IAAI,CAAC,YAAY;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,GAAG,CAAC,CAAC;IACtF,OAAO,YAAY,CAAC;AACtB,CAAC;AAJD,8DAIC;AAED,SAAgB,qBAAqB,CAAC,UAAsB,EAAE,QAAgB;IAC5E,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAChD,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,GAAG,CAAC,CAAC;IAC9E,OAAO,QAAQ,CAAC;AAClB,CAAC;AAJD,sDAIC;AAED,SAAgB,4BAA4B,CAAC,UAAsB;IACjE,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,C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ACD,OAAO,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,iBAAiB,CAAC;AAC5D,CAAC;AAVD,oDAUC;AAED,SAAgB,gBAAgB,CAAC,SAAoB;IACnD,OAAO,SAAS,CAAC,QAAQ,KAAK,YAAY,IAAI,SAAS,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9E,CAAC;AAFD,4CAEC;AAED,SAAgB,mBAAmB,CAAC,YAA4B;IAC9D,OAAO,YAAY,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;AAC1E,CAAC;AAFD,kDAEC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTimeWithUnit = exports.isSameTimeUnit = void 0;
|
|
4
|
+
function isSameTimeUnit(dt, timeUnit) {
|
|
5
|
+
const nowDay = new Date().toISOString().substring(0, 10);
|
|
6
|
+
const dtDay = dt.toISOString().substring(0, 10);
|
|
7
|
+
return nowDay === dtDay;
|
|
8
|
+
}
|
|
9
|
+
exports.isSameTimeUnit = isSameTimeUnit;
|
|
10
|
+
function parseTimeWithUnit(timeToIdle) {
|
|
11
|
+
if (!timeToIdle.endsWith("d"))
|
|
12
|
+
throw new Error(`invalid timeToIdle: '${timeToIdle}'`);
|
|
13
|
+
return {
|
|
14
|
+
timeUnit: "day",
|
|
15
|
+
delay: Number(timeToIdle.slice(0, -1)),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.parseTimeWithUnit = parseTimeWithUnit;
|
|
19
|
+
//# sourceMappingURL=time-with-unit.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-with-unit.helpers.js","sourceRoot":"","sources":["../src/time-with-unit.helpers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,EAAQ,EAAE,QAAe;IACtD,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChD,OAAO,MAAM,KAAK,KAAK,CAAC;AAC1B,CAAC;AAJD,wCAIC;AAOD,SAAgB,iBAAiB,CAAC,UAAkB;IAClD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,UAAU,GAAG,CAAC,CAAC;IACtF,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KACvC,CAAC;AACJ,CAAC;AAND,8CAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateSlug(str: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateSlug = void 0;
|
|
4
|
+
function generateSlug(str) {
|
|
5
|
+
return (str
|
|
6
|
+
.trim()
|
|
7
|
+
.normalize("NFD")
|
|
8
|
+
// biome-ignore lint/suspicious/noMisleadingCharacterClass: not sure
|
|
9
|
+
.replace(/[\u0300-\u036f]/g, "") // remove diacritics
|
|
10
|
+
.replace(/[^a-zA-Z0-9]/g, "-")
|
|
11
|
+
.replace(/--+/g, "-")
|
|
12
|
+
.replace(/-+$/, "")
|
|
13
|
+
.replace(/^-+/, "")
|
|
14
|
+
.toLowerCase());
|
|
15
|
+
}
|
|
16
|
+
exports.generateSlug = generateSlug;
|
|
17
|
+
//# sourceMappingURL=url-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-helpers.js","sourceRoot":"","sources":["../src/url-helpers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,CACL,GAAG;SACA,IAAI,EAAE;SACN,SAAS,CAAC,KAAK,CAAC;QACjB,oEAAoE;SACnE,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,oBAAoB;SACpD,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC;SAC7B,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,WAAW,EAAE,CACjB,CAAC;AACJ,CAAC;AAbD,oCAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PART_DEFAULT_LIST_NAME = "subParts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class NumberLocalization {
|
|
2
|
+
#numberFormat;
|
|
3
|
+
constructor(locale) {
|
|
4
|
+
this.#numberFormat = new Intl.NumberFormat(locale, {
|
|
5
|
+
minimumFractionDigits: 0,
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
parse(val) {
|
|
9
|
+
const parts = this.#numberFormat.formatToParts(1234.5);
|
|
10
|
+
const group = parts.find((d) => d.type === "group")?.value;
|
|
11
|
+
const decimal = parts.find((d) => d.type === "decimal")?.value;
|
|
12
|
+
if (!group)
|
|
13
|
+
throw new Error("group not found");
|
|
14
|
+
if (!decimal)
|
|
15
|
+
throw new Error("group not found");
|
|
16
|
+
return val
|
|
17
|
+
.trim()
|
|
18
|
+
.replace(new RegExp(group, "g"), "")
|
|
19
|
+
.replace(decimal === "." ? /\./ : new RegExp(decimal), ".");
|
|
20
|
+
}
|
|
21
|
+
format(val) {
|
|
22
|
+
return this.#numberFormat.format(val);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=number-localization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-localization.js","sourceRoot":"","sources":["../src/number-localization.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAkB;IAC7B,aAAa,CAAoB;IAEjC,YAAY,MAAc;QACxB,IAAI,CAAC,aAAa,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YACjD,qBAAqB,EAAE,CAAC;SACzB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAW;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,EAAE,KAAK,CAAC;QAC3D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,EAAE,KAAK,CAAC;QAE/D,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAEjD,OAAO,GAAG;aACP,IAAI,EAAE;aACN,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;aACnC,OAAO,CAAC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { nbVal } from "@paroi/data-formatters-lib";
|
|
2
|
+
export function sortParts(listType, list) {
|
|
3
|
+
if (listType.orderBy === "manual") {
|
|
4
|
+
list.sort((a, b) => {
|
|
5
|
+
if (a.orderNum === b.orderNum)
|
|
6
|
+
return 0;
|
|
7
|
+
if (a.orderNum === undefined)
|
|
8
|
+
return -1;
|
|
9
|
+
if (b.orderNum === undefined)
|
|
10
|
+
return 1;
|
|
11
|
+
return a.orderNum - b.orderNum;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
else if (includesOrderBy(listType.orderBy, ["publishDate", "desc"])) {
|
|
15
|
+
list.sort((a, b) => {
|
|
16
|
+
if ("publishDate" in a && "publishDate" in b) {
|
|
17
|
+
if (a.publishDate === b.publishDate) {
|
|
18
|
+
if (nbVal(a.leafId) > nbVal(b.leafId))
|
|
19
|
+
return -1;
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
return new Date(b.publishDate).getTime() - new Date(a.publishDate).getTime();
|
|
23
|
+
}
|
|
24
|
+
return 0;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else if (includesOrderBy(listType.orderBy, ["publishDate", "asc"])) {
|
|
28
|
+
list.sort((a, b) => {
|
|
29
|
+
if ("publishDate" in a && "publishDate" in b) {
|
|
30
|
+
if (a.publishDate === b.publishDate) {
|
|
31
|
+
if (nbVal(a.leafId) > nbVal(b.leafId))
|
|
32
|
+
return -1;
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
return new Date(a.publishDate).getTime() - new Date(b.publishDate).getTime();
|
|
36
|
+
}
|
|
37
|
+
return 0;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function includesOrderBy(orderBy, valueToCheck) {
|
|
42
|
+
return orderBy.some((item) => item[0] === valueToCheck[0] && item[1] === valueToCheck[1]);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=parts.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.helper.js","sourceRoot":"","sources":["../src/parts.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGnD,MAAM,UAAU,SAAS,CAAC,QAAoB,EAAE,IAAW;IACzD,IAAI,QAAQ,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAClC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACjB,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;gBAAE,OAAO,CAAC,CAAC;YACxC,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS;gBAAE,OAAO,CAAC,CAAC,CAAC;YACxC,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS;gBAAE,OAAO,CAAC,CAAC;YACvC,OAAO,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;QACtE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACjB,IAAI,aAAa,IAAI,CAAC,IAAI,aAAa,IAAI,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;oBACpC,I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CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClassicDocumentSchema, DocumentSchema, FTextFieldType, FieldType, LeafSchema, PartSchema, RoutingPointDocumentSchema, SiteSchema } from "@paroicms/public-anywhere-lib";
|
|
2
|
+
export declare function getDocumentTypeByLeafType(siteSchema: SiteSchema, leafType: string): DocumentSchema;
|
|
3
|
+
export declare function getPartTypeByLeafType(siteSchema: SiteSchema, leafType: string): PartSchema;
|
|
4
|
+
export declare function getRoutingPointDocumentTypes(siteSchema: SiteSchema): RoutingPointDocumentSchema[];
|
|
5
|
+
export declare function getClassicDocumentTypes(siteSchema: SiteSchema): ClassicDocumentSchema[];
|
|
6
|
+
export declare function classicChildDocumentTypesOf(siteSchema: SiteSchema, parentLeafType: string): ClassicDocumentSchema[];
|
|
7
|
+
export declare function getDocumentTypeByBoDirName({ boDirName, siteSchema, }: {
|
|
8
|
+
boDirName: string;
|
|
9
|
+
siteSchema: SiteSchema;
|
|
10
|
+
}): DocumentSchema | undefined;
|
|
11
|
+
export declare function getParentDocumentTypeOf({ leafType, siteSchema, }: {
|
|
12
|
+
leafType: string;
|
|
13
|
+
siteSchema: SiteSchema;
|
|
14
|
+
}): DocumentSchema;
|
|
15
|
+
export declare function getLeafSchema(siteSchema: SiteSchema, leafType: string): LeafSchema;
|
|
16
|
+
export declare function getMediaLimitPerDocument(siteSchema: SiteSchema, documentType: DocumentSchema): number | undefined;
|
|
17
|
+
export declare function getMediaLimitPerPart(siteSchema: SiteSchema, partType: PartSchema): number | undefined;
|
|
18
|
+
export declare function isFTextFieldType(fieldType: FieldType): fieldType is FTextFieldType;
|
|
19
|
+
export declare function documentTypeHasData(documentType: DocumentSchema): boolean;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export function getDocumentTypeByLeafType(siteSchema, leafType) {
|
|
2
|
+
const documentType = siteSchema.documentTypes[leafType];
|
|
3
|
+
if (!documentType)
|
|
4
|
+
throw new Error(`Unknown documentType for leafType '${leafType}'`);
|
|
5
|
+
return documentType;
|
|
6
|
+
}
|
|
7
|
+
export function getPartTypeByLeafType(siteSchema, leafType) {
|
|
8
|
+
const partType = siteSchema.partTypes[leafType];
|
|
9
|
+
if (!partType)
|
|
10
|
+
throw new Error(`Unknown partType for leafType '${leafType}'`);
|
|
11
|
+
return partType;
|
|
12
|
+
}
|
|
13
|
+
export function getRoutingPointDocumentTypes(siteSchema) {
|
|
14
|
+
return Object.values(siteSchema.documentTypes).filter((item) => item.kind === "routingPoint");
|
|
15
|
+
}
|
|
16
|
+
export function getClassicDocumentTypes(siteSchema) {
|
|
17
|
+
return Object.values(siteSchema.documentTypes).filter((item) => item.kind === "classic");
|
|
18
|
+
}
|
|
19
|
+
export function classicChildDocumentTypesOf(siteSchema, parentLeafType) {
|
|
20
|
+
const found = [];
|
|
21
|
+
const parent = getDocumentTypeByLeafType(siteSchema, parentLeafType);
|
|
22
|
+
for (const child of parent.children ?? []) {
|
|
23
|
+
const documentType = getDocumentTypeByLeafType(siteSchema, child);
|
|
24
|
+
if (documentType.kind !== "routingPoint") {
|
|
25
|
+
found.push(documentType);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return found;
|
|
29
|
+
}
|
|
30
|
+
export function getDocumentTypeByBoDirName({ boDirName, siteSchema, }) {
|
|
31
|
+
const found = Object.values(siteSchema.documentTypes).find((item) => item.boDirName === boDirName);
|
|
32
|
+
return found;
|
|
33
|
+
}
|
|
34
|
+
export function getParentDocumentTypeOf({ leafType, siteSchema, }) {
|
|
35
|
+
const foundDocumentType = Object.values(siteSchema.documentTypes).find((item) => item.children?.includes(leafType));
|
|
36
|
+
if (!foundDocumentType)
|
|
37
|
+
throw new Error(`Unknown parent documentType of leafType:'${leafType}'`);
|
|
38
|
+
return foundDocumentType;
|
|
39
|
+
}
|
|
40
|
+
export function getLeafSchema(siteSchema, leafType) {
|
|
41
|
+
if (leafType === siteSchema.site.leafType)
|
|
42
|
+
return siteSchema.site;
|
|
43
|
+
const type = siteSchema.documentTypes[leafType] ?? siteSchema.partTypes[leafType];
|
|
44
|
+
if (!type)
|
|
45
|
+
throw new Error(`unknown leaf-type '${leafType}'`);
|
|
46
|
+
return type;
|
|
47
|
+
}
|
|
48
|
+
export function getMediaLimitPerDocument(siteSchema, documentType) {
|
|
49
|
+
const policyName = documentType.mediaPolicy;
|
|
50
|
+
if (policyName) {
|
|
51
|
+
const val = siteSchema.mediaPolicies[policyName].mediaLimitPerDocument;
|
|
52
|
+
if (val !== undefined)
|
|
53
|
+
return val;
|
|
54
|
+
}
|
|
55
|
+
return siteSchema.mediaPolicies.default.mediaLimitPerDocument;
|
|
56
|
+
}
|
|
57
|
+
export function getMediaLimitPerPart(siteSchema, partType) {
|
|
58
|
+
const policyName = partType.mediaPolicy;
|
|
59
|
+
if (policyName) {
|
|
60
|
+
const val = siteSchema.mediaPolicies[policyName].mediaLimitPerPart;
|
|
61
|
+
if (val !== undefined)
|
|
62
|
+
return val;
|
|
63
|
+
}
|
|
64
|
+
return siteSchema.mediaPolicies.default.mediaLimitPerPart;
|
|
65
|
+
}
|
|
66
|
+
export function isFTextFieldType(fieldType) {
|
|
67
|
+
return fieldType.dataType === "quillDelta" || fieldType.dataType === "html";
|
|
68
|
+
}
|
|
69
|
+
export function documentTypeHasData(documentType) {
|
|
70
|
+
return documentType.kind !== "routingPoint" || !documentType.redirectTo;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=site-schema-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-schema-helpers.js","sourceRoot":"","sources":["../src/site-schema-helpers.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,yBAAyB,CAAC,UAAsB,EAAE,QAAgB;IAChF,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACxD,IAAI,CAAC,YAAY;QAAE,MAAM,IAAI,KA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,CAAC;IACpC,CAAC;IACD,OAAO,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,qBAAqB,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,UAAsB,EACtB,QAAoB;IAEpB,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC;IACxC,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,iBAAiB,CAAC;QACnE,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,GAAG,CAAC;IACpC,CAAC;IACD,OAAO,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,iBAAiB,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,SAAoB;IACnD,OAAO,SAAS,CAAC,QAAQ,KAAK,YAAY,IAAI,SAAS,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,YAA4B;IAC9D,OAAO,YAAY,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function isSameTimeUnit(dt, timeUnit) {
|
|
2
|
+
const nowDay = new Date().toISOString().substring(0, 10);
|
|
3
|
+
const dtDay = dt.toISOString().substring(0, 10);
|
|
4
|
+
return nowDay === dtDay;
|
|
5
|
+
}
|
|
6
|
+
export function parseTimeWithUnit(timeToIdle) {
|
|
7
|
+
if (!timeToIdle.endsWith("d"))
|
|
8
|
+
throw new Error(`invalid timeToIdle: '${timeToIdle}'`);
|
|
9
|
+
return {
|
|
10
|
+
timeUnit: "day",
|
|
11
|
+
delay: Number(timeToIdle.slice(0, -1)),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=time-with-unit.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-with-unit.helpers.js","sourceRoot":"","sources":["../src/time-with-unit.helpers.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,EAAQ,EAAE,QAAe;IACtD,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChD,OAAO,MAAM,KAAK,KAAK,CAAC;AAC1B,CAAC;AAOD,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,UAAU,GAAG,CAAC,CAAC;IACtF,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateSlug(str: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function generateSlug(str) {
|
|
2
|
+
return (str
|
|
3
|
+
.trim()
|
|
4
|
+
.normalize("NFD")
|
|
5
|
+
// biome-ignore lint/suspicious/noMisleadingCharacterClass: not sure
|
|
6
|
+
.replace(/[\u0300-\u036f]/g, "") // remove diacritics
|
|
7
|
+
.replace(/[^a-zA-Z0-9]/g, "-")
|
|
8
|
+
.replace(/--+/g, "-")
|
|
9
|
+
.replace(/-+$/, "")
|
|
10
|
+
.replace(/^-+/, "")
|
|
11
|
+
.toLowerCase());
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=url-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-helpers.js","sourceRoot":"","sources":["../src/url-helpers.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,CACL,GAAG;SACA,IAAI,EAAE;SACN,SAAS,CAAC,KAAK,CAAC;QACjB,oEAAoE;SACnE,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,oBAAoB;SACpD,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC;SAC7B,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,WAAW,EAAE,CACjB,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@paroicms/internal-anywhere-lib",
|
|
3
|
+
"version": "1.17.0",
|
|
4
|
+
"description": "Front lib for Paroi CMS.",
|
|
5
|
+
"author": "Paroi Team",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"paroicms"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://gitlab.com/paroi/opensource/paroicms.git",
|
|
12
|
+
"directory": "packages/internal-anywhere-lib"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"main": "dist-cjs/index.js",
|
|
16
|
+
"module": "dist-mjs/index.js",
|
|
17
|
+
"types": "dist-mjs/index.d.ts",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "npm run tsc:cjs && npm run tsc:mjs",
|
|
20
|
+
"clear": "rimraf dist-cjs/* dist-mjs/*",
|
|
21
|
+
"tsc:cjs": "tsc --project ./tsconfig.cjs.json",
|
|
22
|
+
"tsc:mjs": "tsc --project ./tsconfig.mjs.json",
|
|
23
|
+
"tsc:dev-cjs": "tsc --watch --preserveWatchOutput --project ./tsconfig.cjs.json",
|
|
24
|
+
"tsc:dev-mjs": "tsc --watch --preserveWatchOutput --project ./tsconfig.mjs.json",
|
|
25
|
+
"dev": "turbo dev",
|
|
26
|
+
"eslint": "eslint .",
|
|
27
|
+
"test": "vitest",
|
|
28
|
+
"test:run": "vitest run"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@paroi/data-formatters-lib": "~0.4.0",
|
|
32
|
+
"@paroicms/public-anywhere-lib": "0.2.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"rimraf": "~5.0.5",
|
|
36
|
+
"typescript": "~5.4.5",
|
|
37
|
+
"vitest": "~1.5.3"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist-cjs",
|
|
41
|
+
"dist-mjs",
|
|
42
|
+
"types"
|
|
43
|
+
]
|
|
44
|
+
}
|