@techextensor/tab-sdk 0.0.2 → 0.0.3

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.
@@ -0,0 +1,56 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class FormService {
3
+ private readonly _helperFunctionService;
4
+ /**
5
+ * Processes form components with individual actions in a single pass
6
+ *
7
+ * @example
8
+ * // Process multiple components with different actions in one pass
9
+ * sdk.form.processComponents(
10
+ * screenParameters.rendererInstance.form.components,
11
+ * [
12
+ * {
13
+ * keys: 'documentDetails', // Single key
14
+ * action: (component) => component.hidden = true,
15
+ * type: 'columns' // Optional type filter
16
+ * },
17
+ * {
18
+ * keys: 'documentPreview,documentComments', // Multiple keys as comma-separated string
19
+ * action: (component) => component.hidden = false
20
+ * }
21
+ * ]
22
+ * );
23
+ */
24
+ processComponents(components: any[], processors: Array<{
25
+ keys: string;
26
+ type?: string;
27
+ action: (component: any) => void;
28
+ }>): void;
29
+ /**
30
+ * Updates visibility of multiple form components at once
31
+ *
32
+ * @example
33
+ * sdk.form.setComponentsVisibility(
34
+ * screenParameters.rendererInstance.form.components,
35
+ * {
36
+ * 'documentDetails': false,
37
+ * 'documentComments': true
38
+ * }
39
+ * );
40
+ */
41
+ setComponentsVisibility(components: any[], visibilityMap: Record<string, boolean>): void;
42
+ /**
43
+ * Finds components by key and returns them in a structured object
44
+ *
45
+ * @example
46
+ * const components = sdk.form.findComponentsByKeys(
47
+ * form.components,
48
+ * ['documentDetails', 'documentPreview', 'documentComments']
49
+ * );
50
+ */
51
+ findComponentsByKeys(components: any[], keys: string[], options?: {
52
+ type?: string;
53
+ }): Record<string, any>;
54
+ static ɵfac: i0.ɵɵFactoryDeclaration<FormService, never>;
55
+ static ɵprov: i0.ɵɵInjectableDeclaration<FormService>;
56
+ }
@@ -0,0 +1,5 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class UiService {
3
+ static ɵfac: i0.ɵɵFactoryDeclaration<UiService, never>;
4
+ static ɵprov: i0.ɵɵInjectableDeclaration<UiService>;
5
+ }
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "@techextensor/tab-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^17.3.0",
6
6
  "@angular/core": "^17.3.0",
7
- "@techextensor/tab-core-utility": "^2.2.129"
8
- },
9
- "scripts": {
10
- "updateVersion": "npm version patch"
7
+ "@techextensor/tab-core-utility": "^2.2.135"
11
8
  },
12
9
  "dependencies": {
13
10
  "tslib": "^2.3.0"
@@ -15,5 +12,18 @@
15
12
  "sideEffects": false,
16
13
  "publishConfig": {
17
14
  "access": "public"
15
+ },
16
+ "module": "fesm2022/techextensor-tab-sdk.mjs",
17
+ "typings": "index.d.ts",
18
+ "exports": {
19
+ "./package.json": {
20
+ "default": "./package.json"
21
+ },
22
+ ".": {
23
+ "types": "./index.d.ts",
24
+ "esm2022": "./esm2022/techextensor-tab-sdk.mjs",
25
+ "esm": "./esm2022/techextensor-tab-sdk.mjs",
26
+ "default": "./fesm2022/techextensor-tab-sdk.mjs"
27
+ }
18
28
  }
19
- }
29
+ }
@@ -0,0 +1 @@
1
+ export * from './lib/tab-sdk.service';
package/ng-package.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/tab-sdk",
4
- "lib": {
5
- "entryFile": "src/public-api.ts"
6
- }
7
- }
package/project.json DELETED
@@ -1,37 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
3
- "name": "tab-sdk",
4
- "projectType": "library",
5
- "sourceRoot": "projects/tab-sdk/src",
6
- "prefix": "lib",
7
- "targets": {
8
- "build": {
9
- "executor": "@angular-devkit/build-angular:ng-packagr",
10
- "options": {
11
- "project": "projects/tab-sdk/ng-package.json"
12
- },
13
- "configurations": {
14
- "production": {
15
- "tsConfig": "projects/tab-sdk/tsconfig.lib.prod.json"
16
- },
17
- "development": {
18
- "tsConfig": "projects/tab-sdk/tsconfig.lib.json"
19
- }
20
- },
21
- "defaultConfiguration": "production",
22
- "outputs": [
23
- "{workspaceRoot}/dist/tab-sdk"
24
- ]
25
- },
26
- "test": {
27
- "executor": "@angular-devkit/build-angular:karma",
28
- "options": {
29
- "tsConfig": "projects/tab-sdk/tsconfig.spec.json",
30
- "polyfills": [
31
- "zone.js",
32
- "zone.js/testing"
33
- ]
34
- }
35
- }
36
- }
37
- }
@@ -1,184 +0,0 @@
1
- import { inject, Injectable } from "@angular/core";
2
- import { AuthService } from "../core/auth.service";
3
- import { TabSdk } from "../tab-sdk.service";
4
-
5
- @Injectable({
6
- providedIn: 'root'
7
- })
8
- export class UtilsService {
9
- private readonly _authService: AuthService = inject(AuthService);
10
- private readonly _helperFunctionService: any = TabSdk.context?.HelperFunctionService;
11
-
12
-
13
- /**
14
- * Extracts the event name from various event parameter structures
15
- *
16
- * @example
17
- * const eventName = sdk.utils.extractEventName(screenParameters.event);
18
- * if (eventName === 'deleteDocument') {
19
- * // Handle delete document event
20
- * }
21
- */
22
- extractEventName(event: any): string {
23
- if (!event) return '';
24
-
25
- // Check common patterns for event names
26
- return event.event?.component?.configuration?.configScreen?.componentValue?.eventName ??
27
- event.detail?.type ??
28
- event.type ??
29
- event.name ??
30
- '';
31
- }
32
-
33
-
34
- /**
35
- * Builds an application URL with the specified path and parameters
36
- *
37
- * @example
38
- * // Get full URL with protocol
39
- * const fullUrl = sdk.utils.buildAppUrl('screen/12345', { id: '12345' });
40
- */
41
- buildAppUrl(
42
- path: string,
43
- parameters?: Record<string, any>,
44
- includeProtocol: boolean = true
45
- ): string {
46
- const appCode = this._authService.getAppCode();
47
- const params = new URLSearchParams();
48
-
49
- // Add parameters to the URL
50
- if (parameters) {
51
- Object.entries(parameters).forEach(([key, value]) => {
52
- if (value !== undefined && value !== null) {
53
- params.append(key, String(value));
54
- }
55
- });
56
- }
57
-
58
- // Build query string
59
- const queryString = params.toString() ? `?${params.toString()}` : '';
60
-
61
- // Build URL
62
- if (includeProtocol) {
63
- const host = window.location.host;
64
- return `http://${host}/${appCode}/${path}${queryString}`;
65
-
66
- } else {
67
- return `/${appCode}/${path}${queryString}`;
68
- }
69
- }
70
-
71
- /**
72
- * Generates and copies a screen URL to the clipboard
73
- *
74
- * @example
75
- * // Copy URL to clipboard
76
- * sdk.utils.copyScreenLink('12345', { id: '12345' });
77
- */
78
- copyScreenLinkToClipboard(
79
- screenId: string,
80
- parameters?: Record<string, any>
81
- ): any {
82
- const url = this.buildAppUrl(`screen/${screenId}`, parameters);
83
- return this._helperFunctionService.copyToClipboard(url);
84
- }
85
-
86
- /**
87
- * Downloads a blob as a file
88
- *
89
- * @example
90
- * // Download a blob as 'report.pdf'
91
- * const pdfBlob = new Blob([pdfContent], { type: 'application/pdf' });
92
- * sdk.utils.downloadBlob(pdfBlob, 'report.pdf');
93
- */
94
- downloadBlob(blob: Blob, filename: string): void {
95
- // Create object URL
96
- const url = URL.createObjectURL(blob);
97
-
98
- // Create download link
99
- const downloadLink = document.createElement('a');
100
- downloadLink.href = url;
101
- downloadLink.download = filename;
102
-
103
- // Append to body, click, and remove
104
- document.body.appendChild(downloadLink);
105
- downloadLink.click();
106
- document.body.removeChild(downloadLink);
107
-
108
- // Release object URL after a short delay to ensure download starts
109
- setTimeout(() => URL.revokeObjectURL(url), 100);
110
- }
111
-
112
- /**
113
- * Exports HTML content as a Word document (.doc)
114
- *
115
- * @example
116
- * // Export editor content as Word document
117
- * sdk.utils.exportAsWord(editorContent, 'report');
118
- */
119
- exportAsWord(content: string, filename: string = 'document'): void {
120
- // Format content with Word-compatible namespaces
121
- const docContent = `
122
- <html xmlns:o="urn:schemas-microsoft-com:office:office"
123
- xmlns:w="urn:schemas-microsoft-com:office:word"
124
- xmlns="http://www.w3.org/TR/REC-html40">
125
- <head>
126
- <meta charset="utf-8">
127
- <title>${filename}</title>
128
- </head>
129
- <body>${content}</body>
130
- </html>`;
131
-
132
- // Create blob with BOM for Word compatibility
133
- const blob = new Blob(['\ufeff', docContent], {
134
- type: 'application/msword'
135
- });
136
-
137
- // Use the downloadBlob utility
138
- this.downloadBlob(blob, `${filename}.doc`);
139
- }
140
-
141
-
142
- /**
143
- * Exports HTML content as PDF using browser print functionality
144
- *
145
- * @example
146
- * // Export content as PDF
147
- * sdk.utils.exportAsPdf(documentContent, 'Invoice');
148
- */
149
- exportAsPdf(content: string, title: string = 'Document'): void {
150
- // Open new window
151
- const printWindow: any = window.open('', '', 'width=800,height=600');
152
-
153
- // Add content with basic styling
154
- printWindow.document?.write(`
155
- <html>
156
- <head>
157
- <title>${title}</title>
158
- <style>
159
- body { font-family: Arial, sans-serif; margin: 20px; }
160
- @media print {
161
- body { margin: 0mm; }
162
- }
163
- </style>
164
- </head>
165
- <body>
166
- ${content}
167
- </body>
168
- </html>
169
- `);
170
-
171
- // Prepare for printing
172
- printWindow.document.close();
173
- printWindow.focus();
174
-
175
- // Use timeout to ensure content is rendered before printing
176
- setTimeout(() => {
177
- printWindow.print();
178
- // Close window after print dialog is closed or printing is complete
179
- printWindow.addEventListener('afterprint', () => {
180
- printWindow.close();
181
- });
182
- }, 300);
183
- }
184
- }
@@ -1,46 +0,0 @@
1
- import { inject, Injectable } from "@angular/core";
2
- import { LocalStorageService, SessionStorageService, StorageConstants } from "@techextensor/tab-core-utility";
3
-
4
- @Injectable({
5
- providedIn: 'root'
6
- })
7
- export class AuthService {
8
- private readonly _sessionStorageService: SessionStorageService = inject(SessionStorageService);
9
- private readonly _localStorageService: LocalStorageService = inject(LocalStorageService);
10
-
11
- /**
12
- * Get the current application code/identifier
13
- *
14
- * @example
15
- * const appCode = sdk.config.getAppCode();
16
- */
17
- getAppCode(): string {
18
- return this._sessionStorageService.getSessionStorage(StorageConstants.applicationCode) ?? '';
19
- }
20
-
21
- /**
22
- * Get the current user ID
23
- *
24
- * @example
25
- * const userId = sdk.auth.getCurrentUserId();
26
- */
27
- getCurrentUserId(): string {
28
- const userInfo = this.getCurrentUser();
29
- return userInfo?.user?.Id ?? '';
30
- }
31
-
32
- /**
33
- * Get the current user information
34
- *
35
- * @example
36
- * const user = sdk.auth.getCurrentUser();
37
- */
38
- getCurrentUser(): any {
39
- const userInfoStr = this._localStorageService.getLocalStorage(StorageConstants.userInfo);
40
- if (userInfoStr) {
41
- return JSON.parse(userInfoStr);
42
- }
43
-
44
- return null;
45
- }
46
- }
@@ -1,75 +0,0 @@
1
- import { inject, Injectable } from "@angular/core";
2
- import { TabDeleteService, TabInsertService, TabUpdateService } from '@techextensor/tab-core-utility';
3
-
4
- @Injectable({
5
- providedIn: 'root'
6
- })
7
- export class DataService {
8
- private readonly _tabInsertService: TabInsertService = inject(TabInsertService);
9
- private readonly _tabUpdateService: TabUpdateService = inject(TabUpdateService);
10
- private readonly _tabDeleteService: TabDeleteService = inject(TabDeleteService);
11
-
12
- /**
13
- * Insert a new record
14
- *
15
- * @example
16
- * const newRecord = await sdk.data.insert('123456', {
17
- * name: 'ACME Corp',
18
- * email: 'contact@acme.com'
19
- * });
20
- */
21
- insert(objectId: string, data: any): Promise<void> {
22
- return new Promise((resolve, reject) => {
23
- this._tabInsertService.insertByObjectId(objectId, { data })
24
- ?.subscribe((response: any) => {
25
- if (response?.StatusCode == 200 && response?.Result) {
26
- resolve(response.Result);
27
- } else {
28
- reject(new Error('Failed to insert record'));
29
- }
30
- });
31
- });
32
- }
33
-
34
- /**
35
- * Update an existing record
36
- *
37
- * @example
38
- * await sdk.data.update('12345', {
39
- * Id: '12345',
40
- * name: 'ACME Corporation',
41
- * status: 'active'
42
- * });
43
- */
44
- update(objectId: string, data: any): Promise<void> {
45
- return new Promise((resolve, reject) => {
46
- this._tabUpdateService.updateByObjectId(objectId, { data })
47
- ?.subscribe((response: any) => {
48
- if (response?.StatusCode == 200 && response?.Result) {
49
- resolve(response.Result);
50
- } else {
51
- reject(new Error('Failed to update record'));
52
- }
53
- });
54
- });
55
- }
56
-
57
- /**
58
- * Delete a record
59
- *
60
- * @example
61
- * await sdk.data.delete('12345', {Id: '12345'});
62
- */
63
- delete(objectId: string, data: any): Promise<void> {
64
- return new Promise((resolve, reject) => {
65
- this._tabDeleteService.deleteRecord('', {data}, objectId)
66
- ?.subscribe((response: any) => {
67
- if (response?.StatusCode == 200) {
68
- resolve();
69
- } else {
70
- reject(new Error('Failed to delete record'));
71
- }
72
- });
73
- });
74
- }
75
- }
@@ -1,45 +0,0 @@
1
- import { Injectable, Injector } from '@angular/core';
2
- import { DataService } from './data/data.service';
3
- import { UiService } from './ui/ui.service';
4
- import { FormService } from './ui/form.service';
5
- import { AuthService } from './core/auth.service';
6
- import { UtilsService } from './common/utils.service';
7
-
8
- @Injectable({
9
- providedIn: 'root'
10
- })
11
- export class TabSdk {
12
- public static data: DataService;
13
- public static ui: UiService;
14
- public static form: FormService;
15
- public static auth: AuthService;
16
- public static utils: UtilsService;
17
- public static context: any;
18
-
19
- /**
20
- * Initialize the SDK with necessary services
21
- */
22
- public static init(injector: Injector, context: any): void {
23
- // Expose to window for global access if needed
24
- (window as any).TabSdk = TabSdk;
25
-
26
- // external services
27
- this.context = context;
28
-
29
- // Initialize services
30
- this.data = injector.get(DataService);
31
- this.ui = injector.get(UiService);
32
- this.form = injector.get(FormService);
33
- this.auth = injector.get(AuthService);
34
- this.utils = injector.get(UtilsService);
35
-
36
- // Freeze the global object to prevent modifications
37
- Object.freeze(this);
38
- Object.freeze(this.context);
39
- Object.freeze(this.data);
40
- Object.freeze(this.ui);
41
- Object.freeze(this.form);
42
- Object.freeze(this.auth);
43
- Object.freeze(this.utils);
44
- }
45
- }
@@ -1,118 +0,0 @@
1
- import { Injectable } from "@angular/core";
2
- import { TabSdk } from "../tab-sdk.service";
3
-
4
- @Injectable({
5
- providedIn: 'root'
6
- })
7
- export class FormService {
8
- private readonly _helperFunctionService: any = TabSdk.context?.HelperFunctionService;
9
-
10
- /**
11
- * Processes form components with individual actions in a single pass
12
- *
13
- * @example
14
- * // Process multiple components with different actions in one pass
15
- * sdk.form.processComponents(
16
- * screenParameters.rendererInstance.form.components,
17
- * [
18
- * {
19
- * keys: 'documentDetails', // Single key
20
- * action: (component) => component.hidden = true,
21
- * type: 'columns' // Optional type filter
22
- * },
23
- * {
24
- * keys: 'documentPreview,documentComments', // Multiple keys as comma-separated string
25
- * action: (component) => component.hidden = false
26
- * }
27
- * ]
28
- * );
29
- */
30
- processComponents(
31
- components: any[],
32
- processors: Array<{
33
- keys: string, // Required: Component key(s) to match (comma-separated for multiple)
34
- type?: string, // Optional: Component type to match
35
- action: (component: any) => void // Action to perform on matched component
36
- }>
37
- ): void {
38
- if (!components || !Array.isArray(components) || !processors?.length) {
39
- return;
40
- }
41
-
42
- this._helperFunctionService?.eachComponent(components, (component: any) => {
43
- processors.forEach(processor => {
44
- // Split the keys string into an array
45
- const keyList = processor.keys.split(',').map(k => k.trim());
46
-
47
- // Check if component key is in the list of keys to process
48
- if (!keyList.includes(component.key)) return;
49
-
50
- // Check type match if specified
51
- if (processor.type && component.type !== processor.type) return;
52
-
53
- // All criteria matched, execute the action
54
- processor.action(component);
55
- });
56
- });
57
- }
58
-
59
- /**
60
- * Updates visibility of multiple form components at once
61
- *
62
- * @example
63
- * sdk.form.setComponentsVisibility(
64
- * screenParameters.rendererInstance.form.components,
65
- * {
66
- * 'documentDetails': false,
67
- * 'documentComments': true
68
- * }
69
- * );
70
- */
71
- setComponentsVisibility(
72
- components: any[],
73
- visibilityMap: Record<string, boolean>
74
- ): void {
75
- const keys = Object.keys(visibilityMap);
76
-
77
- this.processComponents(components,
78
- keys.map(key => ({
79
- keys: key,
80
- action: (component) => {
81
- component.hidden = visibilityMap[key];
82
- }
83
- }))
84
- );
85
- }
86
-
87
- /**
88
- * Finds components by key and returns them in a structured object
89
- *
90
- * @example
91
- * const components = sdk.form.findComponentsByKeys(
92
- * form.components,
93
- * ['documentDetails', 'documentPreview', 'documentComments']
94
- * );
95
- */
96
- findComponentsByKeys(
97
- components: any[],
98
- keys: string[],
99
- options?: {
100
- type?: string
101
- }
102
- ): Record<string, any> {
103
- const result: Record<string, any> = {};
104
-
105
- if (!components || !Array.isArray(components) || !keys?.length) {
106
- return result;
107
- }
108
-
109
- // Use the existing eachComponent helper
110
- this._helperFunctionService.eachComponent(components, (component: any) => {
111
- if (!options?.type || component.type === options.type) {
112
- result[component.key] = component;
113
- }
114
- }, keys);
115
-
116
- return result;
117
- }
118
- }
@@ -1,6 +0,0 @@
1
- import { Injectable } from "@angular/core";
2
-
3
- @Injectable({
4
- providedIn: 'root'
5
- })
6
- export class UiService {}
package/src/public-api.ts DELETED
@@ -1,5 +0,0 @@
1
- /*
2
- * Public API Surface of tab-sdk
3
- */
4
-
5
- export * from './lib/tab-sdk.service';
package/tsconfig.lib.json DELETED
@@ -1,15 +0,0 @@
1
- /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
- /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
- {
4
- "extends": "../../tsconfig.json",
5
- "compilerOptions": {
6
- "outDir": "../../out-tsc/lib",
7
- "declaration": true,
8
- "declarationMap": true,
9
- "inlineSources": true,
10
- "types": []
11
- },
12
- "exclude": [
13
- "**/*.spec.ts"
14
- ]
15
- }
@@ -1,11 +0,0 @@
1
- /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
- /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
- {
4
- "extends": "./tsconfig.lib.json",
5
- "compilerOptions": {
6
- "declarationMap": false
7
- },
8
- "angularCompilerOptions": {
9
- "compilationMode": "partial"
10
- }
11
- }
@@ -1,15 +0,0 @@
1
- /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
- /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
- {
4
- "extends": "../../tsconfig.json",
5
- "compilerOptions": {
6
- "outDir": "../../out-tsc/spec",
7
- "types": [
8
- "jasmine"
9
- ]
10
- },
11
- "include": [
12
- "**/*.spec.ts",
13
- "**/*.d.ts"
14
- ]
15
- }