@drodil/backstage-plugin-qeta-common 2.9.0 → 2.10.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.js +1 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/utils.esm.js +1 -2
- package/dist/utils.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -94,8 +94,7 @@ const truncate = (str, n) => {
|
|
|
94
94
|
return str.length > n ? `${str.slice(0, n - 1)}...` : str;
|
|
95
95
|
};
|
|
96
96
|
const removeMarkdownFormatting = (text) => {
|
|
97
|
-
let fixed = text.replace(
|
|
98
|
-
fixed = text.replace(/<[^>]*>/g, "");
|
|
97
|
+
let fixed = text.replace(/<[^>]*>/g, "");
|
|
99
98
|
fixed = fixed.replace(/```[\s\S]*?```/g, (match) => {
|
|
100
99
|
return match.replace(/(^```[a-z]*\n)|(```$)/g, "").trim();
|
|
101
100
|
});
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/permissions.ts","../src/tags.ts","../src/utils.ts"],"sourcesContent":["import {\n BasicPermission,\n createPermission,\n isPermission,\n ResourcePermission,\n} from '@backstage/plugin-permission-common';\n\nexport const qetaCreateQuestionPermission = createPermission({\n name: 'qeta.create.question',\n attributes: { action: 'create' },\n});\n\nexport const qetaCreateAnswerPermission = createPermission({\n name: 'qeta.create.answer',\n attributes: { action: 'create' },\n});\n\nexport const qetaCreateCommentPermission = createPermission({\n name: 'qeta.create.comment',\n attributes: { action: 'create' },\n});\n\nexport const QUESTION_RESOURCE_TYPE = 'question';\n\nexport const qetaReadQuestionPermission = createPermission({\n name: 'qeta.read.question',\n attributes: { action: 'read' },\n resourceType: QUESTION_RESOURCE_TYPE,\n});\n\nexport const qetaEditQuestionPermission = createPermission({\n name: 'qeta.edit.question',\n attributes: { action: 'update' },\n resourceType: QUESTION_RESOURCE_TYPE,\n});\n\nexport const qetaDeleteQuestionPermission = createPermission({\n name: 'qeta.delete.question',\n attributes: { action: 'delete' },\n resourceType: QUESTION_RESOURCE_TYPE,\n});\n\nexport const ANSWER_RESOURCE_TYPE = 'answer';\nexport const qetaReadAnswerPermission = createPermission({\n name: 'qeta.read.question',\n attributes: { action: 'read' },\n resourceType: QUESTION_RESOURCE_TYPE,\n});\nexport const qetaEditAnswerPermission = createPermission({\n name: 'qeta.edit.answer',\n attributes: { action: 'update' },\n resourceType: ANSWER_RESOURCE_TYPE,\n});\n\nexport const qetaDeleteAnswerPermission = createPermission({\n name: 'qeta.delete.answer',\n attributes: { action: 'delete' },\n resourceType: ANSWER_RESOURCE_TYPE,\n});\n\nexport const COMMENT_RESOURCE_TYPE = 'comment';\nexport const qetaReadCommentPermission = createPermission({\n name: 'qeta.read.comment',\n attributes: { action: 'read' },\n resourceType: COMMENT_RESOURCE_TYPE,\n});\nexport const qetaEditCommentPermission = createPermission({\n name: 'qeta.edit.comment',\n attributes: { action: 'update' },\n resourceType: COMMENT_RESOURCE_TYPE,\n});\n\nexport const qetaDeleteCommentPermission = createPermission({\n name: 'qeta.delete.comment',\n attributes: { action: 'delete' },\n resourceType: COMMENT_RESOURCE_TYPE,\n});\n\nexport const qetaPermissions = [\n qetaReadQuestionPermission,\n qetaCreateQuestionPermission,\n qetaCreateAnswerPermission,\n qetaEditQuestionPermission,\n qetaDeleteQuestionPermission,\n qetaReadAnswerPermission,\n qetaEditAnswerPermission,\n qetaDeleteAnswerPermission,\n qetaCreateCommentPermission,\n qetaReadCommentPermission,\n qetaEditCommentPermission,\n qetaDeleteCommentPermission,\n];\n\nexport const isQetaPermission = (\n permission: BasicPermission | ResourcePermission,\n) => {\n return qetaPermissions.some(p => isPermission(permission, p));\n};\n","export const TAGS_REGEX = new RegExp('^[a-z0-9+#]+((\\\\-|_)[a-z0-9+#_]+)*$');\n\nexport const filterTags = (input?: null | string | string[]) => {\n if (!input) {\n return undefined;\n }\n return (Array.isArray(input) ? input : input.split(',')).filter(\n v => v.length > 0 && v.length < 255 && TAGS_REGEX.test(v),\n );\n};\n","export const truncate = (str: string, n: number): string => {\n return str.length > n ? `${str.slice(0, n - 1)}...` : str;\n};\n\n// Covers many common but not all cases of markdown formatting\nexport const removeMarkdownFormatting = (text: string): string => {\n // Remove
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/permissions.ts","../src/tags.ts","../src/utils.ts"],"sourcesContent":["import {\n BasicPermission,\n createPermission,\n isPermission,\n ResourcePermission,\n} from '@backstage/plugin-permission-common';\n\nexport const qetaCreateQuestionPermission = createPermission({\n name: 'qeta.create.question',\n attributes: { action: 'create' },\n});\n\nexport const qetaCreateAnswerPermission = createPermission({\n name: 'qeta.create.answer',\n attributes: { action: 'create' },\n});\n\nexport const qetaCreateCommentPermission = createPermission({\n name: 'qeta.create.comment',\n attributes: { action: 'create' },\n});\n\nexport const QUESTION_RESOURCE_TYPE = 'question';\n\nexport const qetaReadQuestionPermission = createPermission({\n name: 'qeta.read.question',\n attributes: { action: 'read' },\n resourceType: QUESTION_RESOURCE_TYPE,\n});\n\nexport const qetaEditQuestionPermission = createPermission({\n name: 'qeta.edit.question',\n attributes: { action: 'update' },\n resourceType: QUESTION_RESOURCE_TYPE,\n});\n\nexport const qetaDeleteQuestionPermission = createPermission({\n name: 'qeta.delete.question',\n attributes: { action: 'delete' },\n resourceType: QUESTION_RESOURCE_TYPE,\n});\n\nexport const ANSWER_RESOURCE_TYPE = 'answer';\nexport const qetaReadAnswerPermission = createPermission({\n name: 'qeta.read.question',\n attributes: { action: 'read' },\n resourceType: QUESTION_RESOURCE_TYPE,\n});\nexport const qetaEditAnswerPermission = createPermission({\n name: 'qeta.edit.answer',\n attributes: { action: 'update' },\n resourceType: ANSWER_RESOURCE_TYPE,\n});\n\nexport const qetaDeleteAnswerPermission = createPermission({\n name: 'qeta.delete.answer',\n attributes: { action: 'delete' },\n resourceType: ANSWER_RESOURCE_TYPE,\n});\n\nexport const COMMENT_RESOURCE_TYPE = 'comment';\nexport const qetaReadCommentPermission = createPermission({\n name: 'qeta.read.comment',\n attributes: { action: 'read' },\n resourceType: COMMENT_RESOURCE_TYPE,\n});\nexport const qetaEditCommentPermission = createPermission({\n name: 'qeta.edit.comment',\n attributes: { action: 'update' },\n resourceType: COMMENT_RESOURCE_TYPE,\n});\n\nexport const qetaDeleteCommentPermission = createPermission({\n name: 'qeta.delete.comment',\n attributes: { action: 'delete' },\n resourceType: COMMENT_RESOURCE_TYPE,\n});\n\nexport const qetaPermissions = [\n qetaReadQuestionPermission,\n qetaCreateQuestionPermission,\n qetaCreateAnswerPermission,\n qetaEditQuestionPermission,\n qetaDeleteQuestionPermission,\n qetaReadAnswerPermission,\n qetaEditAnswerPermission,\n qetaDeleteAnswerPermission,\n qetaCreateCommentPermission,\n qetaReadCommentPermission,\n qetaEditCommentPermission,\n qetaDeleteCommentPermission,\n];\n\nexport const isQetaPermission = (\n permission: BasicPermission | ResourcePermission,\n) => {\n return qetaPermissions.some(p => isPermission(permission, p));\n};\n","export const TAGS_REGEX = new RegExp('^[a-z0-9+#]+((\\\\-|_)[a-z0-9+#_]+)*$');\n\nexport const filterTags = (input?: null | string | string[]) => {\n if (!input) {\n return undefined;\n }\n return (Array.isArray(input) ? input : input.split(',')).filter(\n v => v.length > 0 && v.length < 255 && TAGS_REGEX.test(v),\n );\n};\n","export const truncate = (str: string, n: number): string => {\n return str.length > n ? `${str.slice(0, n - 1)}...` : str;\n};\n\n// Covers many common but not all cases of markdown formatting\nexport const removeMarkdownFormatting = (text: string): string => {\n // Remove HTML tags\n let fixed = text.replace(/<[^>]*>/g, '');\n\n // Handle code blocks defined with a language\n fixed = fixed.replace(/```[\\s\\S]*?```/g, match => {\n return match.replace(/(^```[a-z]*\\n)|(```$)/g, '').trim();\n });\n\n // Handle inline code blocks and code blocks defined using ```\n fixed = fixed.replace(/`{1,2}([^`]*)`{1,2}/g, '$1');\n\n // Remove other markdown formatting\n fixed = fixed\n .replace(/(?:\\*\\*|__)([^\\n*]+)(?:\\*\\*|__)/g, '$1') // Bold\n .replace(/(?:\\*|_)([^\\n*]+)(?:\\*|_)/g, '$1') // Italic\n .replace(/(?:~~)([^~]+)(?:~~)/g, '$1') // Strikethrough\n .replace(/^[>\\t]{0,3}>+\\s?/gm, '') // Blockquotes\n .replace(/\\[\\^.+?\\](: .*?$)?/g, '') // Footnotes\n .replace(/^([ \\t]*)([*\\-+]|\\d+\\.)\\s+/gm, '') // Lists\n .replace(/!\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1') // Images\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1') // Links\n .replace(/^#{1,6}[ \\t]+/gm, '') // Headers\n .replace(/^[=-]{2,}\\s*$/g, '') // Setex style headers\n .replace(/(?:\\r\\n|\\r|\\n)/g, ' ') // Newlines\n .replace(/(^\\s+|\\s+$)/g, ''); // Trimming leading and trailing spaces\n\n // Remove remaining HTML tags\n fixed = fixed.replace(/<[^>]*>/g, '');\n\n return fixed;\n};\n"],"names":["createPermission","isPermission"],"mappings":";;;;AAOO,MAAM,+BAA+BA,uCAAiB,CAAA;AAAA,EAC3D,IAAM,EAAA,sBAAA;AAAA,EACN,UAAA,EAAY,EAAE,MAAA,EAAQ,QAAS,EAAA;AACjC,CAAC,EAAA;AAEM,MAAM,6BAA6BA,uCAAiB,CAAA;AAAA,EACzD,IAAM,EAAA,oBAAA;AAAA,EACN,UAAA,EAAY,EAAE,MAAA,EAAQ,QAAS,EAAA;AACjC,CAAC,EAAA;AAEM,MAAM,8BAA8BA,uCAAiB,CAAA;AAAA,EAC1D,IAAM,EAAA,qBAAA;AAAA,EACN,UAAA,EAAY,EAAE,MAAA,EAAQ,QAAS,EAAA;AACjC,CAAC,EAAA;AAEM,MAAM,sBAAyB,GAAA,WAAA;AAE/B,MAAM,6BAA6BA,uCAAiB,CAAA;AAAA,EACzD,IAAM,EAAA,oBAAA;AAAA,EACN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ACT;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -173,6 +173,10 @@ interface UserTagsResponse {
|
|
|
173
173
|
tags: string[];
|
|
174
174
|
count: number;
|
|
175
175
|
}
|
|
176
|
+
interface UserEntitiesResponse {
|
|
177
|
+
entityRefs: string[];
|
|
178
|
+
count: number;
|
|
179
|
+
}
|
|
176
180
|
|
|
177
181
|
declare const TAGS_REGEX: RegExp;
|
|
178
182
|
declare const filterTags: (input?: null | string | string[]) => string[] | undefined;
|
|
@@ -180,4 +184,4 @@ declare const filterTags: (input?: null | string | string[]) => string[] | undef
|
|
|
180
184
|
declare const truncate: (str: string, n: number) => string;
|
|
181
185
|
declare const removeMarkdownFormatting: (text: string) => string;
|
|
182
186
|
|
|
183
|
-
export { ANSWER_RESOURCE_TYPE, type Answer, type AnswerFilter, type AnswerRequest, type AnswerResponse, type AnswerResponseBody, type AnswersResponse, type AnswersResponseBody, type Attachment, type AttachmentResponseBody, COMMENT_RESOURCE_TYPE, type Comment, type CommentFilter, type EntityResponse, QUESTION_RESOURCE_TYPE, type QetaAnswerStatsSignal, type QetaDocument, type QetaEntity, type QetaQuestionStatsSignal, type QetaSignal, type Question, type QuestionAnswerEntity, type QuestionFilter, type QuestionRequest, type QuestionResponse, type QuestionResponseBody, type QuestionsResponse, type QuestionsResponseBody, type Statistic, type StatisticResponse, type StatisticsOptions, type StatisticsRequestParameters, TAGS_REGEX, type TagResponse, type UserTagsResponse, type Vote, filterTags, isQetaPermission, qetaCreateAnswerPermission, qetaCreateCommentPermission, qetaCreateQuestionPermission, qetaDeleteAnswerPermission, qetaDeleteCommentPermission, qetaDeleteQuestionPermission, qetaEditAnswerPermission, qetaEditCommentPermission, qetaEditQuestionPermission, qetaPermissions, qetaReadAnswerPermission, qetaReadCommentPermission, qetaReadQuestionPermission, removeMarkdownFormatting, truncate };
|
|
187
|
+
export { ANSWER_RESOURCE_TYPE, type Answer, type AnswerFilter, type AnswerRequest, type AnswerResponse, type AnswerResponseBody, type AnswersResponse, type AnswersResponseBody, type Attachment, type AttachmentResponseBody, COMMENT_RESOURCE_TYPE, type Comment, type CommentFilter, type EntityResponse, QUESTION_RESOURCE_TYPE, type QetaAnswerStatsSignal, type QetaDocument, type QetaEntity, type QetaQuestionStatsSignal, type QetaSignal, type Question, type QuestionAnswerEntity, type QuestionFilter, type QuestionRequest, type QuestionResponse, type QuestionResponseBody, type QuestionsResponse, type QuestionsResponseBody, type Statistic, type StatisticResponse, type StatisticsOptions, type StatisticsRequestParameters, TAGS_REGEX, type TagResponse, type UserEntitiesResponse, type UserTagsResponse, type Vote, filterTags, isQetaPermission, qetaCreateAnswerPermission, qetaCreateCommentPermission, qetaCreateQuestionPermission, qetaDeleteAnswerPermission, qetaDeleteCommentPermission, qetaDeleteQuestionPermission, qetaEditAnswerPermission, qetaEditCommentPermission, qetaEditQuestionPermission, qetaPermissions, qetaReadAnswerPermission, qetaReadCommentPermission, qetaReadQuestionPermission, removeMarkdownFormatting, truncate };
|
package/dist/utils.esm.js
CHANGED
|
@@ -2,8 +2,7 @@ const truncate = (str, n) => {
|
|
|
2
2
|
return str.length > n ? `${str.slice(0, n - 1)}...` : str;
|
|
3
3
|
};
|
|
4
4
|
const removeMarkdownFormatting = (text) => {
|
|
5
|
-
let fixed = text.replace(
|
|
6
|
-
fixed = text.replace(/<[^>]*>/g, "");
|
|
5
|
+
let fixed = text.replace(/<[^>]*>/g, "");
|
|
7
6
|
fixed = fixed.replace(/```[\s\S]*?```/g, (match) => {
|
|
8
7
|
return match.replace(/(^```[a-z]*\n)|(```$)/g, "").trim();
|
|
9
8
|
});
|
package/dist/utils.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.esm.js","sources":["../src/utils.ts"],"sourcesContent":["export const truncate = (str: string, n: number): string => {\n return str.length > n ? `${str.slice(0, n - 1)}...` : str;\n};\n\n// Covers many common but not all cases of markdown formatting\nexport const removeMarkdownFormatting = (text: string): string => {\n // Remove
|
|
1
|
+
{"version":3,"file":"utils.esm.js","sources":["../src/utils.ts"],"sourcesContent":["export const truncate = (str: string, n: number): string => {\n return str.length > n ? `${str.slice(0, n - 1)}...` : str;\n};\n\n// Covers many common but not all cases of markdown formatting\nexport const removeMarkdownFormatting = (text: string): string => {\n // Remove HTML tags\n let fixed = text.replace(/<[^>]*>/g, '');\n\n // Handle code blocks defined with a language\n fixed = fixed.replace(/```[\\s\\S]*?```/g, match => {\n return match.replace(/(^```[a-z]*\\n)|(```$)/g, '').trim();\n });\n\n // Handle inline code blocks and code blocks defined using ```\n fixed = fixed.replace(/`{1,2}([^`]*)`{1,2}/g, '$1');\n\n // Remove other markdown formatting\n fixed = fixed\n .replace(/(?:\\*\\*|__)([^\\n*]+)(?:\\*\\*|__)/g, '$1') // Bold\n .replace(/(?:\\*|_)([^\\n*]+)(?:\\*|_)/g, '$1') // Italic\n .replace(/(?:~~)([^~]+)(?:~~)/g, '$1') // Strikethrough\n .replace(/^[>\\t]{0,3}>+\\s?/gm, '') // Blockquotes\n .replace(/\\[\\^.+?\\](: .*?$)?/g, '') // Footnotes\n .replace(/^([ \\t]*)([*\\-+]|\\d+\\.)\\s+/gm, '') // Lists\n .replace(/!\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1') // Images\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1') // Links\n .replace(/^#{1,6}[ \\t]+/gm, '') // Headers\n .replace(/^[=-]{2,}\\s*$/g, '') // Setex style headers\n .replace(/(?:\\r\\n|\\r|\\n)/g, ' ') // Newlines\n .replace(/(^\\s+|\\s+$)/g, ''); // Trimming leading and trailing spaces\n\n // Remove remaining HTML tags\n fixed = fixed.replace(/<[^>]*>/g, '');\n\n return fixed;\n};\n"],"names":[],"mappings":"AAAa,MAAA,QAAA,GAAW,CAAC,GAAA,EAAa,CAAsB,KAAA;AAC1D,EAAO,OAAA,GAAA,CAAI,MAAS,GAAA,CAAA,GAAI,CAAG,EAAA,GA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end",
|
|
8
8
|
"backstage.io"
|
|
9
9
|
],
|
|
10
|
-
"version": "2.
|
|
10
|
+
"version": "2.10.0",
|
|
11
11
|
"main": "dist/index.cjs.js",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
13
|
"prepublishOnly": "yarn tsc && yarn build",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"ajv": "^8.12.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@backstage/catalog-model": "^1.
|
|
55
|
+
"@backstage/catalog-model": "^1.7.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@backstage/cli": "^0.27.
|
|
58
|
+
"@backstage/cli": "^0.27.1"
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
|
61
61
|
"dist"
|