@umituz/web-hono 1.8.6 → 1.8.7
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 +1 -1
- package/src/dates.ts +22 -12
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-hono",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.7",
|
|
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
CHANGED
|
@@ -4,22 +4,31 @@
|
|
|
4
4
|
* Fleet schemas split into two worlds: timestamptz columns (drizzle wants a
|
|
5
5
|
* Date — see pickPatch/stampUpdate) and TEXT/date-string columns whose wire
|
|
6
6
|
* format is a truncated ISO string the client renders verbatim. These helpers
|
|
7
|
-
* are the canon for the second world: one
|
|
8
|
-
* each domain keeps its historical wire format byte-identical, plus the
|
|
9
|
-
* calendar-day arithmetic (today /
|
|
10
|
-
* re-implementing. All UTC — the local-calendar branch inside
|
|
11
|
-
* the only local-time stamp in the package and stays that way.
|
|
7
|
+
* are the canon for the second world: one precision-parameterized formatter
|
|
8
|
+
* so each domain keeps its historical wire format byte-identical, plus the
|
|
9
|
+
* calendar-day arithmetic (today / base-date shifts) that deadline features
|
|
10
|
+
* keep re-implementing. All UTC — the local-calendar branch inside
|
|
11
|
+
* stampUpdate is the only local-time stamp in the package and stays that way.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
export type IsoPrecision = 'ms' | 's' | 'm' | 'd';
|
|
15
15
|
|
|
16
16
|
const ISO_LENGTH: Record<Exclude<IsoPrecision, 'ms'>, number> = { s: 19, m: 16, d: 10 };
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
function trunc(iso: string, precision: IsoPrecision): string {
|
|
19
|
+
return precision === 'ms' ? iso : iso.slice(0, ISO_LENGTH[precision]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Current instant truncated to the requested precision:
|
|
19
23
|
* 'ms' → 2026-10-18T05:28:47.941Z (full), 's' → …:47, 'm' → …:28, 'd' → 2026-10-18. */
|
|
20
24
|
export function isoNow(precision: IsoPrecision = 'ms'): string {
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
return trunc(new Date().toISOString(), precision);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Any instant truncated to the requested precision — the formatter for
|
|
29
|
+
* stored Dates and computed offsets (`isoAt(new Date(Date.now() + 5 * DAY), 's')`). */
|
|
30
|
+
export function isoAt(d: Date, precision: IsoPrecision = 'ms'): string {
|
|
31
|
+
return trunc(d.toISOString(), precision);
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
/** UTC calendar day as 'YYYY-MM-DD' — equals isoNow('d'). */
|
|
@@ -27,10 +36,11 @@ export function todayISO(): string {
|
|
|
27
36
|
return new Date().toISOString().slice(0, 10);
|
|
28
37
|
}
|
|
29
38
|
|
|
30
|
-
/** Day-shifted UTC calendar day: addDaysISO(3) is
|
|
31
|
-
* values reach back. Month/year rollovers ride
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
/** Day-shifted UTC calendar day from a base date: addDaysISO(base, 3) is
|
|
40
|
+
* three days out, negative values reach back. Month/year rollovers ride
|
|
41
|
+
* Date's own calendar math. */
|
|
42
|
+
export function addDaysISO(iso: string, days: number): string {
|
|
43
|
+
const d = new Date(`${iso.slice(0, 10)}T00:00:00Z`);
|
|
34
44
|
d.setUTCDate(d.getUTCDate() + days);
|
|
35
45
|
return d.toISOString().slice(0, 10);
|
|
36
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -30,7 +30,7 @@ export { docStore, canTransition, epoch, WorkflowError, UnknownCollectionError }
|
|
|
30
30
|
export type { Doc, DocTable, DocCollectionSpec, DocStoreSpec, DocValidateFn } from './docstore';
|
|
31
31
|
export { getDb } from './db';
|
|
32
32
|
export { uid, pickPatch, patchTypeErrors, normalizeRow, stampUpdate, trio, actor } from './lib';
|
|
33
|
-
export { isoNow, todayISO, addDaysISO } from './dates';
|
|
33
|
+
export { isoNow, isoAt, todayISO, addDaysISO } from './dates';
|
|
34
34
|
export type { IsoPrecision } from './dates';
|
|
35
35
|
export { resolveOrg, orgHasMode, nextNumber } from './org';
|
|
36
36
|
export type { UsersLike, OrgsLike, NumberedTable } from './org';
|