@vuu-ui/vuu-utils 0.13.97 → 0.13.99-alpha.1
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/cjs/packages/vuu-utils/src/cookie-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/date/date-utils.js +5 -0
- package/cjs/packages/vuu-utils/src/date/date-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/form-utils.js +2 -2
- package/cjs/packages/vuu-utils/src/form-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/index.js +5 -0
- package/cjs/packages/vuu-utils/src/index.js.map +1 -1
- package/cjs/packages/vuu-utils/src/protocol-message-utils.js +18 -2
- package/cjs/packages/vuu-utils/src/protocol-message-utils.js.map +1 -1
- package/esm/packages/vuu-utils/src/cookie-utils.js.map +1 -1
- package/esm/packages/vuu-utils/src/date/date-utils.js +5 -0
- package/esm/packages/vuu-utils/src/date/date-utils.js.map +1 -1
- package/esm/packages/vuu-utils/src/form-utils.js +2 -2
- package/esm/packages/vuu-utils/src/form-utils.js.map +1 -1
- package/esm/packages/vuu-utils/src/index.js +1 -1
- package/esm/packages/vuu-utils/src/protocol-message-utils.js +14 -3
- package/esm/packages/vuu-utils/src/protocol-message-utils.js.map +1 -1
- package/package.json +6 -6
- package/types/cookie-utils.d.ts +1 -1
- package/types/date/date-utils.d.ts +1 -0
- package/types/protocol-message-utils.d.ts +7 -2
- package/types/user-types.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-utils.js","sources":["../../../../../../packages/vuu-utils/src/cookie-utils.ts"],"sourcesContent":["export const getCookieValue = (name: string): string |
|
|
1
|
+
{"version":3,"file":"cookie-utils.js","sources":["../../../../../../packages/vuu-utils/src/cookie-utils.ts"],"sourcesContent":["export const getCookieValue = (name: string): string | undefined => {\n if (globalThis.document?.cookie !== undefined) {\n return globalThis.document.cookie\n .split(\"; \")\n .find((row) => row.startsWith(`${name}=`))\n ?.split(\"=\")[1];\n }\n};\n\n/**\n * Sets a cookie value.\n *\n * @param {string} name - Cookie name\n * @param {string} value - Cookie value\n * @param {number} [days] - Optional: number of days until the cookie expires\n */\nexport function setCookieValue(name: string, value: string, days?: number) {\n let expires = \"\";\n\n if (typeof days === \"number\") {\n const date = new Date();\n // days -> milliseconds\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = \"; expires=\" + date.toUTCString();\n }\n\n const encodedName = encodeURIComponent(name);\n const encodedValue = encodeURIComponent(value);\n\n document.cookie = `${encodedName}=${encodedValue}${expires};`;\n}\n"],"names":[],"mappings":";;AAAa,MAAA,cAAA,GAAiB,CAAC,IAAqC,KAAA;AAClE,EAAI,IAAA,UAAA,CAAW,QAAU,EAAA,MAAA,KAAW,KAAW,CAAA,EAAA;AAC7C,IAAA,OAAO,WAAW,QAAS,CAAA,MAAA,CACxB,MAAM,IAAI,CAAA,CACV,KAAK,CAAC,GAAA,KAAQ,IAAI,UAAW,CAAA,CAAA,EAAG,IAAI,CAAG,CAAA,CAAA,CAAC,GACvC,KAAM,CAAA,GAAG,EAAE,CAAC,CAAA;AAAA;AAEpB;AASgB,SAAA,cAAA,CAAe,IAAc,EAAA,KAAA,EAAe,IAAe,EAAA;AACzE,EAAA,IAAI,OAAU,GAAA,EAAA;AAEd,EAAI,IAAA,OAAO,SAAS,QAAU,EAAA;AAC5B,IAAM,MAAA,IAAA,uBAAW,IAAK,EAAA;AAEtB,IAAK,IAAA,CAAA,OAAA,CAAQ,KAAK,OAAQ,EAAA,GAAI,OAAO,EAAK,GAAA,EAAA,GAAK,KAAK,GAAI,CAAA;AACxD,IAAU,OAAA,GAAA,YAAA,GAAe,KAAK,WAAY,EAAA;AAAA;AAG5C,EAAM,MAAA,WAAA,GAAc,mBAAmB,IAAI,CAAA;AAC3C,EAAM,MAAA,YAAA,GAAe,mBAAmB,KAAK,CAAA;AAE7C,EAAA,QAAA,CAAS,SAAS,CAAG,EAAA,WAAW,CAAI,CAAA,EAAA,YAAY,GAAG,OAAO,CAAA,CAAA,CAAA;AAC5D;;;;;"}
|
|
@@ -113,6 +113,11 @@ Time.millisToTimeString = (timestamp) => new Date(timestamp).toTimeString().slic
|
|
|
113
113
|
Time.toString = (hours, minutes, seconds) => {
|
|
114
114
|
return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}`;
|
|
115
115
|
};
|
|
116
|
+
Time.isDateInMillis = (dtInMillis) => {
|
|
117
|
+
const n = typeof dtInMillis === "number" ? dtInMillis : Number(dtInMillis);
|
|
118
|
+
if (!Number.isFinite(n) || !Number.isInteger(n)) return false;
|
|
119
|
+
return new Date(n).getTime() === n;
|
|
120
|
+
};
|
|
116
121
|
|
|
117
122
|
exports.Time = Time;
|
|
118
123
|
exports.asTimeString = asTimeString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-utils.js","sources":["../../../../../../../packages/vuu-utils/src/date/date-utils.ts"],"sourcesContent":["import { CalendarDate } from \"@internationalized/date\";\n\nexport function toCalendarDate(d: Date) {\n return new CalendarDate(d.getFullYear(), d.getMonth() + 1, d.getDate());\n}\n\nexport type oneToFive = 1 | 2 | 3 | 4 | 5;\nexport type zeroToFive = 0 | oneToFive;\nexport type sixToNine = 6 | 7 | 8 | 9;\nexport type zeroToNine = zeroToFive | sixToNine;\nexport type oneToNine = oneToFive | sixToNine;\nexport type TimeUnit = \"hours\" | \"minutes\" | \"seconds\";\nexport type Hours = `${0 | 1}${zeroToNine}` | `2${0 | 1 | 2 | 3}`;\nexport type Minutes = `${zeroToFive}${zeroToNine}`;\nexport type Seconds = `${zeroToFive}${zeroToNine}`;\n\nexport type TimeUnitValue<T extends TimeUnit> = T extends \"hours\"\n ? Hours\n : T extends \"minutes\"\n ? Minutes\n : Seconds;\n\n// This should work, works fine in TypeScript playground, but hangs tsc\n// export type TimeString = `${Hours}:${Minutes}:${Seconds}`;\nexport type TimeString =\n `${number}${number}:${number}${number}:${number}${number}`;\n\ntype YYYY = `19${zeroToNine}${zeroToNine}` | `20${zeroToNine}${zeroToNine}`;\ntype MM = `0${oneToNine}` | `1${0 | 1 | 2}`;\ntype DD = `${0}${oneToNine}` | `${1 | 2}${zeroToNine}` | `3${0 | 1}`;\n\nexport type DateStringISO = `${YYYY}-${MM}-${DD}`;\n\nexport const zeroTime: TimeString = \"00:00:00\";\nexport const zeroTimeUnit: TimeUnitValue<TimeUnit> = \"00\";\n\nexport function incrementTimeUnitValue<T extends TimeUnit>(\n unit: T,\n value: TimeUnitValue<T>,\n) {\n const num = parseInt(value);\n if (unit === \"hours\" && num < 23) {\n return `${num + 1}`.padStart(2, \"0\").slice(-2) as Hours;\n } else if (unit === \"hours\" && num === 23) {\n return \"00\" as Hours;\n } else if (num < 59) {\n return `${num + 1}`.padStart(2, \"0\").slice(-2) as TimeUnitValue<T>;\n } else if (num === 59) {\n return \"00\" as TimeUnitValue<T>;\n }\n return value;\n}\n\nexport function decrementTimeUnitValue<T extends TimeUnit>(\n unit: T,\n value: TimeUnitValue<T>,\n) {\n const num = parseInt(value);\n if (unit === \"hours\" && num > 0) {\n return `${num - 1}`.padStart(2, \"0\").slice(-2) as Hours;\n } else if (unit === \"hours\" && num === 0) {\n return \"23\" as Hours;\n } else if (num > 0) {\n return `${num - 1}`.padStart(2, \"0\").slice(-2) as TimeUnitValue<T>;\n } else if (num === 0) {\n return \"59\" as TimeUnitValue<T>;\n }\n return value;\n}\n\n// TODO accept numeric values with appropriate type checks\nexport function updateTimeString<T extends TimeUnit>(\n timeString: TimeString,\n unit: T,\n value: TimeUnitValue<T>,\n): TimeString {\n const newTimeString =\n unit === \"hours\"\n ? value.concat(timeString.slice(2))\n : unit === \"minutes\"\n ? timeString.slice(0, 3).concat(value).concat(timeString.slice(5))\n : timeString.slice(0, 6).concat(value);\n if (isValidTimeString(newTimeString)) {\n return newTimeString;\n } else {\n throw Error(`[date-utils] udateTimeSting invalid result ${newTimeString}`);\n }\n}\n\nconst validTimePattern = /(?:[0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/;\nexport const isValidTimeString = (value: unknown): value is TimeString =>\n typeof value === \"string\" && validTimePattern.test(value);\n\nexport function asTimeString(value: unknown, allowUndefined: false): TimeString;\nexport function asTimeString(\n value: unknown,\n allowUndefined?: true,\n): TimeString | undefined;\nexport function asTimeString(\n value: unknown,\n allowUndefined = false,\n): TimeString | undefined {\n if (value === undefined) {\n if (allowUndefined) {\n return value;\n } else {\n throw Error(\"[date-utils] asTimeString, value cannot be undefined\");\n }\n } else if (isValidTimeString(value)) {\n return value;\n } else if (typeof value === \"number\") {\n // we are assuming we have a value representing milliseconds since epoch.\n // If not, we will get an unpredictable time here. Is this too risky ?\n return Time.millisToTimeString(value);\n } else if (typeof value === \"string\") {\n // see if we have a long value, test if we can create time\n const valueAsInt = parseInt(value);\n if (!isNaN(valueAsInt)) {\n return Time.millisToTimeString(valueAsInt);\n }\n } else {\n throw Error(\n `[date-utils] asTimeString, value ${value} is not valid TimeString`,\n );\n }\n}\n\nexport interface Time {\n hours: number;\n minutes: number;\n seconds: number;\n asDate: (date?: Date | DateStringISO) => Date;\n}\n\nconst padZero = (val: number) => `${val}`.padStart(2, \"0\");\n\nclass TimeImpl implements Time {\n #hours: number;\n #minutes: number;\n #seconds: number;\n\n constructor(timeString: TimeString) {\n const [hours, minutes, seconds] = timeString.split(\":\");\n this.#hours = parseInt(hours);\n this.#minutes = parseInt(minutes);\n this.#seconds = parseInt(seconds);\n }\n\n get hours() {\n return this.#hours;\n }\n get minutes() {\n return this.#minutes;\n }\n get seconds() {\n return this.#seconds;\n }\n\n asDate(date?: Date | DateStringISO) {\n const dt =\n date === undefined\n ? new Date()\n : typeof date === \"string\"\n ? new Date(date)\n : date;\n\n dt.setHours(this.#hours);\n dt.setMinutes(this.#minutes);\n dt.setSeconds(this.seconds);\n dt.setMilliseconds(0);\n return dt;\n }\n\n toString() {\n return Time.toString(this.#hours, this.#minutes, this.#seconds);\n }\n}\n\nexport const Time = (timeString: TimeString): Time =>\n new TimeImpl(timeString) as Time;\n\nTime.millisToTimeString = (timestamp: number) =>\n new Date(timestamp).toTimeString().slice(0, 8) as TimeString;\n\nTime.toString = (hours: number, minutes: number, seconds: number) => {\n return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}` as TimeString;\n};\n"],"names":["CalendarDate"],"mappings":";;;;;;;;;;;AAAA,IAAA,MAAA,EAAA,QAAA,EAAA,QAAA;AAEO,SAAS,eAAe,CAAS,EAAA;AACtC,EAAO,OAAA,IAAIA,iBAAa,CAAA,CAAA,CAAE,WAAY,EAAA,EAAG,CAAE,CAAA,QAAA,EAAa,GAAA,CAAA,EAAG,CAAE,CAAA,OAAA,EAAS,CAAA;AACxE;AA6BO,MAAM,QAAuB,GAAA;AAC7B,MAAM,YAAwC,GAAA;AAErC,SAAA,sBAAA,CACd,MACA,KACA,EAAA;AACA,EAAM,MAAA,GAAA,GAAM,SAAS,KAAK,CAAA;AAC1B,EAAI,IAAA,IAAA,KAAS,OAAW,IAAA,GAAA,GAAM,EAAI,EAAA;AAChC,IAAO,OAAA,CAAA,EAAG,MAAM,CAAC,CAAA,CAAA,CAAG,SAAS,CAAG,EAAA,GAAG,CAAE,CAAA,KAAA,CAAM,CAAE,CAAA,CAAA;AAAA,GACpC,MAAA,IAAA,IAAA,KAAS,OAAW,IAAA,GAAA,KAAQ,EAAI,EAAA;AACzC,IAAO,OAAA,IAAA;AAAA,GACT,MAAA,IAAW,MAAM,EAAI,EAAA;AACnB,IAAO,OAAA,CAAA,EAAG,MAAM,CAAC,CAAA,CAAA,CAAG,SAAS,CAAG,EAAA,GAAG,CAAE,CAAA,KAAA,CAAM,CAAE,CAAA,CAAA;AAAA,GAC/C,MAAA,IAAW,QAAQ,EAAI,EAAA;AACrB,IAAO,OAAA,IAAA;AAAA;AAET,EAAO,OAAA,KAAA;AACT;AAEgB,SAAA,sBAAA,CACd,MACA,KACA,EAAA;AACA,EAAM,MAAA,GAAA,GAAM,SAAS,KAAK,CAAA;AA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qB,CAAC,SAAA,KACzB,IAAI,IAAA,CAAK,SAAS,CAAA,CAAE,YAAa,EAAA,CAAE,KAAM,CAAA,CAAA,EAAG,CAAC,CAAA;AAE/C,IAAA,CAAK,QAAW,GAAA,CAAC,KAAe,EAAA,OAAA,EAAiB,OAAoB,KAAA;AACnE,EAAO,OAAA,CAAA,EAAG,OAAQ,CAAA,KAAK,CAAC,CAAA,CAAA,EAAI,OAAQ,CAAA,OAAO,CAAC,CAAA,CAAA,EAAI,OAAQ,CAAA,OAAO,CAAC,CAAA,CAAA;AAClE,CAAA;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"date-utils.js","sources":["../../../../../../../packages/vuu-utils/src/date/date-utils.ts"],"sourcesContent":["import { CalendarDate } from \"@internationalized/date\";\n\nexport function toCalendarDate(d: Date) {\n return new CalendarDate(d.getFullYear(), d.getMonth() + 1, d.getDate());\n}\n\nexport type oneToFive = 1 | 2 | 3 | 4 | 5;\nexport type zeroToFive = 0 | oneToFive;\nexport type sixToNine = 6 | 7 | 8 | 9;\nexport type zeroToNine = zeroToFive | sixToNine;\nexport type oneToNine = oneToFive | sixToNine;\nexport type TimeUnit = \"hours\" | \"minutes\" | \"seconds\";\nexport type Hours = `${0 | 1}${zeroToNine}` | `2${0 | 1 | 2 | 3}`;\nexport type Minutes = `${zeroToFive}${zeroToNine}`;\nexport type Seconds = `${zeroToFive}${zeroToNine}`;\n\nexport type TimeUnitValue<T extends TimeUnit> = T extends \"hours\"\n ? Hours\n : T extends \"minutes\"\n ? Minutes\n : Seconds;\n\n// This should work, works fine in TypeScript playground, but hangs tsc\n// export type TimeString = `${Hours}:${Minutes}:${Seconds}`;\nexport type TimeString =\n `${number}${number}:${number}${number}:${number}${number}`;\n\ntype YYYY = `19${zeroToNine}${zeroToNine}` | `20${zeroToNine}${zeroToNine}`;\ntype MM = `0${oneToNine}` | `1${0 | 1 | 2}`;\ntype DD = `${0}${oneToNine}` | `${1 | 2}${zeroToNine}` | `3${0 | 1}`;\n\nexport type DateStringISO = `${YYYY}-${MM}-${DD}`;\n\nexport const zeroTime: TimeString = \"00:00:00\";\nexport const zeroTimeUnit: TimeUnitValue<TimeUnit> = \"00\";\n\nexport function incrementTimeUnitValue<T extends TimeUnit>(\n unit: T,\n value: TimeUnitValue<T>,\n) {\n const num = parseInt(value);\n if (unit === \"hours\" && num < 23) {\n return `${num + 1}`.padStart(2, \"0\").slice(-2) as Hours;\n } else if (unit === \"hours\" && num === 23) {\n return \"00\" as Hours;\n } else if (num < 59) {\n return `${num + 1}`.padStart(2, \"0\").slice(-2) as TimeUnitValue<T>;\n } else if (num === 59) {\n return \"00\" as TimeUnitValue<T>;\n }\n return value;\n}\n\nexport function decrementTimeUnitValue<T extends TimeUnit>(\n unit: T,\n value: TimeUnitValue<T>,\n) {\n const num = parseInt(value);\n if (unit === \"hours\" && num > 0) {\n return `${num - 1}`.padStart(2, \"0\").slice(-2) as Hours;\n } else if (unit === \"hours\" && num === 0) {\n return \"23\" as Hours;\n } else if (num > 0) {\n return `${num - 1}`.padStart(2, \"0\").slice(-2) as TimeUnitValue<T>;\n } else if (num === 0) {\n return \"59\" as TimeUnitValue<T>;\n }\n return value;\n}\n\n// TODO accept numeric values with appropriate type checks\nexport function updateTimeString<T extends TimeUnit>(\n timeString: TimeString,\n unit: T,\n value: TimeUnitValue<T>,\n): TimeString {\n const newTimeString =\n unit === \"hours\"\n ? value.concat(timeString.slice(2))\n : unit === \"minutes\"\n ? timeString.slice(0, 3).concat(value).concat(timeString.slice(5))\n : timeString.slice(0, 6).concat(value);\n if (isValidTimeString(newTimeString)) {\n return newTimeString;\n } else {\n throw Error(`[date-utils] udateTimeSting invalid result ${newTimeString}`);\n }\n}\n\nconst validTimePattern = /(?:[0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/;\nexport const isValidTimeString = (value: unknown): value is TimeString =>\n typeof value === \"string\" && validTimePattern.test(value);\n\nexport function asTimeString(value: unknown, allowUndefined: false): TimeString;\nexport function asTimeString(\n value: unknown,\n allowUndefined?: true,\n): TimeString | undefined;\nexport function asTimeString(\n value: unknown,\n allowUndefined = false,\n): TimeString | undefined {\n if (value === undefined) {\n if (allowUndefined) {\n return value;\n } else {\n throw Error(\"[date-utils] asTimeString, value cannot be undefined\");\n }\n } else if (isValidTimeString(value)) {\n return value;\n } else if (typeof value === \"number\") {\n // we are assuming we have a value representing milliseconds since epoch.\n // If not, we will get an unpredictable time here. Is this too risky ?\n return Time.millisToTimeString(value);\n } else if (typeof value === \"string\") {\n // see if we have a long value, test if we can create time\n const valueAsInt = parseInt(value);\n if (!isNaN(valueAsInt)) {\n return Time.millisToTimeString(valueAsInt);\n }\n } else {\n throw Error(\n `[date-utils] asTimeString, value ${value} is not valid TimeString`,\n );\n }\n}\n\nexport interface Time {\n hours: number;\n minutes: number;\n seconds: number;\n asDate: (date?: Date | DateStringISO) => Date;\n}\n\nconst padZero = (val: number) => `${val}`.padStart(2, \"0\");\n\nclass TimeImpl implements Time {\n #hours: number;\n #minutes: number;\n #seconds: number;\n\n constructor(timeString: TimeString) {\n const [hours, minutes, seconds] = timeString.split(\":\");\n this.#hours = parseInt(hours);\n this.#minutes = parseInt(minutes);\n this.#seconds = parseInt(seconds);\n }\n\n get hours() {\n return this.#hours;\n }\n get minutes() {\n return this.#minutes;\n }\n get seconds() {\n return this.#seconds;\n }\n\n asDate(date?: Date | DateStringISO) {\n const dt =\n date === undefined\n ? new Date()\n : typeof date === \"string\"\n ? new Date(date)\n : date;\n\n dt.setHours(this.#hours);\n dt.setMinutes(this.#minutes);\n dt.setSeconds(this.seconds);\n dt.setMilliseconds(0);\n return dt;\n }\n\n toString() {\n return Time.toString(this.#hours, this.#minutes, this.#seconds);\n }\n}\n\nexport const Time = (timeString: TimeString): Time =>\n new TimeImpl(timeString) as Time;\n\nTime.millisToTimeString = (timestamp: number) =>\n new Date(timestamp).toTimeString().slice(0, 8) as TimeString;\n\nTime.toString = (hours: number, minutes: number, seconds: number) => {\n return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}` as TimeString;\n};\n\nTime.isDateInMillis = (dtInMillis: string | number): boolean => {\n const n =\n typeof dtInMillis === \"number\" ? dtInMillis : Number(dtInMillis);\n if (!Number.isFinite(n) || !Number.isInteger(n)) return false;\n\n return new Date(n).getTime() === n;\n};\n"],"names":["CalendarDate"],"mappings":";;;;;;;;;;;AAAA,IAAA,MAAA,EAAA,QAAA,EAAA,QAAA;AAEO,SAAS,eAAe,CAAS,EAAA;AACtC,EAAO,OAAA,IAAIA,iBAAa,CAAA,CAAA,CAAE,WAAY,EAAA,EAAG,CAAE,CAAA,QAAA,EAAa,GAAA,CAAA,EAAG,CAAE,CAAA,OAAA,EAAS,CAAA;AACxE;AA6BO,MAAM,QAAuB,GAAA;AAC7B,MAAM,YAAwC,GAAA;AAErC,SAAA,sBAAA,CACd,MACA,KACA,EAAA;AACA,EAAM,MAAA,GAAA,GAAM,SAAS,KAAK,CAAA;AAC1B,EAAI,IAAA,IAAA,KAAS,OAAW,IAAA,GAAA,GAAM,EAAI,EAAA;AAChC,IAAO,OAAA,CAAA,EAAG,MAAM,CAAC,CAAA,CAAA,CAAG,SAAS,CAAG,EAAA,GAAG,CAAE,CAAA,KAAA,CAAM,CAAE,CAAA,CAAA;AAAA,GACpC,MAAA,IAAA,IAAA,KAAS,OAAW,IAAA,GAAA,KAAQ,EAAI,EAAA;AACzC,IAAO,OAAA,IAAA;AAAA,GACT,MAAA,IAAW,MAAM,EAAI,EAAA;AACnB,IAAO,OAAA,CAAA,EAAG,MAAM,CAAC,CAAA,CAAA,CAAG,SAAS,CAAG,EAAA,GAAG,CAAE,CAAA,KAAA,CAAM,CAAE,CAAA,CAAA;AAAA,GAC/C,MAAA,IAAW,QAAQ,EAAI,EAAA;AACrB,IAAO,OAAA,IAAA;AAAA;AAET,EAAO,OAAA,KAAA;AACT;AAEgB,SAAA,sBAAA,CACd,MACA,KACA,EAAA;AACA,EAAM,MAAA,GAAA,GAAM,SAAS,KAAK,C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AA,GAAqB,CAAC,SAAA,KACzB,IAAI,IAAA,CAAK,SAAS,CAAA,CAAE,YAAa,EAAA,CAAE,KAAM,CAAA,CAAA,EAAG,CAAC,CAAA;AAE/C,IAAA,CAAK,QAAW,GAAA,CAAC,KAAe,EAAA,OAAA,EAAiB,OAAoB,KAAA;AACnE,EAAO,OAAA,CAAA,EAAG,OAAQ,CAAA,KAAK,CAAC,CAAA,CAAA,EAAI,OAAQ,CAAA,OAAO,CAAC,CAAA,CAAA,EAAI,OAAQ,CAAA,OAAO,CAAC,CAAA,CAAA;AAClE,CAAA;AAEA,IAAK,CAAA,cAAA,GAAiB,CAAC,UAAyC,KAAA;AAC9D,EAAA,MAAM,IACJ,OAAO,UAAA,KAAe,QAAW,GAAA,UAAA,GAAa,OAAO,UAAU,CAAA;AACjE,EAAI,IAAA,CAAC,MAAO,CAAA,QAAA,CAAS,CAAC,CAAA,IAAK,CAAC,MAAO,CAAA,SAAA,CAAU,CAAC,CAAA,EAAU,OAAA,KAAA;AAExD,EAAA,OAAO,IAAI,IAAA,CAAK,CAAC,CAAA,CAAE,SAAc,KAAA,CAAA;AACnC,CAAA;;;;;;;;;;;;"}
|
|
@@ -61,8 +61,8 @@ function getTypedValue(value, type, throwIfInvalid = false, options) {
|
|
|
61
61
|
} else {
|
|
62
62
|
return +dateUtils.Time(value).asDate();
|
|
63
63
|
}
|
|
64
|
-
} else if (
|
|
65
|
-
return value;
|
|
64
|
+
} else if (value.length > 0 && dateUtils.Time.isDateInMillis(value)) {
|
|
65
|
+
return Number(value);
|
|
66
66
|
} else if (throwIfInvalid) {
|
|
67
67
|
throw Error(`value ${value} is not a valid ${type}`);
|
|
68
68
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-utils.js","sources":["../../../../../../packages/vuu-utils/src/form-utils.ts"],"sourcesContent":["import { DataValueTypeSimple } from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuColumnDataType,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { KeyboardEvent, SyntheticEvent } from \"react\";\nimport { stringIsValidDecimal, stringIsValidInt } from \"./data-utils\";\nimport { isValidTimeString, Time } from \"./date\";\nimport { queryClosest } from \"./html-utils\";\nimport { ExtendedFilterOptions } from \"@vuu-ui/vuu-filter-types\";\n\n/**\n * Use with the following convention:\n *\n * <FormField data-field=\"my-field-name\">\n */\nexport const getFieldName = (target: EventTarget | HTMLElement): string => {\n const saltFormField = queryClosest(target, \"[data-field]\") as HTMLElement;\n const fieldName = saltFormField?.dataset.field;\n if (fieldName) {\n return fieldName;\n } else {\n throw Error(\"named form field not found\");\n }\n};\n\nexport type InputSource = \"typeahead-suggestion\" | \"text-input\";\n\nexport const isNumber = (\n type: string,\n value: VuuRowDataItemType,\n): value is number => type === \"number\";\n\nexport type CommitHandler<\n E extends HTMLElement = HTMLInputElement,\n T = VuuRowDataItemType,\n> = (\n evt: SyntheticEvent<E> | KeyboardEvent<E>,\n value: T,\n source?: InputSource,\n) => void;\n\nexport const isValidRange = <T>([val1, val2]: [T, T]) => {\n if (isValidTimeString(val1) && isValidTimeString(val2)) {\n return val2 > val1;\n }\n return true;\n};\n\n/**\n * Convert a pair of string values to the type appropriate for the\n * associated column or form field. Can be used when processing a string value\n * from an input used for user editing.\n *\n */\nexport function getTypedRange(\n [value1, value2]: [string, string],\n dataType: VuuColumnDataType | DataValueTypeSimple,\n options?: ExtendedFilterOptions,\n) {\n return [\n getTypedValue(value1, dataType, false, options),\n getTypedValue(value2, dataType, false, options),\n ];\n}\n\n/**\n * Convert a string value to the type appropriate for the associated\n * column or form field. Can be used when processing a string value\n * from an input used for user editing.\n *\n * @param value\n * @param type\n * @param throwIfInvalid\n */\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid?: false,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType | undefined;\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid: true,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType;\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid = false,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType | undefined {\n switch (type) {\n case \"int\":\n case \"long\": {\n if (stringIsValidInt(value)) {\n return parseInt(value, 10);\n } else if (isValidTimeString(value)) {\n //TOCHECK\n return value;\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n }\n\n case \"double\":\n case \"number\": {\n if (stringIsValidDecimal(value)) {\n return parseFloat(value);\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n }\n\n case \"boolean\":\n return value === \"true\" ? true : false;\n\n case \"time\":\n if (isValidTimeString(value)) {\n // We don't manipulate the values of 'extended' filters, the\n // ExtendedFilter impementation will do that.\n if (options?.type === \"TimeString\") {\n return value;\n } else {\n return +Time(value).asDate();\n }\n } else if (
|
|
1
|
+
{"version":3,"file":"form-utils.js","sources":["../../../../../../packages/vuu-utils/src/form-utils.ts"],"sourcesContent":["import { DataValueTypeSimple } from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuColumnDataType,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { KeyboardEvent, SyntheticEvent } from \"react\";\nimport { stringIsValidDecimal, stringIsValidInt } from \"./data-utils\";\nimport { isValidTimeString, Time } from \"./date\";\nimport { queryClosest } from \"./html-utils\";\nimport { ExtendedFilterOptions } from \"@vuu-ui/vuu-filter-types\";\n\n/**\n * Use with the following convention:\n *\n * <FormField data-field=\"my-field-name\">\n */\nexport const getFieldName = (target: EventTarget | HTMLElement): string => {\n const saltFormField = queryClosest(target, \"[data-field]\") as HTMLElement;\n const fieldName = saltFormField?.dataset.field;\n if (fieldName) {\n return fieldName;\n } else {\n throw Error(\"named form field not found\");\n }\n};\n\nexport type InputSource = \"typeahead-suggestion\" | \"text-input\";\n\nexport const isNumber = (\n type: string,\n value: VuuRowDataItemType,\n): value is number => type === \"number\";\n\nexport type CommitHandler<\n E extends HTMLElement = HTMLInputElement,\n T = VuuRowDataItemType,\n> = (\n evt: SyntheticEvent<E> | KeyboardEvent<E>,\n value: T,\n source?: InputSource,\n) => void;\n\nexport const isValidRange = <T>([val1, val2]: [T, T]) => {\n if (isValidTimeString(val1) && isValidTimeString(val2)) {\n return val2 > val1;\n }\n return true;\n};\n\n/**\n * Convert a pair of string values to the type appropriate for the\n * associated column or form field. Can be used when processing a string value\n * from an input used for user editing.\n *\n */\nexport function getTypedRange(\n [value1, value2]: [string, string],\n dataType: VuuColumnDataType | DataValueTypeSimple,\n options?: ExtendedFilterOptions,\n) {\n return [\n getTypedValue(value1, dataType, false, options),\n getTypedValue(value2, dataType, false, options),\n ];\n}\n\n/**\n * Convert a string value to the type appropriate for the associated\n * column or form field. Can be used when processing a string value\n * from an input used for user editing.\n *\n * @param value\n * @param type\n * @param throwIfInvalid\n */\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid?: false,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType | undefined;\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid: true,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType;\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid = false,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType | undefined {\n switch (type) {\n case \"int\":\n case \"long\": {\n if (stringIsValidInt(value)) {\n return parseInt(value, 10);\n } else if (isValidTimeString(value)) {\n //TOCHECK\n return value;\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n }\n\n case \"double\":\n case \"number\": {\n if (stringIsValidDecimal(value)) {\n return parseFloat(value);\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n }\n\n case \"boolean\":\n return value === \"true\" ? true : false;\n\n case \"time\":\n if (isValidTimeString(value)) {\n // We don't manipulate the values of 'extended' filters, the\n // ExtendedFilter impementation will do that.\n if (options?.type === \"TimeString\") {\n return value;\n } else {\n return +Time(value).asDate();\n }\n } else if (value.length > 0 && Time.isDateInMillis(value)) {\n //if value previously converted\n return Number(value);\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n default:\n return value;\n }\n}\n"],"names":["queryClosest","isValidTimeString","stringIsValidInt","stringIsValidDecimal","Time"],"mappings":";;;;;;;;AAgBa,MAAA,YAAA,GAAe,CAAC,MAA8C,KAAA;AACzE,EAAM,MAAA,aAAA,GAAgBA,sBAAa,CAAA,MAAA,EAAQ,cAAc,CAAA;AACzD,EAAM,MAAA,SAAA,GAAY,eAAe,OAAQ,CAAA,KAAA;AACzC,EAAA,IAAI,SAAW,EAAA;AACb,IAAO,OAAA,SAAA;AAAA,GACF,MAAA;AACL,IAAA,MAAM,MAAM,4BAA4B,CAAA;AAAA;AAE5C;AAIO,MAAM,QAAW,GAAA,CACtB,IACA,EAAA,KAAA,KACoB,IAAS,KAAA;AAWxB,MAAM,YAAe,GAAA,CAAI,CAAC,IAAA,EAAM,IAAI,CAAc,KAAA;AACvD,EAAA,IAAIC,2BAAkB,CAAA,IAAI,CAAK,IAAAA,2BAAA,CAAkB,IAAI,CAAG,EAAA;AACtD,IAAA,OAAO,IAAO,GAAA,IAAA;AAAA;AAEhB,EAAO,OAAA,IAAA;AACT;AAQO,SAAS,cACd,CAAC,MAAA,EAAQ,MAAM,CAAA,EACf,UACA,OACA,EAAA;AACA,EAAO,OAAA;AAAA,IACL,aAAc,CAAA,MAAA,EAAQ,QAAU,EAAA,KAAA,EAAO,OAAO,CAAA;AAAA,IAC9C,aAAc,CAAA,MAAA,EAAQ,QAAU,EAAA,KAAA,EAAO,OAAO;AAAA,GAChD;AACF;AAuBO,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EAAA;AAEzD,QAAA,OAAO,OAAO,KAAK,CAAA;AAAA,iBACV,cAAgB,EAAA;AACzB,QAAA,MAAM,KAAM,CAAA,CAAA,MAAA,EAAS,KAAK,CAAA,gBAAA,EAAmB,IAAI,CAAE,CAAA,CAAA;AAAA,OAC9C,MAAA;AACL,QAAO,OAAA,KAAA,CAAA;AAAA;AACT,IACF;AACE,MAAO,OAAA,KAAA;AAAA;AAEb;;;;;;;;"}
|
|
@@ -358,10 +358,15 @@ exports.roundDecimal = roundDecimal.roundDecimal;
|
|
|
358
358
|
exports.debounce = perfUtils.debounce;
|
|
359
359
|
exports.throttle = perfUtils.throttle;
|
|
360
360
|
exports.DeferredPromise = promiseUtils.DeferredPromise;
|
|
361
|
+
exports.INVALID_SESSION = protocolMessageUtils.INVALID_SESSION;
|
|
362
|
+
exports.INVALID_TOKEN = protocolMessageUtils.INVALID_TOKEN;
|
|
363
|
+
exports.SESSION_LIMIT_EXCEEDED = protocolMessageUtils.SESSION_LIMIT_EXCEEDED;
|
|
364
|
+
exports.TOKEN_EXPIRED = protocolMessageUtils.TOKEN_EXPIRED;
|
|
361
365
|
exports.hasViewPortContext = protocolMessageUtils.hasViewPortContext;
|
|
362
366
|
exports.isActionMessage = protocolMessageUtils.isActionMessage;
|
|
363
367
|
exports.isCreateVpSuccess = protocolMessageUtils.isCreateVpSuccess;
|
|
364
368
|
exports.isCustomComponentActionMessage = protocolMessageUtils.isCustomComponentActionMessage;
|
|
369
|
+
exports.isLoginErrorMessage = protocolMessageUtils.isLoginErrorMessage;
|
|
365
370
|
exports.isLoginResponse = protocolMessageUtils.isLoginResponse;
|
|
366
371
|
exports.isOpenDialogAction = protocolMessageUtils.isOpenDialogAction;
|
|
367
372
|
exports.isOpenSessionTableDialogMessage = protocolMessageUtils.isOpenSessionTableDialogMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -8,7 +8,18 @@ const MENU_RPC_TYPES = [
|
|
|
8
8
|
"VIEW_PORT_MENU_ROW_RPC",
|
|
9
9
|
"VIEW_PORT_MENU_CELL_RPC"
|
|
10
10
|
];
|
|
11
|
-
const
|
|
11
|
+
const INVALID_SESSION = "Invalid session";
|
|
12
|
+
const SESSION_LIMIT_EXCEEDED = "User session limit exceeded";
|
|
13
|
+
const INVALID_TOKEN = "Invalid token";
|
|
14
|
+
const TOKEN_EXPIRED = "Token has expired";
|
|
15
|
+
const InvalidLoginMessages = [
|
|
16
|
+
INVALID_SESSION,
|
|
17
|
+
SESSION_LIMIT_EXCEEDED,
|
|
18
|
+
INVALID_TOKEN,
|
|
19
|
+
TOKEN_EXPIRED
|
|
20
|
+
];
|
|
21
|
+
const isLoginErrorMessage = (message) => typeof message === "string" && InvalidLoginMessages.includes(message);
|
|
22
|
+
const isSelectRequest = (message) => message && typeof message === "object" && "type" in message && (message.type === "SELECT_ROW" || message.type === "DESELECT_ROW" || message.type === "SELECT_ROW_RANGE" || message.type === "SELECT_ALL" || message.type === "DESELECT_ALL");
|
|
12
23
|
const isSelectSuccessWithRowCount = (response) => [
|
|
13
24
|
"SELECT_ROW_SUCCESS",
|
|
14
25
|
"DESELECT_ROW_SUCCESS",
|
|
@@ -19,7 +30,7 @@ const isSelectSuccessWithRowCount = (response) => [
|
|
|
19
30
|
const isRpcServiceRequest = (message) => message.type === "RPC_REQUEST";
|
|
20
31
|
const hasViewPortContext = (message) => message.context.type === "VIEWPORT_CONTEXT";
|
|
21
32
|
const isVuuMenuRpcRequest = (message) => MENU_RPC_TYPES.includes(message["type"]);
|
|
22
|
-
const isLoginResponse = (message) => "type" in message && (message.type === "LOGIN_SUCCESS" || message.type === "LOGIN_FAIL");
|
|
33
|
+
const isLoginResponse = (message) => message !== null && typeof message === "object" && "type" in message && (message.type === "LOGIN_SUCCESS" || message.type === "LOGIN_FAIL");
|
|
23
34
|
const isRequestResponse = (message) => "requestId" in message;
|
|
24
35
|
const isOpenSessionTableDialogMessage = (rpcResponse) => rpcResponse.type === "VIEW_PORT_MENU_RESP" && isOpenDialogAction(rpcResponse.action) && "tableSchema" in rpcResponse.action;
|
|
25
36
|
const isOpenDialogAction = (action) => action !== void 0 && action.type === "OPEN_DIALOG_ACTION";
|
|
@@ -43,10 +54,15 @@ function isCustomComponentActionMessage(rpcResponse) {
|
|
|
43
54
|
return isActionMessage(rpcResponse) && isOpenDialogAction(rpcResponse.action) && isSessionTable(rpcResponse.action.table) && typeof rpcResponse.action.renderComponent === "string" && componentRegistry.isView(rpcResponse.action.renderComponent);
|
|
44
55
|
}
|
|
45
56
|
|
|
57
|
+
exports.INVALID_SESSION = INVALID_SESSION;
|
|
58
|
+
exports.INVALID_TOKEN = INVALID_TOKEN;
|
|
59
|
+
exports.SESSION_LIMIT_EXCEEDED = SESSION_LIMIT_EXCEEDED;
|
|
60
|
+
exports.TOKEN_EXPIRED = TOKEN_EXPIRED;
|
|
46
61
|
exports.hasViewPortContext = hasViewPortContext;
|
|
47
62
|
exports.isActionMessage = isActionMessage;
|
|
48
63
|
exports.isCreateVpSuccess = isCreateVpSuccess;
|
|
49
64
|
exports.isCustomComponentActionMessage = isCustomComponentActionMessage;
|
|
65
|
+
exports.isLoginErrorMessage = isLoginErrorMessage;
|
|
50
66
|
exports.isLoginResponse = isLoginResponse;
|
|
51
67
|
exports.isOpenDialogAction = isOpenDialogAction;
|
|
52
68
|
exports.isOpenSessionTableDialogMessage = isOpenSessionTableDialogMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-message-utils.js","sources":["../../../../../../packages/vuu-utils/src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n TableSchema,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcMenuRequest,\n OpenDialogAction,\n VuuRpcRequest,\n VuuRpcResponse,\n VuuRpcMenuSuccess,\n VuuTable,\n VuuViewportRpcTypeaheadRequest,\n VuuRpcServiceRequest,\n ViewportRpcContext,\n OpenComponentInDialogAction,\n
|
|
1
|
+
{"version":3,"file":"protocol-message-utils.js","sources":["../../../../../../packages/vuu-utils/src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n TableSchema,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcMenuRequest,\n OpenDialogAction,\n VuuRpcRequest,\n VuuRpcResponse,\n VuuRpcMenuSuccess,\n VuuTable,\n VuuViewportRpcTypeaheadRequest,\n VuuRpcServiceRequest,\n ViewportRpcContext,\n OpenComponentInDialogAction,\n VuuLoginSuccessResponse,\n SelectRequest,\n SelectResponse,\n SelectSuccessWithRowCount,\n VuuViewportCreateSuccessResponse,\n VuuViewportCreateResponse,\n InvalidTokenReason,\n InvalidSessionReason,\n LoginErrorMessage,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { isView as componentInRegistry } from \"./component-registry\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n];\n\nexport const INVALID_SESSION: InvalidSessionReason = \"Invalid session\";\nexport const SESSION_LIMIT_EXCEEDED: InvalidSessionReason =\n \"User session limit exceeded\";\nexport const INVALID_TOKEN: InvalidTokenReason = \"Invalid token\";\nexport const TOKEN_EXPIRED: InvalidTokenReason = \"Token has expired\";\n\nconst InvalidLoginMessages: string[] = [\n INVALID_SESSION,\n SESSION_LIMIT_EXCEEDED,\n INVALID_TOKEN,\n TOKEN_EXPIRED,\n];\n\nexport const isLoginErrorMessage = (\n message: unknown,\n): message is LoginErrorMessage =>\n typeof message === \"string\" && InvalidLoginMessages.includes(message);\n\nexport const isSelectRequest = (message: object): message is SelectRequest =>\n message &&\n typeof message === \"object\" &&\n \"type\" in message &&\n (message.type === \"SELECT_ROW\" ||\n message.type === \"DESELECT_ROW\" ||\n message.type === \"SELECT_ROW_RANGE\" ||\n message.type === \"SELECT_ALL\" ||\n message.type === \"DESELECT_ALL\");\n\nexport const isSelectSuccessWithRowCount = (\n response: SelectResponse | SelectSuccessWithRowCount,\n): response is SelectSuccessWithRowCount =>\n [\n \"SELECT_ROW_SUCCESS\",\n \"DESELECT_ROW_SUCCESS\",\n \"SELECT_ROW_RANGE_SUCCESS\",\n \"SELECT_ALL_SUCCESS\",\n \"DESELECT_ALL_SUCCESS\",\n ].includes(response.type ?? \"\") &&\n typeof (response as SelectSuccessWithRowCount).selectedRowCount === \"number\";\n\nexport const isRpcServiceRequest = (message: {\n type: string;\n}): message is VuuRpcServiceRequest | Omit<VuuRpcServiceRequest, \"context\"> =>\n message.type === \"RPC_REQUEST\";\n\nexport const hasViewPortContext = (\n message: VuuRpcServiceRequest,\n): message is VuuRpcServiceRequest<ViewportRpcContext> =>\n message.context.type === \"VIEWPORT_CONTEXT\";\n\nexport const isVuuMenuRpcRequest = (\n message: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): message is VuuRpcMenuRequest => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isLoginResponse = (\n message: unknown,\n): message is VuuLoginSuccessResponse =>\n message !== null &&\n typeof message === \"object\" &&\n \"type\" in message &&\n (message.type === \"LOGIN_SUCCESS\" || message.type === \"LOGIN_FAIL\");\n\nexport const isRequestResponse = (\n message: object,\n): message is VuuUiMessageInRequestResponse => \"requestId\" in message;\n\nexport const isOpenSessionTableDialogMessage = (\n rpcResponse: RpcResponse,\n): rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema> =>\n rpcResponse.type === \"VIEW_PORT_MENU_RESP\" &&\n isOpenDialogAction(rpcResponse.action) &&\n \"tableSchema\" in rpcResponse.action;\n\nexport const isOpenDialogAction = (\n action?: MenuRpcAction,\n): action is OpenDialogAction =>\n action !== undefined && action.type === \"OPEN_DIALOG_ACTION\";\n\nexport const isTypeaheadRequest = (\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuViewportRpcTypeaheadRequest, \"vpId\"> => {\n return (\n isRpcServiceRequest(request) &&\n (request.rpcName === \"getUniqueFieldValues\" ||\n request.rpcName === \"getUniqueFieldValuesStartingWith\")\n );\n};\n\nexport const isCreateVpSuccess = (\n response: VuuViewportCreateResponse,\n): response is VuuViewportCreateSuccessResponse =>\n response.type === \"CREATE_VP_SUCCESS\";\n\nexport const isSessionTable = (table?: unknown) => {\n if (\n table !== null &&\n typeof table === \"object\" &&\n \"table\" in table &&\n \"module\" in table\n ) {\n return (table as VuuTable).table.startsWith(\"session\");\n }\n return false;\n};\n\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess;\nexport function isActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<VuuRpcMenuSuccess, \"vpId\">;\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n) {\n return rpcResponse.type === \"VIEW_PORT_MENU_RESP\";\n}\n\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<\n VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n >,\n \"vpId\"\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n rpcResponse.action?.renderComponent === \"inline-form\"\n );\n}\n\nexport function isCustomComponentActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenComponentInDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n typeof rpcResponse.action.renderComponent === \"string\" &&\n componentInRegistry(rpcResponse.action.renderComponent)\n );\n}\n"],"names":["componentInRegistry"],"mappings":";;;;AA+BA,MAAM,cAAiB,GAAA;AAAA,EACrB,4BAAA;AAAA,EACA,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA;AACF,CAAA;AAEO,MAAM,eAAwC,GAAA;AAC9C,MAAM,sBACX,GAAA;AACK,MAAM,aAAoC,GAAA;AAC1C,MAAM,aAAoC,GAAA;AAEjD,MAAM,oBAAiC,GAAA;AAAA,EACrC,eAAA;AAAA,EACA,sBAAA;AAAA,EACA,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":["../../../../../../packages/vuu-utils/src/cookie-utils.ts"],"sourcesContent":["export const getCookieValue = (name: string): string |
|
|
1
|
+
{"version":3,"file":"cookie-utils.js","sources":["../../../../../../packages/vuu-utils/src/cookie-utils.ts"],"sourcesContent":["export const getCookieValue = (name: string): string | undefined => {\n if (globalThis.document?.cookie !== undefined) {\n return globalThis.document.cookie\n .split(\"; \")\n .find((row) => row.startsWith(`${name}=`))\n ?.split(\"=\")[1];\n }\n};\n\n/**\n * Sets a cookie value.\n *\n * @param {string} name - Cookie name\n * @param {string} value - Cookie value\n * @param {number} [days] - Optional: number of days until the cookie expires\n */\nexport function setCookieValue(name: string, value: string, days?: number) {\n let expires = \"\";\n\n if (typeof days === \"number\") {\n const date = new Date();\n // days -> milliseconds\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = \"; expires=\" + date.toUTCString();\n }\n\n const encodedName = encodeURIComponent(name);\n const encodedValue = encodeURIComponent(value);\n\n document.cookie = `${encodedName}=${encodedValue}${expires};`;\n}\n"],"names":[],"mappings":"AAAa,MAAA,cAAA,GAAiB,CAAC,IAAqC,KAAA;AAClE,EAAI,IAAA,UAAA,CAAW,QAAU,EAAA,MAAA,KAAW,KAAW,CAAA,EAAA;AAC7C,IAAA,OAAO,WAAW,QAAS,CAAA,MAAA,CACxB,MAAM,IAAI,CAAA,CACV,KAAK,CAAC,GAAA,KAAQ,IAAI,UAAW,CAAA,CAAA,EAAG,IAAI,CAAG,CAAA,CAAA,CAAC,GACvC,KAAM,CAAA,GAAG,EAAE,CAAC,CAAA;AAAA;AAEpB;AASgB,SAAA,cAAA,CAAe,IAAc,EAAA,KAAA,EAAe,IAAe,EAAA;AACzE,EAAA,IAAI,OAAU,GAAA,EAAA;AAEd,EAAI,IAAA,OAAO,SAAS,QAAU,EAAA;AAC5B,IAAM,MAAA,IAAA,uBAAW,IAAK,EAAA;AAEtB,IAAK,IAAA,CAAA,OAAA,CAAQ,KAAK,OAAQ,EAAA,GAAI,OAAO,EAAK,GAAA,EAAA,GAAK,KAAK,GAAI,CAAA;AACxD,IAAU,OAAA,GAAA,YAAA,GAAe,KAAK,WAAY,EAAA;AAAA;AAG5C,EAAM,MAAA,WAAA,GAAc,mBAAmB,IAAI,CAAA;AAC3C,EAAM,MAAA,YAAA,GAAe,mBAAmB,KAAK,CAAA;AAE7C,EAAA,QAAA,CAAS,SAAS,CAAG,EAAA,WAAW,CAAI,CAAA,EAAA,YAAY,GAAG,OAAO,CAAA,CAAA,CAAA;AAC5D;;;;"}
|
|
@@ -111,6 +111,11 @@ Time.millisToTimeString = (timestamp) => new Date(timestamp).toTimeString().slic
|
|
|
111
111
|
Time.toString = (hours, minutes, seconds) => {
|
|
112
112
|
return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}`;
|
|
113
113
|
};
|
|
114
|
+
Time.isDateInMillis = (dtInMillis) => {
|
|
115
|
+
const n = typeof dtInMillis === "number" ? dtInMillis : Number(dtInMillis);
|
|
116
|
+
if (!Number.isFinite(n) || !Number.isInteger(n)) return false;
|
|
117
|
+
return new Date(n).getTime() === n;
|
|
118
|
+
};
|
|
114
119
|
|
|
115
120
|
export { Time, asTimeString, decrementTimeUnitValue, incrementTimeUnitValue, isValidTimeString, toCalendarDate, updateTimeString, zeroTime, zeroTimeUnit };
|
|
116
121
|
//# sourceMappingURL=date-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-utils.js","sources":["../../../../../../../packages/vuu-utils/src/date/date-utils.ts"],"sourcesContent":["import { CalendarDate } from \"@internationalized/date\";\n\nexport function toCalendarDate(d: Date) {\n return new CalendarDate(d.getFullYear(), d.getMonth() + 1, d.getDate());\n}\n\nexport type oneToFive = 1 | 2 | 3 | 4 | 5;\nexport type zeroToFive = 0 | oneToFive;\nexport type sixToNine = 6 | 7 | 8 | 9;\nexport type zeroToNine = zeroToFive | sixToNine;\nexport type oneToNine = oneToFive | sixToNine;\nexport type TimeUnit = \"hours\" | \"minutes\" | \"seconds\";\nexport type Hours = `${0 | 1}${zeroToNine}` | `2${0 | 1 | 2 | 3}`;\nexport type Minutes = `${zeroToFive}${zeroToNine}`;\nexport type Seconds = `${zeroToFive}${zeroToNine}`;\n\nexport type TimeUnitValue<T extends TimeUnit> = T extends \"hours\"\n ? Hours\n : T extends \"minutes\"\n ? Minutes\n : Seconds;\n\n// This should work, works fine in TypeScript playground, but hangs tsc\n// export type TimeString = `${Hours}:${Minutes}:${Seconds}`;\nexport type TimeString =\n `${number}${number}:${number}${number}:${number}${number}`;\n\ntype YYYY = `19${zeroToNine}${zeroToNine}` | `20${zeroToNine}${zeroToNine}`;\ntype MM = `0${oneToNine}` | `1${0 | 1 | 2}`;\ntype DD = `${0}${oneToNine}` | `${1 | 2}${zeroToNine}` | `3${0 | 1}`;\n\nexport type DateStringISO = `${YYYY}-${MM}-${DD}`;\n\nexport const zeroTime: TimeString = \"00:00:00\";\nexport const zeroTimeUnit: TimeUnitValue<TimeUnit> = \"00\";\n\nexport function incrementTimeUnitValue<T extends TimeUnit>(\n unit: T,\n value: TimeUnitValue<T>,\n) {\n const num = parseInt(value);\n if (unit === \"hours\" && num < 23) {\n return `${num + 1}`.padStart(2, \"0\").slice(-2) as Hours;\n } else if (unit === \"hours\" && num === 23) {\n return \"00\" as Hours;\n } else if (num < 59) {\n return `${num + 1}`.padStart(2, \"0\").slice(-2) as TimeUnitValue<T>;\n } else if (num === 59) {\n return \"00\" as TimeUnitValue<T>;\n }\n return value;\n}\n\nexport function decrementTimeUnitValue<T extends TimeUnit>(\n unit: T,\n value: TimeUnitValue<T>,\n) {\n const num = parseInt(value);\n if (unit === \"hours\" && num > 0) {\n return `${num - 1}`.padStart(2, \"0\").slice(-2) as Hours;\n } else if (unit === \"hours\" && num === 0) {\n return \"23\" as Hours;\n } else if (num > 0) {\n return `${num - 1}`.padStart(2, \"0\").slice(-2) as TimeUnitValue<T>;\n } else if (num === 0) {\n return \"59\" as TimeUnitValue<T>;\n }\n return value;\n}\n\n// TODO accept numeric values with appropriate type checks\nexport function updateTimeString<T extends TimeUnit>(\n timeString: TimeString,\n unit: T,\n value: TimeUnitValue<T>,\n): TimeString {\n const newTimeString =\n unit === \"hours\"\n ? value.concat(timeString.slice(2))\n : unit === \"minutes\"\n ? timeString.slice(0, 3).concat(value).concat(timeString.slice(5))\n : timeString.slice(0, 6).concat(value);\n if (isValidTimeString(newTimeString)) {\n return newTimeString;\n } else {\n throw Error(`[date-utils] udateTimeSting invalid result ${newTimeString}`);\n }\n}\n\nconst validTimePattern = /(?:[0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/;\nexport const isValidTimeString = (value: unknown): value is TimeString =>\n typeof value === \"string\" && validTimePattern.test(value);\n\nexport function asTimeString(value: unknown, allowUndefined: false): TimeString;\nexport function asTimeString(\n value: unknown,\n allowUndefined?: true,\n): TimeString | undefined;\nexport function asTimeString(\n value: unknown,\n allowUndefined = false,\n): TimeString | undefined {\n if (value === undefined) {\n if (allowUndefined) {\n return value;\n } else {\n throw Error(\"[date-utils] asTimeString, value cannot be undefined\");\n }\n } else if (isValidTimeString(value)) {\n return value;\n } else if (typeof value === \"number\") {\n // we are assuming we have a value representing milliseconds since epoch.\n // If not, we will get an unpredictable time here. Is this too risky ?\n return Time.millisToTimeString(value);\n } else if (typeof value === \"string\") {\n // see if we have a long value, test if we can create time\n const valueAsInt = parseInt(value);\n if (!isNaN(valueAsInt)) {\n return Time.millisToTimeString(valueAsInt);\n }\n } else {\n throw Error(\n `[date-utils] asTimeString, value ${value} is not valid TimeString`,\n );\n }\n}\n\nexport interface Time {\n hours: number;\n minutes: number;\n seconds: number;\n asDate: (date?: Date | DateStringISO) => Date;\n}\n\nconst padZero = (val: number) => `${val}`.padStart(2, \"0\");\n\nclass TimeImpl implements Time {\n #hours: number;\n #minutes: number;\n #seconds: number;\n\n constructor(timeString: TimeString) {\n const [hours, minutes, seconds] = timeString.split(\":\");\n this.#hours = parseInt(hours);\n this.#minutes = parseInt(minutes);\n this.#seconds = parseInt(seconds);\n }\n\n get hours() {\n return this.#hours;\n }\n get minutes() {\n return this.#minutes;\n }\n get seconds() {\n return this.#seconds;\n }\n\n asDate(date?: Date | DateStringISO) {\n const dt =\n date === undefined\n ? new Date()\n : typeof date === \"string\"\n ? new Date(date)\n : date;\n\n dt.setHours(this.#hours);\n dt.setMinutes(this.#minutes);\n dt.setSeconds(this.seconds);\n dt.setMilliseconds(0);\n return dt;\n }\n\n toString() {\n return Time.toString(this.#hours, this.#minutes, this.#seconds);\n }\n}\n\nexport const Time = (timeString: TimeString): Time =>\n new TimeImpl(timeString) as Time;\n\nTime.millisToTimeString = (timestamp: number) =>\n new Date(timestamp).toTimeString().slice(0, 8) as TimeString;\n\nTime.toString = (hours: number, minutes: number, seconds: number) => {\n return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}` as TimeString;\n};\n"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,MAAA,EAAA,QAAA,EAAA,QAAA;AAEO,SAAS,eAAe,CAAS,EAAA;AACtC,EAAO,OAAA,IAAI,YAAa,CAAA,CAAA,CAAE,WAAY,EAAA,EAAG,CAAE,CAAA,QAAA,EAAa,GAAA,CAAA,EAAG,CAAE,CAAA,OAAA,EAAS,CAAA;AACxE;AA6BO,MAAM,QAAuB,GAAA;AAC7B,MAAM,YAAwC,GAAA;AAErC,SAAA,sBAAA,CACd,MACA,KACA,EAAA;AACA,EAAM,MAAA,GAAA,GAAM,SAAS,KAAK,CAAA;AAC1B,EAAI,IAAA,IAAA,KAAS,OAAW,IAAA,GAAA,GAAM,EAAI,EAAA;AAChC,IAAO,OAAA,CAAA,EAAG,MAAM,CAAC,CAAA,CAAA,CAAG,SAAS,CAAG,EAAA,GAAG,CAAE,CAAA,KAAA,CAAM,CAAE,CAAA,CAAA;AAAA,GACpC,MAAA,IAAA,IAAA,KAAS,OAAW,IAAA,GAAA,KAAQ,EAAI,EAAA;AACzC,IAAO,OAAA,IAAA;AAAA,GACT,MAAA,IAAW,MAAM,E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,KAAK,QAAS,CAAA,YAAA,CAAA,IAAA,EAAK,SAAQ,YAAK,CAAA,IAAA,EAAA,QAAA,CAAA,EAAU,mBAAK,QAAQ,CAAA,CAAA;AAAA;AAElE;AAvCE,MAAA,GAAA,IAAA,OAAA,EAAA;AACA,QAAA,GAAA,IAAA,OAAA,EAAA;AACA,QAAA,GAAA,IAAA,OAAA,EAAA;AAuCK,MAAM,IAAO,GAAA,CAAC,UACnB,KAAA,IAAI,SAAS,UAAU;AAEzB,IAAK,CAAA,kBAAA,GAAqB,CAAC,SAAA,KACzB,IAAI,IAAA,CAAK,SAAS,CAAA,CAAE,YAAa,EAAA,CAAE,KAAM,CAAA,CAAA,EAAG,CAAC,CAAA;AAE/C,IAAA,CAAK,QAAW,GAAA,CAAC,KAAe,EAAA,OAAA,EAAiB,OAAoB,KAAA;AACnE,EAAO,OAAA,CAAA,EAAG,OAAQ,CAAA,KAAK,CAAC,CAAA,CAAA,EAAI,OAAQ,CAAA,OAAO,CAAC,CAAA,CAAA,EAAI,OAAQ,CAAA,OAAO,CAAC,CAAA,CAAA;AAClE,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"date-utils.js","sources":["../../../../../../../packages/vuu-utils/src/date/date-utils.ts"],"sourcesContent":["import { CalendarDate } from \"@internationalized/date\";\n\nexport function toCalendarDate(d: Date) {\n return new CalendarDate(d.getFullYear(), d.getMonth() + 1, d.getDate());\n}\n\nexport type oneToFive = 1 | 2 | 3 | 4 | 5;\nexport type zeroToFive = 0 | oneToFive;\nexport type sixToNine = 6 | 7 | 8 | 9;\nexport type zeroToNine = zeroToFive | sixToNine;\nexport type oneToNine = oneToFive | sixToNine;\nexport type TimeUnit = \"hours\" | \"minutes\" | \"seconds\";\nexport type Hours = `${0 | 1}${zeroToNine}` | `2${0 | 1 | 2 | 3}`;\nexport type Minutes = `${zeroToFive}${zeroToNine}`;\nexport type Seconds = `${zeroToFive}${zeroToNine}`;\n\nexport type TimeUnitValue<T extends TimeUnit> = T extends \"hours\"\n ? Hours\n : T extends \"minutes\"\n ? Minutes\n : Seconds;\n\n// This should work, works fine in TypeScript playground, but hangs tsc\n// export type TimeString = `${Hours}:${Minutes}:${Seconds}`;\nexport type TimeString =\n `${number}${number}:${number}${number}:${number}${number}`;\n\ntype YYYY = `19${zeroToNine}${zeroToNine}` | `20${zeroToNine}${zeroToNine}`;\ntype MM = `0${oneToNine}` | `1${0 | 1 | 2}`;\ntype DD = `${0}${oneToNine}` | `${1 | 2}${zeroToNine}` | `3${0 | 1}`;\n\nexport type DateStringISO = `${YYYY}-${MM}-${DD}`;\n\nexport const zeroTime: TimeString = \"00:00:00\";\nexport const zeroTimeUnit: TimeUnitValue<TimeUnit> = \"00\";\n\nexport function incrementTimeUnitValue<T extends TimeUnit>(\n unit: T,\n value: TimeUnitValue<T>,\n) {\n const num = parseInt(value);\n if (unit === \"hours\" && num < 23) {\n return `${num + 1}`.padStart(2, \"0\").slice(-2) as Hours;\n } else if (unit === \"hours\" && num === 23) {\n return \"00\" as Hours;\n } else if (num < 59) {\n return `${num + 1}`.padStart(2, \"0\").slice(-2) as TimeUnitValue<T>;\n } else if (num === 59) {\n return \"00\" as TimeUnitValue<T>;\n }\n return value;\n}\n\nexport function decrementTimeUnitValue<T extends TimeUnit>(\n unit: T,\n value: TimeUnitValue<T>,\n) {\n const num = parseInt(value);\n if (unit === \"hours\" && num > 0) {\n return `${num - 1}`.padStart(2, \"0\").slice(-2) as Hours;\n } else if (unit === \"hours\" && num === 0) {\n return \"23\" as Hours;\n } else if (num > 0) {\n return `${num - 1}`.padStart(2, \"0\").slice(-2) as TimeUnitValue<T>;\n } else if (num === 0) {\n return \"59\" as TimeUnitValue<T>;\n }\n return value;\n}\n\n// TODO accept numeric values with appropriate type checks\nexport function updateTimeString<T extends TimeUnit>(\n timeString: TimeString,\n unit: T,\n value: TimeUnitValue<T>,\n): TimeString {\n const newTimeString =\n unit === \"hours\"\n ? value.concat(timeString.slice(2))\n : unit === \"minutes\"\n ? timeString.slice(0, 3).concat(value).concat(timeString.slice(5))\n : timeString.slice(0, 6).concat(value);\n if (isValidTimeString(newTimeString)) {\n return newTimeString;\n } else {\n throw Error(`[date-utils] udateTimeSting invalid result ${newTimeString}`);\n }\n}\n\nconst validTimePattern = /(?:[0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/;\nexport const isValidTimeString = (value: unknown): value is TimeString =>\n typeof value === \"string\" && validTimePattern.test(value);\n\nexport function asTimeString(value: unknown, allowUndefined: false): TimeString;\nexport function asTimeString(\n value: unknown,\n allowUndefined?: true,\n): TimeString | undefined;\nexport function asTimeString(\n value: unknown,\n allowUndefined = false,\n): TimeString | undefined {\n if (value === undefined) {\n if (allowUndefined) {\n return value;\n } else {\n throw Error(\"[date-utils] asTimeString, value cannot be undefined\");\n }\n } else if (isValidTimeString(value)) {\n return value;\n } else if (typeof value === \"number\") {\n // we are assuming we have a value representing milliseconds since epoch.\n // If not, we will get an unpredictable time here. Is this too risky ?\n return Time.millisToTimeString(value);\n } else if (typeof value === \"string\") {\n // see if we have a long value, test if we can create time\n const valueAsInt = parseInt(value);\n if (!isNaN(valueAsInt)) {\n return Time.millisToTimeString(valueAsInt);\n }\n } else {\n throw Error(\n `[date-utils] asTimeString, value ${value} is not valid TimeString`,\n );\n }\n}\n\nexport interface Time {\n hours: number;\n minutes: number;\n seconds: number;\n asDate: (date?: Date | DateStringISO) => Date;\n}\n\nconst padZero = (val: number) => `${val}`.padStart(2, \"0\");\n\nclass TimeImpl implements Time {\n #hours: number;\n #minutes: number;\n #seconds: number;\n\n constructor(timeString: TimeString) {\n const [hours, minutes, seconds] = timeString.split(\":\");\n this.#hours = parseInt(hours);\n this.#minutes = parseInt(minutes);\n this.#seconds = parseInt(seconds);\n }\n\n get hours() {\n return this.#hours;\n }\n get minutes() {\n return this.#minutes;\n }\n get seconds() {\n return this.#seconds;\n }\n\n asDate(date?: Date | DateStringISO) {\n const dt =\n date === undefined\n ? new Date()\n : typeof date === \"string\"\n ? new Date(date)\n : date;\n\n dt.setHours(this.#hours);\n dt.setMinutes(this.#minutes);\n dt.setSeconds(this.seconds);\n dt.setMilliseconds(0);\n return dt;\n }\n\n toString() {\n return Time.toString(this.#hours, this.#minutes, this.#seconds);\n }\n}\n\nexport const Time = (timeString: TimeString): Time =>\n new TimeImpl(timeString) as Time;\n\nTime.millisToTimeString = (timestamp: number) =>\n new Date(timestamp).toTimeString().slice(0, 8) as TimeString;\n\nTime.toString = (hours: number, minutes: number, seconds: number) => {\n return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}` as TimeString;\n};\n\nTime.isDateInMillis = (dtInMillis: string | number): boolean => {\n const n =\n typeof dtInMillis === \"number\" ? dtInMillis : Number(dtInMillis);\n if (!Number.isFinite(n) || !Number.isInteger(n)) return false;\n\n return new Date(n).getTime() === n;\n};\n"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,MAAA,EAAA,QAAA,EAAA,QAAA;AAEO,SAAS,eAAe,CAAS,EAAA;AACtC,EAAO,OAAA,IAAI,YAAa,CAAA,CAAA,CAAE,WAAY,EAAA,EAAG,CAAE,CAAA,QAAA,EAAa,GAAA,CAAA,EAAG,CAAE,CAAA,OAAA,EAAS,CAAA;AACxE;AA6BO,MAAM,QAAuB,GAAA;AAC7B,MAAM,YAAwC,GAAA;AAErC,SAAA,sBAAA,CACd,MACA,KACA,EAAA;AACA,EAAM,MAAA,GAAA,GAAM,SAAS,KAAK,CAAA;AAC1B,EAAI,IAAA,IAAA,KAAS,OAAW,IAAA,GAAA,GAAM,EAAI,EAAA;AAChC,IAAO,OAAA,CAAA,EAAG,MAAM,CAAC,CAAA,CAAA,CAAG,SAAS,CAAG,EAAA,GAAG,CAAE,CAAA,KAAA,CAAM,CAAE,CAAA,CAAA;AAAA,GACpC,MAAA,IAAA,IAAA,KAAS,OAAW,IAAA,GAAA,KAAQ,EAAI,EAAA;AACzC,IAAO,OAAA,IAAA;AAAA,GACT,MAAA,IAAW,MAAM,EAAI,EAAA;AACnB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AA,YAAA,CAAA,IAAA,EAAK,SAAQ,YAAK,CAAA,IAAA,EAAA,QAAA,CAAA,EAAU,mBAAK,QAAQ,CAAA,CAAA;AAAA;AAElE;AAvCE,MAAA,GAAA,IAAA,OAAA,EAAA;AACA,QAAA,GAAA,IAAA,OAAA,EAAA;AACA,QAAA,GAAA,IAAA,OAAA,EAAA;AAuCK,MAAM,IAAO,GAAA,CAAC,UACnB,KAAA,IAAI,SAAS,UAAU;AAEzB,IAAK,CAAA,kBAAA,GAAqB,CAAC,SAAA,KACzB,IAAI,IAAA,CAAK,SAAS,CAAA,CAAE,YAAa,EAAA,CAAE,KAAM,CAAA,CAAA,EAAG,CAAC,CAAA;AAE/C,IAAA,CAAK,QAAW,GAAA,CAAC,KAAe,EAAA,OAAA,EAAiB,OAAoB,KAAA;AACnE,EAAO,OAAA,CAAA,EAAG,OAAQ,CAAA,KAAK,CAAC,CAAA,CAAA,EAAI,OAAQ,CAAA,OAAO,CAAC,CAAA,CAAA,EAAI,OAAQ,CAAA,OAAO,CAAC,CAAA,CAAA;AAClE,CAAA;AAEA,IAAK,CAAA,cAAA,GAAiB,CAAC,UAAyC,KAAA;AAC9D,EAAA,MAAM,IACJ,OAAO,UAAA,KAAe,QAAW,GAAA,UAAA,GAAa,OAAO,UAAU,CAAA;AACjE,EAAI,IAAA,CAAC,MAAO,CAAA,QAAA,CAAS,CAAC,CAAA,IAAK,CAAC,MAAO,CAAA,SAAA,CAAU,CAAC,CAAA,EAAU,OAAA,KAAA;AAExD,EAAA,OAAO,IAAI,IAAA,CAAK,CAAC,CAAA,CAAE,SAAc,KAAA,CAAA;AACnC,CAAA;;;;"}
|
|
@@ -59,8 +59,8 @@ function getTypedValue(value, type, throwIfInvalid = false, options) {
|
|
|
59
59
|
} else {
|
|
60
60
|
return +Time(value).asDate();
|
|
61
61
|
}
|
|
62
|
-
} else if (
|
|
63
|
-
return value;
|
|
62
|
+
} else if (value.length > 0 && Time.isDateInMillis(value)) {
|
|
63
|
+
return Number(value);
|
|
64
64
|
} else if (throwIfInvalid) {
|
|
65
65
|
throw Error(`value ${value} is not a valid ${type}`);
|
|
66
66
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-utils.js","sources":["../../../../../../packages/vuu-utils/src/form-utils.ts"],"sourcesContent":["import { DataValueTypeSimple } from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuColumnDataType,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { KeyboardEvent, SyntheticEvent } from \"react\";\nimport { stringIsValidDecimal, stringIsValidInt } from \"./data-utils\";\nimport { isValidTimeString, Time } from \"./date\";\nimport { queryClosest } from \"./html-utils\";\nimport { ExtendedFilterOptions } from \"@vuu-ui/vuu-filter-types\";\n\n/**\n * Use with the following convention:\n *\n * <FormField data-field=\"my-field-name\">\n */\nexport const getFieldName = (target: EventTarget | HTMLElement): string => {\n const saltFormField = queryClosest(target, \"[data-field]\") as HTMLElement;\n const fieldName = saltFormField?.dataset.field;\n if (fieldName) {\n return fieldName;\n } else {\n throw Error(\"named form field not found\");\n }\n};\n\nexport type InputSource = \"typeahead-suggestion\" | \"text-input\";\n\nexport const isNumber = (\n type: string,\n value: VuuRowDataItemType,\n): value is number => type === \"number\";\n\nexport type CommitHandler<\n E extends HTMLElement = HTMLInputElement,\n T = VuuRowDataItemType,\n> = (\n evt: SyntheticEvent<E> | KeyboardEvent<E>,\n value: T,\n source?: InputSource,\n) => void;\n\nexport const isValidRange = <T>([val1, val2]: [T, T]) => {\n if (isValidTimeString(val1) && isValidTimeString(val2)) {\n return val2 > val1;\n }\n return true;\n};\n\n/**\n * Convert a pair of string values to the type appropriate for the\n * associated column or form field. Can be used when processing a string value\n * from an input used for user editing.\n *\n */\nexport function getTypedRange(\n [value1, value2]: [string, string],\n dataType: VuuColumnDataType | DataValueTypeSimple,\n options?: ExtendedFilterOptions,\n) {\n return [\n getTypedValue(value1, dataType, false, options),\n getTypedValue(value2, dataType, false, options),\n ];\n}\n\n/**\n * Convert a string value to the type appropriate for the associated\n * column or form field. Can be used when processing a string value\n * from an input used for user editing.\n *\n * @param value\n * @param type\n * @param throwIfInvalid\n */\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid?: false,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType | undefined;\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid: true,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType;\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid = false,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType | undefined {\n switch (type) {\n case \"int\":\n case \"long\": {\n if (stringIsValidInt(value)) {\n return parseInt(value, 10);\n } else if (isValidTimeString(value)) {\n //TOCHECK\n return value;\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n }\n\n case \"double\":\n case \"number\": {\n if (stringIsValidDecimal(value)) {\n return parseFloat(value);\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n }\n\n case \"boolean\":\n return value === \"true\" ? true : false;\n\n case \"time\":\n if (isValidTimeString(value)) {\n // We don't manipulate the values of 'extended' filters, the\n // ExtendedFilter impementation will do that.\n if (options?.type === \"TimeString\") {\n return value;\n } else {\n return +Time(value).asDate();\n }\n } else if (
|
|
1
|
+
{"version":3,"file":"form-utils.js","sources":["../../../../../../packages/vuu-utils/src/form-utils.ts"],"sourcesContent":["import { DataValueTypeSimple } from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuColumnDataType,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { KeyboardEvent, SyntheticEvent } from \"react\";\nimport { stringIsValidDecimal, stringIsValidInt } from \"./data-utils\";\nimport { isValidTimeString, Time } from \"./date\";\nimport { queryClosest } from \"./html-utils\";\nimport { ExtendedFilterOptions } from \"@vuu-ui/vuu-filter-types\";\n\n/**\n * Use with the following convention:\n *\n * <FormField data-field=\"my-field-name\">\n */\nexport const getFieldName = (target: EventTarget | HTMLElement): string => {\n const saltFormField = queryClosest(target, \"[data-field]\") as HTMLElement;\n const fieldName = saltFormField?.dataset.field;\n if (fieldName) {\n return fieldName;\n } else {\n throw Error(\"named form field not found\");\n }\n};\n\nexport type InputSource = \"typeahead-suggestion\" | \"text-input\";\n\nexport const isNumber = (\n type: string,\n value: VuuRowDataItemType,\n): value is number => type === \"number\";\n\nexport type CommitHandler<\n E extends HTMLElement = HTMLInputElement,\n T = VuuRowDataItemType,\n> = (\n evt: SyntheticEvent<E> | KeyboardEvent<E>,\n value: T,\n source?: InputSource,\n) => void;\n\nexport const isValidRange = <T>([val1, val2]: [T, T]) => {\n if (isValidTimeString(val1) && isValidTimeString(val2)) {\n return val2 > val1;\n }\n return true;\n};\n\n/**\n * Convert a pair of string values to the type appropriate for the\n * associated column or form field. Can be used when processing a string value\n * from an input used for user editing.\n *\n */\nexport function getTypedRange(\n [value1, value2]: [string, string],\n dataType: VuuColumnDataType | DataValueTypeSimple,\n options?: ExtendedFilterOptions,\n) {\n return [\n getTypedValue(value1, dataType, false, options),\n getTypedValue(value2, dataType, false, options),\n ];\n}\n\n/**\n * Convert a string value to the type appropriate for the associated\n * column or form field. Can be used when processing a string value\n * from an input used for user editing.\n *\n * @param value\n * @param type\n * @param throwIfInvalid\n */\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid?: false,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType | undefined;\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid: true,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType;\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | DataValueTypeSimple,\n throwIfInvalid = false,\n options?: ExtendedFilterOptions,\n): VuuRowDataItemType | undefined {\n switch (type) {\n case \"int\":\n case \"long\": {\n if (stringIsValidInt(value)) {\n return parseInt(value, 10);\n } else if (isValidTimeString(value)) {\n //TOCHECK\n return value;\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n }\n\n case \"double\":\n case \"number\": {\n if (stringIsValidDecimal(value)) {\n return parseFloat(value);\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n }\n\n case \"boolean\":\n return value === \"true\" ? true : false;\n\n case \"time\":\n if (isValidTimeString(value)) {\n // We don't manipulate the values of 'extended' filters, the\n // ExtendedFilter impementation will do that.\n if (options?.type === \"TimeString\") {\n return value;\n } else {\n return +Time(value).asDate();\n }\n } else if (value.length > 0 && Time.isDateInMillis(value)) {\n //if value previously converted\n return Number(value);\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n default:\n return value;\n }\n}\n"],"names":[],"mappings":";;;;;;AAgBa,MAAA,YAAA,GAAe,CAAC,MAA8C,KAAA;AACzE,EAAM,MAAA,aAAA,GAAgB,YAAa,CAAA,MAAA,EAAQ,cAAc,CAAA;AACzD,EAAM,MAAA,SAAA,GAAY,eAAe,OAAQ,CAAA,KAAA;AACzC,EAAA,IAAI,SAAW,EAAA;AACb,IAAO,OAAA,SAAA;AAAA,GACF,MAAA;AACL,IAAA,MAAM,MAAM,4BAA4B,CAAA;AAAA;AAE5C;AAIO,MAAM,QAAW,GAAA,CACtB,IACA,EAAA,KAAA,KACoB,IAAS,KAAA;AAWxB,MAAM,YAAe,GAAA,CAAI,CAAC,IAAA,EAAM,IAAI,CAAc,KAAA;AACvD,EAAA,IAAI,iBAAkB,CAAA,IAAI,CAAK,IAAA,iBAAA,CAAkB,IAAI,CAAG,EAAA;AACtD,IAAA,OAAO,IAAO,GAAA,IAAA;AAAA;AAEhB,EAAO,OAAA,IAAA;AACT;AAQO,SAAS,cACd,CA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AA,OAAA,EAAS,SAAS,YAAc,EAAA;AAClC,UAAO,OAAA,KAAA;AAAA,SACF,MAAA;AACL,UAAA,OAAO,CAAC,IAAA,CAAK,KAAK,CAAA,CAAE,MAAO,EAAA;AAAA;AAC7B,iBACS,KAAM,CAAA,MAAA,GAAS,KAAK,IAAK,CAAA,cAAA,CAAe,KAAK,CAAG,EAAA;AAEzD,QAAA,OAAO,OAAO,KAAK,CAAA;AAAA,iBACV,cAAgB,EAAA;AACzB,QAAA,MAAM,KAAM,CAAA,CAAA,MAAA,EAAS,KAAK,CAAA,gBAAA,EAAmB,IAAI,CAAE,CAAA,CAAA;AAAA,OAC9C,MAAA;AACL,QAAO,OAAA,KAAA,CAAA;AAAA;AACT,IACF;AACE,MAAO,OAAA,KAAA;AAAA;AAEb;;;;"}
|
|
@@ -45,7 +45,7 @@ export { asReactElements, createSyntheticEvent, isSimpleStateValue, useIsMounted
|
|
|
45
45
|
export { roundDecimal } from './round-decimal.js';
|
|
46
46
|
export { debounce, throttle } from './perf-utils.js';
|
|
47
47
|
export { DeferredPromise } from './promise-utils.js';
|
|
48
|
-
export { hasViewPortContext, isActionMessage, isCreateVpSuccess, isCustomComponentActionMessage, isLoginResponse, isOpenDialogAction, isOpenSessionTableDialogMessage, isRequestResponse, isRpcServiceRequest, isSelectRequest, isSelectSuccessWithRowCount, isSessionTable, isSessionTableActionMessage, isTypeaheadRequest, isVuuMenuRpcRequest } from './protocol-message-utils.js';
|
|
48
|
+
export { INVALID_SESSION, INVALID_TOKEN, SESSION_LIMIT_EXCEEDED, TOKEN_EXPIRED, hasViewPortContext, isActionMessage, isCreateVpSuccess, isCustomComponentActionMessage, isLoginErrorMessage, isLoginResponse, isOpenDialogAction, isOpenSessionTableDialogMessage, isRequestResponse, isRpcServiceRequest, isSelectRequest, isSelectSuccessWithRowCount, isSessionTable, isSessionTableActionMessage, isTypeaheadRequest, isVuuMenuRpcRequest } from './protocol-message-utils.js';
|
|
49
49
|
export { NULL_RANGE, Range, WindowRange, getFullRange, rangeNewItems, withinRange } from './range-utils.js';
|
|
50
50
|
export { actualRowPositioning, asDataSourceRowObject, virtualRowPositioning, vuuRowToDataSourceRow } from './row-utils.js';
|
|
51
51
|
export { deselectItem, selectItem } from './selection-utils.js';
|
|
@@ -6,7 +6,18 @@ const MENU_RPC_TYPES = [
|
|
|
6
6
|
"VIEW_PORT_MENU_ROW_RPC",
|
|
7
7
|
"VIEW_PORT_MENU_CELL_RPC"
|
|
8
8
|
];
|
|
9
|
-
const
|
|
9
|
+
const INVALID_SESSION = "Invalid session";
|
|
10
|
+
const SESSION_LIMIT_EXCEEDED = "User session limit exceeded";
|
|
11
|
+
const INVALID_TOKEN = "Invalid token";
|
|
12
|
+
const TOKEN_EXPIRED = "Token has expired";
|
|
13
|
+
const InvalidLoginMessages = [
|
|
14
|
+
INVALID_SESSION,
|
|
15
|
+
SESSION_LIMIT_EXCEEDED,
|
|
16
|
+
INVALID_TOKEN,
|
|
17
|
+
TOKEN_EXPIRED
|
|
18
|
+
];
|
|
19
|
+
const isLoginErrorMessage = (message) => typeof message === "string" && InvalidLoginMessages.includes(message);
|
|
20
|
+
const isSelectRequest = (message) => message && typeof message === "object" && "type" in message && (message.type === "SELECT_ROW" || message.type === "DESELECT_ROW" || message.type === "SELECT_ROW_RANGE" || message.type === "SELECT_ALL" || message.type === "DESELECT_ALL");
|
|
10
21
|
const isSelectSuccessWithRowCount = (response) => [
|
|
11
22
|
"SELECT_ROW_SUCCESS",
|
|
12
23
|
"DESELECT_ROW_SUCCESS",
|
|
@@ -17,7 +28,7 @@ const isSelectSuccessWithRowCount = (response) => [
|
|
|
17
28
|
const isRpcServiceRequest = (message) => message.type === "RPC_REQUEST";
|
|
18
29
|
const hasViewPortContext = (message) => message.context.type === "VIEWPORT_CONTEXT";
|
|
19
30
|
const isVuuMenuRpcRequest = (message) => MENU_RPC_TYPES.includes(message["type"]);
|
|
20
|
-
const isLoginResponse = (message) => "type" in message && (message.type === "LOGIN_SUCCESS" || message.type === "LOGIN_FAIL");
|
|
31
|
+
const isLoginResponse = (message) => message !== null && typeof message === "object" && "type" in message && (message.type === "LOGIN_SUCCESS" || message.type === "LOGIN_FAIL");
|
|
21
32
|
const isRequestResponse = (message) => "requestId" in message;
|
|
22
33
|
const isOpenSessionTableDialogMessage = (rpcResponse) => rpcResponse.type === "VIEW_PORT_MENU_RESP" && isOpenDialogAction(rpcResponse.action) && "tableSchema" in rpcResponse.action;
|
|
23
34
|
const isOpenDialogAction = (action) => action !== void 0 && action.type === "OPEN_DIALOG_ACTION";
|
|
@@ -41,5 +52,5 @@ function isCustomComponentActionMessage(rpcResponse) {
|
|
|
41
52
|
return isActionMessage(rpcResponse) && isOpenDialogAction(rpcResponse.action) && isSessionTable(rpcResponse.action.table) && typeof rpcResponse.action.renderComponent === "string" && isView(rpcResponse.action.renderComponent);
|
|
42
53
|
}
|
|
43
54
|
|
|
44
|
-
export { hasViewPortContext, isActionMessage, isCreateVpSuccess, isCustomComponentActionMessage, isLoginResponse, isOpenDialogAction, isOpenSessionTableDialogMessage, isRequestResponse, isRpcServiceRequest, isSelectRequest, isSelectSuccessWithRowCount, isSessionTable, isSessionTableActionMessage, isTypeaheadRequest, isVuuMenuRpcRequest };
|
|
55
|
+
export { INVALID_SESSION, INVALID_TOKEN, SESSION_LIMIT_EXCEEDED, TOKEN_EXPIRED, hasViewPortContext, isActionMessage, isCreateVpSuccess, isCustomComponentActionMessage, isLoginErrorMessage, isLoginResponse, isOpenDialogAction, isOpenSessionTableDialogMessage, isRequestResponse, isRpcServiceRequest, isSelectRequest, isSelectSuccessWithRowCount, isSessionTable, isSessionTableActionMessage, isTypeaheadRequest, isVuuMenuRpcRequest };
|
|
45
56
|
//# sourceMappingURL=protocol-message-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-message-utils.js","sources":["../../../../../../packages/vuu-utils/src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n TableSchema,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcMenuRequest,\n OpenDialogAction,\n VuuRpcRequest,\n VuuRpcResponse,\n VuuRpcMenuSuccess,\n VuuTable,\n VuuViewportRpcTypeaheadRequest,\n VuuRpcServiceRequest,\n ViewportRpcContext,\n OpenComponentInDialogAction,\n
|
|
1
|
+
{"version":3,"file":"protocol-message-utils.js","sources":["../../../../../../packages/vuu-utils/src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n TableSchema,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcMenuRequest,\n OpenDialogAction,\n VuuRpcRequest,\n VuuRpcResponse,\n VuuRpcMenuSuccess,\n VuuTable,\n VuuViewportRpcTypeaheadRequest,\n VuuRpcServiceRequest,\n ViewportRpcContext,\n OpenComponentInDialogAction,\n VuuLoginSuccessResponse,\n SelectRequest,\n SelectResponse,\n SelectSuccessWithRowCount,\n VuuViewportCreateSuccessResponse,\n VuuViewportCreateResponse,\n InvalidTokenReason,\n InvalidSessionReason,\n LoginErrorMessage,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { isView as componentInRegistry } from \"./component-registry\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n];\n\nexport const INVALID_SESSION: InvalidSessionReason = \"Invalid session\";\nexport const SESSION_LIMIT_EXCEEDED: InvalidSessionReason =\n \"User session limit exceeded\";\nexport const INVALID_TOKEN: InvalidTokenReason = \"Invalid token\";\nexport const TOKEN_EXPIRED: InvalidTokenReason = \"Token has expired\";\n\nconst InvalidLoginMessages: string[] = [\n INVALID_SESSION,\n SESSION_LIMIT_EXCEEDED,\n INVALID_TOKEN,\n TOKEN_EXPIRED,\n];\n\nexport const isLoginErrorMessage = (\n message: unknown,\n): message is LoginErrorMessage =>\n typeof message === \"string\" && InvalidLoginMessages.includes(message);\n\nexport const isSelectRequest = (message: object): message is SelectRequest =>\n message &&\n typeof message === \"object\" &&\n \"type\" in message &&\n (message.type === \"SELECT_ROW\" ||\n message.type === \"DESELECT_ROW\" ||\n message.type === \"SELECT_ROW_RANGE\" ||\n message.type === \"SELECT_ALL\" ||\n message.type === \"DESELECT_ALL\");\n\nexport const isSelectSuccessWithRowCount = (\n response: SelectResponse | SelectSuccessWithRowCount,\n): response is SelectSuccessWithRowCount =>\n [\n \"SELECT_ROW_SUCCESS\",\n \"DESELECT_ROW_SUCCESS\",\n \"SELECT_ROW_RANGE_SUCCESS\",\n \"SELECT_ALL_SUCCESS\",\n \"DESELECT_ALL_SUCCESS\",\n ].includes(response.type ?? \"\") &&\n typeof (response as SelectSuccessWithRowCount).selectedRowCount === \"number\";\n\nexport const isRpcServiceRequest = (message: {\n type: string;\n}): message is VuuRpcServiceRequest | Omit<VuuRpcServiceRequest, \"context\"> =>\n message.type === \"RPC_REQUEST\";\n\nexport const hasViewPortContext = (\n message: VuuRpcServiceRequest,\n): message is VuuRpcServiceRequest<ViewportRpcContext> =>\n message.context.type === \"VIEWPORT_CONTEXT\";\n\nexport const isVuuMenuRpcRequest = (\n message: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): message is VuuRpcMenuRequest => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isLoginResponse = (\n message: unknown,\n): message is VuuLoginSuccessResponse =>\n message !== null &&\n typeof message === \"object\" &&\n \"type\" in message &&\n (message.type === \"LOGIN_SUCCESS\" || message.type === \"LOGIN_FAIL\");\n\nexport const isRequestResponse = (\n message: object,\n): message is VuuUiMessageInRequestResponse => \"requestId\" in message;\n\nexport const isOpenSessionTableDialogMessage = (\n rpcResponse: RpcResponse,\n): rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema> =>\n rpcResponse.type === \"VIEW_PORT_MENU_RESP\" &&\n isOpenDialogAction(rpcResponse.action) &&\n \"tableSchema\" in rpcResponse.action;\n\nexport const isOpenDialogAction = (\n action?: MenuRpcAction,\n): action is OpenDialogAction =>\n action !== undefined && action.type === \"OPEN_DIALOG_ACTION\";\n\nexport const isTypeaheadRequest = (\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuViewportRpcTypeaheadRequest, \"vpId\"> => {\n return (\n isRpcServiceRequest(request) &&\n (request.rpcName === \"getUniqueFieldValues\" ||\n request.rpcName === \"getUniqueFieldValuesStartingWith\")\n );\n};\n\nexport const isCreateVpSuccess = (\n response: VuuViewportCreateResponse,\n): response is VuuViewportCreateSuccessResponse =>\n response.type === \"CREATE_VP_SUCCESS\";\n\nexport const isSessionTable = (table?: unknown) => {\n if (\n table !== null &&\n typeof table === \"object\" &&\n \"table\" in table &&\n \"module\" in table\n ) {\n return (table as VuuTable).table.startsWith(\"session\");\n }\n return false;\n};\n\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess;\nexport function isActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<VuuRpcMenuSuccess, \"vpId\">;\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n) {\n return rpcResponse.type === \"VIEW_PORT_MENU_RESP\";\n}\n\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<\n VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n >,\n \"vpId\"\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n rpcResponse.action?.renderComponent === \"inline-form\"\n );\n}\n\nexport function isCustomComponentActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenComponentInDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n typeof rpcResponse.action.renderComponent === \"string\" &&\n componentInRegistry(rpcResponse.action.renderComponent)\n );\n}\n"],"names":["componentInRegistry"],"mappings":";;AA+BA,MAAM,cAAiB,GAAA;AAAA,EACrB,4BAAA;AAAA,EACA,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA;AACF,CAAA;AAEO,MAAM,eAAwC,GAAA;AAC9C,MAAM,sBACX,GAAA;AACK,MAAM,aAAoC,GAAA;AAC1C,MAAM,aAAoC,GAAA;AAEjD,MAAM,oBAAiC,GAAA;AAAA,EACrC,eAAA;AAAA,EACA,sBAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAAA;AAEa,MAAA,mBAAA,GAAsB,CACjC,OAEA,KAAA,OAAO,YAAY,QAAY,IAAA,oBAAA,CAAqB,SAAS,OAAO;AAEzD,MAAA,eAAA,GAAkB,CAAC,OAC9B,KAAA,OAAA,IACA,OAAO,OAAY,KAAA,QAAA,IACnB,MAAU,IAAA,OAAA,KACT,OAAQ,CAAA,IAAA,KAAS,gBAChB,OAAQ,CAAA,IAAA,KAAS,kBACjB,OAAQ,CAAA,IAAA,KAAS,sBACjB,OAAQ,CAAA,IAAA,KAAS,YACjB,IAAA,OAAA,CAAQ,IAAS,KAAA,cAAA;AAER,M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,KAAU,QACV,OAAO,KAAA,KAAU,YACjB,OAAW,IAAA,KAAA,IACX,YAAY,KACZ,EAAA;AACA,IAAQ,OAAA,KAAA,CAAmB,KAAM,CAAA,UAAA,CAAW,SAAS,CAAA;AAAA;AAEvD,EAAO,OAAA,KAAA;AACT;AAQO,SAAS,gBACd,WACA,EAAA;AACA,EAAA,OAAO,YAAY,IAAS,KAAA,qBAAA;AAC9B;AAmBO,SAAS,4BACd,WAKA,EAAA;AACA,EAAA,OACE,eAAgB,CAAA,WAAW,CAC3B,IAAA,kBAAA,CAAmB,YAAY,MAAM,CAAA,IACrC,cAAe,CAAA,WAAA,CAAY,MAAO,CAAA,KAAK,CACvC,IAAA,WAAA,CAAY,QAAQ,eAAoB,KAAA,aAAA;AAE5C;AAEO,SAAS,+BACd,WAKA,EAAA;AACA,EACE,OAAA,eAAA,CAAgB,WAAW,CAC3B,IAAA,kBAAA,CAAmB,YAAY,MAAM,CAAA,IACrC,eAAe,WAAY,CAAA,MAAA,CAAO,KAAK,CACvC,IAAA,OAAO,YAAY,MAAO,CAAA,eAAA,KAAoB,YAC9CA,MAAoB,CAAA,WAAA,CAAY,OAAO,eAAe,CAAA;AAE1D;;;;"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.13.
|
|
2
|
+
"version": "0.13.99-alpha.1",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@vuu-ui/vuu-data-types": "0.13.
|
|
8
|
-
"@vuu-ui/vuu-table-types": "0.13.
|
|
9
|
-
"@vuu-ui/vuu-filter-types": "0.13.
|
|
10
|
-
"@vuu-ui/vuu-protocol-types": "0.13.
|
|
7
|
+
"@vuu-ui/vuu-data-types": "0.13.99-alpha.1",
|
|
8
|
+
"@vuu-ui/vuu-table-types": "0.13.99-alpha.1",
|
|
9
|
+
"@vuu-ui/vuu-filter-types": "0.13.99-alpha.1",
|
|
10
|
+
"@vuu-ui/vuu-protocol-types": "0.13.99-alpha.1"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@internationalized/date": "^3.0.0",
|
|
14
|
-
"@vuu-ui/vuu-filter-parser": "0.13.
|
|
14
|
+
"@vuu-ui/vuu-filter-parser": "0.13.99-alpha.1",
|
|
15
15
|
"clsx": "^2.0.0",
|
|
16
16
|
"react": "^19.2.3",
|
|
17
17
|
"react-dom": "^19.2.3"
|
package/types/cookie-utils.d.ts
CHANGED
|
@@ -33,5 +33,6 @@ export declare const Time: {
|
|
|
33
33
|
(timeString: TimeString): Time;
|
|
34
34
|
millisToTimeString(timestamp: number): TimeString;
|
|
35
35
|
toString(hours: number, minutes: number, seconds: number): TimeString;
|
|
36
|
+
isDateInMillis(dtInMillis: string | number): boolean;
|
|
36
37
|
};
|
|
37
38
|
export {};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { MenuRpcAction, MenuRpcResponse, OpenDialogActionWithSchema, RpcResponse, TableSchema, VuuUiMessageInRequestResponse } from "@vuu-ui/vuu-data-types";
|
|
2
|
-
import { VuuRpcMenuRequest, OpenDialogAction, VuuRpcRequest, VuuRpcResponse, VuuRpcMenuSuccess, VuuViewportRpcTypeaheadRequest, VuuRpcServiceRequest, ViewportRpcContext, OpenComponentInDialogAction,
|
|
2
|
+
import { VuuRpcMenuRequest, OpenDialogAction, VuuRpcRequest, VuuRpcResponse, VuuRpcMenuSuccess, VuuViewportRpcTypeaheadRequest, VuuRpcServiceRequest, ViewportRpcContext, OpenComponentInDialogAction, VuuLoginSuccessResponse, SelectRequest, SelectResponse, SelectSuccessWithRowCount, VuuViewportCreateSuccessResponse, VuuViewportCreateResponse, InvalidTokenReason, InvalidSessionReason, LoginErrorMessage } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
export declare const INVALID_SESSION: InvalidSessionReason;
|
|
4
|
+
export declare const SESSION_LIMIT_EXCEEDED: InvalidSessionReason;
|
|
5
|
+
export declare const INVALID_TOKEN: InvalidTokenReason;
|
|
6
|
+
export declare const TOKEN_EXPIRED: InvalidTokenReason;
|
|
7
|
+
export declare const isLoginErrorMessage: (message: unknown) => message is LoginErrorMessage;
|
|
3
8
|
export declare const isSelectRequest: (message: object) => message is SelectRequest;
|
|
4
9
|
export declare const isSelectSuccessWithRowCount: (response: SelectResponse | SelectSuccessWithRowCount) => response is SelectSuccessWithRowCount;
|
|
5
10
|
export declare const isRpcServiceRequest: (message: {
|
|
@@ -7,7 +12,7 @@ export declare const isRpcServiceRequest: (message: {
|
|
|
7
12
|
}) => message is VuuRpcServiceRequest | Omit<VuuRpcServiceRequest, "context">;
|
|
8
13
|
export declare const hasViewPortContext: (message: VuuRpcServiceRequest) => message is VuuRpcServiceRequest<ViewportRpcContext>;
|
|
9
14
|
export declare const isVuuMenuRpcRequest: (message: VuuRpcRequest | Omit<VuuRpcRequest, "vpId">) => message is VuuRpcMenuRequest;
|
|
10
|
-
export declare const isLoginResponse: (message:
|
|
15
|
+
export declare const isLoginResponse: (message: unknown) => message is VuuLoginSuccessResponse;
|
|
11
16
|
export declare const isRequestResponse: (message: object) => message is VuuUiMessageInRequestResponse;
|
|
12
17
|
export declare const isOpenSessionTableDialogMessage: (rpcResponse: RpcResponse) => rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema>;
|
|
13
18
|
export declare const isOpenDialogAction: (action?: MenuRpcAction) => action is OpenDialogAction;
|
package/types/user-types.d.ts
CHANGED