@timeback/core 0.2.3-beta.20260326015342 → 0.2.3-beta.20260326022000

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.
@@ -39,7 +39,17 @@ function getTimezoneOffsetMs(at, timezone) {
39
39
  const localMs = Date.UTC(n("year"), n("month") - 1, n("day"), n("hour"), n("minute"), n("second"));
40
40
  return at.getTime() - at.getTime() % 1000 - localMs;
41
41
  }
42
- function bareDateToUTC(bareDate, time, timezone) {
42
+ function validateBareDate(bareDate, fieldName) {
43
+ const [year, month, day] = bareDate.split("-").map(Number);
44
+ const d = new Date(Date.UTC(year, month - 1, day));
45
+ if (d.getUTCFullYear() !== year || d.getUTCMonth() !== month - 1 || d.getUTCDate() !== day) {
46
+ throw createInputValidationError("Invalid date", [
47
+ { path: fieldName, message: `Not a valid calendar date: "${bareDate}"` }
48
+ ]);
49
+ }
50
+ }
51
+ function bareDateToUTC(bareDate, time, timezone, fieldName) {
52
+ validateBareDate(bareDate, fieldName);
43
53
  try {
44
54
  const [year, month, day] = bareDate.split("-").map(Number);
45
55
  const [h, m, secMs] = time.split(":");
@@ -59,19 +69,23 @@ function bareDateToUTC(bareDate, time, timezone) {
59
69
  throw err;
60
70
  }
61
71
  }
62
- function normalizeStartDate(date, timezone) {
72
+ function normalizeStartDate(date, timezone, fieldName = "startDate") {
63
73
  if (date.includes("T"))
64
74
  return date;
75
+ validateBareDate(date, fieldName);
65
76
  if (!timezone)
66
77
  return `${date}T00:00:00.000Z`;
67
- return bareDateToUTC(date, "00:00:00.000", timezone);
78
+ return bareDateToUTC(date, "00:00:00.000", timezone, fieldName);
68
79
  }
69
- function normalizeEndDate(date, timezone) {
70
- if (date.includes("T"))
80
+ function normalizeEndDate(date, timezone, fieldName = "endDate") {
81
+ if (date.includes("T")) {
71
82
  return date;
72
- if (!timezone)
83
+ }
84
+ validateBareDate(date, fieldName);
85
+ if (!timezone) {
73
86
  return `${date}T23:59:59.999Z`;
74
- return bareDateToUTC(date, "23:59:59.999", timezone);
87
+ }
88
+ return bareDateToUTC(date, "23:59:59.999", timezone, fieldName);
75
89
  }
76
90
  function aggregateActivityMetrics(data) {
77
91
  const result = {
@@ -1961,7 +1975,7 @@ class AnalyticsResource {
1961
1975
  params: {
1962
1976
  email: validated.email,
1963
1977
  studentId: validated.studentId,
1964
- weekDate: normalizeStartDate(validated.weekDate, validated.timezone),
1978
+ weekDate: normalizeStartDate(validated.weekDate, validated.timezone, "weekDate"),
1965
1979
  timezone: validated.timezone
1966
1980
  }
1967
1981
  });
package/dist/index.js CHANGED
@@ -85,7 +85,7 @@ import {
85
85
  WebhookFilterCreateInput,
86
86
  WebhookFilterUpdateInput,
87
87
  WebhookUpdateInput
88
- } from "./chunk-z964w2xh.js";
88
+ } from "./chunk-sdbhq9cc.js";
89
89
  import {
90
90
  ApiError,
91
91
  BaseTransport,
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  aggregateActivityMetrics
3
- } from "./chunk-z964w2xh.js";
3
+ } from "./chunk-sdbhq9cc.js";
4
4
  import"./chunk-bjb7ngh9.js";
5
5
  import"./chunk-3j7jywnx.js";
6
6
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timeback/core",
3
- "version": "0.2.3-beta.20260326015342",
3
+ "version": "0.2.3-beta.20260326022000",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {