@adatechnology/content-contracts 0.4.0 → 0.5.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 +47 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +42 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21,7 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
|
+
ActorRequiredError: () => ActorRequiredError,
|
|
24
25
|
BULK_MODERATION_ACTIONS: () => BULK_MODERATION_ACTIONS,
|
|
26
|
+
COMMUNITY_LINK_REL: () => COMMUNITY_LINK_REL,
|
|
25
27
|
COMMUNITY_MODERATION: () => COMMUNITY_MODERATION,
|
|
26
28
|
COMMUNITY_MODERATIONS: () => COMMUNITY_MODERATIONS,
|
|
27
29
|
COMMUNITY_REVISION_STATE: () => COMMUNITY_REVISION_STATE,
|
|
@@ -59,6 +61,7 @@ __export(index_exports, {
|
|
|
59
61
|
PT_BR_STOP_WORDS: () => PT_BR_STOP_WORDS,
|
|
60
62
|
PostNotFoundError: () => PostNotFoundError,
|
|
61
63
|
PostNotPublishedError: () => PostNotPublishedError,
|
|
64
|
+
PostStateChangedError: () => PostStateChangedError,
|
|
62
65
|
RECURRENCE_FREQUENCIES: () => RECURRENCE_FREQUENCIES,
|
|
63
66
|
RECURRENCE_FREQUENCY: () => RECURRENCE_FREQUENCY,
|
|
64
67
|
REPORT_STATUSES: () => REPORT_STATUSES,
|
|
@@ -70,6 +73,7 @@ __export(index_exports, {
|
|
|
70
73
|
TAGS_MAX_COUNT: () => TAGS_MAX_COUNT,
|
|
71
74
|
TAG_MAX_LENGTH: () => TAG_MAX_LENGTH,
|
|
72
75
|
TemplateNotPublishableError: () => TemplateNotPublishableError,
|
|
76
|
+
approvePostSchema: () => approvePostSchema,
|
|
73
77
|
buildAtomFeed: () => buildAtomFeed,
|
|
74
78
|
buildExcerpt: () => buildExcerpt,
|
|
75
79
|
buildPostPath: () => buildPostPath,
|
|
@@ -101,6 +105,7 @@ __export(index_exports, {
|
|
|
101
105
|
isAbsoluteHttpUrl: () => isAbsoluteHttpUrl,
|
|
102
106
|
isCanonicalPostRef: () => isCanonicalPostRef,
|
|
103
107
|
isPostStatus: () => isPostStatus,
|
|
108
|
+
isProtocolRelativeUrl: () => isProtocolRelativeUrl,
|
|
104
109
|
isShortId: () => isShortId,
|
|
105
110
|
isValidSlug: () => isValidSlug,
|
|
106
111
|
listPostReportsQuerySchema: () => listPostReportsQuerySchema,
|
|
@@ -208,6 +213,8 @@ var CONTENT_ERROR_CODES = {
|
|
|
208
213
|
COMMUNITY_TOO_MANY_IMAGES: "CONTENT_COMMUNITY_TOO_MANY_IMAGES",
|
|
209
214
|
COMMUNITY_IMAGE_NOT_ALLOWED: "CONTENT_COMMUNITY_IMAGE_NOT_ALLOWED",
|
|
210
215
|
INVALID_TRANSITION: "CONTENT_INVALID_TRANSITION",
|
|
216
|
+
POST_STATE_CHANGED: "CONTENT_POST_STATE_CHANGED",
|
|
217
|
+
ACTOR_REQUIRED: "CONTENT_ACTOR_REQUIRED",
|
|
211
218
|
COMMUNITY_POST_READ_ONLY: "CONTENT_COMMUNITY_POST_READ_ONLY",
|
|
212
219
|
REPORT_NOT_FOUND: "CONTENT_REPORT_NOT_FOUND"
|
|
213
220
|
};
|
|
@@ -395,6 +402,25 @@ var InvalidPostTransitionError = class extends ContentError {
|
|
|
395
402
|
}), this.from = from, this.action = action;
|
|
396
403
|
}
|
|
397
404
|
};
|
|
405
|
+
var ActorRequiredError = class extends ContentError {
|
|
406
|
+
static {
|
|
407
|
+
__name(this, "ActorRequiredError");
|
|
408
|
+
}
|
|
409
|
+
constructor() {
|
|
410
|
+
super("Esta a\xE7\xE3o exige um usu\xE1rio da equipe.", 403, CONTENT_ERROR_CODES.ACTOR_REQUIRED);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
var PostStateChangedError = class extends ContentError {
|
|
414
|
+
static {
|
|
415
|
+
__name(this, "PostStateChangedError");
|
|
416
|
+
}
|
|
417
|
+
postId;
|
|
418
|
+
constructor(postId) {
|
|
419
|
+
super("O post mudou desde que voc\xEA o abriu. Recarregue e confira antes de decidir.", 409, CONTENT_ERROR_CODES.POST_STATE_CHANGED, {
|
|
420
|
+
postId
|
|
421
|
+
}), this.postId = postId;
|
|
422
|
+
}
|
|
423
|
+
};
|
|
398
424
|
var CommunityPostReadOnlyError = class extends ContentError {
|
|
399
425
|
static {
|
|
400
426
|
__name(this, "CommunityPostReadOnlyError");
|
|
@@ -664,8 +690,15 @@ var updateCommunityPostSchema = communityFieldsSchema.partial().strict();
|
|
|
664
690
|
var submitCommunityPostSchema = import_zod.z.object({
|
|
665
691
|
termsAccepted: import_zod.z.boolean()
|
|
666
692
|
}).strict();
|
|
693
|
+
var expectedUpdatedAtSchema = import_zod.z.string().datetime({
|
|
694
|
+
offset: true
|
|
695
|
+
});
|
|
696
|
+
var approvePostSchema = import_zod.z.object({
|
|
697
|
+
expectedUpdatedAt: expectedUpdatedAtSchema.optional()
|
|
698
|
+
}).strict();
|
|
667
699
|
var rejectPostSchema = import_zod.z.object({
|
|
668
|
-
note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE)
|
|
700
|
+
note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE),
|
|
701
|
+
expectedUpdatedAt: expectedUpdatedAtSchema.optional()
|
|
669
702
|
}).strict();
|
|
670
703
|
var unpublishCommunityPostSchema = import_zod.z.object({
|
|
671
704
|
note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE).optional()
|
|
@@ -679,7 +712,9 @@ var BULK_MODERATION_ACTIONS = [
|
|
|
679
712
|
var bulkModerationSchema = import_zod.z.object({
|
|
680
713
|
action: import_zod.z.enum(BULK_MODERATION_ACTIONS),
|
|
681
714
|
ids: import_zod.z.array(import_zod.z.string().uuid()).min(1).max(POST_LIMITS.BULK_IDS),
|
|
682
|
-
note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE).optional()
|
|
715
|
+
note: import_zod.z.string().trim().min(1).max(POST_LIMITS.REVIEW_NOTE).optional(),
|
|
716
|
+
/** Por id: o `updatedAt` que a tela leu. Id sem entrada decide sem a checagem. */
|
|
717
|
+
expectedUpdatedAt: import_zod.z.record(import_zod.z.string().uuid(), expectedUpdatedAtSchema).optional()
|
|
683
718
|
}).strict();
|
|
684
719
|
var contentSettingsSchema = import_zod.z.object({
|
|
685
720
|
communityModeration: import_zod.z.enum(COMMUNITY_MODERATIONS),
|
|
@@ -804,6 +839,10 @@ function sanitizeImageUrl(url) {
|
|
|
804
839
|
return sanitize(url, IMAGE_SCHEMES);
|
|
805
840
|
}
|
|
806
841
|
__name(sanitizeImageUrl, "sanitizeImageUrl");
|
|
842
|
+
function isProtocolRelativeUrl(url) {
|
|
843
|
+
return /^[/\\]{2}/.test(url);
|
|
844
|
+
}
|
|
845
|
+
__name(isProtocolRelativeUrl, "isProtocolRelativeUrl");
|
|
807
846
|
function isAbsoluteHttpUrl(url) {
|
|
808
847
|
return /^https?:\/\//i.test(url) || url.startsWith("//");
|
|
809
848
|
}
|
|
@@ -1454,6 +1493,7 @@ __name(createHeadingIdGenerator, "createHeadingIdGenerator");
|
|
|
1454
1493
|
|
|
1455
1494
|
// src/markdown/renderHtml.ts
|
|
1456
1495
|
var DEFAULT_LINK_REL = "noopener noreferrer";
|
|
1496
|
+
var COMMUNITY_LINK_REL = "noopener noreferrer nofollow ugc";
|
|
1457
1497
|
var ESCAPES = {
|
|
1458
1498
|
"&": "&",
|
|
1459
1499
|
"<": "<",
|
|
@@ -1685,7 +1725,9 @@ function buildSitemapXml(entries) {
|
|
|
1685
1725
|
__name(buildSitemapXml, "buildSitemapXml");
|
|
1686
1726
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1687
1727
|
0 && (module.exports = {
|
|
1728
|
+
ActorRequiredError,
|
|
1688
1729
|
BULK_MODERATION_ACTIONS,
|
|
1730
|
+
COMMUNITY_LINK_REL,
|
|
1689
1731
|
COMMUNITY_MODERATION,
|
|
1690
1732
|
COMMUNITY_MODERATIONS,
|
|
1691
1733
|
COMMUNITY_REVISION_STATE,
|
|
@@ -1723,6 +1765,7 @@ __name(buildSitemapXml, "buildSitemapXml");
|
|
|
1723
1765
|
PT_BR_STOP_WORDS,
|
|
1724
1766
|
PostNotFoundError,
|
|
1725
1767
|
PostNotPublishedError,
|
|
1768
|
+
PostStateChangedError,
|
|
1726
1769
|
RECURRENCE_FREQUENCIES,
|
|
1727
1770
|
RECURRENCE_FREQUENCY,
|
|
1728
1771
|
REPORT_STATUSES,
|
|
@@ -1734,6 +1777,7 @@ __name(buildSitemapXml, "buildSitemapXml");
|
|
|
1734
1777
|
TAGS_MAX_COUNT,
|
|
1735
1778
|
TAG_MAX_LENGTH,
|
|
1736
1779
|
TemplateNotPublishableError,
|
|
1780
|
+
approvePostSchema,
|
|
1737
1781
|
buildAtomFeed,
|
|
1738
1782
|
buildExcerpt,
|
|
1739
1783
|
buildPostPath,
|
|
@@ -1765,6 +1809,7 @@ __name(buildSitemapXml, "buildSitemapXml");
|
|
|
1765
1809
|
isAbsoluteHttpUrl,
|
|
1766
1810
|
isCanonicalPostRef,
|
|
1767
1811
|
isPostStatus,
|
|
1812
|
+
isProtocolRelativeUrl,
|
|
1768
1813
|
isShortId,
|
|
1769
1814
|
isValidSlug,
|
|
1770
1815
|
listPostReportsQuerySchema,
|