@singi-labs/sifa-sdk 0.19.41 → 0.19.42

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.
@@ -162,10 +162,24 @@ async function fetchGetProfileView(config, actor, options = {}) {
162
162
  }
163
163
  }
164
164
 
165
+ // src/logic/date-lookahead.ts
166
+ function isBeyondLookahead(value, months, now = /* @__PURE__ */ new Date()) {
167
+ const match = /^(\d{4})(?:-(\d{2}))?/.exec(value);
168
+ if (!match) return false;
169
+ const index = Number(match[1]) * 12 + (match[2] ? Number(match[2]) : 1);
170
+ const limit = now.getFullYear() * 12 + now.getMonth() + 1 + months;
171
+ return index > limit;
172
+ }
173
+ function isUpcomingStart(startedAt, now = /* @__PURE__ */ new Date()) {
174
+ return !!startedAt && isBeyondLookahead(startedAt, 0, now);
175
+ }
176
+
165
177
  // src/logic/primary-position.ts
166
- function pickPrimaryPosition(positions) {
178
+ function pickPrimaryPosition(positions, now = /* @__PURE__ */ new Date()) {
167
179
  if (!positions || positions.length === 0) return void 0;
168
- const active = positions.filter((p) => !p.endedAt && !p.hidden);
180
+ const active = positions.filter(
181
+ (p) => !p.endedAt && !p.hidden && !isUpcomingStart(p.startedAt, now)
182
+ );
169
183
  if (active.length === 0) return void 0;
170
184
  const flagged = active.find((p) => p.primary === true);
171
185
  if (flagged) return flagged;