@mulmoclaude/collection-plugin 0.5.2 → 0.5.3
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/dist/core/schema.d.ts +24 -2
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.js +2 -2
- package/dist/{schema-LrmrgW12.cjs → schema-5P5ZJPrY.cjs} +11 -1
- package/dist/schema-5P5ZJPrY.cjs.map +1 -0
- package/dist/{schema-DyfSfVzh.js → schema-BcnitlL8.js} +6 -2
- package/dist/schema-BcnitlL8.js.map +1 -0
- package/dist/server/discovery.d.ts +14 -2
- package/dist/server/discovery.d.ts.map +1 -1
- package/dist/server/spawn.d.ts +8 -1
- package/dist/server/spawn.d.ts.map +1 -1
- package/dist/server.cjs +85 -9
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +85 -10
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/dist/schema-DyfSfVzh.js.map +0 -1
- package/dist/schema-LrmrgW12.cjs.map +0 -1
package/dist/core/schema.d.ts
CHANGED
|
@@ -41,6 +41,27 @@ export interface CollectionEvery {
|
|
|
41
41
|
* Ignored for `day`/`week` units. */
|
|
42
42
|
dayOfMonth?: number | "last";
|
|
43
43
|
}
|
|
44
|
+
/** Field-driven recurrence: the advance interval is selected PER RECORD by
|
|
45
|
+
* the value of an `enum` field (`fromField`), looked up in `map`. Lets one
|
|
46
|
+
* collection mix daily / weekly / monthly obligations in a single list — the
|
|
47
|
+
* host reads `record[fromField]`, finds the matching `CollectionEvery`, and
|
|
48
|
+
* advances by it. `fromField` must point at a top-level `enum` field whose
|
|
49
|
+
* `values` the `map` keys exactly cover (validated at discovery), and must
|
|
50
|
+
* itself be carried/`set` onto the successor so the chain keeps recurring. */
|
|
51
|
+
export interface CollectionEveryFieldDriven {
|
|
52
|
+
/** Top-level `enum` field whose value selects the interval. */
|
|
53
|
+
fromField: string;
|
|
54
|
+
/** Interval per enum value. Keys exactly cover `fromField`'s `values`;
|
|
55
|
+
* each value is a literal {@link CollectionEvery}. */
|
|
56
|
+
map: Record<string, CollectionEvery>;
|
|
57
|
+
}
|
|
58
|
+
/** The `every` of a `spawn`: either a single literal interval applied to
|
|
59
|
+
* every record, or a per-record interval selected by an `enum` field. The
|
|
60
|
+
* literal arm is what `advanceTriggerDate` consumes — the field-driven arm
|
|
61
|
+
* is resolved down to one of its `map` values before the date math runs. */
|
|
62
|
+
export type CollectionSpawnEvery = CollectionEvery | CollectionEveryFieldDriven;
|
|
63
|
+
/** Narrowing guard: true when `every` is the field-driven arm. */
|
|
64
|
+
export declare function isFieldDrivenEvery(every: CollectionSpawnEvery): every is CollectionEveryFieldDriven;
|
|
44
65
|
/** Host-driven recurrence: when a record satisfies `when`, the host
|
|
45
66
|
* creates the next record with a forward-advanced `triggerField` date.
|
|
46
67
|
* The successor's id and contents are a pure function of (source
|
|
@@ -52,8 +73,9 @@ export interface CollectionSpawn {
|
|
|
52
73
|
* "`completionField` value ∈ `completionDoneValues`" (i.e. spawn the
|
|
53
74
|
* next instance when this one is done). */
|
|
54
75
|
when?: CollectionWhen;
|
|
55
|
-
/** How to advance `triggerField` from the source to the successor
|
|
56
|
-
|
|
76
|
+
/** How to advance `triggerField` from the source to the successor —
|
|
77
|
+
* either a single literal interval or a per-record, field-driven map. */
|
|
78
|
+
every: CollectionSpawnEvery;
|
|
57
79
|
/** Record fields copied verbatim onto the successor. Fields not listed
|
|
58
80
|
* here, not in `set`, and not the trigger / primary keys start
|
|
59
81
|
* blank. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAaA;;;;;;wCAMwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;+CAG+C;AAC/C,eAAO,M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
|
2
|
-
const require_schema = require("./schema-
|
|
2
|
+
const require_schema = require("./schema-5P5ZJPrY.cjs");
|
|
3
3
|
const require_promptSafety = require("./promptSafety-B0pPJkfQ.cjs");
|
|
4
4
|
const require_deriveAll = require("./deriveAll-BJ0Lvm1Q.cjs");
|
|
5
5
|
exports.ENUM_ALERT = require_promptSafety.ENUM_ALERT;
|
|
@@ -34,6 +34,7 @@ exports.evaluateDerived = require_deriveAll.evaluateDerived;
|
|
|
34
34
|
exports.executePresentCollection = require_promptSafety.executePresentCollection;
|
|
35
35
|
exports.fieldVisible = require_promptSafety.fieldVisible;
|
|
36
36
|
exports.firstMissingRequiredField = require_promptSafety.firstMissingRequiredField;
|
|
37
|
+
exports.isFieldDrivenEvery = require_schema.isFieldDrivenEvery;
|
|
37
38
|
exports.isSortableField = require_promptSafety.isSortableField;
|
|
38
39
|
exports.itemIdOf = require_promptSafety.itemIdOf;
|
|
39
40
|
exports.itemLabelOf = require_promptSafety.itemLabelOf;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as INGEST_KINDS, t as FEED_SCHEDULES } from "./schema-
|
|
1
|
+
import { n as INGEST_KINDS, r as isFieldDrivenEvery, t as FEED_SCHEDULES } from "./schema-BcnitlL8.js";
|
|
2
2
|
import { A as buildUpdatedRecord, B as ENUM_NEUTRAL, C as dateSortValue, D as numericSortValue, E as nextSortDirection, F as rowFromItem, G as TOOL_DEFINITION, H as enumColorClasses, I as actionVisible, K as TOOL_NAME, L as fieldVisible, M as draftToRecord, N as emptyRow, O as sortItems, P as firstMissingRequiredField, R as whenMatches, S as compareSortValues, T as isSortableField, U as enumValueIndex, V as ENUM_NUDGE, W as resolveEnumColor, _ as ymdKey, a as assignLanes, b as labelFieldFor, c as compareYmd, d as monthAnchorDate, f as parseIsoDate, g as spanCoversDay, h as recordSpan, i as MINUTES_PER_DAY, j as coerceInlineValue, k as stringSortValue, l as dateOf, m as parseTimeRange, n as shortHexId, o as bucketRecords, p as parseIsoDateTime, q as executePresentCollection, r as errorMessage, s as buildMonthGrid, t as defangForPrompt, u as daySlice, v as itemIdOf, w as enumSortValue, x as boolSortValue, y as itemLabelOf, z as ENUM_ALERT } from "./promptSafety-DIQ2yDca.js";
|
|
3
3
|
import { n as resolveRowRefs, r as evaluateDerived, t as deriveAll } from "./deriveAll-BHcs1erT.js";
|
|
4
|
-
export { ENUM_ALERT, ENUM_NEUTRAL, ENUM_NUDGE, FEED_SCHEDULES, INGEST_KINDS, MINUTES_PER_DAY, TOOL_DEFINITION, TOOL_NAME, actionVisible, assignLanes, boolSortValue, bucketRecords, buildMonthGrid, buildUpdatedRecord, coerceInlineValue, compareSortValues, compareYmd, dateOf, dateSortValue, daySlice, defangForPrompt, deriveAll, draftToRecord, emptyRow, enumColorClasses, enumSortValue, enumValueIndex, errorMessage, evaluateDerived, executePresentCollection, fieldVisible, firstMissingRequiredField, isSortableField, itemIdOf, itemLabelOf, labelFieldFor, monthAnchorDate, nextSortDirection, numericSortValue, parseIsoDate, parseIsoDateTime, parseTimeRange, recordSpan, resolveEnumColor, resolveRowRefs, rowFromItem, shortHexId, sortItems, spanCoversDay, stringSortValue, whenMatches, ymdKey };
|
|
4
|
+
export { ENUM_ALERT, ENUM_NEUTRAL, ENUM_NUDGE, FEED_SCHEDULES, INGEST_KINDS, MINUTES_PER_DAY, TOOL_DEFINITION, TOOL_NAME, actionVisible, assignLanes, boolSortValue, bucketRecords, buildMonthGrid, buildUpdatedRecord, coerceInlineValue, compareSortValues, compareYmd, dateOf, dateSortValue, daySlice, defangForPrompt, deriveAll, draftToRecord, emptyRow, enumColorClasses, enumSortValue, enumValueIndex, errorMessage, evaluateDerived, executePresentCollection, fieldVisible, firstMissingRequiredField, isFieldDrivenEvery, isSortableField, itemIdOf, itemLabelOf, labelFieldFor, monthAnchorDate, nextSortDirection, numericSortValue, parseIsoDate, parseIsoDateTime, parseTimeRange, recordSpan, resolveEnumColor, resolveRowRefs, rowFromItem, shortHexId, sortItems, spanCoversDay, stringSortValue, whenMatches, ymdKey };
|
|
@@ -15,6 +15,10 @@ var FEED_SCHEDULES = [
|
|
|
15
15
|
"weekly",
|
|
16
16
|
"on-demand"
|
|
17
17
|
];
|
|
18
|
+
/** Narrowing guard: true when `every` is the field-driven arm. */
|
|
19
|
+
function isFieldDrivenEvery(every) {
|
|
20
|
+
return "fromField" in every;
|
|
21
|
+
}
|
|
18
22
|
//#endregion
|
|
19
23
|
Object.defineProperty(exports, "FEED_SCHEDULES", {
|
|
20
24
|
enumerable: true,
|
|
@@ -28,5 +32,11 @@ Object.defineProperty(exports, "INGEST_KINDS", {
|
|
|
28
32
|
return INGEST_KINDS;
|
|
29
33
|
}
|
|
30
34
|
});
|
|
35
|
+
Object.defineProperty(exports, "isFieldDrivenEvery", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function() {
|
|
38
|
+
return isFieldDrivenEvery;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
31
41
|
|
|
32
|
-
//# sourceMappingURL=schema-
|
|
42
|
+
//# sourceMappingURL=schema-5P5ZJPrY.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-5P5ZJPrY.cjs","names":[],"sources":["../src/core/schema.ts"],"sourcesContent":["// Schema-driven collection types. A \"collection\" is a skill (under\n// .claude/skills/<slug>/) that also ships a sibling `schema.json`.\n// The host's <CollectionView> reads the schema + records and renders\n// a table/form; Claude reads SKILL.md and CRUDs the records as JSON\n// files.\n//\n// Field types for v0 — keep this list narrow and grow it only when a\n// real collection needs the new type. v0 supports flat records only;\n// nested tables / cross-collection refs / derived fields / actions are\n// deferred to follow-ups (see plans/done/feat-skill-driven-apps.md and\n// plans/done/feat-skill-driven-apps-worklog.md — historical names predate\n// the rename).\n\n/** Minimal \"this collection is a feed\" descriptor carried on the schema.\n * Deliberately narrow — the canonical collection contract stays\n * independent of the host's feeds subsystem. The host's richer retrieval\n * spec (`IngestSpec` in `server/workspace/feeds/ingestTypes.ts`)\n * `extends CollectionIngest`, so feed code reads the extra fields by\n * typing feed schemas with that subtype; collection rendering only needs\n * these three + the presence check. */\nexport interface CollectionIngest {\n kind: string;\n url: string;\n schedule: string;\n}\n\n/** Retriever kinds a Feed's `ingest.kind` may declare. The host's feeds engine\n * dispatches on these; they live here (with the schema contract) so the schema\n * validator can enforce them. The host re-exports these from\n * `server/workspace/feeds/ingestTypes.ts`. */\nexport const INGEST_KINDS = [\"rss\", \"atom\", \"http-json\"] as const;\nexport type IngestKind = (typeof INGEST_KINDS)[number];\n\n/** Refresh cadences a Feed's `ingest.schedule` may declare. */\nexport const FEED_SCHEDULES = [\"hourly\", \"daily\", \"weekly\", \"on-demand\"] as const;\nexport type FeedSchedule = (typeof FEED_SCHEDULES)[number];\n\nexport type CollectionFieldType =\n | \"string\"\n | \"text\"\n | \"email\"\n | \"number\"\n | \"date\"\n | \"datetime\"\n | \"boolean\"\n | \"markdown\"\n | \"ref\"\n | \"money\"\n | \"enum\"\n | \"table\"\n | \"derived\"\n | \"embed\"\n // Holds a workspace-relative image path (e.g. a `data/attachments/...`\n // upload); rendered as an <img> in the detail view (not the list table —\n // a per-row fetch is too expensive at scale). Stored and edited as a\n // plain string.\n | \"image\"\n // Holds a workspace-relative file path as a plain string (e.g. an\n // `artifacts/html/<name>.html` app). Rendered as a clickable link in\n // both the list table and the detail view: HTML / SVG artifacts open\n // their rendered form in a new tab; any other path opens in the File\n // Explorer. Stored and edited as a plain string, like `image`.\n | \"file\"\n // A checkbox that is a pure PROJECTION of an `enum` field — it stores\n // nothing of its own. Checked when the enum equals `onValue`; toggling\n // writes `onValue` / `offValue` back to that enum field. Lets a \"done\"\n // checkbox front a kanban `status` field with the enum as the single\n // source of truth (no separate stored boolean to keep in sync).\n | \"toggle\";\n\n// \"feed\" collections live in the non-skill `<workspace>/feeds/` registry\n// and carry an `ingest` block; they reuse the same storage + rendering\n// as skill-backed collections but are never loaded into the agent prompt.\nexport type CollectionSource = \"user\" | \"project\" | \"feed\";\n\n/** Recurrence unit for a `spawn.every` advance. */\nexport type CollectionRecurUnit = \"day\" | \"week\" | \"month\" | \"year\";\n\n/** How a `spawn` advances the source item's `triggerField` date to\n * produce the successor's. All arithmetic is done on the civil\n * (year, month, day) triple — never by adding milliseconds — so month\n * lengths and leap years are handled correctly. */\nexport interface CollectionEvery {\n unit: CollectionRecurUnit;\n /** Number of `unit`s to advance (≥ 1). `interval: 3` + `unit: \"month\"`\n * = quarterly; `interval: 1` + `unit: \"year\"` = annual. */\n interval: number;\n /** Day-of-month anchor for `month`/`year` units. The CANONICAL day —\n * read from the rule, never re-derived from the prior concrete date,\n * so \"31st of every month\" yields 31 → 28/29 → 31 → 30 … with no\n * drift (it is clamped per-month at compute time, not stored\n * clamped). `\"last\"` always means the last day of the target month.\n * Omitted ⇒ preserve the source date's day (safe for days ≤ 28).\n * Ignored for `day`/`week` units. */\n dayOfMonth?: number | \"last\";\n}\n\n/** Field-driven recurrence: the advance interval is selected PER RECORD by\n * the value of an `enum` field (`fromField`), looked up in `map`. Lets one\n * collection mix daily / weekly / monthly obligations in a single list — the\n * host reads `record[fromField]`, finds the matching `CollectionEvery`, and\n * advances by it. `fromField` must point at a top-level `enum` field whose\n * `values` the `map` keys exactly cover (validated at discovery), and must\n * itself be carried/`set` onto the successor so the chain keeps recurring. */\nexport interface CollectionEveryFieldDriven {\n /** Top-level `enum` field whose value selects the interval. */\n fromField: string;\n /** Interval per enum value. Keys exactly cover `fromField`'s `values`;\n * each value is a literal {@link CollectionEvery}. */\n map: Record<string, CollectionEvery>;\n}\n\n/** The `every` of a `spawn`: either a single literal interval applied to\n * every record, or a per-record interval selected by an `enum` field. The\n * literal arm is what `advanceTriggerDate` consumes — the field-driven arm\n * is resolved down to one of its `map` values before the date math runs. */\nexport type CollectionSpawnEvery = CollectionEvery | CollectionEveryFieldDriven;\n\n/** Narrowing guard: true when `every` is the field-driven arm. */\nexport function isFieldDrivenEvery(every: CollectionSpawnEvery): every is CollectionEveryFieldDriven {\n return \"fromField\" in every;\n}\n\n/** Host-driven recurrence: when a record satisfies `when`, the host\n * creates the next record with a forward-advanced `triggerField` date.\n * The successor's id and contents are a pure function of (source\n * record, this rule); creation is create-if-absent, so the mechanism\n * stays convergent — observing the predicate N times writes one\n * successor. Requires the schema to declare `triggerField`. */\nexport interface CollectionSpawn {\n /** Predicate that fires the spawn (a `CollectionWhen`). Defaults to\n * \"`completionField` value ∈ `completionDoneValues`\" (i.e. spawn the\n * next instance when this one is done). */\n when?: CollectionWhen;\n /** How to advance `triggerField` from the source to the successor —\n * either a single literal interval or a per-record, field-driven map. */\n every: CollectionSpawnEvery;\n /** Record fields copied verbatim onto the successor. Fields not listed\n * here, not in `set`, and not the trigger / primary keys start\n * blank. */\n carry?: string[];\n /** Fields forced to fixed values on the successor (typically resetting\n * the status field to its pending value). */\n set?: Record<string, unknown>;\n}\n\n/** The kind of work an action kicks off. v1 ships only `\"chat\"` —\n * start a new chat in a role with a templated seed prompt. The enum\n * reserves room for a future `\"mutate\"` (status transitions) without\n * another schema-shape change. */\nexport type CollectionActionKind = \"chat\";\n\n/** Optional visibility predicate: the target (an action button or a\n * field) renders only when the open record's `field` (stringified) is\n * one of `in`. Generic and domain-free — the host evaluates it against\n * the record with no knowledge of what the field means. Absent ⇒\n * always shown. */\nexport interface CollectionWhen {\n /** Top-level record field key whose value gates visibility. */\n field: string;\n /** Allowed values; the target shows when `String(record[field])` is\n * one of these. Non-empty. */\n in: string[];\n}\n\n/** @deprecated Name retained for back-compat; use {@link CollectionWhen}.\n * Both actions and fields share the same predicate shape. */\nexport type CollectionActionWhen = CollectionWhen;\n\n/** What a custom view's capability token is allowed to do against the\n * collection's data endpoint. `read` returns enriched records (getItems\n * semantics); `write` validates-and-stores rows (putItems semantics).\n * There is deliberately no `delete` — a view can never do more than the\n * agent's own `manageCollection` tool. */\nexport type CollectionViewCapability = \"read\" | \"write\";\n\n/** A custom (LLM-authored) HTML view for a collection. The host renders\n * `file` in a sandboxed iframe over the collection's records; the view\n * reaches its data only through a slug- and capability-scoped token (see\n * `server/api/auth/viewToken.ts`). Pure data — the host holds no\n * view-specific code; meaning lives in the HTML file + this registration. */\nexport interface CollectionCustomView {\n /** Stable id; the view-mode selector key (`custom:<id>`) and the\n * capability-token clamp key. Must be a valid slug. */\n id: string;\n /** Button label in the view-mode selector (author-authored, like field\n * labels — not run through i18n). */\n label: string;\n /** Optional Material-icon name for the selector button. */\n icon?: string;\n /** Skill-relative path to the HTML file under `views/` (e.g.\n * `views/year.html`). Path-safe, must end in `.html`. */\n file: string;\n /** What the view may do with the data endpoint. Defaults to `[\"read\"]`\n * (least privilege); declare `[\"read\",\"write\"]` only for views that\n * edit records. The mint endpoint clamps any requested caps to this. */\n capabilities?: CollectionViewCapability[];\n}\n\n/** A schema-declared, per-record action rendered as a button in the\n * read-only detail view. Pure UI/behaviour directive — never stored,\n * never validated against record data. All domain specifics (label,\n * role, template) live here in the schema / skill folder, so the host\n * stays generic. */\nexport interface CollectionAction {\n /** Stable id (used in the dispatch route + testids). */\n id: string;\n /** Button text (English, like field labels). */\n label: string;\n /** Material-icon name shown on the button. */\n icon?: string;\n /** What the action does. v1: `\"chat\"`. */\n kind: CollectionActionKind;\n /** `kind: \"chat\"`: the role id the new chat runs in. */\n role: string;\n /** `kind: \"chat\"`: skill-relative path to the template file whose\n * text becomes the seed prompt body (e.g. `templates/invoice.md`). */\n template: string;\n /** Optional visibility predicate; the button renders only when the\n * open record matches (see CollectionWhen). Absent ⇒ always\n * shown. */\n when?: CollectionWhen;\n}\n\nexport interface CollectionFieldSpec {\n type: CollectionFieldType;\n label: string;\n /** True for the field whose value is the record's filename (no\n * separate auto-id). Exactly one field per schema may set this. */\n primary?: boolean;\n required?: boolean;\n /** When `type === \"ref\"` or `type === \"embed\"`: the slug of the\n * target collection. For `ref` the record stores the target\n * item's primary-key slug and the host renders a clickable link\n * + dropdown picker. For `embed` the host pulls a *fixed* record\n * (see `id`) from the target and renders its fields read-only in\n * the detail view. Required for both; ignored on every other\n * type. */\n to?: string;\n /** When `type === \"embed\"`: the primary-key value of the fixed\n * record to pull from the `to` collection (e.g. `me` for the\n * singleton mc-profile). Nothing is stored on this record — the\n * embed is a display-only directive resolved at render time, so\n * it never appears in the list table or the edit form. Required\n * when type is `embed`; ignored on every other type. */\n id?: string;\n /** When `type === \"money\"` (or `type === \"derived\"` with\n * `display: \"money\"`): a literal ISO 4217 currency code passed to\n * `Intl.NumberFormat` for display — fixed for every record. The\n * stored value is always a plain decimal number; currency is\n * presentation only. Mutually substitutable with `currencyField`:\n * a money field must declare at least one of the two. */\n currency?: string;\n /** When `type === \"money\"` (or `type === \"derived\"` with\n * `display: \"money\"`): the name of a sibling record field whose\n * value holds the ISO 4217 code, letting currency vary per record\n * (e.g. an invoice's `currency` enum). The renderer reads\n * `record[currencyField]` and falls back to the literal `currency`\n * (then \"USD\") when the field is absent or empty. Resolved against\n * the top-level record even for money sub-fields inside a table. */\n currencyField?: string;\n /** When `type === \"enum\"`: the closed set of allowed string\n * values. The form renders a `<select>` populated from this\n * list; storage is a plain string. Required when type is\n * `enum`; ignored on every other type. */\n values?: readonly string[];\n /** When `type === \"table\"`: the sub-schema for each row (a flat\n * record of non-table / non-derived field specs). Required when\n * type is `table`. v0 disallows nested tables and derived\n * columns to keep the editor + evaluator simple. */\n of?: Record<string, CollectionFieldSpec>;\n /** When `type === \"derived\"`: a tiny expression evaluated against\n * the record. Supports `+ - * /`, parens, identifier refs to\n * top-level fields, `sum(tableField[].col)`, and\n * `sum(tableField[].col * tableField[].col)`. See\n * `src/utils/collections/derivedFormula.ts`. Required when type\n * is `derived`. */\n formula?: string;\n /** When `type === \"derived\"`: an inner field type the computed\n * value should be rendered as (e.g. `\"money\"` so $1,234.56 is\n * formatted). Defaults to `\"number\"`. */\n display?: CollectionFieldType;\n /** Optional visibility predicate: this field renders only when the\n * record matches (e.g. hide a `rating` field until `visited` is\n * `true` via `{ field: \"visited\", in: [\"true\"] }`). Applies to the\n * list cell (blank when hidden), the edit form (hidden live as the\n * gating field changes), and the detail view. Purely presentational\n * — a hidden field's stored value is never cleared. `when.field`\n * must name another top-level field. Absent ⇒ always shown. Only\n * honoured on top-level fields, not inside a `table`'s `of`. */\n when?: CollectionWhen;\n /** When `type === \"toggle\"`: the name of the top-level `enum` field this\n * checkbox projects. The toggle stores nothing itself — it reads and\n * writes this field. Required when type is `toggle`; ignored otherwise.\n * Must name a real `enum` field. */\n field?: string;\n /** When `type === \"toggle\"`: the enum value that means \"checked\". The\n * box is checked when the projected `field` equals this; checking writes\n * it. Required when type is `toggle`; must be one of the enum's `values`. */\n onValue?: string;\n /** When `type === \"toggle\"`: the enum value written when the box is\n * unchecked. Required when type is `toggle`; must be one of the enum's\n * `values`. */\n offValue?: string;\n}\n\nexport interface CollectionSchema {\n /** Human-facing collection name (sidebar, header). */\n title: string;\n /** Material-icon name shown next to the title. */\n icon: string;\n /** Workspace-relative folder holding one-JSON-per-record. Validated\n * to live under the workspace root at load time. */\n dataPath: string;\n /** Field name whose value doubles as the record's filename. */\n primaryKey: string;\n /** When set, the collection is a singleton: at most one record,\n * whose primary key is fixed to this value (e.g. `me` for the\n * business profile). The host pre-fills + locks the create form's\n * primary key and hides Add once the record exists. */\n singleton?: string;\n /** Ordered map: insertion order = column order in the table view. */\n fields: Record<string, CollectionFieldSpec>;\n /** Optional per-record actions rendered as buttons in the detail\n * view (e.g. \"Generate PDF\"). Order = button order. */\n actions?: CollectionAction[];\n /** Optional collection-level actions rendered as buttons in the\n * collection header (e.g. \"Extend the course\"). Unlike `actions`,\n * these carry no record context: the seed prompt injects a compact\n * progress summary of every record instead. The `when` predicate is\n * not evaluated (there is no record to gate on). Order = button order. */\n collectionActions?: CollectionAction[];\n /** Name of the field whose value marks an item as \"done\". When set,\n * a notification fires on item create (unless the item is born done)\n * and clears when the field's value transitions into\n * `completionDoneValues`. Must name a real field in `fields`. */\n completionField?: string;\n /** The set of values for `completionField` that count as \"done\"\n * (e.g. `[\"Done\"]` for a todo status field, `[\"paid\"]` for an\n * invoice). Non-empty. Compared as strings. */\n completionDoneValues?: readonly string[];\n /** Name of the field whose value is shown as the human-readable\n * label in a completion notification's title (e.g. a `name` field,\n * so the bell reads `Contacts: Jane Doe` instead of the opaque\n * primaryKey). Must name a real field in `fields`. When unset — or\n * when the record's value for it is empty — the title falls back to\n * the record's primaryKey value. Display-only; never stored. */\n displayField?: string;\n /** Name of a `date` field that gates this item's completion\n * notification: the bell is suppressed until the clock reaches that\n * date (compared at day-granularity in the server's local timezone),\n * instead of firing on create. Requires `completionField` /\n * `completionDoneValues` (the bell still clears via the done value).\n * Must name a real `date` field. Absent ⇒ fire on create, as before. */\n triggerField?: string;\n /** Lead time in whole days: fire the bell this many days BEFORE\n * `triggerField` (so `10` shows the reminder 10 days early). The lead\n * is applied at fire time, not stored, so it composes with `spawn` —\n * every recurred cycle fires the same number of days before its own\n * trigger. Non-negative integer; requires `triggerField`. Default 0\n * (fire on the trigger date). */\n triggerLeadDays?: number;\n /** Host-driven recurrence. When set, requires `triggerField`. See\n * {@link CollectionSpawn}. */\n spawn?: CollectionSpawn;\n /** Name of a `date` field that anchors the optional calendar view: a\n * month grid where each record lands on the day cell matching this\n * field's value. When unset, the calendar toggle still appears if the\n * schema has any `date` field (the first one, in declaration order, is\n * used by default and is switchable in-view). Set this to pin a specific\n * anchor. Must name a real `date` field. */\n calendarField?: string;\n /** Name of a second `date` field marking the END of a multi-day span on\n * the calendar: the record renders from `calendarField` through this\n * date inclusive. Requires `calendarField`. Must name a real `date`\n * field. Absent ⇒ single-day placement. */\n calendarEndField?: string;\n /** Name of a string field holding a free-form time or time-range\n * (e.g. \"14:00-17:00\", \"17:00-\", \"16:30\") that places records on the\n * calendar's day (time-allocation) view. Consulted only when the calendar\n * date fields are date-only. Requires `calendarField`. */\n calendarTimeField?: string;\n /** Name of an `enum` field that groups records into columns on the\n * optional Kanban board: each record lands in the column matching its\n * value, with empty/unknown values collected in an \"Uncategorized\"\n * column. When unset, the Kanban toggle still appears if the schema has\n * any `enum` field (the first one, in declaration order, is used by\n * default and is switchable in-view). Set this to pin a specific group\n * field. Must name a real `enum` field. */\n kanbanField?: string;\n /** Optional custom (LLM-authored) HTML views, each rendered in a\n * sandboxed iframe over the records. Absent ⇒ only the built-in\n * field-derived views (table / calendar / kanban / dashboard). See\n * {@link CollectionCustomView}. */\n views?: CollectionCustomView[];\n /** Optional predicate that gates the completion bell: when set, the bell\n * fires only for records whose `String(record[notifyWhen.field])` is one\n * of `notifyWhen.in` (e.g. notify only `high`/`urgent` priority todos).\n * Reuses the `when` predicate shape. Requires `completionField` — it\n * narrows that bell rather than introducing a second one. The bell still\n * clears on done / delete / when the predicate stops matching. Absent ⇒\n * notify for every open record (the prior behaviour). `notifyWhen.field`\n * must name a real top-level field. */\n notifyWhen?: CollectionWhen;\n /** Optional declarative retrieval config. When present, this collection\n * is a \"Feed\": the host periodically fetches `ingest.url`, maps the\n * response into records, and upserts them by `primaryKey`. Only feeds\n * discovered from the `<workspace>/feeds/` registry carry this; skill\n * collections omit it. The host's feeds subsystem narrows this to its\n * richer `IngestSpec` (which `extends CollectionIngest`). */\n ingest?: CollectionIngest;\n}\n\nexport interface CollectionSummary {\n slug: string;\n title: string;\n icon: string;\n source: CollectionSource;\n}\n\nexport interface CollectionDetail extends CollectionSummary {\n schema: CollectionSchema;\n}\n\nexport type CollectionItem = Record<string, unknown>;\n"],"mappings":";;;;;AA8BA,IAAa,eAAe;CAAC;CAAO;CAAQ;AAAW;;AAIvD,IAAa,iBAAiB;CAAC;CAAU;CAAS;CAAU;AAAW;;AAqFvE,SAAgB,mBAAmB,OAAkE;CACnG,OAAO,eAAe;AACxB"}
|
|
@@ -15,7 +15,11 @@ var FEED_SCHEDULES = [
|
|
|
15
15
|
"weekly",
|
|
16
16
|
"on-demand"
|
|
17
17
|
];
|
|
18
|
+
/** Narrowing guard: true when `every` is the field-driven arm. */
|
|
19
|
+
function isFieldDrivenEvery(every) {
|
|
20
|
+
return "fromField" in every;
|
|
21
|
+
}
|
|
18
22
|
//#endregion
|
|
19
|
-
export { INGEST_KINDS as n, FEED_SCHEDULES as t };
|
|
23
|
+
export { INGEST_KINDS as n, isFieldDrivenEvery as r, FEED_SCHEDULES as t };
|
|
20
24
|
|
|
21
|
-
//# sourceMappingURL=schema-
|
|
25
|
+
//# sourceMappingURL=schema-BcnitlL8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-BcnitlL8.js","names":[],"sources":["../src/core/schema.ts"],"sourcesContent":["// Schema-driven collection types. A \"collection\" is a skill (under\n// .claude/skills/<slug>/) that also ships a sibling `schema.json`.\n// The host's <CollectionView> reads the schema + records and renders\n// a table/form; Claude reads SKILL.md and CRUDs the records as JSON\n// files.\n//\n// Field types for v0 — keep this list narrow and grow it only when a\n// real collection needs the new type. v0 supports flat records only;\n// nested tables / cross-collection refs / derived fields / actions are\n// deferred to follow-ups (see plans/done/feat-skill-driven-apps.md and\n// plans/done/feat-skill-driven-apps-worklog.md — historical names predate\n// the rename).\n\n/** Minimal \"this collection is a feed\" descriptor carried on the schema.\n * Deliberately narrow — the canonical collection contract stays\n * independent of the host's feeds subsystem. The host's richer retrieval\n * spec (`IngestSpec` in `server/workspace/feeds/ingestTypes.ts`)\n * `extends CollectionIngest`, so feed code reads the extra fields by\n * typing feed schemas with that subtype; collection rendering only needs\n * these three + the presence check. */\nexport interface CollectionIngest {\n kind: string;\n url: string;\n schedule: string;\n}\n\n/** Retriever kinds a Feed's `ingest.kind` may declare. The host's feeds engine\n * dispatches on these; they live here (with the schema contract) so the schema\n * validator can enforce them. The host re-exports these from\n * `server/workspace/feeds/ingestTypes.ts`. */\nexport const INGEST_KINDS = [\"rss\", \"atom\", \"http-json\"] as const;\nexport type IngestKind = (typeof INGEST_KINDS)[number];\n\n/** Refresh cadences a Feed's `ingest.schedule` may declare. */\nexport const FEED_SCHEDULES = [\"hourly\", \"daily\", \"weekly\", \"on-demand\"] as const;\nexport type FeedSchedule = (typeof FEED_SCHEDULES)[number];\n\nexport type CollectionFieldType =\n | \"string\"\n | \"text\"\n | \"email\"\n | \"number\"\n | \"date\"\n | \"datetime\"\n | \"boolean\"\n | \"markdown\"\n | \"ref\"\n | \"money\"\n | \"enum\"\n | \"table\"\n | \"derived\"\n | \"embed\"\n // Holds a workspace-relative image path (e.g. a `data/attachments/...`\n // upload); rendered as an <img> in the detail view (not the list table —\n // a per-row fetch is too expensive at scale). Stored and edited as a\n // plain string.\n | \"image\"\n // Holds a workspace-relative file path as a plain string (e.g. an\n // `artifacts/html/<name>.html` app). Rendered as a clickable link in\n // both the list table and the detail view: HTML / SVG artifacts open\n // their rendered form in a new tab; any other path opens in the File\n // Explorer. Stored and edited as a plain string, like `image`.\n | \"file\"\n // A checkbox that is a pure PROJECTION of an `enum` field — it stores\n // nothing of its own. Checked when the enum equals `onValue`; toggling\n // writes `onValue` / `offValue` back to that enum field. Lets a \"done\"\n // checkbox front a kanban `status` field with the enum as the single\n // source of truth (no separate stored boolean to keep in sync).\n | \"toggle\";\n\n// \"feed\" collections live in the non-skill `<workspace>/feeds/` registry\n// and carry an `ingest` block; they reuse the same storage + rendering\n// as skill-backed collections but are never loaded into the agent prompt.\nexport type CollectionSource = \"user\" | \"project\" | \"feed\";\n\n/** Recurrence unit for a `spawn.every` advance. */\nexport type CollectionRecurUnit = \"day\" | \"week\" | \"month\" | \"year\";\n\n/** How a `spawn` advances the source item's `triggerField` date to\n * produce the successor's. All arithmetic is done on the civil\n * (year, month, day) triple — never by adding milliseconds — so month\n * lengths and leap years are handled correctly. */\nexport interface CollectionEvery {\n unit: CollectionRecurUnit;\n /** Number of `unit`s to advance (≥ 1). `interval: 3` + `unit: \"month\"`\n * = quarterly; `interval: 1` + `unit: \"year\"` = annual. */\n interval: number;\n /** Day-of-month anchor for `month`/`year` units. The CANONICAL day —\n * read from the rule, never re-derived from the prior concrete date,\n * so \"31st of every month\" yields 31 → 28/29 → 31 → 30 … with no\n * drift (it is clamped per-month at compute time, not stored\n * clamped). `\"last\"` always means the last day of the target month.\n * Omitted ⇒ preserve the source date's day (safe for days ≤ 28).\n * Ignored for `day`/`week` units. */\n dayOfMonth?: number | \"last\";\n}\n\n/** Field-driven recurrence: the advance interval is selected PER RECORD by\n * the value of an `enum` field (`fromField`), looked up in `map`. Lets one\n * collection mix daily / weekly / monthly obligations in a single list — the\n * host reads `record[fromField]`, finds the matching `CollectionEvery`, and\n * advances by it. `fromField` must point at a top-level `enum` field whose\n * `values` the `map` keys exactly cover (validated at discovery), and must\n * itself be carried/`set` onto the successor so the chain keeps recurring. */\nexport interface CollectionEveryFieldDriven {\n /** Top-level `enum` field whose value selects the interval. */\n fromField: string;\n /** Interval per enum value. Keys exactly cover `fromField`'s `values`;\n * each value is a literal {@link CollectionEvery}. */\n map: Record<string, CollectionEvery>;\n}\n\n/** The `every` of a `spawn`: either a single literal interval applied to\n * every record, or a per-record interval selected by an `enum` field. The\n * literal arm is what `advanceTriggerDate` consumes — the field-driven arm\n * is resolved down to one of its `map` values before the date math runs. */\nexport type CollectionSpawnEvery = CollectionEvery | CollectionEveryFieldDriven;\n\n/** Narrowing guard: true when `every` is the field-driven arm. */\nexport function isFieldDrivenEvery(every: CollectionSpawnEvery): every is CollectionEveryFieldDriven {\n return \"fromField\" in every;\n}\n\n/** Host-driven recurrence: when a record satisfies `when`, the host\n * creates the next record with a forward-advanced `triggerField` date.\n * The successor's id and contents are a pure function of (source\n * record, this rule); creation is create-if-absent, so the mechanism\n * stays convergent — observing the predicate N times writes one\n * successor. Requires the schema to declare `triggerField`. */\nexport interface CollectionSpawn {\n /** Predicate that fires the spawn (a `CollectionWhen`). Defaults to\n * \"`completionField` value ∈ `completionDoneValues`\" (i.e. spawn the\n * next instance when this one is done). */\n when?: CollectionWhen;\n /** How to advance `triggerField` from the source to the successor —\n * either a single literal interval or a per-record, field-driven map. */\n every: CollectionSpawnEvery;\n /** Record fields copied verbatim onto the successor. Fields not listed\n * here, not in `set`, and not the trigger / primary keys start\n * blank. */\n carry?: string[];\n /** Fields forced to fixed values on the successor (typically resetting\n * the status field to its pending value). */\n set?: Record<string, unknown>;\n}\n\n/** The kind of work an action kicks off. v1 ships only `\"chat\"` —\n * start a new chat in a role with a templated seed prompt. The enum\n * reserves room for a future `\"mutate\"` (status transitions) without\n * another schema-shape change. */\nexport type CollectionActionKind = \"chat\";\n\n/** Optional visibility predicate: the target (an action button or a\n * field) renders only when the open record's `field` (stringified) is\n * one of `in`. Generic and domain-free — the host evaluates it against\n * the record with no knowledge of what the field means. Absent ⇒\n * always shown. */\nexport interface CollectionWhen {\n /** Top-level record field key whose value gates visibility. */\n field: string;\n /** Allowed values; the target shows when `String(record[field])` is\n * one of these. Non-empty. */\n in: string[];\n}\n\n/** @deprecated Name retained for back-compat; use {@link CollectionWhen}.\n * Both actions and fields share the same predicate shape. */\nexport type CollectionActionWhen = CollectionWhen;\n\n/** What a custom view's capability token is allowed to do against the\n * collection's data endpoint. `read` returns enriched records (getItems\n * semantics); `write` validates-and-stores rows (putItems semantics).\n * There is deliberately no `delete` — a view can never do more than the\n * agent's own `manageCollection` tool. */\nexport type CollectionViewCapability = \"read\" | \"write\";\n\n/** A custom (LLM-authored) HTML view for a collection. The host renders\n * `file` in a sandboxed iframe over the collection's records; the view\n * reaches its data only through a slug- and capability-scoped token (see\n * `server/api/auth/viewToken.ts`). Pure data — the host holds no\n * view-specific code; meaning lives in the HTML file + this registration. */\nexport interface CollectionCustomView {\n /** Stable id; the view-mode selector key (`custom:<id>`) and the\n * capability-token clamp key. Must be a valid slug. */\n id: string;\n /** Button label in the view-mode selector (author-authored, like field\n * labels — not run through i18n). */\n label: string;\n /** Optional Material-icon name for the selector button. */\n icon?: string;\n /** Skill-relative path to the HTML file under `views/` (e.g.\n * `views/year.html`). Path-safe, must end in `.html`. */\n file: string;\n /** What the view may do with the data endpoint. Defaults to `[\"read\"]`\n * (least privilege); declare `[\"read\",\"write\"]` only for views that\n * edit records. The mint endpoint clamps any requested caps to this. */\n capabilities?: CollectionViewCapability[];\n}\n\n/** A schema-declared, per-record action rendered as a button in the\n * read-only detail view. Pure UI/behaviour directive — never stored,\n * never validated against record data. All domain specifics (label,\n * role, template) live here in the schema / skill folder, so the host\n * stays generic. */\nexport interface CollectionAction {\n /** Stable id (used in the dispatch route + testids). */\n id: string;\n /** Button text (English, like field labels). */\n label: string;\n /** Material-icon name shown on the button. */\n icon?: string;\n /** What the action does. v1: `\"chat\"`. */\n kind: CollectionActionKind;\n /** `kind: \"chat\"`: the role id the new chat runs in. */\n role: string;\n /** `kind: \"chat\"`: skill-relative path to the template file whose\n * text becomes the seed prompt body (e.g. `templates/invoice.md`). */\n template: string;\n /** Optional visibility predicate; the button renders only when the\n * open record matches (see CollectionWhen). Absent ⇒ always\n * shown. */\n when?: CollectionWhen;\n}\n\nexport interface CollectionFieldSpec {\n type: CollectionFieldType;\n label: string;\n /** True for the field whose value is the record's filename (no\n * separate auto-id). Exactly one field per schema may set this. */\n primary?: boolean;\n required?: boolean;\n /** When `type === \"ref\"` or `type === \"embed\"`: the slug of the\n * target collection. For `ref` the record stores the target\n * item's primary-key slug and the host renders a clickable link\n * + dropdown picker. For `embed` the host pulls a *fixed* record\n * (see `id`) from the target and renders its fields read-only in\n * the detail view. Required for both; ignored on every other\n * type. */\n to?: string;\n /** When `type === \"embed\"`: the primary-key value of the fixed\n * record to pull from the `to` collection (e.g. `me` for the\n * singleton mc-profile). Nothing is stored on this record — the\n * embed is a display-only directive resolved at render time, so\n * it never appears in the list table or the edit form. Required\n * when type is `embed`; ignored on every other type. */\n id?: string;\n /** When `type === \"money\"` (or `type === \"derived\"` with\n * `display: \"money\"`): a literal ISO 4217 currency code passed to\n * `Intl.NumberFormat` for display — fixed for every record. The\n * stored value is always a plain decimal number; currency is\n * presentation only. Mutually substitutable with `currencyField`:\n * a money field must declare at least one of the two. */\n currency?: string;\n /** When `type === \"money\"` (or `type === \"derived\"` with\n * `display: \"money\"`): the name of a sibling record field whose\n * value holds the ISO 4217 code, letting currency vary per record\n * (e.g. an invoice's `currency` enum). The renderer reads\n * `record[currencyField]` and falls back to the literal `currency`\n * (then \"USD\") when the field is absent or empty. Resolved against\n * the top-level record even for money sub-fields inside a table. */\n currencyField?: string;\n /** When `type === \"enum\"`: the closed set of allowed string\n * values. The form renders a `<select>` populated from this\n * list; storage is a plain string. Required when type is\n * `enum`; ignored on every other type. */\n values?: readonly string[];\n /** When `type === \"table\"`: the sub-schema for each row (a flat\n * record of non-table / non-derived field specs). Required when\n * type is `table`. v0 disallows nested tables and derived\n * columns to keep the editor + evaluator simple. */\n of?: Record<string, CollectionFieldSpec>;\n /** When `type === \"derived\"`: a tiny expression evaluated against\n * the record. Supports `+ - * /`, parens, identifier refs to\n * top-level fields, `sum(tableField[].col)`, and\n * `sum(tableField[].col * tableField[].col)`. See\n * `src/utils/collections/derivedFormula.ts`. Required when type\n * is `derived`. */\n formula?: string;\n /** When `type === \"derived\"`: an inner field type the computed\n * value should be rendered as (e.g. `\"money\"` so $1,234.56 is\n * formatted). Defaults to `\"number\"`. */\n display?: CollectionFieldType;\n /** Optional visibility predicate: this field renders only when the\n * record matches (e.g. hide a `rating` field until `visited` is\n * `true` via `{ field: \"visited\", in: [\"true\"] }`). Applies to the\n * list cell (blank when hidden), the edit form (hidden live as the\n * gating field changes), and the detail view. Purely presentational\n * — a hidden field's stored value is never cleared. `when.field`\n * must name another top-level field. Absent ⇒ always shown. Only\n * honoured on top-level fields, not inside a `table`'s `of`. */\n when?: CollectionWhen;\n /** When `type === \"toggle\"`: the name of the top-level `enum` field this\n * checkbox projects. The toggle stores nothing itself — it reads and\n * writes this field. Required when type is `toggle`; ignored otherwise.\n * Must name a real `enum` field. */\n field?: string;\n /** When `type === \"toggle\"`: the enum value that means \"checked\". The\n * box is checked when the projected `field` equals this; checking writes\n * it. Required when type is `toggle`; must be one of the enum's `values`. */\n onValue?: string;\n /** When `type === \"toggle\"`: the enum value written when the box is\n * unchecked. Required when type is `toggle`; must be one of the enum's\n * `values`. */\n offValue?: string;\n}\n\nexport interface CollectionSchema {\n /** Human-facing collection name (sidebar, header). */\n title: string;\n /** Material-icon name shown next to the title. */\n icon: string;\n /** Workspace-relative folder holding one-JSON-per-record. Validated\n * to live under the workspace root at load time. */\n dataPath: string;\n /** Field name whose value doubles as the record's filename. */\n primaryKey: string;\n /** When set, the collection is a singleton: at most one record,\n * whose primary key is fixed to this value (e.g. `me` for the\n * business profile). The host pre-fills + locks the create form's\n * primary key and hides Add once the record exists. */\n singleton?: string;\n /** Ordered map: insertion order = column order in the table view. */\n fields: Record<string, CollectionFieldSpec>;\n /** Optional per-record actions rendered as buttons in the detail\n * view (e.g. \"Generate PDF\"). Order = button order. */\n actions?: CollectionAction[];\n /** Optional collection-level actions rendered as buttons in the\n * collection header (e.g. \"Extend the course\"). Unlike `actions`,\n * these carry no record context: the seed prompt injects a compact\n * progress summary of every record instead. The `when` predicate is\n * not evaluated (there is no record to gate on). Order = button order. */\n collectionActions?: CollectionAction[];\n /** Name of the field whose value marks an item as \"done\". When set,\n * a notification fires on item create (unless the item is born done)\n * and clears when the field's value transitions into\n * `completionDoneValues`. Must name a real field in `fields`. */\n completionField?: string;\n /** The set of values for `completionField` that count as \"done\"\n * (e.g. `[\"Done\"]` for a todo status field, `[\"paid\"]` for an\n * invoice). Non-empty. Compared as strings. */\n completionDoneValues?: readonly string[];\n /** Name of the field whose value is shown as the human-readable\n * label in a completion notification's title (e.g. a `name` field,\n * so the bell reads `Contacts: Jane Doe` instead of the opaque\n * primaryKey). Must name a real field in `fields`. When unset — or\n * when the record's value for it is empty — the title falls back to\n * the record's primaryKey value. Display-only; never stored. */\n displayField?: string;\n /** Name of a `date` field that gates this item's completion\n * notification: the bell is suppressed until the clock reaches that\n * date (compared at day-granularity in the server's local timezone),\n * instead of firing on create. Requires `completionField` /\n * `completionDoneValues` (the bell still clears via the done value).\n * Must name a real `date` field. Absent ⇒ fire on create, as before. */\n triggerField?: string;\n /** Lead time in whole days: fire the bell this many days BEFORE\n * `triggerField` (so `10` shows the reminder 10 days early). The lead\n * is applied at fire time, not stored, so it composes with `spawn` —\n * every recurred cycle fires the same number of days before its own\n * trigger. Non-negative integer; requires `triggerField`. Default 0\n * (fire on the trigger date). */\n triggerLeadDays?: number;\n /** Host-driven recurrence. When set, requires `triggerField`. See\n * {@link CollectionSpawn}. */\n spawn?: CollectionSpawn;\n /** Name of a `date` field that anchors the optional calendar view: a\n * month grid where each record lands on the day cell matching this\n * field's value. When unset, the calendar toggle still appears if the\n * schema has any `date` field (the first one, in declaration order, is\n * used by default and is switchable in-view). Set this to pin a specific\n * anchor. Must name a real `date` field. */\n calendarField?: string;\n /** Name of a second `date` field marking the END of a multi-day span on\n * the calendar: the record renders from `calendarField` through this\n * date inclusive. Requires `calendarField`. Must name a real `date`\n * field. Absent ⇒ single-day placement. */\n calendarEndField?: string;\n /** Name of a string field holding a free-form time or time-range\n * (e.g. \"14:00-17:00\", \"17:00-\", \"16:30\") that places records on the\n * calendar's day (time-allocation) view. Consulted only when the calendar\n * date fields are date-only. Requires `calendarField`. */\n calendarTimeField?: string;\n /** Name of an `enum` field that groups records into columns on the\n * optional Kanban board: each record lands in the column matching its\n * value, with empty/unknown values collected in an \"Uncategorized\"\n * column. When unset, the Kanban toggle still appears if the schema has\n * any `enum` field (the first one, in declaration order, is used by\n * default and is switchable in-view). Set this to pin a specific group\n * field. Must name a real `enum` field. */\n kanbanField?: string;\n /** Optional custom (LLM-authored) HTML views, each rendered in a\n * sandboxed iframe over the records. Absent ⇒ only the built-in\n * field-derived views (table / calendar / kanban / dashboard). See\n * {@link CollectionCustomView}. */\n views?: CollectionCustomView[];\n /** Optional predicate that gates the completion bell: when set, the bell\n * fires only for records whose `String(record[notifyWhen.field])` is one\n * of `notifyWhen.in` (e.g. notify only `high`/`urgent` priority todos).\n * Reuses the `when` predicate shape. Requires `completionField` — it\n * narrows that bell rather than introducing a second one. The bell still\n * clears on done / delete / when the predicate stops matching. Absent ⇒\n * notify for every open record (the prior behaviour). `notifyWhen.field`\n * must name a real top-level field. */\n notifyWhen?: CollectionWhen;\n /** Optional declarative retrieval config. When present, this collection\n * is a \"Feed\": the host periodically fetches `ingest.url`, maps the\n * response into records, and upserts them by `primaryKey`. Only feeds\n * discovered from the `<workspace>/feeds/` registry carry this; skill\n * collections omit it. The host's feeds subsystem narrows this to its\n * richer `IngestSpec` (which `extends CollectionIngest`). */\n ingest?: CollectionIngest;\n}\n\nexport interface CollectionSummary {\n slug: string;\n title: string;\n icon: string;\n source: CollectionSource;\n}\n\nexport interface CollectionDetail extends CollectionSummary {\n schema: CollectionSchema;\n}\n\nexport type CollectionItem = Record<string, unknown>;\n"],"mappings":";;;;;AA8BA,IAAa,eAAe;CAAC;CAAO;CAAQ;AAAW;;AAIvD,IAAa,iBAAiB;CAAC;CAAU;CAAS;CAAU;AAAW;;AAqFvE,SAAgB,mBAAmB,OAAkE;CACnG,OAAO,eAAe;AACxB"}
|
|
@@ -109,7 +109,7 @@ export declare const CollectionSchemaZ: z.ZodObject<{
|
|
|
109
109
|
field: z.ZodString;
|
|
110
110
|
in: z.ZodArray<z.ZodString>;
|
|
111
111
|
}, z.core.$strip>>;
|
|
112
|
-
every: z.ZodObject<{
|
|
112
|
+
every: z.ZodUnion<readonly [z.ZodObject<{
|
|
113
113
|
unit: z.ZodEnum<{
|
|
114
114
|
day: "day";
|
|
115
115
|
week: "week";
|
|
@@ -118,7 +118,19 @@ export declare const CollectionSchemaZ: z.ZodObject<{
|
|
|
118
118
|
}>;
|
|
119
119
|
interval: z.ZodNumber;
|
|
120
120
|
dayOfMonth: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"last">]>>;
|
|
121
|
-
}, z.core.$
|
|
121
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
122
|
+
fromField: z.ZodString;
|
|
123
|
+
map: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
124
|
+
unit: z.ZodEnum<{
|
|
125
|
+
day: "day";
|
|
126
|
+
week: "week";
|
|
127
|
+
month: "month";
|
|
128
|
+
year: "year";
|
|
129
|
+
}>;
|
|
130
|
+
interval: z.ZodNumber;
|
|
131
|
+
dayOfMonth: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"last">]>>;
|
|
132
|
+
}, z.core.$strict>>;
|
|
133
|
+
}, z.core.$strict>]>;
|
|
122
134
|
carry: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
123
135
|
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
124
136
|
}, z.core.$strip>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/server/discovery.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/server/discovery.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAA8B,gBAAgB,EAAE,gBAAgB,EAAwB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA+YhK,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmR1B,CAAC;AAmBL;qEACqE;AACrE,MAAM,MAAM,gBAAgB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7F;;;;;;;;;;;;;;6EAc6E;AAC7E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,gBAAgB,CAQxI;AA+ED,MAAM,WAAW,gBAAgB;IAC/B;;;;+DAI2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;4CAGwC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;+BAM+B;AAC/B,wBAAsB,mBAAmB,CAAC,IAAI,GAAE,gBAAqB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAgBlG;AAED;4DAC4D;AAC5D,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,gBAAqB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAchH;AAED,wBAAgB,SAAS,CAAC,UAAU,EAAE,gBAAgB,GAAG,iBAAiB,CAEzE;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,gBAAgB,GAAG,gBAAgB,CAEvE"}
|
package/dist/server/spawn.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type IoOptions } from "./io";
|
|
2
|
-
import type { CollectionEvery, CollectionItem, CollectionSchema } from "../core/schema";
|
|
2
|
+
import type { CollectionEvery, CollectionItem, CollectionSchema, CollectionSpawnEvery } from "../core/schema";
|
|
3
3
|
/** A timezone-free calendar date. `m` is 1-12. */
|
|
4
4
|
export interface CivilDate {
|
|
5
5
|
y: number;
|
|
@@ -32,6 +32,13 @@ export declare function isTriggerDue(triggerRaw: unknown, now: Date, leadDays?:
|
|
|
32
32
|
* Slug-safe (alphanumeric + hyphen) and a pure function of the inputs,
|
|
33
33
|
* which is what makes create-if-absent idempotent. */
|
|
34
34
|
export declare function successorId(sourceId: string, next: CivilDate): string;
|
|
35
|
+
/** Resolve the literal `every` that applies to `sourceItem`. Literal-arm
|
|
36
|
+
* `spawn.every` passes through unchanged. Field-driven `spawn.every` reads
|
|
37
|
+
* `sourceItem[fromField]` and looks it up in `map`; an empty field or a
|
|
38
|
+
* value with no map entry yields null (caller skips + logs — see plan §5).
|
|
39
|
+
* Discovery rejects a map that doesn't cover the enum's values, so null
|
|
40
|
+
* here means a record that predates a map/enum edit. */
|
|
41
|
+
export declare function resolveEvery(every: CollectionSpawnEvery, sourceItem: CollectionItem): CollectionEvery | null;
|
|
35
42
|
export interface ComputedSuccessor {
|
|
36
43
|
id: string;
|
|
37
44
|
record: CollectionItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/server/spawn.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/server/spawn.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,oBAAoB,EAAkB,MAAM,gBAAgB,CAAC;AAE9H,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAYD;;kDAEkD;AAClD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;kDACkD;AAClD,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAUzD;AAED,kDAAkD;AAClD,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAEnD;AAeD;;0DAE0D;AAC1D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,GAAG,SAAS,CAYvF;AAED;;;oEAGoE;AACpE,wBAAgB,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,SAAI,GAAG,OAAO,GAAG,IAAI,CAMzF;AAID;;;;;;uDAMuD;AACvD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAGrE;AAiBD;;;;;yDAKyD;AACzD,wBAAgB,YAAY,CAAC,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,cAAc,GAAG,eAAe,GAAG,IAAI,CAK5G;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;4CAE4C;AAC5C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAiBjI;AAoBD;;;;mEAImE;AACnE,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,cAAc,EAC1B,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,SAAc,GACrB,OAAO,CAAC,IAAI,CAAC,CAiCf"}
|
package/dist/server.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("./chunk-CKQMccvm.cjs");
|
|
3
|
-
const require_schema = require("./schema-
|
|
3
|
+
const require_schema = require("./schema-5P5ZJPrY.cjs");
|
|
4
4
|
const require_deriveAll = require("./deriveAll-BJ0Lvm1Q.cjs");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
node_path = require_chunk.__toESM(node_path, 1);
|
|
@@ -780,7 +780,7 @@ var CustomViewSchema = zod.z.object({
|
|
|
780
780
|
file: zod.z.string().trim().min(1).refine(isSafeCustomViewPath, "must be a safe path under `views/` ending in `.html` (e.g. `views/year.html`; no `..`, no leading `/`, no backslash)"),
|
|
781
781
|
capabilities: zod.z.array(zod.z.enum(["read", "write"])).optional()
|
|
782
782
|
});
|
|
783
|
-
var
|
|
783
|
+
var EveryLiteralSchema = zod.z.object({
|
|
784
784
|
unit: zod.z.enum([
|
|
785
785
|
"day",
|
|
786
786
|
"week",
|
|
@@ -789,7 +789,12 @@ var EverySchema = zod.z.object({
|
|
|
789
789
|
]),
|
|
790
790
|
interval: zod.z.number().int().min(1),
|
|
791
791
|
dayOfMonth: zod.z.union([zod.z.number().int().min(1).max(31), zod.z.literal("last")]).optional()
|
|
792
|
-
});
|
|
792
|
+
}).strict();
|
|
793
|
+
var EveryFieldDrivenSchema = zod.z.object({
|
|
794
|
+
fromField: zod.z.string().trim().min(1),
|
|
795
|
+
map: zod.z.record(zod.z.string(), EveryLiteralSchema)
|
|
796
|
+
}).strict();
|
|
797
|
+
var EverySchema = zod.z.union([EveryLiteralSchema, EveryFieldDrivenSchema]);
|
|
793
798
|
var SpawnSchema = zod.z.object({
|
|
794
799
|
when: WhenSchema.optional(),
|
|
795
800
|
every: EverySchema,
|
|
@@ -831,6 +836,36 @@ function spawnSuccessorStartsInert(schema) {
|
|
|
831
836
|
if (spawn.set && Object.prototype.hasOwnProperty.call(spawn.set, field)) return !values.includes(String(spawn.set[field]));
|
|
832
837
|
return !(spawn.carry ?? []).includes(field);
|
|
833
838
|
}
|
|
839
|
+
function fieldDrivenSpawnEvery(schema) {
|
|
840
|
+
const every = schema.spawn?.every;
|
|
841
|
+
if (!every || !require_schema.isFieldDrivenEvery(every)) return null;
|
|
842
|
+
return every;
|
|
843
|
+
}
|
|
844
|
+
function fieldDrivenFromFieldIsEnum(schema) {
|
|
845
|
+
const driven = fieldDrivenSpawnEvery(schema);
|
|
846
|
+
if (!driven) return true;
|
|
847
|
+
return schema.fields[driven.fromField]?.type === "enum";
|
|
848
|
+
}
|
|
849
|
+
function fieldDrivenMapCoversValues(schema) {
|
|
850
|
+
const driven = fieldDrivenSpawnEvery(schema);
|
|
851
|
+
if (!driven) return true;
|
|
852
|
+
const target = schema.fields[driven.fromField];
|
|
853
|
+
if (!target || target.type !== "enum" || target.values === void 0) return true;
|
|
854
|
+
const values = new Set(target.values);
|
|
855
|
+
const keys = Object.keys(driven.map);
|
|
856
|
+
return keys.length === values.size && keys.every((key) => values.has(key));
|
|
857
|
+
}
|
|
858
|
+
function fieldDrivenFromFieldCarried(schema) {
|
|
859
|
+
const driven = fieldDrivenSpawnEvery(schema);
|
|
860
|
+
if (!driven) return true;
|
|
861
|
+
const { carry, set } = schema.spawn ?? {};
|
|
862
|
+
if (set && Object.prototype.hasOwnProperty.call(set, driven.fromField)) {
|
|
863
|
+
const raw = set[driven.fromField];
|
|
864
|
+
if (raw === void 0 || raw === null || raw === "") return false;
|
|
865
|
+
return Object.prototype.hasOwnProperty.call(driven.map, String(raw));
|
|
866
|
+
}
|
|
867
|
+
return (carry ?? []).includes(driven.fromField);
|
|
868
|
+
}
|
|
834
869
|
var IngestSchemaZ = zod.z.object({
|
|
835
870
|
kind: zod.z.enum(require_schema.INGEST_KINDS),
|
|
836
871
|
url: zod.z.string().url(),
|
|
@@ -907,6 +942,15 @@ var CollectionSchemaZ = zod.z.object({
|
|
|
907
942
|
}).refine((schema) => spawnSuccessorStartsInert(schema), {
|
|
908
943
|
message: "`spawn` must leave the successor in a non-matching state (e.g. `set` the status to a pending value); seeding the predicate field to a matching value via `set`/`carry` would respawn forever",
|
|
909
944
|
path: ["spawn"]
|
|
945
|
+
}).refine((schema) => fieldDrivenFromFieldIsEnum(schema), {
|
|
946
|
+
message: "`spawn.every.fromField` must name a top-level `enum` field declared in `fields`",
|
|
947
|
+
path: ["spawn"]
|
|
948
|
+
}).refine((schema) => fieldDrivenMapCoversValues(schema), {
|
|
949
|
+
message: "`spawn.every.map` keys must exactly cover the `values` of the `enum` named by `fromField` (no missing or extra keys)",
|
|
950
|
+
path: ["spawn"]
|
|
951
|
+
}).refine((schema) => fieldDrivenFromFieldCarried(schema), {
|
|
952
|
+
message: "`spawn.every.fromField` must appear in `spawn.carry`, or be written by `spawn.set` to a value present in `spawn.every.map`, so the successor keeps a resolvable recurrence interval",
|
|
953
|
+
path: ["spawn"]
|
|
910
954
|
}).refine((schema) => schema.calendarField === void 0 || isDateLike(schema.fields[schema.calendarField]?.type), {
|
|
911
955
|
message: "schema `calendarField` must name a top-level `date` or `datetime` field declared in `fields`",
|
|
912
956
|
path: ["calendarField"]
|
|
@@ -1313,6 +1357,18 @@ function matchesWhen(when, schema, item) {
|
|
|
1313
1357
|
const raw = item[completionField];
|
|
1314
1358
|
return raw !== void 0 && raw !== null && completionDoneValues.includes(String(raw));
|
|
1315
1359
|
}
|
|
1360
|
+
/** Resolve the literal `every` that applies to `sourceItem`. Literal-arm
|
|
1361
|
+
* `spawn.every` passes through unchanged. Field-driven `spawn.every` reads
|
|
1362
|
+
* `sourceItem[fromField]` and looks it up in `map`; an empty field or a
|
|
1363
|
+
* value with no map entry yields null (caller skips + logs — see plan §5).
|
|
1364
|
+
* Discovery rejects a map that doesn't cover the enum's values, so null
|
|
1365
|
+
* here means a record that predates a map/enum edit. */
|
|
1366
|
+
function resolveEvery(every, sourceItem) {
|
|
1367
|
+
if (!require_schema.isFieldDrivenEvery(every)) return every;
|
|
1368
|
+
const raw = sourceItem[every.fromField];
|
|
1369
|
+
if (raw === void 0 || raw === null || raw === "") return null;
|
|
1370
|
+
return every.map[String(raw)] ?? null;
|
|
1371
|
+
}
|
|
1316
1372
|
/** Build the successor record purely from (schema, source record, source
|
|
1317
1373
|
* id). Returns null when the schema has no spawn/triggerField or the
|
|
1318
1374
|
* source's trigger date is unparseable. */
|
|
@@ -1321,7 +1377,9 @@ function computeSuccessor(schema, sourceItem, sourceId) {
|
|
|
1321
1377
|
if (!spawn || !triggerField) return null;
|
|
1322
1378
|
const srcDate = parseCivil(sourceItem[triggerField]);
|
|
1323
1379
|
if (srcDate === null) return null;
|
|
1324
|
-
const
|
|
1380
|
+
const every = resolveEvery(spawn.every, sourceItem);
|
|
1381
|
+
if (every === null) return null;
|
|
1382
|
+
const next = advanceTriggerDate(srcDate, every);
|
|
1325
1383
|
const nextId = successorId(sourceId, next);
|
|
1326
1384
|
const record = {};
|
|
1327
1385
|
for (const field of spawn.carry ?? []) if (Object.prototype.hasOwnProperty.call(sourceItem, field)) record[field] = sourceItem[field];
|
|
@@ -1333,6 +1391,27 @@ function computeSuccessor(schema, sourceItem, sourceId) {
|
|
|
1333
1391
|
record
|
|
1334
1392
|
};
|
|
1335
1393
|
}
|
|
1394
|
+
/** Warn precisely about which of `computeSuccessor`'s two null causes fired
|
|
1395
|
+
* (plan §5): an unparseable source trigger date (the original cause), or a
|
|
1396
|
+
* field-driven `every` whose record value has no `map` entry (a record that
|
|
1397
|
+
* predates a map/enum edit — discovery rejects this statically otherwise). */
|
|
1398
|
+
function logSpawnSkip(slug, triggerField, every, sourceItem, sourceId) {
|
|
1399
|
+
if (parseCivil(sourceItem[triggerField]) === null) {
|
|
1400
|
+
log.warn("collections", "spawn skipped: source trigger date unparseable", {
|
|
1401
|
+
slug,
|
|
1402
|
+
sourceId,
|
|
1403
|
+
triggerField
|
|
1404
|
+
});
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
const fromField = require_schema.isFieldDrivenEvery(every) ? every.fromField : void 0;
|
|
1408
|
+
log.warn("collections", "spawn skipped: no `every` mapping for frequency value", {
|
|
1409
|
+
slug,
|
|
1410
|
+
sourceId,
|
|
1411
|
+
fromField,
|
|
1412
|
+
value: fromField === void 0 ? void 0 : sourceItem[fromField]
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1336
1415
|
/** Idempotently create the successor for `sourceItem` when it matches the
|
|
1337
1416
|
* spawn predicate. No-op when the schema declares no spawn, the
|
|
1338
1417
|
* predicate doesn't match, the trigger date is unparseable, or the
|
|
@@ -1344,11 +1423,7 @@ async function maybeSpawnSuccessor(slug, schema, dataDir, sourceItem, sourceId,
|
|
|
1344
1423
|
if (!matchesWhen(spawn.when, schema, sourceItem)) return;
|
|
1345
1424
|
const computed = computeSuccessor(schema, sourceItem, sourceId);
|
|
1346
1425
|
if (computed === null) {
|
|
1347
|
-
|
|
1348
|
-
slug,
|
|
1349
|
-
sourceId,
|
|
1350
|
-
triggerField: schema.triggerField
|
|
1351
|
-
});
|
|
1426
|
+
logSpawnSkip(slug, schema.triggerField, spawn.every, sourceItem, sourceId);
|
|
1352
1427
|
return;
|
|
1353
1428
|
}
|
|
1354
1429
|
if (matchesWhen(spawn.when, schema, computed.record)) {
|
|
@@ -1646,6 +1721,7 @@ exports.readItem = readItem;
|
|
|
1646
1721
|
exports.readSkillTemplate = readSkillTemplate;
|
|
1647
1722
|
exports.resolveCreateItemId = resolveCreateItemId;
|
|
1648
1723
|
exports.resolveDataDir = resolveDataDir;
|
|
1724
|
+
exports.resolveEvery = resolveEvery;
|
|
1649
1725
|
exports.resolveTemplatePath = resolveTemplatePath;
|
|
1650
1726
|
exports.safeRecordId = safeRecordId;
|
|
1651
1727
|
exports.safeSlugName = safeSlugName;
|