@faststore/api 4.9.1-dev.0 → 4.9.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.
@@ -67,7 +67,7 @@ type StoreProduct {
67
67
  """
68
68
  additionalProperty: [StorePropertyValue!]!
69
69
  """
70
- The product's release date. Formatted using https://en.wikipedia.org/wiki/ISO_8601
70
+ The product's release date, passed through exactly as the catalog returns it, without validation or normalization. Usually epoch milliseconds (e.g. "1774224000000"), but some accounts store an ISO 8601 string, and the value may be empty. Parse and validate it before use.
71
71
  """
72
72
  releaseDate: String!
73
73
  """
@@ -1,22 +0,0 @@
1
- /**
2
- * `StoreProduct.releaseDate` is documented in the schema as ISO 8601, but
3
- * Intelligent Search delivers whatever the account has stored — epoch
4
- * milliseconds for some, an ISO string for others. Normalizing here keeps the
5
- * resolver honest about the contract it advertises.
6
- */
7
- /**
8
- * Normalizes a release date to an ISO 8601 calendar date (`YYYY-MM-DD`).
9
- *
10
- * Accepts epoch milliseconds, epoch seconds, and date strings. Returns an empty
11
- * string when the input is absent or unparseable — never throws, and never
12
- * returns `"Invalid Date"`.
13
- *
14
- * The calendar day is always taken in UTC, so a build produces the same markup
15
- * on any machine. An input carrying a timezone offset is converted first, which
16
- * means `2026-03-23T21:00:00-05:00` normalizes to `2026-03-24`. That is
17
- * deliberate: preserving the source calendar day would make the output depend on
18
- * the offset embedded in each record. An input with no timezone designator is
19
- * read as UTC rather than as host-local time, for the same reason.
20
- */
21
- export declare const normalizeReleaseDate: (value: string | number | null | undefined) => string;
22
- //# sourceMappingURL=releaseDate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"releaseDate.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/utils/releaseDate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA8BH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,KACxC,MAkBF,CAAA"}
@@ -1,70 +0,0 @@
1
- /**
2
- * `StoreProduct.releaseDate` is documented in the schema as ISO 8601, but
3
- * Intelligent Search delivers whatever the account has stored — epoch
4
- * milliseconds for some, an ISO string for others. Normalizing here keeps the
5
- * resolver honest about the contract it advertises.
6
- */
7
-
8
- // Epoch values are disambiguated by magnitude, not digit count: anything at or
9
- // above this is milliseconds (>= 1973-03-03), anything below is seconds. A
10
- // millisecond value under the threshold is read as seconds — accepted, since no
11
- // real catalog carries a release date that early, and a digit-count heuristic
12
- // leaves a strictly larger hole (9-digit seconds and 12-digit milliseconds both
13
- // fall through to the string parser, which reads them as a year).
14
- const MILLISECONDS_THRESHOLD = 1e11
15
-
16
- const isAllDigits = (value: string) => /^\d+$/.test(value)
17
-
18
- // An ISO date-time with no timezone designator. `new Date()` reads these as
19
- // host-local time (date-only forms are already read as UTC), which would make
20
- // the emitted calendar day depend on the build machine's zone.
21
- const ISO_DATE_TIME_WITHOUT_ZONE =
22
- /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/
23
-
24
- const toDate = (value: string): Date => {
25
- if (!isAllDigits(value)) {
26
- return new Date(
27
- ISO_DATE_TIME_WITHOUT_ZONE.test(value) ? `${value}Z` : value
28
- )
29
- }
30
-
31
- const epoch = Number(value)
32
-
33
- return new Date(epoch >= MILLISECONDS_THRESHOLD ? epoch : epoch * 1000)
34
- }
35
-
36
- /**
37
- * Normalizes a release date to an ISO 8601 calendar date (`YYYY-MM-DD`).
38
- *
39
- * Accepts epoch milliseconds, epoch seconds, and date strings. Returns an empty
40
- * string when the input is absent or unparseable — never throws, and never
41
- * returns `"Invalid Date"`.
42
- *
43
- * The calendar day is always taken in UTC, so a build produces the same markup
44
- * on any machine. An input carrying a timezone offset is converted first, which
45
- * means `2026-03-23T21:00:00-05:00` normalizes to `2026-03-24`. That is
46
- * deliberate: preserving the source calendar day would make the output depend on
47
- * the offset embedded in each record. An input with no timezone designator is
48
- * read as UTC rather than as host-local time, for the same reason.
49
- */
50
- export const normalizeReleaseDate = (
51
- value: string | number | null | undefined
52
- ): string => {
53
- if (value === null || value === undefined) {
54
- return ''
55
- }
56
-
57
- const raw = String(value).trim()
58
-
59
- if (raw === '') {
60
- return ''
61
- }
62
-
63
- const date = toDate(raw)
64
-
65
- if (Number.isNaN(date.getTime())) {
66
- return ''
67
- }
68
-
69
- return date.toISOString().slice(0, 10)
70
- }