@vermeulen.solutions/eventual 0.18.5 → 0.18.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/README.md +7 -7
- package/astro/EventList.astro +124 -5
- package/astro/blueprint.d.mts +2 -0
- package/astro/blueprint.mjs +1 -1
- package/astro/install.mjs +3 -3
- package/dist/index.mjs +1 -11
- package/dist/plugin.mjs +7 -7
- package/docs/collection-setup.md +58 -58
- package/docs/developer-guide.md +19 -4
- package/docs/history.md +16 -16
- package/docs/registry-installation.md +3 -3
- package/docs/release-notes-0.18.5.md +8 -8
- package/docs/release-notes-0.18.6.md +5 -0
- package/docs/release-notes-0.18.7.md +13 -0
- package/docs/user-guide.md +1 -1
- package/emdash-plugin.jsonc +4 -3
- package/package.json +4 -2
- package/scripts/export-native-schema.mjs +8 -4
- package/src/domain/calendar-links.ts +84 -82
- package/src/domain/invocation-budget.ts +12 -7
- package/src/domain/native-calendar.ts +12 -3
- package/src/schema/blueprint.ts +3 -1
|
@@ -12,6 +12,9 @@ import { categoryKey } from "./category";
|
|
|
12
12
|
import type { CalendarCancellation, EventualContext } from "../storage";
|
|
13
13
|
import { reserveRpcCalls } from './invocation-budget';
|
|
14
14
|
|
|
15
|
+
/** Hex SHA-256 of a text. */
|
|
16
|
+
export const sha256 = async (text: string) => Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text))), byte => byte.toString(16).padStart(2, '0')).join('');
|
|
17
|
+
|
|
15
18
|
interface CalendarState {
|
|
16
19
|
from?: string;
|
|
17
20
|
locales?: string[];
|
|
@@ -102,15 +105,21 @@ export async function reconcileNativeCalendar(ctx: EventualContext): Promise<{
|
|
|
102
105
|
const rows = (groups.get(key) ?? []).sort((a, b) =>
|
|
103
106
|
a.id.localeCompare(b.id),
|
|
104
107
|
);
|
|
105
|
-
const
|
|
108
|
+
const content = JSON.stringify(
|
|
106
109
|
[ctx.site, source.schema?.urlPattern, source.schema?.routable, rows.map((row) => ({
|
|
107
110
|
...row,
|
|
108
111
|
calendarSequence: undefined,
|
|
109
112
|
venue: localizedVenue(venues, row),
|
|
110
113
|
}))],
|
|
111
114
|
);
|
|
115
|
+
// The snapshot keeps a SHA-256 of each group, not the group itself: the full text made a
|
|
116
|
+
// year of one-off events outgrow the 1 MiB snapshot at about 500 events. Snapshots written
|
|
117
|
+
// before 0.18.7 still hold the text; it counts as unchanged and is replaced by its hash.
|
|
118
|
+
const fingerprint = await sha256(content);
|
|
112
119
|
const cache = cached.get(key);
|
|
113
|
-
|
|
120
|
+
const same = cache?.fingerprint === fingerprint || cache?.fingerprint === content;
|
|
121
|
+
if (same && cache!.from === from) {
|
|
122
|
+
if (cache!.fingerprint !== fingerprint) { next.set(key, { ...cache!, fingerprint }); changedSnapshot = true; }
|
|
114
123
|
occurrenceCount += cache.occurrences.length;
|
|
115
124
|
if (occurrenceCount > 10000)
|
|
116
125
|
reject("Calendar occurrence limit exceeded.");
|
|
@@ -122,7 +131,7 @@ export async function reconcileNativeCalendar(ctx: EventualContext): Promise<{
|
|
|
122
131
|
reject("Calendar cancellation limit exceeded.");
|
|
123
132
|
continue;
|
|
124
133
|
}
|
|
125
|
-
const changed =
|
|
134
|
+
const changed = !same;
|
|
126
135
|
const sequence = cache
|
|
127
136
|
? cache.sequence + (changed ? 1 : 0)
|
|
128
137
|
: rows.some((row) => row.calendarUid)
|
package/src/schema/blueprint.ts
CHANGED
|
@@ -48,6 +48,8 @@ export interface SchemaBlueprintOptions {
|
|
|
48
48
|
bindRelations?: boolean;
|
|
49
49
|
/** Opt in only when importing private-storage records from older prototypes. */
|
|
50
50
|
legacyCompatibility?: boolean;
|
|
51
|
+
/** Time zone new events start in (IANA name). Default Europe/Zurich, for existing callers. */
|
|
52
|
+
defaultTimezone?: string;
|
|
51
53
|
}
|
|
52
54
|
function field(
|
|
53
55
|
slug: string,
|
|
@@ -137,7 +139,7 @@ export function createEventsCollectionBlueprint(
|
|
|
137
139
|
field("start_date", "string"),
|
|
138
140
|
field("end_date", "string"),
|
|
139
141
|
field("all_day", "boolean", false, { defaultValue: false }),
|
|
140
|
-
field("timezone", "string", false, { defaultValue: "Europe/Zurich" }),
|
|
142
|
+
field("timezone", "string", false, { defaultValue: options.defaultTimezone ?? "Europe/Zurich" }),
|
|
141
143
|
field("location_type", "select", false, {
|
|
142
144
|
widget: "eventual-editor:location-type",
|
|
143
145
|
defaultValue: "physical",
|