@persei/perseed-api 5.0.18 → 5.0.19

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.
@@ -7,7 +7,7 @@ function resolveTrendWindow(nowMs, config, weekStart = globalLocale.getWeekStart
7
7
  const toValue = config.toValue ?? 0;
8
8
  return {
9
9
  start: globalDates.getPeriodStart(globalDates.subtractPeriods(nowMs, fromValue, unit, utc), unit, weekStart, utc),
10
- end: toValue === 0 ? nowMs : globalDates.getPeriodStart(globalDates.subtractPeriods(nowMs, toValue - 1, unit, utc), unit, weekStart, utc)
10
+ end: globalDates.getPeriodStart(globalDates.subtractPeriods(nowMs, toValue - 1, unit, utc), unit, weekStart, utc)
11
11
  };
12
12
  }
13
13
  function resolveRelativePeriod(nowMs, { value, unit, excludeCurrentPeriod = false }, weekStart = globalLocale.getWeekStart(), utc = false) {
@@ -20,11 +20,12 @@ function resolveRelativePeriod(nowMs, { value, unit, excludeCurrentPeriod = fals
20
20
  }
21
21
  function resolveRelativeDateRange(nowMs, config, format, weekStart = globalLocale.getWeekStart(), utc = false) {
22
22
  const { start, end } = resolveRelativePeriod(nowMs, config, weekStart, utc);
23
+ const cappedEnd = Math.min(end, nowMs);
23
24
  const startDate = globalDates.toCalendar(start, utc);
24
25
  if (format === "discrete") {
25
- return { start_date: startDate.toISOString(), end_date: globalDates.toCalendar(end, utc).toISOString() };
26
+ return { start_date: startDate.toISOString(), end_date: globalDates.toCalendar(cappedEnd, utc).toISOString() };
26
27
  }
27
- const endDate = config.excludeCurrentPeriod ? globalDates.toCalendar(end, utc).subtract(1, "day") : globalDates.toCalendar(end, utc);
28
+ const endDate = config.excludeCurrentPeriod ? globalDates.toCalendar(end, utc).subtract(1, "day") : globalDates.toCalendar(cappedEnd, utc);
28
29
  return { start_date: startDate.format("YYYY-MM-DD"), end_date: endDate.format("YYYY-MM-DD") };
29
30
  }
30
31
  exports.resolveRelativeDateRange = resolveRelativeDateRange;
@@ -1 +1 @@
1
- {"version":3,"file":"ecosystem-container-widget.cjs","sources":["../../src/v2/modules/ecosystem/container-widget/container-widget.helper.ts"],"sourcesContent":["import { getPeriodStart, subtractPeriods, toCalendar } from '../../global/dates/dates.helper'\nimport { getWeekStart } from '../../global/locale/locale.helper'\nimport { type RelativePeriodConfig, type TrendWindow, type TrendWindowConfig } from './container-widget.schema'\n\n/**\n * Trend-widget time windows: the `value`/`from`/`to` → concrete-window resolution shared by the trend\n * widget (front, viewer-local) and the health-data time-range filter (backend, UTC). Built on the\n * generic calendar primitives of `global/dates` (which take the week start as a plain number) and the\n * locale week-start resolver of `global/locale`, so the trend-specific rules live here in one place.\n *\n * The `utc` flag is forwarded to the primitives: `false` (default) uses the ambient local calendar\n * (the front, viewer's timezone); `true` uses UTC (the backend). Both callers produce the exact same\n * window for the same inputs and timezone.\n */\n\n/**\n * Resolves a `from`/`to` range into a concrete, calendar-aligned window. `fromValue` and `toValue`\n * are inclusive bucket offsets (\"N units ago\"), so the window covers the buckets from `toValue`-ago\n * up to `fromValue`-ago and spans `fromValue − toValue + 1` buckets:\n *\n * - `start` (inclusive) = `getPeriodStart(now − fromValue·unit)` — start of the oldest bucket.\n * - `end` (exclusive) = `now` when `toValue = 0` (the current, in-progress bucket is included,\n * up to now); otherwise `getPeriodStart(now (toValue 1)·unit)` the start of the bucket\n * just after the newest included one, which drops the current bucket.\n *\n * Example (unit = week, weekStart = 1 Monday, now = Tue 2026-07-07):\n * from 2, to 0 → [Mon 22 Jun, now) (3 weeks including the current one)\n * from 3, to 1 → [Mon 15 Jun, Mon 06 Jul) (3 complete weeks, current one excluded)\n */\nexport function resolveTrendWindow(\n nowMs: number,\n config: TrendWindowConfig,\n weekStart: number = getWeekStart(),\n utc = false,\n): TrendWindow {\n const { fromValue, unit } = config\n const toValue = config.toValue ?? 0\n return {\n start: getPeriodStart(subtractPeriods(nowMs, fromValue, unit, utc), unit, weekStart, utc),\n end: toValue === 0 ? nowMs : getPeriodStart(subtractPeriods(nowMs, toValue - 1, unit, utc), unit, weekStart, utc),\n }\n}\n\n/**\n * Resolves a count-based relative period into a concrete window — the single source of truth for the\n * `value` → from/to mapping shared by every consumer (backend health-data filter, front trend widget),\n * so the \"current period counts as one of the N\" rule is defined exactly once:\n * - including it → `from = value - 1`, `to = 0` (buckets `value-1`…0 ago, ending now);\n * - excluding it → `from = value`, `to = 1` (`value` complete buckets before the current one).\n */\nexport function resolveRelativePeriod(\n nowMs: number,\n { value, unit, excludeCurrentPeriod = false }: RelativePeriodConfig,\n weekStart: number = getWeekStart(),\n utc = false,\n): TrendWindow {\n return resolveTrendWindow(\n nowMs,\n { fromValue: excludeCurrentPeriod ? value : value - 1, toValue: excludeCurrentPeriod ? 1 : 0, unit },\n weekStart,\n utc,\n )\n}\n\n/**\n * Resolves a count-based relative period into a formatted date range, keeping the whole calculation\n * (from/to mapping + the day-level rule + formatting) in one shared place:\n * - `daily`: date-only `YYYY-MM-DD`; when excluding the current period the inclusive end becomes the\n * last completed calendar day (the day before the current period's start).\n * - `discrete`: ISO-8601, with the exclusive upper bound used verbatim.\n */\nexport function resolveRelativeDateRange(\n nowMs: number,\n config: RelativePeriodConfig,\n format: 'daily' | 'discrete',\n weekStart: number = getWeekStart(),\n utc = false,\n): { start_date: string; end_date: string } {\n const { start, end } = resolveRelativePeriod(nowMs, config, weekStart, utc)\n const startDate = toCalendar(start, utc)\n if (format === 'discrete') {\n return { start_date: startDate.toISOString(), end_date: toCalendar(end, utc).toISOString() }\n }\n const endDate = config.excludeCurrentPeriod ? toCalendar(end, utc).subtract(1, 'day') : toCalendar(end, utc)\n return { start_date: startDate.format('YYYY-MM-DD'), end_date: endDate.format('YYYY-MM-DD') }\n}\n"],"names":["getWeekStart","getPeriodStart","subtractPeriods","toCalendar"],"mappings":";;;;AA6BO,SAAS,mBACd,OACA,QACA,YAAoBA,aAAAA,aAAA,GACpB,MAAM,OACO;AACb,QAAM,EAAE,WAAW,KAAA,IAAS;AAC5B,QAAM,UAAU,OAAO,WAAW;AAClC,SAAO;AAAA,IACL,OAAOC,YAAAA,eAAeC,4BAAgB,OAAO,WAAW,MAAM,GAAG,GAAG,MAAM,WAAW,GAAG;AAAA,IACxF,KAAK,YAAY,IAAI,QAAQD,YAAAA,eAAeC,YAAAA,gBAAgB,OAAO,UAAU,GAAG,MAAM,GAAG,GAAG,MAAM,WAAW,GAAG;AAAA,EAAA;AAEpH;AASO,SAAS,sBACd,OACA,EAAE,OAAO,MAAM,uBAAuB,MAAA,GACtC,YAAoBF,aAAAA,gBACpB,MAAM,OACO;AACb,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,uBAAuB,QAAQ,QAAQ,GAAG,SAAS,uBAAuB,IAAI,GAAG,KAAA;AAAA,IAC9F;AAAA,IACA;AAAA,EAAA;AAEJ;AASO,SAAS,yBACd,OACA,QACA,QACA,YAAoBA,0BAAA,GACpB,MAAM,OACoC;AAC1C,QAAM,EAAE,OAAO,QAAQ,sBAAsB,OAAO,QAAQ,WAAW,GAAG;AAC1E,QAAM,YAAYG,YAAAA,WAAW,OAAO,GAAG;AACvC,MAAI,WAAW,YAAY;AACzB,WAAO,EAAE,YAAY,UAAU,eAAe,UAAUA,YAAAA,WAAW,KAAK,GAAG,EAAE,cAAY;AAAA,EAC3F;AACA,QAAM,UAAU,OAAO,uBAAuBA,YAAAA,WAAW,KAAK,GAAG,EAAE,SAAS,GAAG,KAAK,IAAIA,YAAAA,WAAW,KAAK,GAAG;AAC3G,SAAO,EAAE,YAAY,UAAU,OAAO,YAAY,GAAG,UAAU,QAAQ,OAAO,YAAY,EAAA;AAC5F;;;;"}
1
+ {"version":3,"file":"ecosystem-container-widget.cjs","sources":["../../src/v2/modules/ecosystem/container-widget/container-widget.helper.ts"],"sourcesContent":["import { getPeriodStart, subtractPeriods, toCalendar } from '../../global/dates/dates.helper'\nimport { getWeekStart } from '../../global/locale/locale.helper'\nimport { type RelativePeriodConfig, type TrendWindow, type TrendWindowConfig } from './container-widget.schema'\n\n/**\n * Trend-widget time windows: the `value`/`from`/`to` → concrete-window resolution shared by the trend\n * widget (front, viewer-local) and the health-data time-range filter (backend, UTC). Built on the\n * generic calendar primitives of `global/dates` (which take the week start as a plain number) and the\n * locale week-start resolver of `global/locale`, so the trend-specific rules live here in one place.\n *\n * The `utc` flag is forwarded to the primitives: `false` (default) uses the ambient local calendar\n * (the front, viewer's timezone); `true` uses UTC (the backend). Both callers produce the exact same\n * window for the same inputs and timezone.\n */\n\n/**\n * Resolves a `from`/`to` range into a concrete, calendar-aligned window. `fromValue` and `toValue`\n * are inclusive bucket offsets (\"N units ago\"), so the window covers the **complete** buckets from\n * `toValue`-ago up to `fromValue`-ago (both ends inclusive) and spans `fromValue − toValue + 1`\n * buckets:\n *\n * - `start` (inclusive) = `getPeriodStart(now − fromValue·unit)` — start of the oldest bucket.\n * - `end` (exclusive ms bound) = `getPeriodStart(now (toValue 1)·unit)` the start of the\n * bucket just after the newest included one, i.e. the end of the `toValue` bucket. When\n * `toValue = 0` this is the start of the next bucket, so the current (in-progress) bucket is\n * included in full — the window has no `now` cap, both extremes are complete buckets.\n *\n * Example (unit = week, weekStart = 1 Monday, now = Tue 2026-07-07):\n * from 2, to 0 → [Mon 22 Jun, Mon 13 Jul) (3 weeks, the current one included in full)\n * from 3, to 1 → [Mon 15 Jun, Mon 06 Jul) (3 complete weeks, the current one excluded)\n */\nexport function resolveTrendWindow(\n nowMs: number,\n config: TrendWindowConfig,\n weekStart: number = getWeekStart(),\n utc = false,\n): TrendWindow {\n const { fromValue, unit } = config\n const toValue = config.toValue ?? 0\n return {\n start: getPeriodStart(subtractPeriods(nowMs, fromValue, unit, utc), unit, weekStart, utc),\n end: getPeriodStart(subtractPeriods(nowMs, toValue - 1, unit, utc), unit, weekStart, utc),\n }\n}\n\n/**\n * Resolves a count-based relative period into a concrete window — the single source of truth for the\n * `value` → from/to mapping shared by every consumer (backend health-data filter, front trend widget),\n * so the \"current period counts as one of the N\" rule is defined exactly once:\n * - including it → `from = value - 1`, `to = 0` (buckets `value-1`…0 ago, ending now);\n * - excluding it → `from = value`, `to = 1` (`value` complete buckets before the current one).\n */\nexport function resolveRelativePeriod(\n nowMs: number,\n { value, unit, excludeCurrentPeriod = false }: RelativePeriodConfig,\n weekStart: number = getWeekStart(),\n utc = false,\n): TrendWindow {\n return resolveTrendWindow(\n nowMs,\n { fromValue: excludeCurrentPeriod ? value : value - 1, toValue: excludeCurrentPeriod ? 1 : 0, unit },\n weekStart,\n utc,\n )\n}\n\n/**\n * Resolves a count-based relative period into a formatted date range for the backend health-data\n * query, keeping the whole calculation (from/to mapping + the day-level rule + formatting) in one\n * shared place:\n * - `daily`: date-only `YYYY-MM-DD`; when excluding the current period the inclusive end becomes the\n * last completed calendar day (the day before the current period's start).\n * - `discrete`: ISO-8601.\n *\n * Unlike `resolveTrendWindow` (which now covers the current bucket in full for the front display), the\n * query end is **capped at `now`**: a data query must never reach past the present into the rest of an\n * in-progress bucket, so `to = 0` yields \"up to now\", not \"up to the end of the current bucket\".\n */\nexport function resolveRelativeDateRange(\n nowMs: number,\n config: RelativePeriodConfig,\n format: 'daily' | 'discrete',\n weekStart: number = getWeekStart(),\n utc = false,\n): { start_date: string; end_date: string } {\n const { start, end } = resolveRelativePeriod(nowMs, config, weekStart, utc)\n const cappedEnd = Math.min(end, nowMs)\n const startDate = toCalendar(start, utc)\n if (format === 'discrete') {\n return { start_date: startDate.toISOString(), end_date: toCalendar(cappedEnd, utc).toISOString() }\n }\n const endDate = config.excludeCurrentPeriod ? toCalendar(end, utc).subtract(1, 'day') : toCalendar(cappedEnd, utc)\n return { start_date: startDate.format('YYYY-MM-DD'), end_date: endDate.format('YYYY-MM-DD') }\n}\n"],"names":["getWeekStart","getPeriodStart","subtractPeriods","toCalendar"],"mappings":";;;;AA+BO,SAAS,mBACd,OACA,QACA,YAAoBA,aAAAA,aAAA,GACpB,MAAM,OACO;AACb,QAAM,EAAE,WAAW,KAAA,IAAS;AAC5B,QAAM,UAAU,OAAO,WAAW;AAClC,SAAO;AAAA,IACL,OAAOC,YAAAA,eAAeC,4BAAgB,OAAO,WAAW,MAAM,GAAG,GAAG,MAAM,WAAW,GAAG;AAAA,IACxF,KAAKD,YAAAA,eAAeC,4BAAgB,OAAO,UAAU,GAAG,MAAM,GAAG,GAAG,MAAM,WAAW,GAAG;AAAA,EAAA;AAE5F;AASO,SAAS,sBACd,OACA,EAAE,OAAO,MAAM,uBAAuB,MAAA,GACtC,YAAoBF,aAAAA,gBACpB,MAAM,OACO;AACb,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,uBAAuB,QAAQ,QAAQ,GAAG,SAAS,uBAAuB,IAAI,GAAG,KAAA;AAAA,IAC9F;AAAA,IACA;AAAA,EAAA;AAEJ;AAcO,SAAS,yBACd,OACA,QACA,QACA,YAAoBA,0BAAA,GACpB,MAAM,OACoC;AAC1C,QAAM,EAAE,OAAO,QAAQ,sBAAsB,OAAO,QAAQ,WAAW,GAAG;AAC1E,QAAM,YAAY,KAAK,IAAI,KAAK,KAAK;AACrC,QAAM,YAAYG,YAAAA,WAAW,OAAO,GAAG;AACvC,MAAI,WAAW,YAAY;AACzB,WAAO,EAAE,YAAY,UAAU,eAAe,UAAUA,YAAAA,WAAW,WAAW,GAAG,EAAE,cAAY;AAAA,EACjG;AACA,QAAM,UAAU,OAAO,uBAAuBA,YAAAA,WAAW,KAAK,GAAG,EAAE,SAAS,GAAG,KAAK,IAAIA,YAAAA,WAAW,WAAW,GAAG;AACjH,SAAO,EAAE,YAAY,UAAU,OAAO,YAAY,GAAG,UAAU,QAAQ,OAAO,YAAY,EAAA;AAC5F;;;;"}
@@ -5,7 +5,7 @@ function resolveTrendWindow(nowMs, config, weekStart = getWeekStart(), utc = fal
5
5
  const toValue = config.toValue ?? 0;
6
6
  return {
7
7
  start: getPeriodStart(subtractPeriods(nowMs, fromValue, unit, utc), unit, weekStart, utc),
8
- end: toValue === 0 ? nowMs : getPeriodStart(subtractPeriods(nowMs, toValue - 1, unit, utc), unit, weekStart, utc)
8
+ end: getPeriodStart(subtractPeriods(nowMs, toValue - 1, unit, utc), unit, weekStart, utc)
9
9
  };
10
10
  }
11
11
  function resolveRelativePeriod(nowMs, { value, unit, excludeCurrentPeriod = false }, weekStart = getWeekStart(), utc = false) {
@@ -18,11 +18,12 @@ function resolveRelativePeriod(nowMs, { value, unit, excludeCurrentPeriod = fals
18
18
  }
19
19
  function resolveRelativeDateRange(nowMs, config, format, weekStart = getWeekStart(), utc = false) {
20
20
  const { start, end } = resolveRelativePeriod(nowMs, config, weekStart, utc);
21
+ const cappedEnd = Math.min(end, nowMs);
21
22
  const startDate = toCalendar(start, utc);
22
23
  if (format === "discrete") {
23
- return { start_date: startDate.toISOString(), end_date: toCalendar(end, utc).toISOString() };
24
+ return { start_date: startDate.toISOString(), end_date: toCalendar(cappedEnd, utc).toISOString() };
24
25
  }
25
- const endDate = config.excludeCurrentPeriod ? toCalendar(end, utc).subtract(1, "day") : toCalendar(end, utc);
26
+ const endDate = config.excludeCurrentPeriod ? toCalendar(end, utc).subtract(1, "day") : toCalendar(cappedEnd, utc);
26
27
  return { start_date: startDate.format("YYYY-MM-DD"), end_date: endDate.format("YYYY-MM-DD") };
27
28
  }
28
29
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"ecosystem-container-widget.mjs","sources":["../../src/v2/modules/ecosystem/container-widget/container-widget.helper.ts"],"sourcesContent":["import { getPeriodStart, subtractPeriods, toCalendar } from '../../global/dates/dates.helper'\nimport { getWeekStart } from '../../global/locale/locale.helper'\nimport { type RelativePeriodConfig, type TrendWindow, type TrendWindowConfig } from './container-widget.schema'\n\n/**\n * Trend-widget time windows: the `value`/`from`/`to` → concrete-window resolution shared by the trend\n * widget (front, viewer-local) and the health-data time-range filter (backend, UTC). Built on the\n * generic calendar primitives of `global/dates` (which take the week start as a plain number) and the\n * locale week-start resolver of `global/locale`, so the trend-specific rules live here in one place.\n *\n * The `utc` flag is forwarded to the primitives: `false` (default) uses the ambient local calendar\n * (the front, viewer's timezone); `true` uses UTC (the backend). Both callers produce the exact same\n * window for the same inputs and timezone.\n */\n\n/**\n * Resolves a `from`/`to` range into a concrete, calendar-aligned window. `fromValue` and `toValue`\n * are inclusive bucket offsets (\"N units ago\"), so the window covers the buckets from `toValue`-ago\n * up to `fromValue`-ago and spans `fromValue − toValue + 1` buckets:\n *\n * - `start` (inclusive) = `getPeriodStart(now − fromValue·unit)` — start of the oldest bucket.\n * - `end` (exclusive) = `now` when `toValue = 0` (the current, in-progress bucket is included,\n * up to now); otherwise `getPeriodStart(now (toValue 1)·unit)` the start of the bucket\n * just after the newest included one, which drops the current bucket.\n *\n * Example (unit = week, weekStart = 1 Monday, now = Tue 2026-07-07):\n * from 2, to 0 → [Mon 22 Jun, now) (3 weeks including the current one)\n * from 3, to 1 → [Mon 15 Jun, Mon 06 Jul) (3 complete weeks, current one excluded)\n */\nexport function resolveTrendWindow(\n nowMs: number,\n config: TrendWindowConfig,\n weekStart: number = getWeekStart(),\n utc = false,\n): TrendWindow {\n const { fromValue, unit } = config\n const toValue = config.toValue ?? 0\n return {\n start: getPeriodStart(subtractPeriods(nowMs, fromValue, unit, utc), unit, weekStart, utc),\n end: toValue === 0 ? nowMs : getPeriodStart(subtractPeriods(nowMs, toValue - 1, unit, utc), unit, weekStart, utc),\n }\n}\n\n/**\n * Resolves a count-based relative period into a concrete window — the single source of truth for the\n * `value` → from/to mapping shared by every consumer (backend health-data filter, front trend widget),\n * so the \"current period counts as one of the N\" rule is defined exactly once:\n * - including it → `from = value - 1`, `to = 0` (buckets `value-1`…0 ago, ending now);\n * - excluding it → `from = value`, `to = 1` (`value` complete buckets before the current one).\n */\nexport function resolveRelativePeriod(\n nowMs: number,\n { value, unit, excludeCurrentPeriod = false }: RelativePeriodConfig,\n weekStart: number = getWeekStart(),\n utc = false,\n): TrendWindow {\n return resolveTrendWindow(\n nowMs,\n { fromValue: excludeCurrentPeriod ? value : value - 1, toValue: excludeCurrentPeriod ? 1 : 0, unit },\n weekStart,\n utc,\n )\n}\n\n/**\n * Resolves a count-based relative period into a formatted date range, keeping the whole calculation\n * (from/to mapping + the day-level rule + formatting) in one shared place:\n * - `daily`: date-only `YYYY-MM-DD`; when excluding the current period the inclusive end becomes the\n * last completed calendar day (the day before the current period's start).\n * - `discrete`: ISO-8601, with the exclusive upper bound used verbatim.\n */\nexport function resolveRelativeDateRange(\n nowMs: number,\n config: RelativePeriodConfig,\n format: 'daily' | 'discrete',\n weekStart: number = getWeekStart(),\n utc = false,\n): { start_date: string; end_date: string } {\n const { start, end } = resolveRelativePeriod(nowMs, config, weekStart, utc)\n const startDate = toCalendar(start, utc)\n if (format === 'discrete') {\n return { start_date: startDate.toISOString(), end_date: toCalendar(end, utc).toISOString() }\n }\n const endDate = config.excludeCurrentPeriod ? toCalendar(end, utc).subtract(1, 'day') : toCalendar(end, utc)\n return { start_date: startDate.format('YYYY-MM-DD'), end_date: endDate.format('YYYY-MM-DD') }\n}\n"],"names":[],"mappings":";;AA6BO,SAAS,mBACd,OACA,QACA,YAAoB,aAAA,GACpB,MAAM,OACO;AACb,QAAM,EAAE,WAAW,KAAA,IAAS;AAC5B,QAAM,UAAU,OAAO,WAAW;AAClC,SAAO;AAAA,IACL,OAAO,eAAe,gBAAgB,OAAO,WAAW,MAAM,GAAG,GAAG,MAAM,WAAW,GAAG;AAAA,IACxF,KAAK,YAAY,IAAI,QAAQ,eAAe,gBAAgB,OAAO,UAAU,GAAG,MAAM,GAAG,GAAG,MAAM,WAAW,GAAG;AAAA,EAAA;AAEpH;AASO,SAAS,sBACd,OACA,EAAE,OAAO,MAAM,uBAAuB,MAAA,GACtC,YAAoB,gBACpB,MAAM,OACO;AACb,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,uBAAuB,QAAQ,QAAQ,GAAG,SAAS,uBAAuB,IAAI,GAAG,KAAA;AAAA,IAC9F;AAAA,IACA;AAAA,EAAA;AAEJ;AASO,SAAS,yBACd,OACA,QACA,QACA,YAAoB,aAAA,GACpB,MAAM,OACoC;AAC1C,QAAM,EAAE,OAAO,QAAQ,sBAAsB,OAAO,QAAQ,WAAW,GAAG;AAC1E,QAAM,YAAY,WAAW,OAAO,GAAG;AACvC,MAAI,WAAW,YAAY;AACzB,WAAO,EAAE,YAAY,UAAU,eAAe,UAAU,WAAW,KAAK,GAAG,EAAE,cAAY;AAAA,EAC3F;AACA,QAAM,UAAU,OAAO,uBAAuB,WAAW,KAAK,GAAG,EAAE,SAAS,GAAG,KAAK,IAAI,WAAW,KAAK,GAAG;AAC3G,SAAO,EAAE,YAAY,UAAU,OAAO,YAAY,GAAG,UAAU,QAAQ,OAAO,YAAY,EAAA;AAC5F;"}
1
+ {"version":3,"file":"ecosystem-container-widget.mjs","sources":["../../src/v2/modules/ecosystem/container-widget/container-widget.helper.ts"],"sourcesContent":["import { getPeriodStart, subtractPeriods, toCalendar } from '../../global/dates/dates.helper'\nimport { getWeekStart } from '../../global/locale/locale.helper'\nimport { type RelativePeriodConfig, type TrendWindow, type TrendWindowConfig } from './container-widget.schema'\n\n/**\n * Trend-widget time windows: the `value`/`from`/`to` → concrete-window resolution shared by the trend\n * widget (front, viewer-local) and the health-data time-range filter (backend, UTC). Built on the\n * generic calendar primitives of `global/dates` (which take the week start as a plain number) and the\n * locale week-start resolver of `global/locale`, so the trend-specific rules live here in one place.\n *\n * The `utc` flag is forwarded to the primitives: `false` (default) uses the ambient local calendar\n * (the front, viewer's timezone); `true` uses UTC (the backend). Both callers produce the exact same\n * window for the same inputs and timezone.\n */\n\n/**\n * Resolves a `from`/`to` range into a concrete, calendar-aligned window. `fromValue` and `toValue`\n * are inclusive bucket offsets (\"N units ago\"), so the window covers the **complete** buckets from\n * `toValue`-ago up to `fromValue`-ago (both ends inclusive) and spans `fromValue − toValue + 1`\n * buckets:\n *\n * - `start` (inclusive) = `getPeriodStart(now − fromValue·unit)` — start of the oldest bucket.\n * - `end` (exclusive ms bound) = `getPeriodStart(now (toValue 1)·unit)` the start of the\n * bucket just after the newest included one, i.e. the end of the `toValue` bucket. When\n * `toValue = 0` this is the start of the next bucket, so the current (in-progress) bucket is\n * included in full — the window has no `now` cap, both extremes are complete buckets.\n *\n * Example (unit = week, weekStart = 1 Monday, now = Tue 2026-07-07):\n * from 2, to 0 → [Mon 22 Jun, Mon 13 Jul) (3 weeks, the current one included in full)\n * from 3, to 1 → [Mon 15 Jun, Mon 06 Jul) (3 complete weeks, the current one excluded)\n */\nexport function resolveTrendWindow(\n nowMs: number,\n config: TrendWindowConfig,\n weekStart: number = getWeekStart(),\n utc = false,\n): TrendWindow {\n const { fromValue, unit } = config\n const toValue = config.toValue ?? 0\n return {\n start: getPeriodStart(subtractPeriods(nowMs, fromValue, unit, utc), unit, weekStart, utc),\n end: getPeriodStart(subtractPeriods(nowMs, toValue - 1, unit, utc), unit, weekStart, utc),\n }\n}\n\n/**\n * Resolves a count-based relative period into a concrete window — the single source of truth for the\n * `value` → from/to mapping shared by every consumer (backend health-data filter, front trend widget),\n * so the \"current period counts as one of the N\" rule is defined exactly once:\n * - including it → `from = value - 1`, `to = 0` (buckets `value-1`…0 ago, ending now);\n * - excluding it → `from = value`, `to = 1` (`value` complete buckets before the current one).\n */\nexport function resolveRelativePeriod(\n nowMs: number,\n { value, unit, excludeCurrentPeriod = false }: RelativePeriodConfig,\n weekStart: number = getWeekStart(),\n utc = false,\n): TrendWindow {\n return resolveTrendWindow(\n nowMs,\n { fromValue: excludeCurrentPeriod ? value : value - 1, toValue: excludeCurrentPeriod ? 1 : 0, unit },\n weekStart,\n utc,\n )\n}\n\n/**\n * Resolves a count-based relative period into a formatted date range for the backend health-data\n * query, keeping the whole calculation (from/to mapping + the day-level rule + formatting) in one\n * shared place:\n * - `daily`: date-only `YYYY-MM-DD`; when excluding the current period the inclusive end becomes the\n * last completed calendar day (the day before the current period's start).\n * - `discrete`: ISO-8601.\n *\n * Unlike `resolveTrendWindow` (which now covers the current bucket in full for the front display), the\n * query end is **capped at `now`**: a data query must never reach past the present into the rest of an\n * in-progress bucket, so `to = 0` yields \"up to now\", not \"up to the end of the current bucket\".\n */\nexport function resolveRelativeDateRange(\n nowMs: number,\n config: RelativePeriodConfig,\n format: 'daily' | 'discrete',\n weekStart: number = getWeekStart(),\n utc = false,\n): { start_date: string; end_date: string } {\n const { start, end } = resolveRelativePeriod(nowMs, config, weekStart, utc)\n const cappedEnd = Math.min(end, nowMs)\n const startDate = toCalendar(start, utc)\n if (format === 'discrete') {\n return { start_date: startDate.toISOString(), end_date: toCalendar(cappedEnd, utc).toISOString() }\n }\n const endDate = config.excludeCurrentPeriod ? toCalendar(end, utc).subtract(1, 'day') : toCalendar(cappedEnd, utc)\n return { start_date: startDate.format('YYYY-MM-DD'), end_date: endDate.format('YYYY-MM-DD') }\n}\n"],"names":[],"mappings":";;AA+BO,SAAS,mBACd,OACA,QACA,YAAoB,aAAA,GACpB,MAAM,OACO;AACb,QAAM,EAAE,WAAW,KAAA,IAAS;AAC5B,QAAM,UAAU,OAAO,WAAW;AAClC,SAAO;AAAA,IACL,OAAO,eAAe,gBAAgB,OAAO,WAAW,MAAM,GAAG,GAAG,MAAM,WAAW,GAAG;AAAA,IACxF,KAAK,eAAe,gBAAgB,OAAO,UAAU,GAAG,MAAM,GAAG,GAAG,MAAM,WAAW,GAAG;AAAA,EAAA;AAE5F;AASO,SAAS,sBACd,OACA,EAAE,OAAO,MAAM,uBAAuB,MAAA,GACtC,YAAoB,gBACpB,MAAM,OACO;AACb,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,uBAAuB,QAAQ,QAAQ,GAAG,SAAS,uBAAuB,IAAI,GAAG,KAAA;AAAA,IAC9F;AAAA,IACA;AAAA,EAAA;AAEJ;AAcO,SAAS,yBACd,OACA,QACA,QACA,YAAoB,aAAA,GACpB,MAAM,OACoC;AAC1C,QAAM,EAAE,OAAO,QAAQ,sBAAsB,OAAO,QAAQ,WAAW,GAAG;AAC1E,QAAM,YAAY,KAAK,IAAI,KAAK,KAAK;AACrC,QAAM,YAAY,WAAW,OAAO,GAAG;AACvC,MAAI,WAAW,YAAY;AACzB,WAAO,EAAE,YAAY,UAAU,eAAe,UAAU,WAAW,WAAW,GAAG,EAAE,cAAY;AAAA,EACjG;AACA,QAAM,UAAU,OAAO,uBAAuB,WAAW,KAAK,GAAG,EAAE,SAAS,GAAG,KAAK,IAAI,WAAW,WAAW,GAAG;AACjH,SAAO,EAAE,YAAY,UAAU,OAAO,YAAY,GAAG,UAAU,QAAQ,OAAO,YAAY,EAAA;AAC5F;"}
@@ -10,6 +10,17 @@ import { MFALoginData } from '../schemas';
10
10
  import { FastifyReply, FastifyRequest } from 'fastify';
11
11
  import { FingerprintResult } from '../v2/modules/global/request-fingerprint';
12
12
  import { Scopes } from '../v2/modules/global/auth';
13
+ import { EncryptedCredentials } from './thryve-credentials-crypto';
14
+ /**
15
+ * Thryve SDK client credentials (former appId / appSecret). Delivered to the app in the login
16
+ * response body (never in the JWT) so the native Thryve SDK can be initialised device-side. The
17
+ * secret is a shared secret that the SDK requires on the client — it is sourced exclusively from
18
+ * the server-side credentials file, never committed to the app bundle. See the login flow.
19
+ */
20
+ export interface ThryveClientCredentials {
21
+ authId: string;
22
+ authSecret: string;
23
+ }
13
24
  export interface UserData {
14
25
  language?: string;
15
26
  userId: number;
@@ -22,6 +33,14 @@ export interface UserData {
22
33
  ecosystemLabel: string;
23
34
  tz: string;
24
35
  settings?: SettingResponse[];
36
+ thryveCredentials?: EncryptedCredentials;
37
+ /**
38
+ * Thryve `partnerUserId` (persisted server-side as `user_settings.THRYVE_USER_ID`, keyed by
39
+ * loginId → stable per human). The native Thryve SDK must use this as its `endUserAlias` so the
40
+ * device connection and the server-side cloud / health-data flow operate on the SAME Thryve end
41
+ * user. Present only for ecosystems with Thryve enabled.
42
+ */
43
+ thryvePartnerUserId?: string;
25
44
  }
26
45
  export interface AppUserData extends UserData {
27
46
  profile: UserProfileData;
@@ -109,7 +128,22 @@ declare function getLogedUsersFromRequest(req: FastifyRequest): Promise<GetUsers
109
128
  declare function setPendingLogAccessUsers(req: FastifyRequest, users: UserData[]): void;
110
129
  export declare function registerActionWithToken(ecosystemPool: Objection.TransactionOrKnex | undefined, token: string, userAgent: string | null | undefined, ip: string, action: string, userId: number, requestId: string, fingerprint?: FingerprintResult, countryCode?: string | null, regionCode?: string | null, deviceCode?: string | null): Promise<void>;
111
130
  declare function getScopedToken(ctx: RequestContext, scope: Scopes, duration: number, storeClearToken?: boolean, extraPayload?: Record<string, any>, dontSaveInDB?: boolean): Promise<any>;
112
- declare function addAppDataToUsers(req: FastifyRequest, users: UserData[], pushToken?: string, deviceId?: string): Promise<Record<string, UserData>>;
131
+ /**
132
+ * Resolves the Thryve SDK client credentials (`authId` / `authSecret`) for an ecosystem from the
133
+ * server-side credentials file — the same source the API uses to build the cloud `AppAuthorization`
134
+ * header (`credentials/{env}.json` → `thryve[<ecosystem>] | thryve.default → appAuthorization`).
135
+ * The stored value is `authId:authSecret`, either as plain text or base64-encoded (matching the
136
+ * Basic-auth convention). Returns `undefined` when no Thryve entry is configured.
137
+ */
138
+ /**
139
+ * Parses a raw `appAuthorization` value (`authId:authSecret`, plain or base64, optionally prefixed
140
+ * with `Basic `) into credentials. Returns `undefined` when the value is absent or malformed (no
141
+ * `:` separator). Pure — extracted from {@link resolveThryveClientCredentials} so every branch is
142
+ * unit-testable without mocking the credentials file.
143
+ */
144
+ declare function parseThryveAppAuthorization(raw?: string): ThryveClientCredentials | undefined;
145
+ declare function resolveThryveClientCredentials(ecosystem: string): ThryveClientCredentials | undefined;
146
+ declare function addAppDataToUsers(req: FastifyRequest, users: UserData[], token: string, pushToken?: string, deviceId?: string): Promise<Record<string, UserData>>;
113
147
  declare function searchUsersFromRequest(req: FastifyRequest): Promise<GetUsersResult>;
114
148
  declare function checkMFA(req: FastifyRequest, users: UserData[], mfaLoginData?: MFALoginData, deviceId?: string): Promise<true>;
115
149
  declare function doLogin(req: FastifyRequest, preMFARequest?: boolean): Promise<WithTokens & ({
@@ -190,6 +224,8 @@ export declare const __AuthControllerTestUtils: {
190
224
  registerActionWithToken: typeof registerActionWithToken;
191
225
  getScopedToken: typeof getScopedToken;
192
226
  addAppDataToUsers: typeof addAppDataToUsers;
227
+ parseThryveAppAuthorization: typeof parseThryveAppAuthorization;
228
+ resolveThryveClientCredentials: typeof resolveThryveClientCredentials;
193
229
  searchUsersFromRequest: typeof searchUsersFromRequest;
194
230
  checkMFA: typeof checkMFA;
195
231
  doLogin: typeof doLogin;
@@ -1 +1 @@
1
- {"version":3,"file":"AuthController.d.ts","sourceRoot":"","sources":["../../../../src/controllers/AuthController.ts"],"names":[],"mappings":"AAEA,OAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzD,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAoB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAMvF,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AAInE,OAAO,cAAc,MAAM,kCAAkC,CAAA;AAI7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAsC,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAA;AAOrG,OAAO,YAAY,EAAE,EAAY,eAAe,EAAE,MAAM,gCAAgC,CAAA;AACxF,OAAO,EAAE,YAAY,EAAiB,MAAM,aAAa,CAAA;AAGzD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAQ9C,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAA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.
4
+ *
5
+ * CONTRACT (must not change without coordinating with the app):
6
+ * - key = SHA-256(token) → 32 bytes
7
+ * - iv = 12 random bytes
8
+ * - cipher = AES-256-GCM
9
+ * - plaintext = JSON.stringify({ authId, authSecret })
10
+ * - data = ciphertext || authTag (16 bytes) — concatenated so `@noble/ciphers` `gcm().decrypt`
11
+ * on the app side can verify and decrypt in a single call.
12
+ */
13
+ export interface EncryptedCredentials {
14
+ iv: string;
15
+ data: string;
16
+ }
17
+ /**
18
+ * Encrypts the Thryve SDK client credentials with a key derived from the login JWT, so that only
19
+ * a client holding that exact token can decrypt them.
20
+ */
21
+ export declare function encryptCredentialsForToken(token: string, plain: {
22
+ authId: string;
23
+ authSecret: string;
24
+ }): EncryptedCredentials;
25
+ //# sourceMappingURL=thryve-credentials-crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thryve-credentials-crypto.d.ts","sourceRoot":"","sources":["../../../../src/controllers/thryve-credentials-crypto.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC5C,oBAAoB,CAQtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=thryve-credentials-crypto.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thryve-credentials-crypto.test.d.ts","sourceRoot":"","sources":["../../../../src/controllers/thryve-credentials-crypto.test.ts"],"names":[],"mappings":""}
@@ -11,17 +11,19 @@ import { RelativePeriodConfig, TrendWindow, TrendWindowConfig } from './containe
11
11
  */
12
12
  /**
13
13
  * Resolves a `from`/`to` range into a concrete, calendar-aligned window. `fromValue` and `toValue`
14
- * are inclusive bucket offsets ("N units ago"), so the window covers the buckets from `toValue`-ago
15
- * up to `fromValue`-ago and spans `fromValue − toValue + 1` buckets:
14
+ * are inclusive bucket offsets ("N units ago"), so the window covers the **complete** buckets from
15
+ * `toValue`-ago up to `fromValue`-ago (both ends inclusive) and spans `fromValue − toValue + 1`
16
+ * buckets:
16
17
  *
17
18
  * - `start` (inclusive) = `getPeriodStart(now − fromValue·unit)` — start of the oldest bucket.
18
- * - `end` (exclusive) = `now` when `toValue = 0` (the current, in-progress bucket is included,
19
- * up to now); otherwise `getPeriodStart(now (toValue 1)·unit)` — the start of the bucket
20
- * just after the newest included one, which drops the current bucket.
19
+ * - `end` (exclusive ms bound) = `getPeriodStart(now (toValue 1)·unit)` the start of the
20
+ * bucket just after the newest included one, i.e. the end of the `toValue` bucket. When
21
+ * `toValue = 0` this is the start of the next bucket, so the current (in-progress) bucket is
22
+ * included in full — the window has no `now` cap, both extremes are complete buckets.
21
23
  *
22
24
  * Example (unit = week, weekStart = 1 Monday, now = Tue 2026-07-07):
23
- * from 2, to 0 → [Mon 22 Jun, now) (3 weeks including the current one)
24
- * from 3, to 1 → [Mon 15 Jun, Mon 06 Jul) (3 complete weeks, current one excluded)
25
+ * from 2, to 0 → [Mon 22 Jun, Mon 13 Jul) (3 weeks, the current one included in full)
26
+ * from 3, to 1 → [Mon 15 Jun, Mon 06 Jul) (3 complete weeks, the current one excluded)
25
27
  */
26
28
  export declare function resolveTrendWindow(nowMs: number, config: TrendWindowConfig, weekStart?: number, utc?: boolean): TrendWindow;
27
29
  /**
@@ -33,11 +35,16 @@ export declare function resolveTrendWindow(nowMs: number, config: TrendWindowCon
33
35
  */
34
36
  export declare function resolveRelativePeriod(nowMs: number, { value, unit, excludeCurrentPeriod }: RelativePeriodConfig, weekStart?: number, utc?: boolean): TrendWindow;
35
37
  /**
36
- * Resolves a count-based relative period into a formatted date range, keeping the whole calculation
37
- * (from/to mapping + the day-level rule + formatting) in one shared place:
38
+ * Resolves a count-based relative period into a formatted date range for the backend health-data
39
+ * query, keeping the whole calculation (from/to mapping + the day-level rule + formatting) in one
40
+ * shared place:
38
41
  * - `daily`: date-only `YYYY-MM-DD`; when excluding the current period the inclusive end becomes the
39
42
  * last completed calendar day (the day before the current period's start).
40
- * - `discrete`: ISO-8601, with the exclusive upper bound used verbatim.
43
+ * - `discrete`: ISO-8601.
44
+ *
45
+ * Unlike `resolveTrendWindow` (which now covers the current bucket in full for the front display), the
46
+ * query end is **capped at `now`**: a data query must never reach past the present into the rest of an
47
+ * in-progress bucket, so `to = 0` yields "up to now", not "up to the end of the current bucket".
41
48
  */
42
49
  export declare function resolveRelativeDateRange(nowMs: number, config: RelativePeriodConfig, format: 'daily' | 'discrete', weekStart?: number, utc?: boolean): {
43
50
  start_date: string;
@@ -1 +1 @@
1
- {"version":3,"file":"container-widget.helper.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/container-widget/container-widget.helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE/G;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,iBAAiB,EACzB,SAAS,GAAE,MAAuB,EAClC,GAAG,UAAQ,GACV,WAAW,CAOb;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,EAAE,KAAK,EAAE,IAAI,EAAE,oBAA4B,EAAE,EAAE,oBAAoB,EACnE,SAAS,GAAE,MAAuB,EAClC,GAAG,UAAQ,GACV,WAAW,CAOb;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,OAAO,GAAG,UAAU,EAC5B,SAAS,GAAE,MAAuB,EAClC,GAAG,UAAQ,GACV;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAQ1C"}
1
+ {"version":3,"file":"container-widget.helper.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/container-widget/container-widget.helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE/G;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,iBAAiB,EACzB,SAAS,GAAE,MAAuB,EAClC,GAAG,UAAQ,GACV,WAAW,CAOb;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,EAAE,KAAK,EAAE,IAAI,EAAE,oBAA4B,EAAE,EAAE,oBAAoB,EACnE,SAAS,GAAE,MAAuB,EAClC,GAAG,UAAQ,GACV,WAAW,CAOb;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,OAAO,GAAG,UAAU,EAC5B,SAAS,GAAE,MAAuB,EAClC,GAAG,UAAQ,GACV;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAS1C"}
@@ -1,8 +1,8 @@
1
1
  import { E2eOperationParams } from './e2e-operation.schema';
2
2
  export interface TrxLike {
3
- raw(sql: string, bindings?: unknown[]): Promise<[{
3
+ raw<Row = {
4
4
  id: number;
5
- }[]]>;
5
+ }>(sql: string, bindings?: unknown[]): Promise<[Row[]]>;
6
6
  }
7
7
  export interface WorldOptions {
8
8
  projectName?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"e2e-operation.service.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/global/e2e-operation/e2e-operation.service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAqBhE,MAAM,WAAW,OAAO;IACtB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC,CAAA;CACpE;AAKD,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AA+BD,eAAO,MAAM,aAAa,GAAU,KAAK,OAAO,EAAE,SAAS,MAAM,EAAE,OAAM,YAAiB,KAAG,OAAO,CAAC,IAAI,CAsCxG,CAAA;AAYD,eAAO,MAAM,eAAe,GAC1B,KAAK,OAAO,EACZ,SAAS,MAAM,EACf,OAAM,YAAiB,KACtB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAwDtF,CAAA;AAkLD,eAAO,MAAM,mBAAmB;sCARQ,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC;mBAUrD,MAAM,UAAU,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAQxE,CAAA"}
1
+ {"version":3,"file":"e2e-operation.service.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/global/e2e-operation/e2e-operation.service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AA4ChE,MAAM,WAAW,OAAO;IAGtB,GAAG,CAAC,GAAG,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;CAC/E;AAKD,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AA+BD,eAAO,MAAM,aAAa,GAAU,KAAK,OAAO,EAAE,SAAS,MAAM,EAAE,OAAM,YAAiB,KAAG,OAAO,CAAC,IAAI,CAwDxG,CAAA;AAYD,eAAO,MAAM,eAAe,GAC1B,KAAK,OAAO,EACZ,SAAS,MAAM,EACf,OAAM,YAAiB,KACtB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAmFtF,CAAA;AAmPD,eAAO,MAAM,mBAAmB;sCATQ,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC;mBAWrD,MAAM,UAAU,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAQxE,CAAA"}
@@ -1,8 +1,9 @@
1
1
  import { default as RequestContext } from '../../../../models/request/RequestContext';
2
2
  /**
3
- * Checks the `THRYVE_ENABLED` config flag. The value can be defined at project level (winning)
4
- * or at ecosystem level as a fallback. When it is not set to a truthy value, the Thryve feature
5
- * is considered disabled for that project and every endpoint will return 404 to the client.
3
+ * Checks the `SYNC_CLOUD_WEARABLES` config flag. The value can be defined at project level
4
+ * (winning) or at ecosystem level as a fallback. When it is not set to a truthy value, the Thryve
5
+ * feature is considered disabled for that project and every endpoint will return 404 to the
6
+ * client.
6
7
  *
7
8
  * Fails fast if the caller did not resolve a `projectId` — every Thryve endpoint is mounted
8
9
  * under `/v2/ecosystem/:ecosystemName/project/:projectName/thryve/...` so the upstream middleware
@@ -10,6 +11,16 @@ import { default as RequestContext } from '../../../../models/request/RequestCon
10
11
  * middleware regressions.
11
12
  */
12
13
  declare function isEnabled(ctx: RequestContext): Promise<boolean>;
14
+ /**
15
+ * Resolves the opaque `partnerUserID` used by Thryve for the current user. The value lives in
16
+ * the `user_settings` table under the key `THRYVE_USER_ID` (not scoped to ecosystem, project or
17
+ * device), so the same human reuses the same Thryve end user across projects. On the first call
18
+ * for a user we generate a UUID v4, upsert the setting, and return it.
19
+ *
20
+ * The read-generate-insert section is guarded by a MySQL advisory lock keyed on the loginId to
21
+ * prevent two concurrent calls for a brand-new user from inserting two different UUIDs.
22
+ */
23
+ declare function resolveOrCreatePartnerUserId(ctx: RequestContext): Promise<string>;
13
24
  /**
14
25
  * Requests a short-lived Thryve Connection Widget URL. The caller embeds this URL in an iframe
15
26
  * (web) or a WebView (native) so the end user can authorize their wearable sources.
@@ -25,6 +36,7 @@ export declare const ThryveService: {
25
36
  isEnabled: typeof isEnabled;
26
37
  getIframeUrl: typeof getIframeUrl;
27
38
  isUserAuthorized: typeof isUserAuthorized;
39
+ resolveOrCreatePartnerUserId: typeof resolveOrCreatePartnerUserId;
28
40
  };
29
41
  export {};
30
42
  //# sourceMappingURL=thryve.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"thryve.service.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/project/thryve/thryve.service.ts"],"names":[],"mappings":"AAOA,OAAO,cAAc,MAAM,mCAAmC,CAAA;AAyE9D;;;;;;;;;GASG;AACH,iBAAe,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAO9D;AA6ID;;;GAGG;AACH,iBAAe,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAehE;AAED;;;;GAIG;AACH,iBAAe,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAIrE;AAED,eAAO,MAAM,aAAa;;;;CAIzB,CAAA"}
1
+ {"version":3,"file":"thryve.service.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/project/thryve/thryve.service.ts"],"names":[],"mappings":"AAOA,OAAO,cAAc,MAAM,mCAAmC,CAAA;AAyE9D;;;;;;;;;;GAUG;AACH,iBAAe,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAO9D;AAoFD;;;;;;;;GAQG;AACH,iBAAe,4BAA4B,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAYhF;AAoCD;;;GAGG;AACH,iBAAe,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAehE;AAED;;;;GAIG;AACH,iBAAe,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAIrE;AAED,eAAO,MAAM,aAAa;;;;;CAKzB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@persei/perseed-api",
3
- "version": "5.0.18",
3
+ "version": "5.0.19",
4
4
  "description": "Shared schemas, types and constants from Perseed API",
5
5
  "private": false,
6
6
  "type": "module",