@servicelabsco/slabs-access-manager 0.1.335 → 0.1.336

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.
@@ -153,7 +153,7 @@ declare const es6Classes: {
153
153
  enums: (typeof UiPoliciesTypeEnum | typeof DataViolationStatusTypeEnum | typeof ViolationColumnTypeEnum | typeof ViolationTypeEnum)[];
154
154
  jobs: (typeof PushToBulkItemJob | typeof AnalyseBulkUploadJob | typeof BulkDefinitionJob | typeof BulkDefinitionLoadJob | typeof BulkDefinitionProcessingJob | typeof BulkUploadColumnJob | typeof BulkUploadStatsJob | typeof BulkUploadItemJob | typeof BulkUploadJob | typeof BulkUploadTypeJob | typeof BusinessBulkDefinitionJob | typeof BusinessUiPoliciesJob | typeof BusinessViolationJob | typeof DataAccessJob | typeof DataMappingJob | typeof DataViolationJob | typeof EmailNotificationJob | typeof GchatNotificationJob | typeof GstStateJob | typeof InappNotificationJob | typeof ItemUnitJob | typeof ItemViolationJob | typeof ListingModelJob | typeof NotificationJob | typeof NotificationRecipientJob | typeof PdfLogJob | typeof PdfDocumentJob | typeof SlackNotificationJob | typeof SmsNotificationJob | typeof TagAssignmentJob | typeof UiPoliciesJob | typeof UploadModificationJob | typeof ViolationDefinitionJob | typeof WebhookRequestJob | typeof WhatsappNotificationJob)[];
155
155
  libraries: (typeof ReadXlsFile | typeof AnalyseBulkUpload | typeof ProcessCommonData | typeof ProcessBulkDefinitionData | typeof ProcessBulkDefinitionList | typeof ProcessItemUnitData | typeof ProcessItemUnitList | typeof ProcessViolationDefinitionList | typeof ProcessManualPdfDocument | typeof GenerateBulkUploadSheet | typeof JsonEvaluator | typeof LoadXlsFile | typeof ProcessPdfDocument | typeof ProcessReportListing | typeof SetBulkUploadLogFile | typeof SlabsUtil)[];
156
- services: (typeof BulkUploadService | typeof FileUploadService | typeof PdfService | typeof PdfDocumentService | typeof LambdaService | typeof DataAccessService | typeof Es6JobsService | typeof Es6Service | typeof ZipService)[];
156
+ services: (typeof BulkUploadService | typeof FileUploadService | typeof PdfService | typeof PdfDocumentService | typeof LambdaService | typeof DataAccessService | typeof Es6JobsService | typeof ZipService | typeof Es6Service)[];
157
157
  subscribers: (typeof BulkDefinitionLoadSubscriber | typeof BulkDefinitionProcessingSubscriber | typeof BulkDefinitionSubscriber | typeof BulkUploadColumnSubscriber | typeof BulkUploadItemSubscriber | typeof BulkUploadSubscriber | typeof BulkUploadTypeSubscriber | typeof BusinessBulkDefinitionSubscriber | typeof BusinessUiPoliciesSubscriber | typeof BusinessViolationSubscriber | typeof DataAccessSubscriber | typeof DataMappingSubscriber | typeof DataViolationSubscriber | typeof EmailNotificationSubscriber | typeof GchatNotificationSubscriber | typeof GstStateSubscriber | typeof InappNotificationSubscriber | typeof ItemUnitSubscriber | typeof ItemViolationSubscriber | typeof ListingModelSubscriber | typeof NotificationRecipientSubscriber | typeof NotificationSubscriber | typeof PdfDocumentSubscriber | typeof PdfLogSubscriber | typeof SlackNotificationSubscriber | typeof SmsNotificationSubscriber | typeof TagAssignmentSubscriber | typeof UiPoliciesSubscriber | typeof UploadModificationSubscriber | typeof ViolationDefinitionSubscriber | typeof WebhookRequestSubscriber | typeof WhatsappNotificationSubscriber)[];
158
158
  };
159
159
  export default es6Classes;
@@ -1,10 +1,12 @@
1
1
  import { FileUploadService } from './file.upload.service';
2
2
  import { PdfService } from './pdf.service';
3
+ import { ZipService } from './zip.service';
3
4
  export declare class Es6Service {
4
5
  private readonly fileUploadService;
5
6
  private readonly pdfService;
7
+ private readonly zipService;
6
8
  private services;
7
- constructor(fileUploadService: FileUploadService, pdfService: PdfService);
9
+ constructor(fileUploadService: FileUploadService, pdfService: PdfService, zipService: ZipService);
8
10
  alignServices(): void;
9
11
  setServices(): void;
10
12
  }
@@ -13,11 +13,13 @@ exports.Es6Service = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const file_upload_service_1 = require("./file.upload.service");
15
15
  const pdf_service_1 = require("./pdf.service");
16
+ const zip_service_1 = require("./zip.service");
16
17
  const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
17
18
  let Es6Service = class Es6Service {
18
- constructor(fileUploadService, pdfService) {
19
+ constructor(fileUploadService, pdfService, zipService) {
19
20
  this.fileUploadService = fileUploadService;
20
21
  this.pdfService = pdfService;
22
+ this.zipService = zipService;
21
23
  this.services = {};
22
24
  this.alignServices();
23
25
  this.setServices();
@@ -26,6 +28,7 @@ let Es6Service = class Es6Service {
26
28
  this.services = {
27
29
  '3d34874e5c7f60541cf15f2c6ce48916': this.fileUploadService,
28
30
  '1d1bba2785aca011c9e0a6e5fbe69f64': this.pdfService,
31
+ '33924afe775341ede452e7a2c89b8c87': this.zipService,
29
32
  };
30
33
  }
31
34
  setServices() {
@@ -36,6 +39,7 @@ exports.Es6Service = Es6Service;
36
39
  exports.Es6Service = Es6Service = __decorate([
37
40
  (0, common_1.Injectable)(),
38
41
  __metadata("design:paramtypes", [file_upload_service_1.FileUploadService,
39
- pdf_service_1.PdfService])
42
+ pdf_service_1.PdfService,
43
+ zip_service_1.ZipService])
40
44
  ], Es6Service);
41
45
  //# sourceMappingURL=es6.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"es6.service.js","sourceRoot":"","sources":["../../../src/accessUtility/services/es6.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+DAA0D;AAC1D,+CAA2C;AAC3C,oFAAyE;AAQlE,IAAM,UAAU,GAAhB,MAAM,UAAU;IAGnB,YACqB,iBAAoC,EACpC,UAAsB;QADtB,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,eAAU,GAAV,UAAU,CAAY;QAJnC,aAAQ,GAAG,EAAE,CAAC;QAMlB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAMD,aAAa;QACT,IAAI,CAAC,QAAQ,GAAG;YACZ,kCAAkC,EAAE,IAAI,CAAC,iBAAiB;YAC1D,kCAAkC,EAAE,IAAI,CAAC,UAAU;SACtD,CAAC;IACN,CAAC;IAMD,WAAW;QACP,yCAAe,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;CACJ,CAAA;AA7BY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAK+B,uCAAiB;QACxB,wBAAU;GALlC,UAAU,CA6BtB"}
1
+ {"version":3,"file":"es6.service.js","sourceRoot":"","sources":["../../../src/accessUtility/services/es6.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+DAA0D;AAC1D,+CAA2C;AAC3C,+CAA2C;AAC3C,oFAAyE;AAQlE,IAAM,UAAU,GAAhB,MAAM,UAAU;IAGnB,YACqB,iBAAoC,EACpC,UAAsB,EACtB,UAAsB;QAFtB,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,eAAU,GAAV,UAAU,CAAY;QACtB,eAAU,GAAV,UAAU,CAAY;QALnC,aAAQ,GAAG,EAAE,CAAC;QAOlB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAMD,aAAa;QACT,IAAI,CAAC,QAAQ,GAAG;YACZ,kCAAkC,EAAE,IAAI,CAAC,iBAAiB;YAC1D,kCAAkC,EAAE,IAAI,CAAC,UAAU;YACnD,kCAAkC,EAAE,IAAI,CAAC,UAAU;SACtD,CAAC;IACN,CAAC;IAMD,WAAW;QACP,yCAAe,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;CACJ,CAAA;AA/BY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAK+B,uCAAiB;QACxB,wBAAU;QACV,wBAAU;GANlC,UAAU,CA+BtB"}
@@ -1,43 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
7
  };
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
8
  var __metadata = (this && this.__metadata) || function (k, v) {
42
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
10
  };
@@ -47,7 +14,6 @@ const common_1 = require("@nestjs/common");
47
14
  const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
48
15
  const pdf_templates_entity_1 = require("../entities/pdf.templates.entity");
49
16
  const file_upload_service_1 = require("./file.upload.service");
50
- const Handlebars = __importStar(require("handlebars"));
51
17
  let PdfService = class PdfService extends nestjs_utility_services_1.CommonService {
52
18
  constructor(propertyService, fileUploadService, remoteRequestService) {
53
19
  super();
@@ -62,16 +28,15 @@ let PdfService = class PdfService extends nestjs_utility_services_1.CommonServic
62
28
  }
63
29
  async getHtmlUrl(template, data, path) {
64
30
  const { script } = await pdf_templates_entity_1.PdfTemplatesEntity.findOne({ where: { identifier: template }, relations: ['script'] });
65
- const compiledData = Handlebars.compile(script.script);
66
- const htmlContent = compiledData(data);
67
- const uniqueString = nestjs_utility_services_1.PlatformUtility.getFileName('gross-collection');
31
+ const compiledData = nestjs_utility_services_1.PlatformUtility.compileHandlebar(script.script, data);
32
+ const uniqueString = nestjs_utility_services_1.PlatformUtility.getFileName(template);
68
33
  const filename = `${uniqueString}.html`;
69
34
  const urlKey = `${path}/${filename}`;
70
35
  const bucket = await this.propertyService.get('aws.config.bucket');
71
36
  const params = {
72
37
  Bucket: bucket,
73
38
  Key: urlKey,
74
- Body: htmlContent,
39
+ Body: compiledData,
75
40
  ContentType: 'text/html',
76
41
  ACL: 'public-read',
77
42
  };
@@ -89,16 +54,29 @@ let PdfService = class PdfService extends nestjs_utility_services_1.CommonServic
89
54
  data: {
90
55
  html_url: url,
91
56
  },
57
+ timeout: 900000,
92
58
  };
93
- const response = await this.remoteRequestService.sendThroughAxios(options);
94
- if (!response?.success)
95
- throw new nestjs_utility_services_1.OperationException(response?.message);
96
- return response?.pdf?.url;
59
+ try {
60
+ const response = await this.remoteRequestService.sendThroughAxios(options);
61
+ if (!response?.data?.success) {
62
+ throw new nestjs_utility_services_1.OperationException(response?.data?.error || response?.data?.message || 'Failed to convert HTML to PDF');
63
+ }
64
+ return response?.data?.pdf?.url;
65
+ }
66
+ catch (error) {
67
+ if (error.response?.data) {
68
+ throw new nestjs_utility_services_1.OperationException(error.response.data.error || error.response.data.message);
69
+ }
70
+ throw error;
71
+ }
97
72
  }
98
73
  async getToken() {
99
74
  if (this.token)
100
75
  return this.token;
101
76
  this.token = await this.propertyService.get('html.to.pdf.token');
77
+ if (!this.token)
78
+ throw new nestjs_utility_services_1.OperationException('HTML-to-PDF token not found, set property html.to.pdf.token');
79
+ return this.token;
102
80
  }
103
81
  };
104
82
  exports.PdfService = PdfService;
@@ -1 +1 @@
1
- {"version":3,"file":"pdf.service.js","sourceRoot":"","sources":["../../../src/accessUtility/services/pdf.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,oFAAmJ;AACnJ,2EAAsE;AACtE,+DAA0D;AAC1D,uDAAyC;AAOlC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,uCAAa;IASzC,YACuB,eAAgC,EAChC,iBAAoC,EACpC,oBAA0C;QAE7D,KAAK,EAAE,CAAC;QAJW,oBAAe,GAAf,eAAe,CAAiB;QAChC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,yBAAoB,GAApB,oBAAoB,CAAsB;QAXvD,kBAAa,GAAG,IAAI,CAAC;IAc/B,CAAC;IASD,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,IAAS,EAAE,IAAY;QAClD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IASD,KAAK,CAAC,UAAU,CAAC,QAAgB,EAAE,IAAS,EAAE,IAAY;QACtD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,yCAAkB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC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AED,OAAO,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEb,IAAI,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACvB,MAAM,IAAI,4CAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3F,CAAC;YACD,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAMO,KAAK,CAAC,QAAQ;QAClB,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAEjE,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,4CAAkB,CAAC,6DAA6D,CAAC,CAAC;QAE7G,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;CACJ,CAAA;AAzGY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAW+B,yCAAe;QACb,uCAAiB;QACd,8CAAoB;GAZxD,UAAU,CAyGtB"}
@@ -1,11 +1,14 @@
1
- import { PropertyService, RemoteRequestService } from '@servicelabsco/nestjs-utility-services';
1
+ import { CommonService, PropertyService, RemoteRequestService } from '@servicelabsco/nestjs-utility-services';
2
2
  import { LambdaZipDto } from '../dtos/lambda.zip.dto';
3
- export declare class ZipService {
3
+ export declare class ZipService extends CommonService {
4
4
  protected readonly propertyService: PropertyService;
5
5
  protected readonly remoteRequestService: RemoteRequestService;
6
6
  private zipToken;
7
+ private unzipToken;
8
+ protected publicExposed: boolean;
7
9
  constructor(propertyService: PropertyService, remoteRequestService: RemoteRequestService);
8
10
  zip(files: LambdaZipDto[]): Promise<any>;
9
- unzip(zip: string): Promise<string[]>;
11
+ unzip(url: string): Promise<string[]>;
10
12
  private getZipToken;
13
+ private getUnzipToken;
11
14
  }
@@ -12,10 +12,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ZipService = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
15
- let ZipService = class ZipService {
15
+ let ZipService = class ZipService extends nestjs_utility_services_1.CommonService {
16
16
  constructor(propertyService, remoteRequestService) {
17
+ super();
17
18
  this.propertyService = propertyService;
18
19
  this.remoteRequestService = remoteRequestService;
20
+ this.publicExposed = true;
19
21
  }
20
22
  async zip(files) {
21
23
  const token = await this.getZipToken();
@@ -30,17 +32,67 @@ let ZipService = class ZipService {
30
32
  },
31
33
  data: files,
32
34
  timeout: 900000,
35
+ maxBodyLength: Infinity,
33
36
  };
34
- const response = await this.remoteRequestService.sendThroughAxios(options);
35
- return response?.data?.zipUrl;
37
+ try {
38
+ const response = await this.remoteRequestService.sendThroughAxios(options);
39
+ if (response?.data?.success) {
40
+ return response.data.zipUrl;
41
+ }
42
+ const apiError = response?.data?.error || 'Failed to create zip file';
43
+ throw new nestjs_utility_services_1.OperationException(apiError);
44
+ }
45
+ catch (error) {
46
+ if (error instanceof nestjs_utility_services_1.OperationException)
47
+ throw error;
48
+ const message = error?.response?.data?.error ?? error?.response?.data?.message ?? error?.message ?? 'Zip request failed';
49
+ throw new nestjs_utility_services_1.OperationException(message);
50
+ }
36
51
  }
37
- async unzip(zip) {
38
- return ['file1', 'file2', 'file3'];
52
+ async unzip(url) {
53
+ const token = await this.getUnzipToken();
54
+ if (!token)
55
+ throw new nestjs_utility_services_1.OperationException('Unzip token not found');
56
+ const options = {
57
+ method: 'post',
58
+ maxBodyLength: Infinity,
59
+ url: 'https://stogyux6hk.execute-api.ap-south-1.amazonaws.com/prod/unzip-files',
60
+ headers: {
61
+ Authorization: `Bearer ${token}`,
62
+ 'Content-Type': 'application/json',
63
+ },
64
+ data: { url },
65
+ };
66
+ try {
67
+ const response = await this.remoteRequestService.sendThroughAxios(options);
68
+ if (response?.data?.success) {
69
+ return response.data.files || [];
70
+ }
71
+ const apiError = response?.data?.error || 'Failed to unzip file';
72
+ throw new nestjs_utility_services_1.OperationException(apiError);
73
+ }
74
+ catch (error) {
75
+ if (error instanceof nestjs_utility_services_1.OperationException)
76
+ throw error;
77
+ const message = error?.response?.data?.error ?? error?.response?.data?.message ?? error?.message ?? 'Unzip request failed';
78
+ throw new nestjs_utility_services_1.OperationException(message);
79
+ }
39
80
  }
40
81
  async getZipToken() {
41
82
  if (this.zipToken)
42
83
  return this.zipToken;
43
84
  this.zipToken = await this.propertyService.get('slabs.lambda.zip.token');
85
+ if (!this.zipToken)
86
+ throw new nestjs_utility_services_1.OperationException('Zip token not found, set property slabs.lambda.zip.token');
87
+ return this.zipToken;
88
+ }
89
+ async getUnzipToken() {
90
+ if (this.unzipToken)
91
+ return this.unzipToken;
92
+ this.unzipToken = await this.propertyService.get('slabs.lambda.unzip.token');
93
+ if (!this.unzipToken)
94
+ throw new nestjs_utility_services_1.OperationException('Unzip token not found, set property slabs.lambda.unzip.token');
95
+ return this.unzipToken;
44
96
  }
45
97
  };
46
98
  exports.ZipService = ZipService;
@@ -1 +1 @@
1
- {"version":3,"file":"zip.service.js","sourceRoot":"","sources":["../../../src/accessUtility/services/zip.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,oFAAmH;AAI5G,IAAM,UAAU,GAAhB,MAAM,UAAU;IAGnB,YACuB,eAAgC,EAChC,oBAA0C;QAD1C,oBAAe,GAAf,eAAe,CAAiB;QAChC,yBAAoB,GAApB,oBAAoB,CAAsB;IAC9D,CAAC;IAEJ,KAAK,CAAC,GAAG,CAAC,KAAqB;QAC3B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,4CAAkB,CAAC,qBAAqB,CAAC,CAAC;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,CAAC;IAMO,KAAK,CAAC,aAAa;QACvB,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC;QAC5C,IAAI,CAAC,UAAU,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QAC7E,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,MAAM,IAAI,4CAAkB,CAAC,8DAA8D,CAAC,CAAC;QAEnH,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;CACJ,CAAA;AA1GY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAQ+B,yCAAe;QACV,8CAAoB;GARxD,UAAU,CA0GtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicelabsco/slabs-access-manager",
3
- "version": "0.1.335",
3
+ "version": "0.1.336",
4
4
  "description": "Support for application level menus and dashboards",
5
5
  "author": "Hemant Kumar Sah <hemantanshu@gmail.com>",
6
6
  "license": "MIT",