@olenbetong/appframe-core 2.1.2 → 2.3.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.
package/es/date.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function toLocalISODate(date: Date): string;
2
+ export declare function toLocalISODateTime(date: Date): string;
package/es/date.js ADDED
@@ -0,0 +1,12 @@
1
+ export function toLocalISODate(date) {
2
+ return toLocalISODateTime(date).substring(0, 10);
3
+ }
4
+ export function toLocalISODateTime(date) {
5
+ let newDate = new Date(date);
6
+ newDate.setUTCFullYear(date.getFullYear());
7
+ newDate.setUTCMonth(date.getMonth());
8
+ newDate.setUTCDate(date.getDate());
9
+ newDate.setUTCHours(date.getHours());
10
+ newDate.setUTCMinutes(date.getMinutes());
11
+ return newDate.toISOString().replace("Z", "");
12
+ }
@@ -0,0 +1,31 @@
1
+ export declare type ImageSize = "xs" | "sm" | "md" | "lg" | "xl";
2
+ export interface getUserImageOptions {
3
+ /**
4
+ * Prim key of the record in atbl_Personnel_Employees
5
+ */
6
+ primKey: string | null;
7
+ /**
8
+ * Person ID of the employee
9
+ */
10
+ login: string | null;
11
+ /**
12
+ * The value of the ImageHash column in atbl_Personnel_Employees
13
+ */
14
+ hash: string | number | null;
15
+ /**
16
+ * The image will be resized according to this value. Default is 'xs':
17
+ * - xs: 64px
18
+ * - sm: 128px
19
+ * - md: 256px
20
+ * - lg: 512px
21
+ * - xl: image is not resized
22
+ */
23
+ size?: ImageSize;
24
+ }
25
+ /**
26
+ * Returns the absolute path of a users profile picture. Uses the EmployeesLookup
27
+ * data resource to enable caching across applications.
28
+ *
29
+ * If one of primKey or hash are not provided, or are null, an empty string will be returned.
30
+ */
31
+ export declare function getUserImage({ primKey, login, hash, size }: getUserImageOptions): string;
@@ -0,0 +1,20 @@
1
+ const sizeMap = {
2
+ xs: 64,
3
+ sm: 128,
4
+ md: 256,
5
+ lg: 512,
6
+ xl: undefined,
7
+ };
8
+ /**
9
+ * Returns the absolute path of a users profile picture. Uses the EmployeesLookup
10
+ * data resource to enable caching across applications.
11
+ *
12
+ * If one of primKey or hash are not provided, or are null, an empty string will be returned.
13
+ */
14
+ export function getUserImage({ primKey, login, hash, size = "xs" }) {
15
+ if (!primKey || !hash) {
16
+ return "";
17
+ }
18
+ let sizePx = sizeMap[size];
19
+ return `/api/data/blob/EmployeesLookup/${primKey}/Image/${login}${login ? "." : ""}${hash}.jpg${sizePx ? `?width=${sizePx}` : ""}`;
20
+ }
package/es/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import "./errorHandler.js";
2
2
  import { UserSession } from "./UserSession.js";
3
3
  export { default as mitt } from "mitt";
4
+ export * from "./date.js";
4
5
  export { downloadBlob } from "./downloadBlob.js";
5
6
  export * from "./downloadRequest.js";
6
7
  export { expose } from "./expose.js";
8
+ export * from "./getUserImage.js";
7
9
  export { getLocalizedString } from "./getLocalizedString.js";
8
10
  export { localize } from "./localize.js";
9
11
  export * from "./has.js";
package/es/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import "./errorHandler.js";
2
2
  import { UserSession } from "./UserSession.js";
3
3
  export { default as mitt } from "mitt";
4
+ export * from "./date.js";
4
5
  export { downloadBlob } from "./downloadBlob.js";
5
6
  export * from "./downloadRequest.js";
6
7
  export { expose } from "./expose.js";
8
+ export * from "./getUserImage.js";
7
9
  export { getLocalizedString } from "./getLocalizedString.js";
8
10
  export { localize } from "./localize.js";
9
11
  export * from "./has.js";
@@ -11,4 +13,4 @@ export { default as localStorage } from "./localStorage.js";
11
13
  export { default as SessionHandler } from "./SessionHandler.js";
12
14
  export { UserSession };
13
15
  export * from "./settings.js";
14
- export const version = "2.1.2";
16
+ export const version = "2.3.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/appframe-core",
3
- "version": "2.1.2",
3
+ "version": "2.3.0",
4
4
  "description": "Javascript libraries to utilize the Appframe framework",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -48,5 +48,5 @@
48
48
  "devDependencies": {
49
49
  "chalk": "^5.0.1"
50
50
  },
51
- "gitHead": "16ac538bb4913c802543c23671e4169fa7c7607b"
51
+ "gitHead": "266f97a293771bb2c7e5a97fad143240c6c4e446"
52
52
  }
package/src/date.ts ADDED
@@ -0,0 +1,14 @@
1
+ export function toLocalISODate(date: Date) {
2
+ return toLocalISODateTime(date).substring(0, 10);
3
+ }
4
+
5
+ export function toLocalISODateTime(date: Date) {
6
+ let newDate = new Date(date);
7
+ newDate.setUTCFullYear(date.getFullYear());
8
+ newDate.setUTCMonth(date.getMonth());
9
+ newDate.setUTCDate(date.getDate());
10
+ newDate.setUTCHours(date.getHours());
11
+ newDate.setUTCMinutes(date.getMinutes());
12
+
13
+ return newDate.toISOString().replace("Z", "");
14
+ }
@@ -0,0 +1,50 @@
1
+ export type ImageSize = "xs" | "sm" | "md" | "lg" | "xl";
2
+
3
+ export interface getUserImageOptions {
4
+ /**
5
+ * Prim key of the record in atbl_Personnel_Employees
6
+ */
7
+ primKey: string | null;
8
+ /**
9
+ * Person ID of the employee
10
+ */
11
+ login: string | null;
12
+ /**
13
+ * The value of the ImageHash column in atbl_Personnel_Employees
14
+ */
15
+ hash: string | number | null;
16
+ /**
17
+ * The image will be resized according to this value. Default is 'xs':
18
+ * - xs: 64px
19
+ * - sm: 128px
20
+ * - md: 256px
21
+ * - lg: 512px
22
+ * - xl: image is not resized
23
+ */
24
+ size?: ImageSize;
25
+ }
26
+
27
+ const sizeMap: Record<ImageSize, number | undefined> = {
28
+ xs: 64,
29
+ sm: 128,
30
+ md: 256,
31
+ lg: 512,
32
+ xl: undefined,
33
+ };
34
+
35
+ /**
36
+ * Returns the absolute path of a users profile picture. Uses the EmployeesLookup
37
+ * data resource to enable caching across applications.
38
+ *
39
+ * If one of primKey or hash are not provided, or are null, an empty string will be returned.
40
+ */
41
+ export function getUserImage({ primKey, login, hash, size = "xs" }: getUserImageOptions) {
42
+ if (!primKey || !hash) {
43
+ return "";
44
+ }
45
+
46
+ let sizePx = sizeMap[size];
47
+ return `/api/data/blob/EmployeesLookup/${primKey}/Image/${login}${login ? "." : ""}${hash}.jpg${
48
+ sizePx ? `?width=${sizePx}` : ""
49
+ }`;
50
+ }
package/src/index.ts CHANGED
@@ -3,9 +3,11 @@ import "./errorHandler.js";
3
3
  import { UserSession } from "./UserSession.js";
4
4
 
5
5
  export { default as mitt } from "mitt";
6
+ export * from "./date.js";
6
7
  export { downloadBlob } from "./downloadBlob.js";
7
8
  export * from "./downloadRequest.js";
8
9
  export { expose } from "./expose.js";
10
+ export * from "./getUserImage.js";
9
11
  export { getLocalizedString } from "./getLocalizedString.js";
10
12
  export { localize } from "./localize.js";
11
13
  export * from "./has.js";