@okfit/core 0.14.0 → 0.16.0

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/Source.js CHANGED
@@ -8,8 +8,8 @@ import { Timestamp } from "./Timestamp.js";
8
8
  * @public
9
9
  */
10
10
  var UsageWindow = class extends Schema.Class("UsageWindow")({
11
- from: Timestamp,
12
- to: Timestamp
11
+ from: Schema.optionalKey(Timestamp),
12
+ to: Schema.optionalKey(Timestamp)
13
13
  }) {};
14
14
  /**
15
15
  * One provenance entry. `resource` is a URL, a bundle path or a scope descriptor (D-24); never resolved here.
package/Status.js CHANGED
@@ -10,5 +10,16 @@ const Status = Schema.Literals([
10
10
  "stable",
11
11
  "deprecated"
12
12
  ]);
13
+ /**
14
+ * What `Derive.status` reads: the three known values, or `unknown` for a `status` outside the
15
+ * vocabulary (OKF 0.3 §5.4). `unknown` is never written; `Status` is the write vocabulary.
16
+ * @public
17
+ */
18
+ const DerivedStatus = Schema.Literals([
19
+ "draft",
20
+ "stable",
21
+ "deprecated",
22
+ "unknown"
23
+ ]);
13
24
 
14
- export { Status };
25
+ export { DerivedStatus, Status };
package/Timestamp.js CHANGED
@@ -1,16 +1,23 @@
1
- import { Function, Schema, SchemaTransformation } from "effect";
1
+ import { Schema, SchemaTransformation } from "effect";
2
2
 
3
3
  // src/Timestamp.ts
4
4
  const OFFSET_RE = /(?:Z|[+-]\d{2}:\d{2})$/u;
5
+ const DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/u;
6
+ const isCalendarDay = (value) => {
7
+ const [year, month, day] = value.split("-").map(Number);
8
+ const date = new Date(Date.UTC(year, month - 1, day));
9
+ return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
10
+ };
5
11
  const ZERO_MILLIS = /\.000(?=Z$)/;
6
12
  /**
7
13
  * ISO 8601 string with an explicit offset (`Z`, `+hh:mm` or `-hh:mm`) to `DateTime.Utc`.
8
- * Offset-less input fails before parsing so its family surfaces as `family-invalid` (D-15/D-16).
9
- * Encoding writes `2026-03-01T08:00:00Z` for a whole second and keeps non-zero milliseconds.
14
+ * A date-only `YYYY-MM-DD` value (OKF 0.3 section 5) reads as the start of that day in UTC; an impossible
15
+ * calendar day fails. Offset-less date-times fail before parsing and are reported as `value-malformed`.
16
+ * Encoding always writes a date-time: `2026-03-01T08:00:00Z` for a whole second, non-zero milliseconds kept.
10
17
  * @public
11
18
  */
12
- const Timestamp = Schema.String.pipe(Schema.check(Schema.isPattern(OFFSET_RE, { message: "Expected an ISO 8601 timestamp with an explicit offset (Z, +hh:mm or -hh:mm)" })), Schema.decodeTo(Schema.String, SchemaTransformation.transform({
13
- decode: Function.identity,
19
+ const Timestamp = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => OFFSET_RE.test(value) || DATE_ONLY_RE.test(value) && isCalendarDay(value) || "Expected an ISO 8601 timestamp with an explicit offset (Z, +hh:mm or -hh:mm) or a calendar date (YYYY-MM-DD)")), Schema.decodeTo(Schema.String, SchemaTransformation.transform({
20
+ decode: (value) => DATE_ONLY_RE.test(value) ? `${value}T00:00:00Z` : value,
14
21
  encode: (iso) => iso.replace(ZERO_MILLIS, "")
15
22
  })), Schema.decodeTo(Schema.DateTimeUtcFromString));
16
23
 
package/Validate.js CHANGED
@@ -29,6 +29,7 @@ var Validate = class Validate {
29
29
  config,
30
30
  graph: Graph$1.fromBundle(bundle),
31
31
  now: options.now,
32
+ configPath: options.configPath,
32
33
  severity
33
34
  };
34
35
  return [...loadTime, ...LINT_RULES.flatMap((rule) => rule(context))];