@techextensor/tab-sdk 0.0.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.
Files changed (50) hide show
  1. package/.editorconfig +16 -0
  2. package/.vscode/extensions.json +6 -0
  3. package/.vscode/launch.json +20 -0
  4. package/.vscode/tasks.json +42 -0
  5. package/README.md +27 -0
  6. package/documents/LibraryCreationGuide.md +82 -0
  7. package/documents/Method Access/analytics.md +6 -0
  8. package/documents/Method Access/app.md +22 -0
  9. package/documents/Method Access/auth.md +14 -0
  10. package/documents/Method Access/crud.md +17 -0
  11. package/documents/Method Access/file.md +5 -0
  12. package/documents/Method Access/form.md +14 -0
  13. package/documents/Method Access/http.md +4 -0
  14. package/documents/Method Access/metadata-utils.md +62 -0
  15. package/documents/Method Access/release.md +5 -0
  16. package/documents/Method Access/report.md +6 -0
  17. package/documents/Method Access/store.md +75 -0
  18. package/documents/Method Access/transition.md +5 -0
  19. package/documents/Method Access/translator.md +16 -0
  20. package/documents/Method Access/ui-actions.md +22 -0
  21. package/nx.json +35 -0
  22. package/package.json +46 -0
  23. package/projects/tab-sdk/README.md +24 -0
  24. package/projects/tab-sdk/ng-package.json +7 -0
  25. package/projects/tab-sdk/package.json +19 -0
  26. package/projects/tab-sdk/project.json +37 -0
  27. package/projects/tab-sdk/src/lib/app/analytics.service.ts +54 -0
  28. package/projects/tab-sdk/src/lib/app/app.service.ts +188 -0
  29. package/projects/tab-sdk/src/lib/app/file.service.ts +92 -0
  30. package/projects/tab-sdk/src/lib/app/release.service.ts +38 -0
  31. package/projects/tab-sdk/src/lib/app/report.service.ts +51 -0
  32. package/projects/tab-sdk/src/lib/app/translator.service.ts +80 -0
  33. package/projects/tab-sdk/src/lib/auth/auth.service.ts +119 -0
  34. package/projects/tab-sdk/src/lib/crud/crud.service.ts +187 -0
  35. package/projects/tab-sdk/src/lib/enum/store.enum.ts +4 -0
  36. package/projects/tab-sdk/src/lib/enum/ui.enum.ts +11 -0
  37. package/projects/tab-sdk/src/lib/http/http.service.ts +63 -0
  38. package/projects/tab-sdk/src/lib/interface/http.interface.ts +8 -0
  39. package/projects/tab-sdk/src/lib/interface/ui.interface.ts +28 -0
  40. package/projects/tab-sdk/src/lib/store/store.service.ts +831 -0
  41. package/projects/tab-sdk/src/lib/tab-sdk.service.ts +84 -0
  42. package/projects/tab-sdk/src/lib/ui/form.service.ts +92 -0
  43. package/projects/tab-sdk/src/lib/ui/ui.service.ts +404 -0
  44. package/projects/tab-sdk/src/lib/util/util.service.ts +53 -0
  45. package/projects/tab-sdk/src/lib/workflow/transition.service.ts +40 -0
  46. package/projects/tab-sdk/src/public-api.ts +10 -0
  47. package/projects/tab-sdk/tsconfig.lib.json +15 -0
  48. package/projects/tab-sdk/tsconfig.lib.prod.json +11 -0
  49. package/projects/tab-sdk/tsconfig.spec.json +15 -0
  50. package/tsconfig.json +37 -0
@@ -0,0 +1,84 @@
1
+ import { Injectable, Injector } from '@angular/core';
2
+ import { MetadataHelper } from '@techextensor/tab-core-utility';
3
+ import { UiService } from './ui/ui.service';
4
+ import { AuthUtilService } from './auth/auth.service';
5
+ import { FormService } from './ui/form.service';
6
+ import { TransitionService } from './workflow/transition.service';
7
+ import { AppService } from './app/app.service';
8
+ import { FileService } from './app/file.service';
9
+ import { ReportService } from './app/report.service';
10
+ import { ReleaseService } from './app/release.service';
11
+ import { AnalyticsService } from './app/analytics.service';
12
+ import { TranslatorService } from './app/translator.service';
13
+ import { CrudService } from './crud/crud.service';
14
+ import { HttpService } from './http/http.service';
15
+ import { StoreService } from './store/store.service';
16
+ import { UtilService } from './util/util.service';
17
+
18
+ @Injectable({
19
+ providedIn: 'root'
20
+ })
21
+ export class TabSdk {
22
+ public static app: AppService;
23
+ public static auth: AuthUtilService;
24
+ public static ui: UiService;
25
+ public static form: FormService;
26
+ public static transition: TransitionService;
27
+ public static metadataUtils: MetadataHelper;
28
+ public static file: FileService;
29
+ public static report: ReportService;
30
+ public static release: ReleaseService;
31
+ public static analytics: AnalyticsService;
32
+ public static translator: TranslatorService;
33
+ public static crud: CrudService;
34
+ public static http: HttpService;
35
+ public static store: StoreService;
36
+ public static util: any;
37
+
38
+
39
+ /**
40
+ * Initialize the SDK with necessary services
41
+ */
42
+ public static init(injector: Injector, context: any): void {
43
+ // Expose to window for global access if needed
44
+ (window as any).TabSdk = TabSdk;
45
+
46
+ // Initialize services
47
+ this.app = injector.get(AppService);
48
+ this.auth = injector.get(AuthUtilService);
49
+ this.ui = injector.get(UiService);
50
+ this.form = injector.get(FormService);
51
+ this.transition = injector.get(TransitionService);
52
+ this.metadataUtils = injector.get(MetadataHelper);
53
+ this.file = injector.get(FileService);
54
+ this.report = injector.get(ReportService);
55
+ this.release = injector.get(ReleaseService);
56
+ this.analytics = injector.get(AnalyticsService);
57
+ this.translator = injector.get(TranslatorService);
58
+ this.crud = injector.get(CrudService);
59
+ this.http = injector.get(HttpService);
60
+ this.store = injector.get(StoreService);
61
+
62
+ // Initialize util service with context
63
+ const utilService = injector.get(UtilService);
64
+ this.util = utilService.init(context);
65
+
66
+ // Freeze the global object to prevent modifications
67
+ Object.freeze(this);
68
+
69
+ Object.freeze(this.app);
70
+ Object.freeze(this.auth);
71
+ Object.freeze(this.ui);
72
+ Object.freeze(this.form);
73
+ Object.freeze(this.transition);
74
+ Object.freeze(this.file);
75
+ Object.freeze(this.report);
76
+ Object.freeze(this.release);
77
+ Object.freeze(this.analytics);
78
+ Object.freeze(this.translator);
79
+ Object.freeze(this.crud);
80
+ Object.freeze(this.http);
81
+ Object.freeze(this.store);
82
+ Object.freeze(this.util);
83
+ }
84
+ }
@@ -0,0 +1,92 @@
1
+ import { inject, Injectable } from '@angular/core';
2
+ import { BuildFormComponentType, CommonApiResponse, GetScreenConfig, ProcessRequestPayload, TabFormioService, TemplateHelper, TemplateParsePayload } from '@techextensor/tab-core-utility';
3
+ import { firstValueFrom } from 'rxjs';
4
+
5
+ @Injectable({
6
+ providedIn: 'root'
7
+ })
8
+ export class FormService {
9
+ private readonly _tabFormioService: TabFormioService = inject(TabFormioService);
10
+ private readonly _templateHelper: TemplateHelper = inject(TemplateHelper);
11
+
12
+ /**
13
+ * Retrieves a screen by its ID.
14
+ *
15
+ * @param screenId The ID of the screen to retrieve.
16
+ * @param config Optional configuration object for the request.
17
+ * @returns A promise of the response from the server.
18
+ */
19
+ async getScreen(screenId: string, config?: GetScreenConfig): Promise<CommonApiResponse> {
20
+ const response = await firstValueFrom(
21
+ this._tabFormioService.getScreen(screenId, config)
22
+ );
23
+ return response;
24
+ }
25
+
26
+ /**
27
+ * Retrieves the data for a screen by its ID.
28
+ *
29
+ * @param screenId The ID of the screen to retrieve the data for.
30
+ * @param requestPayload The request payload to send to the server.
31
+ * @returns A promise of the response from the server.
32
+ */
33
+ async getScreenData(screenId: string, requestPayload: any): Promise<CommonApiResponse> {
34
+ // Send the request to the server and get the response.
35
+ const response = await firstValueFrom(
36
+ this._tabFormioService.getScreenData(screenId, requestPayload)
37
+ );
38
+
39
+ // Return the response from the server.
40
+ return response;
41
+ }
42
+
43
+ /**
44
+ * Processes a request using the provided request payload.
45
+ *
46
+ * @param requestPayload The payload to be processed.
47
+ * @returns A promise of the response from the server.
48
+ */
49
+ async processRequest(requestPayload: ProcessRequestPayload): Promise<CommonApiResponse> {
50
+ // Send the request payload to the server and await the response.
51
+ const response = await firstValueFrom(
52
+ this._tabFormioService.processRequest(requestPayload)
53
+ );
54
+
55
+ // Return the server's response.
56
+ return response;
57
+ }
58
+
59
+ /**
60
+ * Builds Form.io components for the specified app object ID and type.
61
+ *
62
+ * @param appObjectId The ID of the app object to build the components for.
63
+ * @param type The type of components to build.
64
+ * @returns A promise of the response from the server.
65
+ */
66
+ async buildFormIOComponents(appObjectId: string, type: BuildFormComponentType): Promise<CommonApiResponse> {
67
+ // Send the request to the server to build the components.
68
+ const response = await firstValueFrom(
69
+ this._tabFormioService.buildFormIOComponents(appObjectId, type)
70
+ );
71
+
72
+ // Return the response from the server.
73
+ return response;
74
+ }
75
+
76
+ /**
77
+ * Parses a template using the provided request payload.
78
+ *
79
+ * @param requestPayload The payload containing the template to be parsed.
80
+ * @param onFailedParseOnServer If the parsing should be done on the server.
81
+ * @returns A promise of the response from the server.
82
+ */
83
+ async parseTemplate(requestPayload: TemplateParsePayload, onFailedParseOnServer = false): Promise<CommonApiResponse> {
84
+ // Send the request to the server to parse the template.
85
+ const response = await firstValueFrom(
86
+ this._templateHelper.templateParseUniversal(requestPayload, onFailedParseOnServer)
87
+ );
88
+
89
+ // Return the response from the server.
90
+ return response;
91
+ }
92
+ }
@@ -0,0 +1,404 @@
1
+ import { inject, Injectable } from '@angular/core';
2
+ import {
3
+ ScreenOpenOptions,
4
+ NavigationOptions,
5
+ BaseScreenOptions,
6
+ NavigateToSubdomainOptions
7
+ } from '../interface/ui.interface';
8
+ import { NavigationType, ScreenDisplayMode } from '../enum/ui.enum';
9
+ import { TabSdk } from '../tab-sdk.service';
10
+ import { BaseNotificationOptions, ConfirmationOptions, ConfirmationService, NotificationOptions, NotificationService, NotificationType } from '@techextensor/tab-core-utility';
11
+
12
+ @Injectable({
13
+ providedIn: 'root'
14
+ })
15
+ export class UiService {
16
+ private readonly _notificationService: NotificationService = inject(NotificationService);
17
+ private readonly _confirmationService: ConfirmationService = inject(ConfirmationService);
18
+
19
+ /**
20
+ * Open a screen with the given options. The mode determines how the screen is
21
+ * displayed.
22
+ *
23
+ * @param options The options for opening the screen.
24
+ */
25
+ openScreen(options: ScreenOpenOptions): void {
26
+ const { mode, ...otherOptions } = options;
27
+
28
+ switch (mode) {
29
+ case ScreenDisplayMode.Sidebar:
30
+ this.showSidebar(otherOptions);
31
+ break;
32
+
33
+ case ScreenDisplayMode.Popup:
34
+ this.showDialog(otherOptions);
35
+ break;
36
+
37
+ case ScreenDisplayMode.SameTab:
38
+ this.navigateTo(otherOptions);
39
+ break;
40
+
41
+ case ScreenDisplayMode.NewTab:
42
+ this.openInNewTab(otherOptions);
43
+ break;
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Opens a screen in a sidebar.
49
+ *
50
+ * @param options The options for opening the sidebar.
51
+ */
52
+ showSidebar(options: BaseScreenOptions): void {
53
+ const otherConfiguration = {
54
+ ...(options.title && { title: options.title }),
55
+ ...(options.width && { width: options.width }),
56
+ ...(options.height && { height: options.height }),
57
+ ...(options.customClass && { customClass: options.customClass }),
58
+ ...(options.refresher && { refresher: options.refresher }),
59
+ ...(options.closer && { closer: options.closer })
60
+ };
61
+
62
+ TabSdk.util?.openScreen(
63
+ ScreenDisplayMode.Sidebar,
64
+ options.screenId,
65
+ options.reqtokens || undefined,
66
+ options.submission || undefined,
67
+ Object.keys(otherConfiguration).length > 0 ? otherConfiguration : undefined
68
+ );
69
+ }
70
+
71
+ /**
72
+ * Opens a screen in a popup dialog.
73
+ *
74
+ * @param options The options for opening the dialog.
75
+ */
76
+ showDialog(options: BaseScreenOptions): void {
77
+ const otherConfiguration = {
78
+ ...(options.title && { title: options.title }),
79
+ ...(options.width && { width: options.width }),
80
+ ...(options.height && { height: options.height }),
81
+ ...(options.customClass && { customClass: options.customClass }),
82
+ ...(options.refresher && { refresher: options.refresher }),
83
+ ...(options.closer && { closer: options.closer })
84
+ };
85
+
86
+ TabSdk.util?.openScreen(
87
+ ScreenDisplayMode.Popup,
88
+ options.screenId,
89
+ options.reqtokens || undefined,
90
+ options.submission || undefined,
91
+ Object.keys(otherConfiguration).length > 0 ? otherConfiguration : undefined
92
+ );
93
+ }
94
+
95
+ /**
96
+ * Navigates to a screen within the same tab.
97
+ *
98
+ * @param options - The options for navigation, including screenId and optional reqtokens.
99
+ */
100
+ navigateTo(options: NavigationOptions): void {
101
+ TabSdk.util?.openScreen(
102
+ ScreenDisplayMode.SameTab,
103
+ options.screenId,
104
+ options.reqtokens || undefined
105
+ );
106
+ }
107
+
108
+ /**
109
+ * Navigates to a screen in a new tab.
110
+ *
111
+ * @param options The options for navigation, including screenId and optional reqtokens.
112
+ */
113
+ openInNewTab(options: NavigationOptions): void {
114
+ TabSdk.util?.openScreen(
115
+ ScreenDisplayMode.NewTab,
116
+ options.screenId,
117
+ options.reqtokens || undefined
118
+ );
119
+ }
120
+
121
+ /**
122
+ * Navigates to the specified URL.
123
+ *
124
+ * @param url - The URL to navigate to.
125
+ */
126
+ navigateToUrl(params: { url: string, extras?: any, replaceUrl?: boolean }): void {
127
+ TabSdk.util?.navigateTo({
128
+ ...params,
129
+ type: NavigationType.NavigateToUrl
130
+ })
131
+ }
132
+
133
+ /**
134
+ * Navigates to a specified subdomain using the provided options.
135
+ *
136
+ * @param options - The options for navigation, including subDomain, appCode, and url.
137
+ */
138
+ navigateToSubdomain(options: NavigateToSubdomainOptions): void {
139
+ TabSdk.util?.navigateTo({
140
+ ...options,
141
+ type: NavigationType.NavigateToSubdomain
142
+ })
143
+ }
144
+
145
+ /**
146
+ * Retrieves the active screen ID from the current URL.
147
+ *
148
+ * @returns The screen ID if present in the URL, otherwise undefined.
149
+ */
150
+ getActiveUrlScreenId(): string | undefined {
151
+ // Split the URL pathname into parts using the '/' character as a delimiter
152
+ const urlParts = window?.location?.pathname?.split('/');
153
+ // Extract the screen ID part and remove any query parameters
154
+ const screenId = urlParts?.length > 1 ? urlParts?.[urlParts?.length - 1]?.split('?')[0] : undefined;
155
+ // Return the screen ID or undefined if not found
156
+ return screenId;
157
+ }
158
+
159
+ /**
160
+ * Retrieves the active redirect URL by combining the active screen ID and any query parameters.
161
+ *
162
+ * @returns The constructed redirect URL or undefined if no screen ID is present.
163
+ */
164
+ getActiveRedirectUrl(): string | undefined {
165
+ // Get the active screen ID from the current URL
166
+ const screenId = this.getActiveUrlScreenId();
167
+ let redirectURL;
168
+
169
+ // Check if the current URL contains a screen ID
170
+ if (screenId) {
171
+ // Initialize the redirect URL with the screen ID
172
+ redirectURL = screenId;
173
+
174
+ // Parse the current URL's query parameters
175
+ const queryParams = new URLSearchParams(window.location.search);
176
+
177
+ // If there are query parameters, append them to the redirect URL
178
+ if (queryParams.toString()) {
179
+ redirectURL += `&${queryParams.toString()}`;
180
+ }
181
+ }
182
+
183
+ // Return the constructed redirect URL or undefined
184
+ return redirectURL;
185
+ }
186
+
187
+ /**
188
+ * Show a notification to the user.
189
+ *
190
+ * @param options The options for the notification.
191
+ */
192
+ notify(options: NotificationOptions) {
193
+ return this._notificationService.notify({
194
+ type: options.type,
195
+ message: TabSdk.translator.translate(options.message),
196
+ ...(options?.title ? { title: TabSdk.translator.translate(options.title) } : {}),
197
+ ...(options?.configuration ? { configuration: options.configuration } : {}),
198
+ });
199
+ }
200
+
201
+ /**
202
+ * Displays a success notification to the user.
203
+ *
204
+ * @param options - The options for the notification, including message, title, and configuration.
205
+ */
206
+ showSuccess(options: BaseNotificationOptions) {
207
+ return this.notify({
208
+ ...options,
209
+ type: NotificationType.Success,
210
+ title: options?.title ?? 'Success'
211
+ });
212
+ }
213
+
214
+ /**
215
+ * Displays a warning notification to the user.
216
+ *
217
+ * @param options - The options for the notification, including message, title, and configuration.
218
+ */
219
+ showWarning(options: BaseNotificationOptions) {
220
+ return this.notify({
221
+ ...options,
222
+ type: NotificationType.Warning,
223
+ title: options?.title ?? 'Warning'
224
+ });
225
+ }
226
+
227
+ /**
228
+ * Displays an info notification to the user.
229
+ *
230
+ * @param options - The options for the notification, including message, title, and configuration.
231
+ */
232
+ showInfo(options: BaseNotificationOptions) {
233
+ return this.notify({
234
+ ...options,
235
+ type: NotificationType.Info,
236
+ title: options?.title ?? 'Info'
237
+ });
238
+ }
239
+
240
+ /**
241
+ * Displays an error notification to the user.
242
+ *
243
+ * @param options - The options for the notification, including message, title, and configuration.
244
+ */
245
+ showError(options: BaseNotificationOptions) {
246
+ return this.notify({
247
+ ...options,
248
+ type: NotificationType.Error,
249
+ title: options?.title ?? 'Error'
250
+ });
251
+ }
252
+
253
+ /**
254
+ * Clears a notification by ID.
255
+ *
256
+ * @param notificationId - The ID of the notification to clear.
257
+ * @returns The cleared notification, or null if the notification doesn't exist.
258
+ */
259
+ clearNotification(notificationId: number) {
260
+ return this._notificationService.clearNotification(notificationId);
261
+ }
262
+
263
+ /**
264
+ * Displays a confirmation dialog to the user and returns a promise that resolves
265
+ * to a boolean indicating whether the user confirmed the action.
266
+ *
267
+ * @param options - The options for the confirmation dialog, including title, message,
268
+ * confirmText, cancelText, and visibility of buttons.
269
+ * @returns A promise that resolves to true if the user confirms, false otherwise.
270
+ */
271
+ confirm(options?: ConfirmationOptions): Promise<boolean> {
272
+ return new Promise((resolve) => {
273
+ this._confirmationService.confirm(options)
274
+ ?.subscribe((isConfirmed: boolean) => {
275
+ resolve(isConfirmed);
276
+ });
277
+ });
278
+ }
279
+
280
+ /**
281
+ * Displays a confirmation dialog to the user with a title and message that indicates
282
+ * the user is about to delete an item. The confirmation dialog has a "Delete" and "Cancel"
283
+ * button.
284
+ *
285
+ * @param options - The options for the confirmation dialog, including the item name and
286
+ * optional message.
287
+ * @returns A promise that resolves to true if the user confirms, false otherwise.
288
+ */
289
+ confirmDelete(options?: ConfirmationOptions): Promise<boolean> {
290
+ return this.confirm({
291
+ title: options?.title ?? `Are you sure you want to delete this record`,
292
+ message: options?.message ?? `You are about to delete the selected record. Are you sure you want to proceed?`,
293
+ primaryOption: 'Delete',
294
+ });
295
+ }
296
+
297
+ /**
298
+ * Displays a confirmation dialog to the user with a title and message that indicates
299
+ * the user is about to discard changes to an item. The confirmation dialog has a "Discard"
300
+ * and "Cancel" button.
301
+ *
302
+ * @param options - The options for the confirmation dialog, including the item name and
303
+ * optional message.
304
+ * @returns A promise that resolves to true if the user confirms, false otherwise.
305
+ */
306
+ confirmDiscard(options?: ConfirmationOptions): Promise<boolean> {
307
+ return this.confirm({
308
+ title: `Are you sure you want to discard your changes`,
309
+ message: options?.message ?? `You are about to discard your changes. Are you sure you want to proceed?`,
310
+ primaryOption: 'Discard',
311
+ });
312
+ }
313
+
314
+ /**
315
+ * Closes the confirmation dialog.
316
+ *
317
+ * This method can be used to manually close the confirmation dialog.
318
+ */
319
+ closeConfirmationDialog() {
320
+ // Close the confirmation dialog
321
+ this._confirmationService.closeDialog();
322
+ }
323
+
324
+ /**
325
+ * Retrieves the confirmation emitter from the confirmation service.
326
+ *
327
+ * @returns The confirmation emitter used for emitting confirmation events.
328
+ */
329
+ getConformationEmitter() {
330
+ return this._confirmationService.getConformationEmitter();
331
+ }
332
+
333
+ /**
334
+ * Retrieves the dialog emitter from the confirmation service.
335
+ *
336
+ * The dialog emitter is an RxJS Subject that emits whenever a confirmation dialog is
337
+ * opened or closed. The value emitted is a boolean indicating whether a dialog is
338
+ * currently open.
339
+ *
340
+ * @returns The dialog emitter used for emitting confirmation dialog events.
341
+ */
342
+ getDialogEmitter() {
343
+ return this._confirmationService.getDialogEmitter();
344
+ }
345
+
346
+ /**
347
+ * Retrieves the remove emitter from the confirmation service.
348
+ *
349
+ * The remove emitter is an RxJS Subject that emits whenever a removal confirmation
350
+ * dialog is opened or closed. The value emitted is a boolean indicating whether a
351
+ * removal dialog is currently open.
352
+ *
353
+ * @returns The remove emitter used for emitting removal confirmation dialog events.
354
+ */
355
+ getRemoveEmitter() {
356
+ return this._confirmationService.getRemoveEmitter();
357
+ }
358
+
359
+ /**
360
+ * Copies the provided text to the clipboard and displays a success notification.
361
+ *
362
+ * @param text - The text to be copied to the clipboard.
363
+ */
364
+ copyToClipboard(text: string) {
365
+ // Create a temporary input element to hold the text
366
+ const tempInput = document.createElement("input");
367
+
368
+ // Set the input's value to the text to be copied
369
+ tempInput.value = text;
370
+
371
+ // Append the temporary input to the document body
372
+ document.body.appendChild(tempInput);
373
+
374
+ // Select the text in the input element
375
+ tempInput.select();
376
+
377
+ // Execute the copy command
378
+ document.execCommand("copy");
379
+
380
+ // Remove the temporary input from the document body
381
+ document.body.removeChild(tempInput);
382
+
383
+ // Show a success notification
384
+ this.showSuccess({
385
+ message: "",
386
+ title: "Copied to clipboard!",
387
+ configuration: {
388
+ timeOut: 1000,
389
+ positionClass: 'toast-top-center',
390
+ easing: 'ease-in',
391
+ easeTime: 300,
392
+ extendedTimeOut: 2000,
393
+ }
394
+ });
395
+ }
396
+
397
+ /**
398
+ * Copies the current URL to the clipboard and displays a success notification.
399
+ */
400
+ copyCurrentUrlToClipboard() {
401
+ // Use the copyToClipboard method to copy the current window URL
402
+ this.copyToClipboard(window.location.href);
403
+ }
404
+ }
@@ -0,0 +1,53 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ @Injectable({
4
+ providedIn: 'root'
5
+ })
6
+ export class UtilService {
7
+ // Will store the services from context
8
+ private _context: any = null;
9
+ private _initialized = false;
10
+
11
+ /**
12
+ * Initializes the UtilService with context that contains service references
13
+ *
14
+ * @param context The context object containing service references
15
+ * @returns A proxy that intercepts and delegates method calls to the appropriate service
16
+ */
17
+ init(context: any): any {
18
+ if (this._initialized) {
19
+ return this;
20
+ }
21
+
22
+ this._context = context;
23
+ this._initialized = true;
24
+
25
+ // Return a proxy that will intercept method calls
26
+ return new Proxy(this, {
27
+ get: (target: any, prop: string | symbol) => {
28
+ // First check if the property exists directly on UtilService
29
+ if (prop in target) {
30
+ return (target as any)[prop];
31
+ }
32
+
33
+ // Convert symbol to string if needed
34
+ const propName = prop.toString();
35
+
36
+ // Check context services first
37
+ if (this._context && Object.keys(this._context).length > 0) {
38
+ // Loop through each service in the context
39
+ for (const serviceName of Object.keys(this._context)) {
40
+ const service = this._context[serviceName];
41
+ if (service && typeof service === 'object' && propName in service && typeof service[propName] === 'function') {
42
+ // Return the bound function from the service
43
+ return service[propName].bind(service);
44
+ }
45
+ }
46
+ }
47
+
48
+ // If property not found anywhere, return undefined
49
+ return undefined;
50
+ }
51
+ });
52
+ }
53
+ }
@@ -0,0 +1,40 @@
1
+ import { inject, Injectable } from '@angular/core';
2
+ import { CommonApiResponse, NextStatusPayload, TabBlueprintService, UpdateStatusPayload } from '@techextensor/tab-core-utility';
3
+ import { firstValueFrom } from 'rxjs';
4
+ import { TabSdk } from '../tab-sdk.service';
5
+
6
+ @Injectable({
7
+ providedIn: 'root'
8
+ })
9
+ export class TransitionService {
10
+ private readonly _tabBlueprintService: TabBlueprintService = inject(TabBlueprintService);
11
+
12
+ /**
13
+ * Retrieves the next status based on the provided payload.
14
+ *
15
+ * @param payload - The payload containing information to determine the next status.
16
+ * @returns A promise that resolves to the common API response.
17
+ */
18
+ async getNextStatus(payload: NextStatusPayload): Promise<CommonApiResponse> {
19
+ // Await the response from the getNextStatus method of the tabBlueprintService
20
+ const response = await firstValueFrom(
21
+ this._tabBlueprintService.getNextStatus(payload)
22
+ );
23
+ // Return the obtained response
24
+ return response;
25
+ }
26
+
27
+ /**
28
+ * Updates the status of an entity based on the provided payload.
29
+ *
30
+ * @param payload - The payload containing information to update the status.
31
+ * @returns A promise that resolves to the common API response.
32
+ */
33
+ async updateStatus(payload: UpdateStatusPayload): Promise<any> {
34
+ const response = await firstValueFrom(
35
+ TabSdk.util?.updateStatus(payload)
36
+ );
37
+ // Return the obtained response
38
+ return response;
39
+ }
40
+ }
@@ -0,0 +1,10 @@
1
+ // SDK
2
+ export * from './lib/tab-sdk.service';
3
+
4
+ // Enums
5
+ export * from './lib/enum/ui.enum';
6
+ export * from './lib/enum/store.enum';
7
+
8
+ // Interfaces
9
+ export * from './lib/interface/ui.interface';
10
+ export * from './lib/interface/http.interface';