@umituz/web-hono 1.8.5 → 1.8.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-hono",
3
- "version": "1.8.5",
3
+ "version": "1.8.6",
4
4
  "description": "API backend platform for Cloudflare Workers + Neon Postgres: createApi skeleton + error envelope layer, full-CRUD resource factory (opt-in create/remove, list params), schema→client type bridge (ClientRow), apiFetch/apiWrite client, reactive fetch-backed store (+React hooks), and db lifecycle scripts (reset / snapshot / seed)",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/dates.ts ADDED
@@ -0,0 +1,36 @@
1
+ /**
2
+ * ISO date-string primitives for TEXT datetime columns and doc-wire dates.
3
+ *
4
+ * Fleet schemas split into two worlds: timestamptz columns (drizzle wants a
5
+ * Date — see pickPatch/stampUpdate) and TEXT/date-string columns whose wire
6
+ * format is a truncated ISO string the client renders verbatim. These helpers
7
+ * are the canon for the second world: one `isoNow` with explicit precision so
8
+ * each domain keeps its historical wire format byte-identical, plus the
9
+ * calendar-day arithmetic (today / addDays) that deadline features keep
10
+ * re-implementing. All UTC — the local-calendar branch inside stampUpdate is
11
+ * the only local-time stamp in the package and stays that way.
12
+ */
13
+
14
+ export type IsoPrecision = 'ms' | 's' | 'm' | 'd';
15
+
16
+ const ISO_LENGTH: Record<Exclude<IsoPrecision, 'ms'>, number> = { s: 19, m: 16, d: 10 };
17
+
18
+ /** Current instant as an ISO string truncated to the requested precision:
19
+ * 'ms' → 2026-10-18T05:28:47.941Z (full), 's' → …:47, 'm' → …:28, 'd' → 2026-10-18. */
20
+ export function isoNow(precision: IsoPrecision = 'ms'): string {
21
+ const iso = new Date().toISOString();
22
+ return precision === 'ms' ? iso : iso.slice(0, ISO_LENGTH[precision]);
23
+ }
24
+
25
+ /** UTC calendar day as 'YYYY-MM-DD' — equals isoNow('d'). */
26
+ export function todayISO(): string {
27
+ return new Date().toISOString().slice(0, 10);
28
+ }
29
+
30
+ /** Day-shifted UTC calendar day: addDaysISO(3) is three days out, negative
31
+ * values reach back. Month/year rollovers ride Date's own calendar math. */
32
+ export function addDaysISO(days: number): string {
33
+ const d = new Date();
34
+ d.setUTCDate(d.getUTCDate() + days);
35
+ return d.toISOString().slice(0, 10);
36
+ }
package/src/index.ts CHANGED
@@ -6,7 +6,8 @@
6
6
  * and business rules — this package owns the cross-cutting skeleton:
7
7
  * the createApi app factory, the error envelope layer, the full-CRUD
8
8
  * resource factory, getDb, the uid/pickPatch/stampUpdate/trio/actor
9
- * helpers, the org-scoped lookups (resolveOrg/orgHasMode/nextNumber),
9
+ * helpers, the ISO date-string primitives (isoNow/todayISO/addDaysISO),
10
+ * the org-scoped lookups (resolveOrg/orgHasMode/nextNumber),
10
11
  * the audit and notification writes, findRow/softDelete, the JSON-404
11
12
  * and SPA-fallback handlers, and the ApiEnv binding types.
12
13
  *
@@ -29,6 +30,8 @@ export { docStore, canTransition, epoch, WorkflowError, UnknownCollectionError }
29
30
  export type { Doc, DocTable, DocCollectionSpec, DocStoreSpec, DocValidateFn } from './docstore';
30
31
  export { getDb } from './db';
31
32
  export { uid, pickPatch, patchTypeErrors, normalizeRow, stampUpdate, trio, actor } from './lib';
33
+ export { isoNow, todayISO, addDaysISO } from './dates';
34
+ export type { IsoPrecision } from './dates';
32
35
  export { resolveOrg, orgHasMode, nextNumber } from './org';
33
36
  export type { UsersLike, OrgsLike, NumberedTable } from './org';
34
37
  export { writeAudit, writeNotification } from './activity';