@simitgroup/simpleapp-generator 2.0.3-e-alpha → 2.0.3-f-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReleaseNote.md +4 -0
- package/package.json +1 -1
- package/templates/nest/src/simple-app/_core/features/mini-app/mini-app-manager/mini-app-manager-policy.service.ts.eta +2 -2
- package/templates/nest/src/simple-app/_core/features/policy/policy.service.ts.eta +3 -4
- package/templates/nuxt/composables/date.generate.ts.eta +18 -17
- package/templates/nest/src/simple-app/config/license-types/index.ts._eta +0 -1
package/ReleaseNote.md
CHANGED
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { PolicyService } from 'src/simple-app/_core/features/policy/policy.servi
|
|
|
5
5
|
import { Role } from 'src/simple-app/_core/features/auth/role-guard/roles.enum';
|
|
6
6
|
import { UserContext } from 'src/simple-app/_core/features/user-context/user.context';
|
|
7
7
|
import { MiniApp } from '../dto';
|
|
8
|
-
import licenseTypes,
|
|
8
|
+
import { licenses as licenseTypes, BaseLicense } from '@simtrain/shared/license';
|
|
9
9
|
@Injectable()
|
|
10
10
|
export class MiniAppManagerPolicyService {
|
|
11
11
|
readonly _RELEASED_STATUSES = [MiniAppStatusEnum.PUBLISHED];
|
|
@@ -33,7 +33,7 @@ export class MiniAppManagerPolicyService {
|
|
|
33
33
|
// const requiredPlans = miniApp.access.requiredPlans ?? [];
|
|
34
34
|
|
|
35
35
|
if (licenseTypes[currentLicense]) {
|
|
36
|
-
const licenseSetting:BaseLicense = licenseTypes[currentLicense]
|
|
36
|
+
const licenseSetting: BaseLicense = licenseTypes[currentLicense];
|
|
37
37
|
return licenseSetting?.feature?.miniApp ?? false;
|
|
38
38
|
} else {
|
|
39
39
|
return false;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { BaseLicense, HasType, licenses as licenseTypes } from '@simtrain/shared/license';
|
|
2
3
|
import { Role } from 'src/simple-app/_core/features/auth/role-guard/roles.enum';
|
|
3
4
|
import { UserContext } from 'src/simple-app/_core/features/user-context/user.context';
|
|
4
|
-
import licenseTypes,{BaseLicense} from 'src/simple-app/config/license-types';
|
|
5
|
-
import { HasType } from 'src/simple-app/config/license-types/license.type';
|
|
6
5
|
@Injectable()
|
|
7
6
|
export class PolicyService {
|
|
8
7
|
private readonly _HIGH_PRIVILEGE_ROLES = [Role.SuperAdmin, Role.SuperUser, Role.TenantOwner];
|
|
@@ -27,8 +26,8 @@ export class PolicyService {
|
|
|
27
26
|
hasFeature(appUser: UserContext, feature: string): boolean {
|
|
28
27
|
const appLicense = appUser.tenantInfo?.license ?? 'free';
|
|
29
28
|
// const allowedPlans = this._FEATURES[feature];
|
|
30
|
-
const licenseSetting:BaseLicense = licenseTypes[appLicense]
|
|
31
|
-
const allowed = licenseSetting.has(HasType.feature,feature) ?? false;
|
|
29
|
+
const licenseSetting: BaseLicense = licenseTypes[appLicense];
|
|
30
|
+
const allowed = licenseSetting.has(HasType.feature, feature) ?? false;
|
|
32
31
|
return allowed;
|
|
33
32
|
}
|
|
34
33
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* last change 2024-04-13
|
|
5
5
|
* Author: Ks Tan
|
|
6
6
|
*/
|
|
7
|
+
import dayjs from 'dayjs'
|
|
7
8
|
import { DateTime } from "luxon";
|
|
8
9
|
import {
|
|
9
10
|
dayjsDateFormatToPrimeVue,
|
|
@@ -16,13 +17,13 @@ const convertToDate = (date: Date | string) => {
|
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
//after review
|
|
19
|
-
export const today = () =>
|
|
20
|
+
export const today = () => dayjs().format("YYYY-MM-DD");
|
|
20
21
|
|
|
21
22
|
export const formatDateByOrgFormat = (date: Date | string) =>
|
|
22
|
-
|
|
23
|
+
dayjs(date).format(getDateFormat());
|
|
23
24
|
|
|
24
25
|
export const formatDateTimeByOrgFormat = (date: Date | string) =>
|
|
25
|
-
|
|
26
|
+
dayjs(date).format(getDateTimeFormat());
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* convert date object or ISO8601 date become local datetime string
|
|
@@ -65,44 +66,44 @@ export const stringToDate = (datestr: string) => new Date(datestr);
|
|
|
65
66
|
*/
|
|
66
67
|
export const dateToISOString = (date: Date | string) =>
|
|
67
68
|
convertToDate(date).toISOString().split(".")[0] + "Z";
|
|
68
|
-
//
|
|
69
|
+
//dayjs(date).toISOString().split('.')[0]+"Z"
|
|
69
70
|
/**
|
|
70
71
|
* convert date object to date string (YYYY-MM-DD)
|
|
71
72
|
* @param date :Date
|
|
72
73
|
* @returns date return string in YYYY-MM-DD
|
|
73
74
|
*/
|
|
74
|
-
export const dateToString = (date: Date | string) =>
|
|
75
|
+
export const dateToString = (date: Date | string) => dayjs(date).format("YYYY-MM-DD");
|
|
75
76
|
/**
|
|
76
77
|
* convert date object to time string (HH:mm:ss)
|
|
77
78
|
* @param date
|
|
78
79
|
* @returns timestring
|
|
79
80
|
*/
|
|
80
|
-
export const dateToTimeString = (date: Date) =>
|
|
81
|
+
export const dateToTimeString = (date: Date) => dayjs(date).format("HH:mm:ss");
|
|
81
82
|
/**
|
|
82
83
|
* get 3 char day name sun/mon/tue in lower case
|
|
83
84
|
* @param date : Date|string date obj or iso8601 date
|
|
84
85
|
* @returns string
|
|
85
86
|
*/
|
|
86
87
|
export const getDayNameInWeek = (date: Date | string) =>
|
|
87
|
-
|
|
88
|
+
dayjs(date).format("ddd").toLowerCase();
|
|
88
89
|
/**
|
|
89
90
|
* get last date of the specific date
|
|
90
91
|
* @param dates: Date|string
|
|
91
92
|
* @returns string
|
|
92
93
|
*/
|
|
93
94
|
export const lastDateOfMonth = (date: Date | string) =>
|
|
94
|
-
|
|
95
|
+
dayjs(date).endOf("month").format("YYYY-MM-DD");
|
|
95
96
|
|
|
96
97
|
//before reevaluate
|
|
97
98
|
|
|
98
|
-
export const setDateLocale = (localename: string) =>
|
|
99
|
+
export const setDateLocale = (localename: string) => dayjs.locale(localename);
|
|
99
100
|
export const dateExists = (date: Date, listDate: Date[]) => {
|
|
100
101
|
const existsrecord = listDate.find((item) => {
|
|
101
102
|
return date.getTime() === item.getTime();
|
|
102
103
|
});
|
|
103
104
|
return existsrecord === undefined ? false : true;
|
|
104
105
|
};
|
|
105
|
-
export const getDayJs = () =>
|
|
106
|
+
export const getDayJs = () => dayjs;
|
|
106
107
|
|
|
107
108
|
export const dateToISOWithoutConvert = (date: Date) => {
|
|
108
109
|
const timestamp = date.getTime() - date.getTimezoneOffset() * 60000;
|
|
@@ -116,15 +117,15 @@ export const convertIsoToDateToWithoutConvert = (datestr: string) => {
|
|
|
116
117
|
};
|
|
117
118
|
|
|
118
119
|
export const dateToDateTimeString = (date: Date) =>
|
|
119
|
-
|
|
120
|
-
export const toLocalDate = (date: string | Date) =>
|
|
120
|
+
dayjs.utc(date).format("YYYY-MM-DD HH:mm:ss");
|
|
121
|
+
export const toLocalDate = (date: string | Date) => dayjs(date).format(getDateFormat());
|
|
121
122
|
export const toLocalDateTime = (date: string | Date) =>
|
|
122
|
-
|
|
123
|
+
dayjs.utc(date).format(getDateTimeFormat());
|
|
123
124
|
|
|
124
|
-
export const toUTCDate = (date: string | Date) =>
|
|
125
|
+
export const toUTCDate = (date: string | Date) => dayjs.utc(date).format(getDateFormat());
|
|
125
126
|
export const toUTCDateTime = (date: string | Date) =>
|
|
126
|
-
|
|
127
|
-
export const toUTCTime = (date: string | Date) =>
|
|
127
|
+
dayjs.utc(date).format(getDateTimeFormat());
|
|
128
|
+
export const toUTCTime = (date: string | Date) => dayjs.utc(date).format("HH:mm");
|
|
128
129
|
export const getDateFormat = (): string => {
|
|
129
130
|
const profile = getUserProfile();
|
|
130
131
|
const orgDateFormat = profile?.orgInfo?.dateFormat?.trim();
|
|
@@ -141,7 +142,7 @@ export const addTime = (date: Date | string, duration: number, unit: DurationTyp
|
|
|
141
142
|
getDayJs()(date).add(duration, "hour").toDate();
|
|
142
143
|
|
|
143
144
|
export const utcToLocalOffset = (utcTime: string, timeZoneOffset: number) => {
|
|
144
|
-
return
|
|
145
|
+
return dayjs.utc(utcTime).utcOffset(Number(timeZoneOffset));
|
|
145
146
|
};
|
|
146
147
|
|
|
147
148
|
export const getOffsetMinutesTimeZone = (timeZone: string, date: Date = new Date()): number => {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const license1 = {id:"app"}
|