@drodil/backstage-plugin-qeta-common 3.39.1 → 3.40.1

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 CHANGED
@@ -46,6 +46,7 @@ exports.isValidTag = tags.isValidTag;
46
46
  exports.findEntityMentions = utils.findEntityMentions;
47
47
  exports.findTagMentions = utils.findTagMentions;
48
48
  exports.findUserMentions = utils.findUserMentions;
49
+ exports.getSupportedEntityKinds = utils.getSupportedEntityKinds;
49
50
  exports.removeMarkdownFormatting = utils.removeMarkdownFormatting;
50
51
  exports.selectByPostType = utils.selectByPostType;
51
52
  exports.truncate = utils.truncate;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { IndexableDocument } from '@backstage/plugin-search-common';
3
3
  import { ErrorObject } from 'ajv';
4
4
  import { PostType as PostType$1, PostStatus as PostStatus$1, PostsResponse as PostsResponse$1, PostRequest as PostRequest$1, PostResponse as PostResponse$1, AIResponse as AIResponse$1, AIStatusResponse as AIStatusResponse$1, TagsResponse as TagsResponse$1, TagResponse as TagResponse$1, EntitiesResponse as EntitiesResponse$1, EntityResponse as EntityResponse$1, UsersResponse as UsersResponse$1, StatisticsRequestParameters as StatisticsRequestParameters$1, StatisticResponse as StatisticResponse$1, AnswerResponse as AnswerResponse$1, AnswerRequest as AnswerRequest$1, AnswerResponseBody as AnswerResponseBody$1, AttachmentResponseBody as AttachmentResponseBody$1, AnswersResponse as AnswersResponse$1, UserCollectionsResponse as UserCollectionsResponse$1, UserTagsResponse as UserTagsResponse$1, UserEntitiesResponse as UserEntitiesResponse$1, UserUsersResponse as UserUsersResponse$1, ImpactResponse as ImpactResponse$1, StatisticsResponse as StatisticsResponse$1, GlobalStat as GlobalStat$1, UserStat as UserStat$1, CollectionsResponse as CollectionsResponse$1, CollectionResponse as CollectionResponse$1, CollectionRequest as CollectionRequest$1, TemplatesResponse as TemplatesResponse$1, TemplateResponse as TemplateResponse$1, TemplateRequest as TemplateRequest$1, SuggestionsResponse as SuggestionsResponse$1, TagSuggestionsResponse as TagSuggestionsResponse$1, URLMetadataRequest as URLMetadataRequest$1, URLMetadataResponse as URLMetadataResponse$1, EntityLinks as EntityLinks$1, Post as Post$1, Answer as Answer$1, TagSuggestionsQuery as TagSuggestionsQuery$1 } from '@drodil/backstage-plugin-qeta-common';
5
5
  import { EntityLink } from '@backstage/catalog-model';
6
+ import { Config } from '@backstage/config';
6
7
 
7
8
  declare const qetaModeratePermission: BasicPermission;
8
9
  declare const qetaCreatePostPermission: BasicPermission;
@@ -717,5 +718,6 @@ declare const findEntityMentions: (text: string) => string[];
717
718
  declare const findTagMentions: (text: string) => string[];
718
719
  declare const removeMarkdownFormatting: (text: string) => string;
719
720
  declare function selectByPostType<T>(type: PostType, questionValue: T, articleValue: T, linkValue: T): T;
721
+ declare function getSupportedEntityKinds(config?: Config): string[];
720
722
 
721
- export { type AIQuery, type AIResponse, type AIStatusResponse, ANSWER_RESOURCE_TYPE, type Answer, type AnswerCommentStatus, type AnswerFilter, type AnswerRequest, type AnswerResponse, type AnswerResponseBody, type AnswersQuery, type AnswersResponse, type AnswersResponseBody, type Article, type Attachment, type AttachmentResponseBody, COLLECTION_RESOUCE_TYPE, COMMENT_RESOURCE_TYPE, type Collection, type CollectionEntity, type CollectionFilter, type CollectionRequest, type CollectionResponse, type CollectionResponseBody, type CollectionsQuery, type CollectionsResponse, type CollectionsResponseBody, type Comment, type CommentFilter, type DraftPostSuggestion, type EntitiesQuery, type EntitiesResponse, type EntityLinks, type EntityResponse, type GlobalStat, type ImpactResponse, type Link, type NewArticleSuggestion, type NewLinkSuggestion, type NewQuestionSuggestion, type NoCorrectAnswerSuggestion, POST_RESOURCE_TYPE, type PaginatedQuery, type Post, type PostAnswerEntity, type PostFilter, type PostRequest, type PostResponse, type PostResponseBody, type PostStatus, type PostType, type PostsQuery, type PostsResponse, type PostsResponseBody, type QetaAnswerStatsSignal, type QetaApi, QetaClient, type QetaCollectionDocument, type QetaEntity, type QetaIdEntity, type QetaPostDocument, type QetaPostsStatsSignal, type QetaSearchDocument, type QetaSignal, type Question, type RequestOptions, type Stat, type Statistic, type StatisticResponse, type StatisticsOptions, type StatisticsRequestParameters, type StatisticsResponse, type Suggestion, type SuggestionType, type SuggestionsQuery, type SuggestionsResponse, TAGS_REGEX, TAG_RESOURCE_TYPE, type TagFilter, type TagResponse, type TagSuggestionsQuery, type TagSuggestionsResponse, type TagsQuery, type TagsResponse, type Template, type TemplateRequest, type TemplateResponse, type TemplatesResponse, type URLMetadataQuery, type URLMetadataRequest, type URLMetadataResponse, type UserCollectionsResponse, type UserEntitiesResponse, type UserResponse, type UserStat, type UserTagsResponse, type UserUsersResponse, type UsersQuery, type UsersResponse, type Vote, filterTags, findEntityMentions, findTagMentions, findUserMentions, isQetaPermission, isValidTag, qetaAnswerPermissions, qetaCollectionPermissions, qetaCommentPermissions, qetaCreateAnswerPermission, qetaCreateCollectionPermission, qetaCreateCommentPermission, qetaCreatePostPermission, qetaCreateTagPermission, qetaDeleteAnswerPermission, qetaDeleteCollectionPermission, qetaDeleteCommentPermission, qetaDeletePostPermission, qetaDeleteTagPermission, qetaEditAnswerPermission, qetaEditCollectionPermission, qetaEditCommentPermission, qetaEditPostPermission, qetaEditTagPermission, qetaModeratePermission, qetaPermissions, qetaPostPermissions, qetaReadAnswerPermission, qetaReadCollectionPermission, qetaReadCommentPermission, qetaReadPostPermission, qetaReadTagPermission, qetaTagPermissions, removeMarkdownFormatting, selectByPostType, truncate };
723
+ export { type AIQuery, type AIResponse, type AIStatusResponse, ANSWER_RESOURCE_TYPE, type Answer, type AnswerCommentStatus, type AnswerFilter, type AnswerRequest, type AnswerResponse, type AnswerResponseBody, type AnswersQuery, type AnswersResponse, type AnswersResponseBody, type Article, type Attachment, type AttachmentResponseBody, COLLECTION_RESOUCE_TYPE, COMMENT_RESOURCE_TYPE, type Collection, type CollectionEntity, type CollectionFilter, type CollectionRequest, type CollectionResponse, type CollectionResponseBody, type CollectionsQuery, type CollectionsResponse, type CollectionsResponseBody, type Comment, type CommentFilter, type DraftPostSuggestion, type EntitiesQuery, type EntitiesResponse, type EntityLinks, type EntityResponse, type GlobalStat, type ImpactResponse, type Link, type NewArticleSuggestion, type NewLinkSuggestion, type NewQuestionSuggestion, type NoCorrectAnswerSuggestion, POST_RESOURCE_TYPE, type PaginatedQuery, type Post, type PostAnswerEntity, type PostFilter, type PostRequest, type PostResponse, type PostResponseBody, type PostStatus, type PostType, type PostsQuery, type PostsResponse, type PostsResponseBody, type QetaAnswerStatsSignal, type QetaApi, QetaClient, type QetaCollectionDocument, type QetaEntity, type QetaIdEntity, type QetaPostDocument, type QetaPostsStatsSignal, type QetaSearchDocument, type QetaSignal, type Question, type RequestOptions, type Stat, type Statistic, type StatisticResponse, type StatisticsOptions, type StatisticsRequestParameters, type StatisticsResponse, type Suggestion, type SuggestionType, type SuggestionsQuery, type SuggestionsResponse, TAGS_REGEX, TAG_RESOURCE_TYPE, type TagFilter, type TagResponse, type TagSuggestionsQuery, type TagSuggestionsResponse, type TagsQuery, type TagsResponse, type Template, type TemplateRequest, type TemplateResponse, type TemplatesResponse, type URLMetadataQuery, type URLMetadataRequest, type URLMetadataResponse, type UserCollectionsResponse, type UserEntitiesResponse, type UserResponse, type UserStat, type UserTagsResponse, type UserUsersResponse, type UsersQuery, type UsersResponse, type Vote, filterTags, findEntityMentions, findTagMentions, findUserMentions, getSupportedEntityKinds, isQetaPermission, isValidTag, qetaAnswerPermissions, qetaCollectionPermissions, qetaCommentPermissions, qetaCreateAnswerPermission, qetaCreateCollectionPermission, qetaCreateCommentPermission, qetaCreatePostPermission, qetaCreateTagPermission, qetaDeleteAnswerPermission, qetaDeleteCollectionPermission, qetaDeleteCommentPermission, qetaDeletePostPermission, qetaDeleteTagPermission, qetaEditAnswerPermission, qetaEditCollectionPermission, qetaEditCommentPermission, qetaEditPostPermission, qetaEditTagPermission, qetaModeratePermission, qetaPermissions, qetaPostPermissions, qetaReadAnswerPermission, qetaReadCollectionPermission, qetaReadCommentPermission, qetaReadPostPermission, qetaReadTagPermission, qetaTagPermissions, removeMarkdownFormatting, selectByPostType, truncate };
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { ANSWER_RESOURCE_TYPE, COLLECTION_RESOUCE_TYPE, COMMENT_RESOURCE_TYPE, POST_RESOURCE_TYPE, TAG_RESOURCE_TYPE, isQetaPermission, qetaAnswerPermissions, qetaCollectionPermissions, qetaCommentPermissions, qetaCreateAnswerPermission, qetaCreateCollectionPermission, qetaCreateCommentPermission, qetaCreatePostPermission, qetaCreateTagPermission, qetaDeleteAnswerPermission, qetaDeleteCollectionPermission, qetaDeleteCommentPermission, qetaDeletePostPermission, qetaDeleteTagPermission, qetaEditAnswerPermission, qetaEditCollectionPermission, qetaEditCommentPermission, qetaEditPostPermission, qetaEditTagPermission, qetaModeratePermission, qetaPermissions, qetaPostPermissions, qetaReadAnswerPermission, qetaReadCollectionPermission, qetaReadCommentPermission, qetaReadPostPermission, qetaReadTagPermission, qetaTagPermissions } from './permissions.esm.js';
2
2
  export { TAGS_REGEX, filterTags, isValidTag } from './tags.esm.js';
3
- export { findEntityMentions, findTagMentions, findUserMentions, removeMarkdownFormatting, selectByPostType, truncate } from './utils.esm.js';
3
+ export { findEntityMentions, findTagMentions, findUserMentions, getSupportedEntityKinds, removeMarkdownFormatting, selectByPostType, truncate } from './utils.esm.js';
4
4
  export { QetaClient } from './api/QetaClient.esm.js';
5
5
  //# sourceMappingURL=index.esm.js.map
package/dist/utils.cjs.js CHANGED
@@ -72,10 +72,17 @@ function selectByPostType(type, questionValue, articleValue, linkValue) {
72
72
  return questionValue;
73
73
  }
74
74
  }
75
+ function getSupportedEntityKinds(config) {
76
+ return (config?.getOptionalStringArray("qeta.entities.kinds") ?? config?.getOptionalStringArray("qeta.entityKinds") ?? [
77
+ "system",
78
+ "component"
79
+ ]).map((k) => k.toLowerCase());
80
+ }
75
81
 
76
82
  exports.findEntityMentions = findEntityMentions;
77
83
  exports.findTagMentions = findTagMentions;
78
84
  exports.findUserMentions = findUserMentions;
85
+ exports.getSupportedEntityKinds = getSupportedEntityKinds;
79
86
  exports.removeMarkdownFormatting = removeMarkdownFormatting;
80
87
  exports.selectByPostType = selectByPostType;
81
88
  exports.truncate = truncate;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs.js","sources":["../src/utils.ts"],"sourcesContent":["import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { compact } from 'lodash';\nimport { isValidTag } from './tags';\nimport { PostType } from './types.ts';\n\nexport const truncate = (str: string, n: number): string => {\n return str.length > n ? `${str.slice(0, n - 1)}...` : str;\n};\n\n/**\n * @deprecated use `findEntityMentions` instead\n */\nexport const findUserMentions = (text: string): string[] => {\n const mentions = text.match(/@(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n return compact(\n ret.map(mention => {\n try {\n const parsed = parseEntityRef(mention.replace(/^@+/, ''));\n if (parsed.kind.toLocaleLowerCase('en-US') !== 'user') {\n return undefined;\n }\n return `@${stringifyEntityRef(parsed)}`;\n } catch (e) {\n return undefined;\n }\n }),\n );\n};\n\n/**\n * Finds entity mentions in the text.\n * @param text The text to search for entity mentions.\n * @returns An array of unique entity mentions in the format `@kind:name`.\n * @remarks currently supports `user` and `group` kinds.\n */\nexport const findEntityMentions = (text: string): string[] => {\n const mentions = text.match(/@(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n\n return compact(\n ret.map(mention => {\n try {\n const parsed = parseEntityRef(mention.replace(/^@+/, ''));\n const kind = parsed.kind.toLocaleLowerCase('en-US');\n if (kind !== 'user' && kind !== 'group') {\n return undefined;\n }\n return `@${stringifyEntityRef(parsed)}`;\n } catch {\n return undefined;\n }\n }),\n );\n};\n\nexport const findTagMentions = (text: string): string[] => {\n const mentions = text.match(/#(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n return compact(\n ret.filter(tag => {\n return isValidTag(tag.slice(1));\n }),\n );\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\nexport function selectByPostType<T>(\n type: PostType,\n questionValue: T,\n articleValue: T,\n linkValue: T,\n): T {\n switch (type) {\n case 'article':\n return articleValue;\n case 'link':\n return linkValue;\n case 'question':\n default:\n return questionValue;\n }\n}\n"],"names":["compact","parseEntityRef","stringifyEntityRef","isValidTag"],"mappings":";;;;;;AAKa,MAAA,QAAA,GAAW,CAAC,GAAA,EAAa,CAAsB,KAAA;AAC1D,EAAO,OAAA,GAAA,CAAI,MAAS,GAAA,CAAA,GAAI,CAAG,EAAA,GAAA,CAAI,MAAM,CAAG,EAAA,CAAA,GAAI,CAAC,CAAC,CAAQ,GAAA,CAAA,GAAA,GAAA;AACxD;AAKa,MAAA,gBAAA,GAAmB,CAAC,IAA2B,KAAA;AAC1D,EAAM,MAAA,QAAA,GAAW,IAAK,CAAA,KAAA,CAAM,SAAS,CAAA;AACrC,EAAM,MAAA,GAAA,GAAM,WAAW,KAAM,CAAA,IAAA,CAAK,IAAI,GAAI,CAAA,QAAQ,CAAC,CAAA,GAAI,EAAC;AACxD,EAAO,OAAAA,cAAA;AAAA,IACL,GAAA,CAAI,IAAI,CAAW,OAAA,KAAA;AACjB,MAAI,IAAA;AACF,QAAA,MAAM,SAASC,2BAAe,CAAA,OAAA,CAAQ,OAAQ,CAAA,KAAA,EAAO,EAAE,CAAC,CAAA;AACxD,QAAA,IAAI,MAAO,CAAA,IAAA,CAAK,iBAAkB,CAAA,OAAO,MAAM,MAAQ,EAAA;AACrD,UAAO,OAAA,KAAA,CAAA;AAAA;AAET,QAAO,OAAA,CAAA,CAAA,EAAIC,+BAAmB,CAAA,MAAM,CAAC,CAAA,CAAA;AAAA,eAC9B,CAAG,EAAA;AACV,QAAO,OAAA,KAAA,CAAA;AAAA;AACT,KACD;AAAA,GACH;AACF;AAQa,MAAA,kBAAA,GAAqB,CAAC,IAA2B,KAAA;AAC5D,EAAM,MAAA,QAAA,GAAW,IAAK,CAAA,KAAA,CAAM,SAAS,CAAA;AACrC,EAAM,MAAA,GAAA,G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O,KAAM,CAAA,OAAA,CAAQ,wBAA0B,EAAA,EAAE,EAAE,IAAK,EAAA;AAAA,GACzD,CAAA;AAGD,EAAQ,KAAA,GAAA,KAAA,CAAM,OAAQ,CAAA,sBAAA,EAAwB,IAAI,CAAA;AAGlD,EAAQ,KAAA,GAAA,KAAA,CACL,QAAQ,kCAAoC,EAAA,IAAI,EAChD,OAAQ,CAAA,4BAAA,EAA8B,IAAI,CAC1C,CAAA,OAAA,CAAQ,wBAAwB,IAAI,CAAA,CACpC,QAAQ,oBAAsB,EAAA,EAAE,EAChC,OAAQ,CAAA,qBAAA,EAAuB,EAAE,CAAA,CACjC,OAAQ,CAAA,8BAAA,EAAgC,EAAE,CAC1C,CAAA,OAAA,CAAQ,2BAA2B,IAAI,CAAA,CACvC,QAAQ,wBAA0B,EAAA,IAAI,CACtC,CAAA,OAAA,CAAQ,iBAAmB,EAAA,EAAE,EAC7B,OAAQ,CAAA,gBAAA,EAAkB,EAAE,CAC5B,CAAA,OAAA,CAAQ,mBAAmB,GAAG,CAAA,CAC9B,OAAQ,CAAA,cAAA,EAAgB,EAAE,CAAA;AAG7B,EAAQ,KAAA,GAAA,KAAA,CAAM,OAAQ,CAAA,UAAA,EAAY,EAAE,CAAA;AAEpC,EAAO,OAAA,KAAA;AACT;AAEO,SAAS,gBACd,CAAA,IAAA,EACA,aACA,EAAA,YAAA,EACA,SACG,EAAA;AACH,EAAA,QAAQ,IAAM;AAAA,IACZ,KAAK,SAAA;AACH,MAAO,OAAA,YAAA;AAAA,IACT,KAAK,MAAA;AACH,MAAO,OAAA,SAAA;AAAA,IACT,KAAK,UAAA;AAAA,IACL;AACE,MAAO,OAAA,aAAA;AAAA;AAEb;;;;;;;;;"}
1
+ {"version":3,"file":"utils.cjs.js","sources":["../src/utils.ts"],"sourcesContent":["import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { compact } from 'lodash';\nimport { isValidTag } from './tags';\nimport { PostType } from './types.ts';\nimport { Config } from '@backstage/config';\n\nexport const truncate = (str: string, n: number): string => {\n return str.length > n ? `${str.slice(0, n - 1)}...` : str;\n};\n\n/**\n * @deprecated use `findEntityMentions` instead\n */\nexport const findUserMentions = (text: string): string[] => {\n const mentions = text.match(/@(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n return compact(\n ret.map(mention => {\n try {\n const parsed = parseEntityRef(mention.replace(/^@+/, ''));\n if (parsed.kind.toLocaleLowerCase('en-US') !== 'user') {\n return undefined;\n }\n return `@${stringifyEntityRef(parsed)}`;\n } catch (e) {\n return undefined;\n }\n }),\n );\n};\n\n/**\n * Finds entity mentions in the text.\n * @param text The text to search for entity mentions.\n * @returns An array of unique entity mentions in the format `@kind:name`.\n * @remarks currently supports `user` and `group` kinds.\n */\nexport const findEntityMentions = (text: string): string[] => {\n const mentions = text.match(/@(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n\n return compact(\n ret.map(mention => {\n try {\n const parsed = parseEntityRef(mention.replace(/^@+/, ''));\n const kind = parsed.kind.toLocaleLowerCase('en-US');\n if (kind !== 'user' && kind !== 'group') {\n return undefined;\n }\n return `@${stringifyEntityRef(parsed)}`;\n } catch {\n return undefined;\n }\n }),\n );\n};\n\nexport const findTagMentions = (text: string): string[] => {\n const mentions = text.match(/#(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n return compact(\n ret.filter(tag => {\n return isValidTag(tag.slice(1));\n }),\n );\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\nexport function selectByPostType<T>(\n type: PostType,\n questionValue: T,\n articleValue: T,\n linkValue: T,\n): T {\n switch (type) {\n case 'article':\n return articleValue;\n case 'link':\n return linkValue;\n case 'question':\n default:\n return questionValue;\n }\n}\n\nexport function getSupportedEntityKinds(config?: Config): string[] {\n return (\n config?.getOptionalStringArray('qeta.entities.kinds') ??\n config?.getOptionalStringArray('qeta.entityKinds') ?? [\n 'system',\n 'component',\n ]\n ).map(k => k.toLowerCase());\n}\n"],"names":["compact","parseEntityRef","stringifyEntityRef","isValidTag"],"mappings":";;;;;;AAMa,MAAA,QAAA,GAAW,CAAC,GAAA,EAAa,CAAsB,KAAA;AAC1D,EAAO,OAAA,GAAA,CAAI,MAAS,GAAA,CAAA,GAAI,CAAG,EAAA,GAAA,CAAI,MAAM,CAAG,EAAA,CAAA,GAAI,CAAC,CAAC,CAAQ,GAAA,CAAA,GAAA,GAAA;AACxD;AAKa,MAAA,gBAAA,GAAmB,CAAC,IAA2B,KAA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AQ,2BAA2B,IAAI,CAAA,CACvC,QAAQ,wBAA0B,EAAA,IAAI,CACtC,CAAA,OAAA,CAAQ,iBAAmB,EAAA,EAAE,EAC7B,OAAQ,CAAA,gBAAA,EAAkB,EAAE,CAC5B,CAAA,OAAA,CAAQ,mBAAmB,GAAG,CAAA,CAC9B,OAAQ,CAAA,cAAA,EAAgB,EAAE,CAAA;AAG7B,EAAQ,KAAA,GAAA,KAAA,CAAM,OAAQ,CAAA,UAAA,EAAY,EAAE,CAAA;AAEpC,EAAO,OAAA,KAAA;AACT;AAEO,SAAS,gBACd,CAAA,IAAA,EACA,aACA,EAAA,YAAA,EACA,SACG,EAAA;AACH,EAAA,QAAQ,IAAM;AAAA,IACZ,KAAK,SAAA;AACH,MAAO,OAAA,YAAA;AAAA,IACT,KAAK,MAAA;AACH,MAAO,OAAA,SAAA;AAAA,IACT,KAAK,UAAA;AAAA,IACL;AACE,MAAO,OAAA,aAAA;AAAA;AAEb;AAEO,SAAS,wBAAwB,MAA2B,EAAA;AACjE,EAAA,OAAA,CACE,QAAQ,sBAAuB,CAAA,qBAAqB,KACpD,MAAQ,EAAA,sBAAA,CAAuB,kBAAkB,CAAK,IAAA;AAAA,IACpD,QAAA;AAAA,IACA;AAAA,GAEF,EAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAA,CAAE,aAAa,CAAA;AAC5B;;;;;;;;;;"}
package/dist/utils.esm.js CHANGED
@@ -70,6 +70,12 @@ function selectByPostType(type, questionValue, articleValue, linkValue) {
70
70
  return questionValue;
71
71
  }
72
72
  }
73
+ function getSupportedEntityKinds(config) {
74
+ return (config?.getOptionalStringArray("qeta.entities.kinds") ?? config?.getOptionalStringArray("qeta.entityKinds") ?? [
75
+ "system",
76
+ "component"
77
+ ]).map((k) => k.toLowerCase());
78
+ }
73
79
 
74
- export { findEntityMentions, findTagMentions, findUserMentions, removeMarkdownFormatting, selectByPostType, truncate };
80
+ export { findEntityMentions, findTagMentions, findUserMentions, getSupportedEntityKinds, removeMarkdownFormatting, selectByPostType, truncate };
75
81
  //# sourceMappingURL=utils.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.esm.js","sources":["../src/utils.ts"],"sourcesContent":["import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { compact } from 'lodash';\nimport { isValidTag } from './tags';\nimport { PostType } from './types.ts';\n\nexport const truncate = (str: string, n: number): string => {\n return str.length > n ? `${str.slice(0, n - 1)}...` : str;\n};\n\n/**\n * @deprecated use `findEntityMentions` instead\n */\nexport const findUserMentions = (text: string): string[] => {\n const mentions = text.match(/@(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n return compact(\n ret.map(mention => {\n try {\n const parsed = parseEntityRef(mention.replace(/^@+/, ''));\n if (parsed.kind.toLocaleLowerCase('en-US') !== 'user') {\n return undefined;\n }\n return `@${stringifyEntityRef(parsed)}`;\n } catch (e) {\n return undefined;\n }\n }),\n );\n};\n\n/**\n * Finds entity mentions in the text.\n * @param text The text to search for entity mentions.\n * @returns An array of unique entity mentions in the format `@kind:name`.\n * @remarks currently supports `user` and `group` kinds.\n */\nexport const findEntityMentions = (text: string): string[] => {\n const mentions = text.match(/@(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n\n return compact(\n ret.map(mention => {\n try {\n const parsed = parseEntityRef(mention.replace(/^@+/, ''));\n const kind = parsed.kind.toLocaleLowerCase('en-US');\n if (kind !== 'user' && kind !== 'group') {\n return undefined;\n }\n return `@${stringifyEntityRef(parsed)}`;\n } catch {\n return undefined;\n }\n }),\n );\n};\n\nexport const findTagMentions = (text: string): string[] => {\n const mentions = text.match(/#(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n return compact(\n ret.filter(tag => {\n return isValidTag(tag.slice(1));\n }),\n );\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\nexport function selectByPostType<T>(\n type: PostType,\n questionValue: T,\n articleValue: T,\n linkValue: T,\n): T {\n switch (type) {\n case 'article':\n return articleValue;\n case 'link':\n return linkValue;\n case 'question':\n default:\n return questionValue;\n }\n}\n"],"names":[],"mappings":";;;;AAKa,MAAA,QAAA,GAAW,CAAC,GAAA,EAAa,CAAsB,KAAA;AAC1D,EAAO,OAAA,GAAA,CAAI,MAAS,GAAA,CAAA,GAAI,CAAG,EAAA,GAAA,CAAI,MAAM,CAAG,EAAA,CAAA,GAAI,CAAC,CAAC,CAAQ,GAAA,CAAA,GAAA,GAAA;AACxD;AAKa,MA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AE,CAC1C,CAAA,OAAA,CAAQ,2BAA2B,IAAI,CAAA,CACvC,QAAQ,wBAA0B,EAAA,IAAI,CACtC,CAAA,OAAA,CAAQ,iBAAmB,EAAA,EAAE,EAC7B,OAAQ,CAAA,gBAAA,EAAkB,EAAE,CAC5B,CAAA,OAAA,CAAQ,mBAAmB,GAAG,CAAA,CAC9B,OAAQ,CAAA,cAAA,EAAgB,EAAE,CAAA;AAG7B,EAAQ,KAAA,GAAA,KAAA,CAAM,OAAQ,CAAA,UAAA,EAAY,EAAE,CAAA;AAEpC,EAAO,OAAA,KAAA;AACT;AAEO,SAAS,gBACd,CAAA,IAAA,EACA,aACA,EAAA,YAAA,EACA,SACG,EAAA;AACH,EAAA,QAAQ,IAAM;AAAA,IACZ,KAAK,SAAA;AACH,MAAO,OAAA,YAAA;AAAA,IACT,KAAK,MAAA;AACH,MAAO,OAAA,SAAA;AAAA,IACT,KAAK,UAAA;AAAA,IACL;AACE,MAAO,OAAA,aAAA;AAAA;AAEb;;;;"}
1
+ {"version":3,"file":"utils.esm.js","sources":["../src/utils.ts"],"sourcesContent":["import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { compact } from 'lodash';\nimport { isValidTag } from './tags';\nimport { PostType } from './types.ts';\nimport { Config } from '@backstage/config';\n\nexport const truncate = (str: string, n: number): string => {\n return str.length > n ? `${str.slice(0, n - 1)}...` : str;\n};\n\n/**\n * @deprecated use `findEntityMentions` instead\n */\nexport const findUserMentions = (text: string): string[] => {\n const mentions = text.match(/@(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n return compact(\n ret.map(mention => {\n try {\n const parsed = parseEntityRef(mention.replace(/^@+/, ''));\n if (parsed.kind.toLocaleLowerCase('en-US') !== 'user') {\n return undefined;\n }\n return `@${stringifyEntityRef(parsed)}`;\n } catch (e) {\n return undefined;\n }\n }),\n );\n};\n\n/**\n * Finds entity mentions in the text.\n * @param text The text to search for entity mentions.\n * @returns An array of unique entity mentions in the format `@kind:name`.\n * @remarks currently supports `user` and `group` kinds.\n */\nexport const findEntityMentions = (text: string): string[] => {\n const mentions = text.match(/@(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n\n return compact(\n ret.map(mention => {\n try {\n const parsed = parseEntityRef(mention.replace(/^@+/, ''));\n const kind = parsed.kind.toLocaleLowerCase('en-US');\n if (kind !== 'user' && kind !== 'group') {\n return undefined;\n }\n return `@${stringifyEntityRef(parsed)}`;\n } catch {\n return undefined;\n }\n }),\n );\n};\n\nexport const findTagMentions = (text: string): string[] => {\n const mentions = text.match(/#(\\S+)/g);\n const ret = mentions ? Array.from(new Set(mentions)) : [];\n return compact(\n ret.filter(tag => {\n return isValidTag(tag.slice(1));\n }),\n );\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\nexport function selectByPostType<T>(\n type: PostType,\n questionValue: T,\n articleValue: T,\n linkValue: T,\n): T {\n switch (type) {\n case 'article':\n return articleValue;\n case 'link':\n return linkValue;\n case 'question':\n default:\n return questionValue;\n }\n}\n\nexport function getSupportedEntityKinds(config?: Config): string[] {\n return (\n config?.getOptionalStringArray('qeta.entities.kinds') ??\n config?.getOptionalStringArray('qeta.entityKinds') ?? [\n 'system',\n 'component',\n ]\n ).map(k => k.toLowerCase());\n}\n"],"names":[],"mappings":";;;;AAMa,MAAA,QAAA,GAAW,CAAC,GAAA,EAAa,CAAsB,KAAA;AAC1D,EAAO,OAAA,GAAA,CAAI,MAAS,GAAA,CAAA,GAAI,CAAG,EAAA,GAAA,CAAI,MAAM,CAAG,EAAA,CAAA,GAAI,CAAC,CAAC,CAAQ,GAAA,CAAA,GAAA,GAAA;AACxD;AAKa,MAAA,gBAAA,GAAmB,CAAC,IAA2B,KAAA;AAC1D,EAAM,MAAA,QAAA,GAAW,IAAK,CAAA,KAAA,CAAM,SAAS,CAAA;AACrC,EAAM,MAAA,GAAA,GAAM,WAAW,KAAM,CAAA,IAAA,CAAK,IAAI,GAAI,CAAA,QAAQ,CAAC,CAAA,GAAI,EAAC;AACxD,EAAO,OAAA,OAAA;AAAA,IACL,GAAA,CAAI,IAAI,CAAW,OAAA,KAAA;AACjB,MAAI,IAAA;AACF,QAAA,MAAM,SAAS,cAAe,CAAA,OAAA,CAAQ,OAAQ,CAAA,KAAA,EAAO,EAAE,CAAC,CAAA;AACxD,QAAA,IAAI,MAAO,CAAA,IAAA,CAAK,iBAAkB,CAAA,OAAO,MAAM,MAAQ,EAAA;AACrD,UAAO,OAAA,KAAA,CAAA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A;AAAA,IACT,KAAK,MAAA;AACH,MAAO,OAAA,SAAA;AAAA,IACT,KAAK,UAAA;AAAA,IACL;AACE,MAAO,OAAA,aAAA;AAAA;AAEb;AAEO,SAAS,wBAAwB,MAA2B,EAAA;AACjE,EAAA,OAAA,CACE,QAAQ,sBAAuB,CAAA,qBAAqB,KACpD,MAAQ,EAAA,sBAAA,CAAuB,kBAAkB,CAAK,IAAA;AAAA,IACpD,QAAA;AAAA,IACA;AAAA,GAEF,EAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAA,CAAE,aAAa,CAAA;AAC5B;;;;"}
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "frontend",
8
8
  "backstage.io"
9
9
  ],
10
- "version": "3.39.1",
10
+ "version": "3.40.1",
11
11
  "main": "dist/index.cjs.js",
12
12
  "types": "dist/index.d.ts",
13
13
  "prepublishOnly": "yarn tsc && yarn build",
@@ -48,6 +48,7 @@
48
48
  "tsc": "tsc"
49
49
  },
50
50
  "dependencies": {
51
+ "@backstage/config": "^1.3.3",
51
52
  "@backstage/errors": "^1.2.7",
52
53
  "@backstage/plugin-permission-common": "^0.9.1",
53
54
  "@backstage/plugin-search-common": "^1.2.19",