@abyss-project/console 1.0.73 → 1.0.75

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.
@@ -1,4 +1,4 @@
1
- import { ICreateInternalTicketSectionParams, ICreateInternalTicketSectionBody, IListInternalTicketSectionParams, IUpdateInternalTicketSectionParams, IUpdateInternalTicketSectionBody, IDeleteInternalTicketSectionParams, IArchiveInternalTicketSectionParams, IUnarchiveInternalTicketSectionParams, IGetInternalTicketSectionStatsParams, ICreateInternalTicketCategoryParams, ICreateInternalTicketCategoryBody, IListInternalTicketCategoryParams, IListInternalTicketCategoryQuery, IUpdateInternalTicketCategoryParams, IUpdateInternalTicketCategoryBody, IDeleteInternalTicketCategoryParams, IArchiveInternalTicketCategoryParams, IUnarchiveInternalTicketCategoryParams, ICreateInternalTicketPriorityParams, ICreateInternalTicketPriorityBody, IListInternalTicketPriorityParams, IListInternalTicketPriorityQuery, IUpdateInternalTicketPriorityParams, IUpdateInternalTicketPriorityBody, IDeleteInternalTicketPriorityParams, IArchiveInternalTicketPriorityParams, IUnarchiveInternalTicketPriorityParams, ICreateInternalTicketSectionResponse, IListInternalTicketSectionResponse, IUpdateInternalTicketSectionResponse, IDeleteInternalTicketSectionResponse, IArchiveInternalTicketSectionResponse, IUnarchiveInternalTicketSectionResponse, IGetInternalTicketSectionStatsResponse, ICreateInternalTicketCategoryResponse, IListInternalTicketCategoryResponse, IUpdateInternalTicketCategoryResponse, IDeleteInternalTicketCategoryResponse, IArchiveInternalTicketCategoryResponse, IUnarchiveInternalTicketCategoryResponse, ICreateInternalTicketPriorityResponse, IListInternalTicketPriorityResponse, IUpdateInternalTicketPriorityResponse, IDeleteInternalTicketPriorityResponse, IArchiveInternalTicketPriorityResponse, IUnarchiveInternalTicketPriorityResponse } from '../types';
1
+ import { ICreateInternalTicketSectionParams, ICreateInternalTicketSectionBody, IListInternalTicketSectionParams, IUpdateInternalTicketSectionParams, IUpdateInternalTicketSectionBody, IDeleteInternalTicketSectionParams, IArchiveInternalTicketSectionParams, IUnarchiveInternalTicketSectionParams, IGetInternalTicketSectionStatsParams, ICreateInternalTicketCategoryParams, ICreateInternalTicketCategoryBody, IListInternalTicketCategoryParams, IListInternalTicketCategoryQuery, IUpdateInternalTicketCategoryParams, IUpdateInternalTicketCategoryBody, IDeleteInternalTicketCategoryParams, ICreateInternalTicketPriorityParams, ICreateInternalTicketPriorityBody, IListInternalTicketPriorityParams, IListInternalTicketPriorityQuery, IUpdateInternalTicketPriorityParams, IUpdateInternalTicketPriorityBody, IDeleteInternalTicketPriorityParams, ICreateInternalTicketSectionResponse, IListInternalTicketSectionResponse, IUpdateInternalTicketSectionResponse, IDeleteInternalTicketSectionResponse, IArchiveInternalTicketSectionResponse, IUnarchiveInternalTicketSectionResponse, IGetInternalTicketSectionStatsResponse, ICreateInternalTicketCategoryResponse, IListInternalTicketCategoryResponse, IUpdateInternalTicketCategoryResponse, IDeleteInternalTicketCategoryResponse, ICreateInternalTicketPriorityResponse, IListInternalTicketPriorityResponse, IUpdateInternalTicketPriorityResponse, IDeleteInternalTicketPriorityResponse } from '../types';
2
2
  export declare const createInternalTicketSection: (params: ICreateInternalTicketSectionParams, body: ICreateInternalTicketSectionBody) => Promise<ICreateInternalTicketSectionResponse>;
3
3
  export declare const listInternalTicketSection: (params: IListInternalTicketSectionParams) => Promise<IListInternalTicketSectionResponse>;
4
4
  export declare const updateInternalTicketSection: (params: IUpdateInternalTicketSectionParams, body: IUpdateInternalTicketSectionBody) => Promise<IUpdateInternalTicketSectionResponse>;
@@ -10,11 +10,7 @@ export declare const createInternalTicketCategory: (params: ICreateInternalTicke
10
10
  export declare const listInternalTicketCategory: (params: IListInternalTicketCategoryParams, query?: IListInternalTicketCategoryQuery) => Promise<IListInternalTicketCategoryResponse>;
11
11
  export declare const updateInternalTicketCategory: (params: IUpdateInternalTicketCategoryParams, body: IUpdateInternalTicketCategoryBody) => Promise<IUpdateInternalTicketCategoryResponse>;
12
12
  export declare const deleteInternalTicketCategory: (params: IDeleteInternalTicketCategoryParams) => Promise<IDeleteInternalTicketCategoryResponse>;
13
- export declare const archiveInternalTicketCategory: (params: IArchiveInternalTicketCategoryParams) => Promise<IArchiveInternalTicketCategoryResponse>;
14
- export declare const unarchiveInternalTicketCategory: (params: IUnarchiveInternalTicketCategoryParams) => Promise<IUnarchiveInternalTicketCategoryResponse>;
15
13
  export declare const createInternalTicketPriority: (params: ICreateInternalTicketPriorityParams, body: ICreateInternalTicketPriorityBody) => Promise<ICreateInternalTicketPriorityResponse>;
16
14
  export declare const listInternalTicketPriority: (params: IListInternalTicketPriorityParams, query?: IListInternalTicketPriorityQuery) => Promise<IListInternalTicketPriorityResponse>;
17
15
  export declare const updateInternalTicketPriority: (params: IUpdateInternalTicketPriorityParams, body: IUpdateInternalTicketPriorityBody) => Promise<IUpdateInternalTicketPriorityResponse>;
18
16
  export declare const deleteInternalTicketPriority: (params: IDeleteInternalTicketPriorityParams) => Promise<IDeleteInternalTicketPriorityResponse>;
19
- export declare const archiveInternalTicketPriority: (params: IArchiveInternalTicketPriorityParams) => Promise<IArchiveInternalTicketPriorityResponse>;
20
- export declare const unarchiveInternalTicketPriority: (params: IUnarchiveInternalTicketPriorityParams) => Promise<IUnarchiveInternalTicketPriorityResponse>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unarchiveInternalTicketPriority = exports.archiveInternalTicketPriority = exports.deleteInternalTicketPriority = exports.updateInternalTicketPriority = exports.listInternalTicketPriority = exports.createInternalTicketPriority = exports.unarchiveInternalTicketCategory = exports.archiveInternalTicketCategory = exports.deleteInternalTicketCategory = exports.updateInternalTicketCategory = exports.listInternalTicketCategory = exports.createInternalTicketCategory = exports.unarchiveInternalTicketSection = exports.archiveInternalTicketSection = exports.getInternalTicketSectionStats = exports.deleteInternalTicketSection = exports.updateInternalTicketSection = exports.listInternalTicketSection = exports.createInternalTicketSection = void 0;
3
+ exports.deleteInternalTicketPriority = exports.updateInternalTicketPriority = exports.listInternalTicketPriority = exports.createInternalTicketPriority = exports.deleteInternalTicketCategory = exports.updateInternalTicketCategory = exports.listInternalTicketCategory = exports.createInternalTicketCategory = exports.unarchiveInternalTicketSection = exports.archiveInternalTicketSection = exports.getInternalTicketSectionStats = exports.deleteInternalTicketSection = exports.updateInternalTicketSection = exports.listInternalTicketSection = exports.createInternalTicketSection = void 0;
4
4
  const __1 = require("..");
5
5
  const createInternalTicketSection = async (params, body) => {
6
6
  const response = await __1.AbyssConsoleCore.axios.post(`/internal-ticket-config/${params.projectId}/section`, body);
@@ -57,16 +57,6 @@ const deleteInternalTicketCategory = async (params) => {
57
57
  return response.data;
58
58
  };
59
59
  exports.deleteInternalTicketCategory = deleteInternalTicketCategory;
60
- const archiveInternalTicketCategory = async (params) => {
61
- const response = await __1.AbyssConsoleCore.axios.put(`/internal-ticket-config/${params.projectId}/category/${params.internalTicketCategoryId}/archive`);
62
- return response.data;
63
- };
64
- exports.archiveInternalTicketCategory = archiveInternalTicketCategory;
65
- const unarchiveInternalTicketCategory = async (params) => {
66
- const response = await __1.AbyssConsoleCore.axios.put(`/internal-ticket-config/${params.projectId}/category/${params.internalTicketCategoryId}/unarchive`);
67
- return response.data;
68
- };
69
- exports.unarchiveInternalTicketCategory = unarchiveInternalTicketCategory;
70
60
  const createInternalTicketPriority = async (params, body) => {
71
61
  const response = await __1.AbyssConsoleCore.axios.post(`/internal-ticket-config/${params.projectId}/priority`, body);
72
62
  return response.data;
@@ -87,13 +77,3 @@ const deleteInternalTicketPriority = async (params) => {
87
77
  return response.data;
88
78
  };
89
79
  exports.deleteInternalTicketPriority = deleteInternalTicketPriority;
90
- const archiveInternalTicketPriority = async (params) => {
91
- const response = await __1.AbyssConsoleCore.axios.put(`/internal-ticket-config/${params.projectId}/priority/${params.internalTicketPriorityId}/archive`);
92
- return response.data;
93
- };
94
- exports.archiveInternalTicketPriority = archiveInternalTicketPriority;
95
- const unarchiveInternalTicketPriority = async (params) => {
96
- const response = await __1.AbyssConsoleCore.axios.put(`/internal-ticket-config/${params.projectId}/priority/${params.internalTicketPriorityId}/unarchive`);
97
- return response.data;
98
- };
99
- exports.unarchiveInternalTicketPriority = unarchiveInternalTicketPriority;
package/dist/index.d.ts CHANGED
@@ -175,16 +175,12 @@ type AbyssConsoleCoreSDK = {
175
175
  list: typeof internalTicketConfigApi.listInternalTicketCategory;
176
176
  update: typeof internalTicketConfigApi.updateInternalTicketCategory;
177
177
  delete: typeof internalTicketConfigApi.deleteInternalTicketCategory;
178
- archive: typeof internalTicketConfigApi.archiveInternalTicketCategory;
179
- unarchive: typeof internalTicketConfigApi.unarchiveInternalTicketCategory;
180
178
  };
181
179
  priority: {
182
180
  create: typeof internalTicketConfigApi.createInternalTicketPriority;
183
181
  list: typeof internalTicketConfigApi.listInternalTicketPriority;
184
182
  update: typeof internalTicketConfigApi.updateInternalTicketPriority;
185
183
  delete: typeof internalTicketConfigApi.deleteInternalTicketPriority;
186
- archive: typeof internalTicketConfigApi.archiveInternalTicketPriority;
187
- unarchive: typeof internalTicketConfigApi.unarchiveInternalTicketPriority;
188
184
  };
189
185
  };
190
186
  workflow: {
package/dist/index.js CHANGED
@@ -279,16 +279,12 @@ class AbyssConsoleCore {
279
279
  list: internalTicketConfigApi.listInternalTicketCategory,
280
280
  update: internalTicketConfigApi.updateInternalTicketCategory,
281
281
  delete: internalTicketConfigApi.deleteInternalTicketCategory,
282
- archive: internalTicketConfigApi.archiveInternalTicketCategory,
283
- unarchive: internalTicketConfigApi.unarchiveInternalTicketCategory,
284
282
  },
285
283
  priority: {
286
284
  create: internalTicketConfigApi.createInternalTicketPriority,
287
285
  list: internalTicketConfigApi.listInternalTicketPriority,
288
286
  update: internalTicketConfigApi.updateInternalTicketPriority,
289
287
  delete: internalTicketConfigApi.deleteInternalTicketPriority,
290
- archive: internalTicketConfigApi.archiveInternalTicketPriority,
291
- unarchive: internalTicketConfigApi.unarchiveInternalTicketPriority,
292
288
  },
293
289
  },
294
290
  workflow: workflowSDK,
@@ -43,15 +43,16 @@ export interface ICreateInternalTicketCategoryParams {
43
43
  }
44
44
  export interface ICreateInternalTicketCategoryBody {
45
45
  name: string;
46
- sectionId: string;
46
+ internalTicketSectionId: string;
47
47
  color?: string;
48
48
  description?: string;
49
+ order?: number;
49
50
  }
50
51
  export interface IListInternalTicketCategoryParams {
51
52
  projectId: string;
52
53
  }
53
54
  export interface IListInternalTicketCategoryQuery {
54
- sectionId?: string;
55
+ internalTicketSectionId?: string;
55
56
  }
56
57
  export interface IUpdateInternalTicketCategoryParams {
57
58
  projectId: string;
@@ -63,35 +64,30 @@ export interface IUpdateInternalTicketCategoryBody {
63
64
  description?: string;
64
65
  order?: number;
65
66
  isEnabled?: boolean;
67
+ isArchived?: boolean;
66
68
  }
67
69
  export interface IDeleteInternalTicketCategoryParams {
68
70
  projectId: string;
69
71
  internalTicketCategoryId: string;
70
72
  }
71
- export interface IArchiveInternalTicketCategoryParams {
72
- projectId: string;
73
- internalTicketCategoryId: string;
74
- }
75
- export interface IUnarchiveInternalTicketCategoryParams {
76
- projectId: string;
77
- internalTicketCategoryId: string;
78
- }
79
73
  export interface ICreateInternalTicketPriorityParams {
80
74
  projectId: string;
81
75
  }
82
76
  export interface ICreateInternalTicketPriorityBody {
83
77
  name: string;
84
- sectionId: string;
78
+ internalTicketSectionId: string;
85
79
  color?: string;
80
+ description?: string;
86
81
  level: number;
87
- label?: string;
82
+ order?: number;
83
+ isDefault?: boolean;
88
84
  requirePriorityReason?: boolean;
89
85
  }
90
86
  export interface IListInternalTicketPriorityParams {
91
87
  projectId: string;
92
88
  }
93
89
  export interface IListInternalTicketPriorityQuery {
94
- sectionId?: string;
90
+ internalTicketSectionId?: string;
95
91
  }
96
92
  export interface IUpdateInternalTicketPriorityParams {
97
93
  projectId: string;
@@ -100,21 +96,15 @@ export interface IUpdateInternalTicketPriorityParams {
100
96
  export interface IUpdateInternalTicketPriorityBody {
101
97
  name?: string;
102
98
  color?: string;
99
+ description?: string;
103
100
  level?: number;
101
+ order?: number;
104
102
  isDefault?: boolean;
105
- label?: string;
106
103
  isEnabled?: boolean;
107
104
  requirePriorityReason?: boolean;
105
+ isArchived?: boolean;
108
106
  }
109
107
  export interface IDeleteInternalTicketPriorityParams {
110
108
  projectId: string;
111
109
  internalTicketPriorityId: string;
112
110
  }
113
- export interface IArchiveInternalTicketPriorityParams {
114
- projectId: string;
115
- internalTicketPriorityId: string;
116
- }
117
- export interface IUnarchiveInternalTicketPriorityParams {
118
- projectId: string;
119
- internalTicketPriorityId: string;
120
- }
@@ -6,9 +6,9 @@ export interface ICreateInternalTicketParams {
6
6
  export interface ICreateInternalTicketBody {
7
7
  title: string;
8
8
  description: string;
9
- sectionId: string;
10
- priorityId?: string;
11
- categoryId?: string;
9
+ internalTicketSectionId: string;
10
+ internalTicketPriorityId: string;
11
+ internalTicketCategoryId?: string;
12
12
  priorityReason?: string;
13
13
  }
14
14
  export interface IPaginateInternalTicketParams {
@@ -16,8 +16,8 @@ export interface IPaginateInternalTicketParams {
16
16
  }
17
17
  export interface IPaginateInternalTicketQuery extends QueryPaginate {
18
18
  status?: InternalTicketStatus;
19
- priorityId?: string;
20
- categoryId?: string;
19
+ internalTicketPriorityId?: string;
20
+ internalTicketCategoryId?: string;
21
21
  sectionId?: string;
22
22
  isArchived?: boolean;
23
23
  search?: string;
@@ -35,8 +35,8 @@ export interface IUpdateInternalTicketBody {
35
35
  title?: string;
36
36
  description?: string;
37
37
  status?: InternalTicketStatus;
38
- priorityId?: string;
39
- categoryId?: string;
38
+ internalTicketPriorityId?: string;
39
+ internalTicketCategoryId?: string;
40
40
  sectionId?: string;
41
41
  assignedToUserId?: string | null;
42
42
  priorityReason?: string;
@@ -61,7 +61,6 @@ export interface ICreateInternalTicketMessageParams {
61
61
  export interface ICreateInternalTicketMessageBody {
62
62
  content: string;
63
63
  replyToMessageId?: string;
64
- mentionedUserIds?: string[];
65
64
  }
66
65
  export interface IUpdateInternalTicketMessageParams {
67
66
  projectId: string;
@@ -49,14 +49,6 @@ export type IUpdateInternalTicketCategoryResponse = IResponse<IUpdateInternalTic
49
49
  export interface IDeleteInternalTicketCategoryData {
50
50
  }
51
51
  export type IDeleteInternalTicketCategoryResponse = IResponse<IDeleteInternalTicketCategoryData>;
52
- export interface IArchiveInternalTicketCategoryData {
53
- internalTicketCategory: IInternalTicketCategory;
54
- }
55
- export type IArchiveInternalTicketCategoryResponse = IResponse<IArchiveInternalTicketCategoryData>;
56
- export interface IUnarchiveInternalTicketCategoryData {
57
- internalTicketCategory: IInternalTicketCategory;
58
- }
59
- export type IUnarchiveInternalTicketCategoryResponse = IResponse<IUnarchiveInternalTicketCategoryData>;
60
52
  export interface ICreateInternalTicketPriorityData {
61
53
  internalTicketPriority: IInternalTicketPriority;
62
54
  }
@@ -72,11 +64,3 @@ export type IUpdateInternalTicketPriorityResponse = IResponse<IUpdateInternalTic
72
64
  export interface IDeleteInternalTicketPriorityData {
73
65
  }
74
66
  export type IDeleteInternalTicketPriorityResponse = IResponse<IDeleteInternalTicketPriorityData>;
75
- export interface IArchiveInternalTicketPriorityData {
76
- internalTicketPriority: IInternalTicketPriority;
77
- }
78
- export type IArchiveInternalTicketPriorityResponse = IResponse<IArchiveInternalTicketPriorityData>;
79
- export interface IUnarchiveInternalTicketPriorityData {
80
- internalTicketPriority: IInternalTicketPriority;
81
- }
82
- export type IUnarchiveInternalTicketPriorityResponse = IResponse<IUnarchiveInternalTicketPriorityData>;
@@ -2,8 +2,7 @@ import { IInternalTicket } from './internal-ticket.model';
2
2
  import { IInternalTicketSection } from './internal-ticket-section.model';
3
3
  export interface IInternalTicketCategory {
4
4
  id: string;
5
- projectId: string;
6
- sectionId: string;
5
+ internalTicketSectionId: string;
7
6
  name: string;
8
7
  color: string | null;
9
8
  description: string | null;
@@ -7,7 +7,6 @@ export interface IInternalTicketMessage {
7
7
  userId: string;
8
8
  content: string;
9
9
  replyToMessageId: string | null;
10
- mentionedUserIds: string[];
11
10
  createdAt?: Date;
12
11
  updatedAt?: Date;
13
12
  internalTicket?: IInternalTicket;
@@ -2,12 +2,12 @@ import { IInternalTicket } from './internal-ticket.model';
2
2
  import { IInternalTicketSection } from './internal-ticket-section.model';
3
3
  export interface IInternalTicketPriority {
4
4
  id: string;
5
- projectId: string;
6
- sectionId: string;
5
+ internalTicketSectionId: string;
7
6
  name: string;
8
- label: string | null;
9
7
  color: string | null;
8
+ description: string | null;
10
9
  level: number;
10
+ order: number;
11
11
  isDefault: boolean;
12
12
  isEnabled: boolean;
13
13
  requirePriorityReason: boolean;
@@ -10,12 +10,12 @@ import { IInternalTicketSection } from './internal-ticket-section.model';
10
10
  export interface IInternalTicket {
11
11
  id: string;
12
12
  projectId: string;
13
- sectionId: string;
13
+ internalTicketSectionId: string;
14
14
  title: string;
15
15
  description: string;
16
16
  status: InternalTicketStatus;
17
- priorityId: string | null;
18
- categoryId: string | null;
17
+ internalTicketPriorityId: string | null;
18
+ internalTicketCategoryId: string | null;
19
19
  createdByUserId: string;
20
20
  assignedToUserId: string | null;
21
21
  priorityCheckedAt: Date | null;
@@ -1,3 +1,4 @@
1
1
  export * from './error.utils';
2
2
  export * from './ip-address-validator.utils';
3
3
  export * from './cidr.util';
4
+ export * from './mention.utils';
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./error.utils"), exports);
18
18
  __exportStar(require("./ip-address-validator.utils"), exports);
19
19
  __exportStar(require("./cidr.util"), exports);
20
+ __exportStar(require("./mention.utils"), exports);
@@ -0,0 +1,3 @@
1
+ export declare function extractMentionedUserIds(content: string): string[];
2
+ export declare function formatMentionsForDisplay(content: string): string;
3
+ export declare function hasMentions(content: string): boolean;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasMentions = exports.formatMentionsForDisplay = exports.extractMentionedUserIds = void 0;
4
+ function extractMentionedUserIds(content) {
5
+ const mentionRegex = /<@([a-f0-9-]+)\|[^>]+>/g;
6
+ const mentionedUserIds = [];
7
+ let match;
8
+ while ((match = mentionRegex.exec(content)) !== null) {
9
+ mentionedUserIds.push(match[1]);
10
+ }
11
+ return [...new Set(mentionedUserIds)];
12
+ }
13
+ exports.extractMentionedUserIds = extractMentionedUserIds;
14
+ function formatMentionsForDisplay(content) {
15
+ return content.replace(/<@[a-f0-9-]+\|([^>]+)>/g, '@$1');
16
+ }
17
+ exports.formatMentionsForDisplay = formatMentionsForDisplay;
18
+ function hasMentions(content) {
19
+ return /<@[a-f0-9-]+\|[^>]+>/.test(content);
20
+ }
21
+ exports.hasMentions = hasMentions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/console",
3
- "version": "1.0.73",
3
+ "version": "1.0.75",
4
4
  "description": "Core package to interact with AbyssConsole",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,52 +0,0 @@
1
- export interface IReferenceResolver<T = any> {
2
- type: string;
3
- resolve: (id: string) => Promise<T> | T;
4
- }
5
- export interface IResolvedReference<T = any> {
6
- type: string;
7
- id: string;
8
- reference: string;
9
- value: T;
10
- resolvedValue: string;
11
- }
12
- export interface IValidationResult {
13
- valid: boolean;
14
- missingReferences: Array<{
15
- type: string;
16
- id: string;
17
- reference: string;
18
- }>;
19
- }
20
- export declare class ReferenceResolverUtils {
21
- private static resolvers;
22
- static registerResolver<T>(resolver: IReferenceResolver<T>): void;
23
- static unregisterResolver(type: string): void;
24
- static clearResolvers(): void;
25
- static hasReferences(value: string): boolean;
26
- static extractReferences(value: string): Array<{
27
- type: string;
28
- id: string;
29
- reference: string;
30
- }>;
31
- static extractReferencesFromArray(values: string[]): Array<{
32
- type: string;
33
- id: string;
34
- reference: string;
35
- }>;
36
- static extractReferencesFromObject(obj: any): Array<{
37
- type: string;
38
- id: string;
39
- reference: string;
40
- }>;
41
- private static uniqueReferences;
42
- static resolveString(value: string): Promise<string>;
43
- static resolveArray(values: string[]): Promise<string[]>;
44
- static resolveObject<T>(obj: T): Promise<T>;
45
- static validateReferences(value: any): Promise<IValidationResult>;
46
- static getResolutionInfo(value: string): Promise<IResolvedReference[]>;
47
- static resolveObjectWithTypes<T>(obj: T, types: string[]): Promise<T>;
48
- }
49
- export declare function resolveReferences<T>(value: T): Promise<T>;
50
- export declare function createResolver<T>(type: string, resolveFn: (id: string) => Promise<T> | T): IReferenceResolver<T>;
51
- export declare function createMapResolver<T>(type: string, map: Map<string, T>): IReferenceResolver<T>;
52
- export declare function createAsyncResolver<T>(type: string, fetchFn: (id: string) => Promise<T>): IReferenceResolver<T>;
@@ -1,219 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAsyncResolver = exports.createMapResolver = exports.createResolver = exports.resolveReferences = exports.ReferenceResolverUtils = void 0;
4
- const REFERENCE_PATTERN = /@(\w+):([a-zA-Z0-9-_]+)/g;
5
- class ReferenceResolverUtils {
6
- static registerResolver(resolver) {
7
- this.resolvers.set(resolver.type, resolver);
8
- }
9
- static unregisterResolver(type) {
10
- this.resolvers.delete(type);
11
- }
12
- static clearResolvers() {
13
- this.resolvers.clear();
14
- }
15
- static hasReferences(value) {
16
- const pattern = new RegExp(REFERENCE_PATTERN);
17
- return pattern.test(value);
18
- }
19
- static extractReferences(value) {
20
- const pattern = new RegExp(REFERENCE_PATTERN);
21
- const matches = value.matchAll(pattern);
22
- return Array.from(matches, (m) => ({
23
- type: m[1],
24
- id: m[2],
25
- reference: m[0],
26
- }));
27
- }
28
- static extractReferencesFromArray(values) {
29
- const allRefs = values.flatMap((value) => this.extractReferences(value));
30
- return this.uniqueReferences(allRefs);
31
- }
32
- static extractReferencesFromObject(obj) {
33
- const refs = [];
34
- const traverse = (value) => {
35
- if (typeof value === 'string' && this.hasReferences(value)) {
36
- refs.push(...this.extractReferences(value));
37
- }
38
- else if (Array.isArray(value)) {
39
- value.forEach(traverse);
40
- }
41
- else if (value && typeof value === 'object') {
42
- Object.values(value).forEach(traverse);
43
- }
44
- };
45
- traverse(obj);
46
- return this.uniqueReferences(refs);
47
- }
48
- static uniqueReferences(refs) {
49
- const seen = new Set();
50
- return refs.filter((ref) => {
51
- const key = `${ref.type}:${ref.id}`;
52
- if (seen.has(key))
53
- return false;
54
- seen.add(key);
55
- return true;
56
- });
57
- }
58
- static async resolveString(value) {
59
- const references = this.extractReferences(value);
60
- let resolved = value;
61
- for (const ref of references) {
62
- const resolver = this.resolvers.get(ref.type);
63
- if (!resolver) {
64
- throw new Error(`No resolver registered for type: ${ref.type}`);
65
- }
66
- const resolvedValue = await resolver.resolve(ref.id);
67
- if (resolvedValue === null || resolvedValue === undefined) {
68
- throw new Error(`Reference not found: ${ref.reference}`);
69
- }
70
- const stringValue = typeof resolvedValue === 'object'
71
- ? resolvedValue.value || JSON.stringify(resolvedValue)
72
- : String(resolvedValue);
73
- resolved = resolved.replace(ref.reference, stringValue);
74
- }
75
- return resolved;
76
- }
77
- static async resolveArray(values) {
78
- const resolved = await Promise.all(values.map(async (value) => {
79
- if (this.hasReferences(value)) {
80
- return await this.resolveString(value);
81
- }
82
- return value;
83
- }));
84
- return resolved.flat();
85
- }
86
- static async resolveObject(obj) {
87
- const resolve = async (value) => {
88
- if (typeof value === 'string' && this.hasReferences(value)) {
89
- return await this.resolveString(value);
90
- }
91
- else if (Array.isArray(value)) {
92
- return await Promise.all(value.map(resolve));
93
- }
94
- else if (value && typeof value === 'object') {
95
- const resolved = {};
96
- for (const [key, val] of Object.entries(value)) {
97
- resolved[key] = await resolve(val);
98
- }
99
- return resolved;
100
- }
101
- return value;
102
- };
103
- return await resolve(obj);
104
- }
105
- static async validateReferences(value) {
106
- const references = typeof value === 'string'
107
- ? this.extractReferences(value)
108
- : this.extractReferencesFromObject(value);
109
- const missingReferences = [];
110
- for (const ref of references) {
111
- const resolver = this.resolvers.get(ref.type);
112
- if (!resolver) {
113
- missingReferences.push(ref);
114
- continue;
115
- }
116
- try {
117
- const resolved = await resolver.resolve(ref.id);
118
- if (resolved === null || resolved === undefined) {
119
- missingReferences.push(ref);
120
- }
121
- }
122
- catch {
123
- missingReferences.push(ref);
124
- }
125
- }
126
- return {
127
- valid: missingReferences.length === 0,
128
- missingReferences,
129
- };
130
- }
131
- static async getResolutionInfo(value) {
132
- const references = this.extractReferences(value);
133
- const results = [];
134
- for (const ref of references) {
135
- const resolver = this.resolvers.get(ref.type);
136
- if (!resolver) {
137
- throw new Error(`No resolver registered for type: ${ref.type}`);
138
- }
139
- const resolvedValue = await resolver.resolve(ref.id);
140
- if (resolvedValue === null || resolvedValue === undefined) {
141
- throw new Error(`Reference not found: ${ref.reference}`);
142
- }
143
- const stringValue = typeof resolvedValue === 'object'
144
- ? resolvedValue.value || JSON.stringify(resolvedValue)
145
- : String(resolvedValue);
146
- results.push({
147
- type: ref.type,
148
- id: ref.id,
149
- reference: ref.reference,
150
- value: resolvedValue,
151
- resolvedValue: stringValue,
152
- });
153
- }
154
- return results;
155
- }
156
- static async resolveObjectWithTypes(obj, types) {
157
- const typeSet = new Set(types);
158
- const resolve = async (value) => {
159
- if (typeof value === 'string' && this.hasReferences(value)) {
160
- const references = this.extractReferences(value);
161
- let resolved = value;
162
- for (const ref of references) {
163
- if (!typeSet.has(ref.type))
164
- continue;
165
- const resolver = this.resolvers.get(ref.type);
166
- if (!resolver)
167
- continue;
168
- const resolvedValue = await resolver.resolve(ref.id);
169
- if (resolvedValue === null || resolvedValue === undefined)
170
- continue;
171
- const stringValue = typeof resolvedValue === 'object'
172
- ? resolvedValue.value || JSON.stringify(resolvedValue)
173
- : String(resolvedValue);
174
- resolved = resolved.replace(ref.reference, stringValue);
175
- }
176
- return resolved;
177
- }
178
- else if (Array.isArray(value)) {
179
- return await Promise.all(value.map(resolve));
180
- }
181
- else if (value && typeof value === 'object') {
182
- const resolved = {};
183
- for (const [key, val] of Object.entries(value)) {
184
- resolved[key] = await resolve(val);
185
- }
186
- return resolved;
187
- }
188
- return value;
189
- };
190
- return await resolve(obj);
191
- }
192
- }
193
- exports.ReferenceResolverUtils = ReferenceResolverUtils;
194
- ReferenceResolverUtils.resolvers = new Map();
195
- async function resolveReferences(value) {
196
- return ReferenceResolverUtils.resolveObject(value);
197
- }
198
- exports.resolveReferences = resolveReferences;
199
- function createResolver(type, resolveFn) {
200
- return {
201
- type,
202
- resolve: resolveFn,
203
- };
204
- }
205
- exports.createResolver = createResolver;
206
- function createMapResolver(type, map) {
207
- return createResolver(type, (id) => {
208
- const value = map.get(id);
209
- if (value === undefined) {
210
- throw new Error(`${type} not found: ${id}`);
211
- }
212
- return value;
213
- });
214
- }
215
- exports.createMapResolver = createMapResolver;
216
- function createAsyncResolver(type, fetchFn) {
217
- return createResolver(type, fetchFn);
218
- }
219
- exports.createAsyncResolver = createAsyncResolver;