@vermeulen.solutions/eventual 0.0.0-stage → 0.18.2
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/LICENSE +21 -0
- package/README.md +139 -2
- package/astro/EventList.astro +57 -0
- package/astro/admin.d.mts +3 -0
- package/astro/admin.mjs +158 -0
- package/astro/blueprint.d.mts +51 -0
- package/astro/blueprint.mjs +236 -0
- package/astro/cache.ts +82 -0
- package/astro/descriptor.mjs +7 -0
- package/astro/editor-compat.mjs +197 -0
- package/astro/editor-i18n.d.mts +8 -0
- package/astro/editor-i18n.mjs +157 -0
- package/astro/event-details.ts +29 -0
- package/astro/event-list.ts +56 -0
- package/astro/feed.ts +201 -0
- package/astro/install.d.mts +9 -0
- package/astro/install.mjs +66 -0
- package/astro/schema.ts +88 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +1585 -0
- package/dist/plugin.d.mts +6 -0
- package/dist/plugin.mjs +13 -0
- package/docs/collection-setup.md +46 -0
- package/docs/history.md +16 -0
- package/docs/native-modernization.md +99 -0
- package/docs/public-feed-caching.md +259 -0
- package/docs/registry-installation.md +13 -0
- package/docs/release-notes-0.14.0.md +27 -0
- package/docs/release-notes-0.14.1.md +40 -0
- package/docs/release-notes-0.15.0.md +18 -0
- package/docs/release-notes-0.16.0.md +7 -0
- package/docs/release-notes-0.17.0.md +7 -0
- package/docs/release-notes-0.18.0.md +8 -0
- package/docs/release-notes-0.18.1.md +7 -0
- package/docs/release-notes-0.18.2.md +6 -0
- package/docs/upgrade-0.13.0.md +21 -0
- package/docs/user-guide.md +40 -0
- package/emdash-plugin.jsonc +77 -0
- package/package.json +143 -4
- package/scripts/check-editor-installation.mjs +32 -0
- package/scripts/export-native-schema.mjs +28 -0
- package/scripts/upgrade-native-editor.mjs +296 -0
- package/src/domain/calendar-links.ts +80 -0
- package/src/domain/category.ts +32 -0
- package/src/domain/collections.ts +101 -0
- package/src/domain/date-time.ts +220 -0
- package/src/domain/description.ts +108 -0
- package/src/domain/event-data.ts +217 -0
- package/src/domain/event-expansion.ts +305 -0
- package/src/domain/event.ts +195 -0
- package/src/domain/icalendar.ts +165 -0
- package/src/domain/image.ts +18 -0
- package/src/domain/invocation-budget.ts +56 -0
- package/src/domain/messages.ts +8 -0
- package/src/domain/migration.ts +666 -0
- package/src/domain/native-calendar.ts +256 -0
- package/src/domain/native-references.ts +41 -0
- package/src/domain/native-source.ts +261 -0
- package/src/domain/native-validation.ts +366 -0
- package/src/domain/occurrences.ts +54 -0
- package/src/domain/portable-text.ts +180 -0
- package/src/domain/public-cache.ts +24 -0
- package/src/domain/recurrence-rule.ts +34 -0
- package/src/domain/recurrence.ts +350 -0
- package/src/domain/request-memo.ts +8 -0
- package/src/domain/schedule-history.ts +14 -0
- package/src/domain/text.ts +2 -0
- package/src/domain/time-entry.ts +23 -0
- package/src/domain/venue-adapter.ts +101 -0
- package/src/domain/venue.ts +42 -0
- package/src/public-event.ts +88 -0
- package/src/schema/blueprint.ts +315 -0
- package/src/storage.ts +257 -0
- package/transfer/index.d.mts +13 -0
- package/transfer/index.mjs +155 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { EventualContext } from '../storage';
|
|
2
|
+
|
|
3
|
+
export class SandboxBudgetError extends Error {
|
|
4
|
+
constructor() {
|
|
5
|
+
super('The sandbox RPC budget is exceeded.');
|
|
6
|
+
this.name = 'SandboxBudgetError';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
type Budget = { used: number; reserved: number };
|
|
10
|
+
const state = Symbol('eventual invocation budget');
|
|
11
|
+
type BudgetContext = EventualContext & {[state]?: Budget};
|
|
12
|
+
const contexts = new WeakMap<object, EventualContext>();
|
|
13
|
+
|
|
14
|
+
/** One counter covers lazy storage collections, parallel calls, and copied contexts. */
|
|
15
|
+
export function withInvocationBudget(ctx: EventualContext): EventualContext {
|
|
16
|
+
if ((ctx as BudgetContext)[state]) return ctx;
|
|
17
|
+
const cached = contexts.get(ctx);
|
|
18
|
+
if (cached) return cached;
|
|
19
|
+
const budget = { used: 0, reserved: 0 };
|
|
20
|
+
// Enumerable symbols survive object spread and are excluded from serialized output.
|
|
21
|
+
const wrapped: BudgetContext = { ...ctx, [state]: budget };
|
|
22
|
+
const facade = (target: object): object => {
|
|
23
|
+
const proxy = new Proxy(target, { get(target, key) {
|
|
24
|
+
const value = Reflect.get(target, key, target);
|
|
25
|
+
if (typeof value !== 'function') return value;
|
|
26
|
+
return (...args: unknown[]) => {
|
|
27
|
+
if (budget.used + budget.reserved >= 10) throw new SandboxBudgetError();
|
|
28
|
+
budget.used++;
|
|
29
|
+
return Reflect.apply(value, target, args);
|
|
30
|
+
};
|
|
31
|
+
}});
|
|
32
|
+
return proxy;
|
|
33
|
+
};
|
|
34
|
+
for (const [name, api] of Object.entries(ctx))
|
|
35
|
+
if (!['site','plugin','storage'].includes(name) && api && typeof api === 'object') (wrapped as any)[name] = facade(api);
|
|
36
|
+
if (ctx.storage) wrapped.storage = new Proxy(ctx.storage, { get(target, key) {
|
|
37
|
+
const collection = Reflect.get(target, key, target);
|
|
38
|
+
return collection && typeof collection === 'object' ? facade(collection) : collection;
|
|
39
|
+
}});
|
|
40
|
+
contexts.set(ctx, wrapped);
|
|
41
|
+
return wrapped;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Reserve final writes before starting reads; exhaustion must precede mutation. */
|
|
45
|
+
export function reserveRpcCalls(ctx: EventualContext, count: number): () => void {
|
|
46
|
+
const budget = (ctx as BudgetContext)[state];
|
|
47
|
+
if (!budget) return () => {};
|
|
48
|
+
if (budget.used + budget.reserved + count > 10) throw new SandboxBudgetError();
|
|
49
|
+
budget.reserved += count;
|
|
50
|
+
let released = false;
|
|
51
|
+
return () => { if (!released) { budget.reserved -= count; released = true; } };
|
|
52
|
+
}
|
|
53
|
+
export function remainingRpcCalls(ctx: EventualContext): number {
|
|
54
|
+
const budget = (ctx as BudgetContext)[state];
|
|
55
|
+
return budget ? 10 - budget.used - budget.reserved : 10;
|
|
56
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Shared validation messages keep the constrained sandbox payload small.
|
|
2
|
+
export const TIMEZONE_ERROR = 'Enter a valid IANA timezone, such as Europe/Paris.';
|
|
3
|
+
export const TIMEZONE_UNAVAILABLE = 'The selected timezone could not be applied.';
|
|
4
|
+
export const DST_ERROR = 'That local time does not exist because of a daylight-saving change.';
|
|
5
|
+
export const EXTERNAL_URL_ERROR = 'External URL must use HTTP or HTTPS.';
|
|
6
|
+
export const NATIVE_VENUES = 'Use the EmDash venue directory.';
|
|
7
|
+
/** Shared throwing path keeps validation messages intact within the sandbox bundle cap. */
|
|
8
|
+
export function reject(message?: string): never { throw new Error(message); }
|