@mark1russell7/stack-feeds 0.0.0-stage → 0.1.1
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 +125 -2
- package/build/add-on.d.ts +16 -0
- package/build/add-on.d.ts.map +1 -0
- package/build/add-on.js +27 -0
- package/build/add-on.js.map +1 -0
- package/build/index.d.ts +80 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +66 -0
- package/build/index.js.map +1 -0
- package/build/join-U6_W4HEG.js +309 -0
- package/build/join-U6_W4HEG.js.map +1 -0
- package/build/layer-B_AkCJdI.d.ts +70 -0
- package/build/layer-B_AkCJdI.d.ts.map +1 -0
- package/build/layer-BhRXComg.js +19 -0
- package/build/layer-BhRXComg.js.map +1 -0
- package/build/schema.d.ts +36 -0
- package/build/schema.d.ts.map +1 -0
- package/build/schema.js +73 -0
- package/build/schema.js.map +1 -0
- package/build/states-DnhuJlh8.d.ts +78 -0
- package/build/states-DnhuJlh8.d.ts.map +1 -0
- package/package.json +72 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mark Russell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,126 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mark1russell7/stack-feeds
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The live lists of a system stack. A feed is a source that lists the parts of some kinds, for example the names of the secrets of a repository. The gate compares each list with the records of the stack.
|
|
4
|
+
|
|
5
|
+
It is the feed add-on of [`@mark1russell7/system-stack`](../system-stack/README.md). The core knows only parts and needs. This package tells which source lists which parts, and how old a list can be.
|
|
6
|
+
|
|
7
|
+
Each function is a plain function with no clock and no network. A program of the owner reads each source and gives the reads to the gate.
|
|
8
|
+
|
|
9
|
+
## The rule
|
|
10
|
+
|
|
11
|
+
The records of a stack become old when the system changes and nobody changes the records. A feed finds this:
|
|
12
|
+
|
|
13
|
+
- The source shows a name with no record. For example, a new seller on the statement of a card is a new paid service.
|
|
14
|
+
- A record has no name in the source. The part is gone, or the source lost it.
|
|
15
|
+
- The newest read of a feed is older than its largest age. The gate then has no current list, so it fails.
|
|
16
|
+
|
|
17
|
+
A feed with no read is a fault too, because no result is not a good result.
|
|
18
|
+
|
|
19
|
+
The owner can ignore a name that is no part, with a reason and a last date. Thus each name of each source is in one of three states: a part, a record with a reason, or a fault of the gate.
|
|
20
|
+
|
|
21
|
+
## The entries
|
|
22
|
+
|
|
23
|
+
| Entry | What it has |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `@mark1russell7/stack-feeds` | The records of a layer, the states of the feeds, the gate, the join and a sample. |
|
|
26
|
+
| `@mark1russell7/stack-feeds/schema` | `feedSchema` and `feedReadsSchema`, the zod schemas of a layer and of its reads, and `parseFeeds` and `parseFeedReads`. |
|
|
27
|
+
| `@mark1russell7/stack-feeds/add-on` | `feedAddOn`, the add-on in the form of the layer contract of the core. |
|
|
28
|
+
|
|
29
|
+
The root entry has no schema library. Thus a page that only shows the states gets no zod.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm install @mark1russell7/stack-feeds @mark1russell7/system-stack
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## A layer
|
|
38
|
+
|
|
39
|
+
A feed layer is one record with feeds, keys and ignore records. Its format has the name `feed/1`. A stack keeps it in `Stack.layers`, with the key `feed/1`.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import type { FeedLayer } from "@mark1russell7/stack-feeds";
|
|
43
|
+
|
|
44
|
+
const layer: FeedLayer = {
|
|
45
|
+
schema: "feed/1",
|
|
46
|
+
feeds: [
|
|
47
|
+
{ id: "card-statement", name: "The sellers on the statement of the payment card", kinds: ["account"], scope: "card", days: 31 },
|
|
48
|
+
{ id: "devices", name: "The devices of the network", kinds: ["host", "device"], days: 7 },
|
|
49
|
+
],
|
|
50
|
+
keys: [
|
|
51
|
+
{ feed: "card-statement", key: "CLOUD PROVIDER", part: "cloud-account" },
|
|
52
|
+
{ feed: "card-statement", key: "CALL SERVICE", part: "call-account" },
|
|
53
|
+
],
|
|
54
|
+
ignores: [{ feed: "devices", key: "tv", reason: "The television is on the network, and no function needs it.", until: "2027-06-30" }],
|
|
55
|
+
};
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- A feed lists the parts of its `kinds`. With a `scope`, it lists only the parts that need the part of the scope directly.
|
|
59
|
+
- `days` is the largest age of the newest read, in days.
|
|
60
|
+
- A feed with `complete: false` lists only some parts of its kinds. A part that its read does not show is then no fault.
|
|
61
|
+
- A key gives the part of a name, when the name in the source is not the `id` of the part. With no key, a name is the `id` of a part.
|
|
62
|
+
- An ignore record tells that a name is no part, with a reason. After its last date `until`, the name is a fault again.
|
|
63
|
+
|
|
64
|
+
## The reads
|
|
65
|
+
|
|
66
|
+
A read is live data: the names that a source shows on one date. A program makes it, and it is no record of the layer.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import type { FeedRead } from "@mark1russell7/stack-feeds";
|
|
70
|
+
|
|
71
|
+
const reads: FeedRead[] = [
|
|
72
|
+
{ feed: "card-statement", date: "2026-11-01", keys: ["CLOUD PROVIDER", "CALL SERVICE", "MUSIC STREAM"] },
|
|
73
|
+
{ feed: "devices", date: "2026-11-15", keys: ["phone", "home-host", "cloud-host", "tv"] },
|
|
74
|
+
];
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
- A read has only names. Thus a read of secrets has the name of each secret, but not its value. `feedReadsSchema` refuses a read with more fields.
|
|
78
|
+
- The newest read of a feed counts. Of two reads of one date, the last read counts.
|
|
79
|
+
|
|
80
|
+
## The gate
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { SAMPLE_STACK } from "@mark1russell7/system-stack";
|
|
84
|
+
import { checkFeeds, SAMPLE_FEED_READS, SAMPLE_FEED_TODAY, SAMPLE_FEEDS } from "@mark1russell7/stack-feeds";
|
|
85
|
+
|
|
86
|
+
checkFeeds(SAMPLE_FEEDS, SAMPLE_STACK, { today: SAMPLE_FEED_TODAY, reads: SAMPLE_FEED_READS });
|
|
87
|
+
// [{ level: "error", code: "feed-unknown", at: "card-statement", key: "MUSIC STREAM",
|
|
88
|
+
// message: 'The feed "card-statement" shows "MUSIC STREAM", and no part or ignore record has that name.' }]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The statement shows a seller that no record has. The owner adds the part of the new service, or an ignore record with a reason.
|
|
92
|
+
|
|
93
|
+
The codes of the faults are in `FEED_CODES`:
|
|
94
|
+
|
|
95
|
+
| Code | Level | The fault |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| `feed-duplicate`, `feed-days`, `feed-scope` | error | Two feeds have one `id`, a largest age is not a whole number from 0, or a scope is no part. |
|
|
98
|
+
| `key-feed`, `key-part`, `key-duplicate` | error | A key names no feed or no part, or two keys name one name of a feed. |
|
|
99
|
+
| `ignore-feed`, `ignore-date`, `ignore-part` | error | An ignore record names no feed, has a wrong date, or names a name of a part. |
|
|
100
|
+
| `read-feed`, `read-date` | error | A read names no feed, or its date is wrong or after the check. A read with a fault does not count. |
|
|
101
|
+
| `feed-none` | error | A feed has no read. |
|
|
102
|
+
| `feed-old` | error | The newest read of a feed is older than its largest age. The gate then compares no names of it. |
|
|
103
|
+
| `feed-unknown` | error | The source shows a name with no part and no current ignore record. |
|
|
104
|
+
| `feed-outside` | error | The source shows a name of a part that the feed does not list, by its kind or by its scope. |
|
|
105
|
+
| `feed-gone` | error | A complete feed lists a part, and its source does not show it. |
|
|
106
|
+
| `ignore-unused` | error | The source does not show the name of a current ignore record. |
|
|
107
|
+
| `ignore-old` | warning | An ignore record ended. |
|
|
108
|
+
|
|
109
|
+
`feedStates` gives the state of each feed. The state has the date and the age of its newest read, and the parts and the names of each kind.
|
|
110
|
+
|
|
111
|
+
## The add-on
|
|
112
|
+
|
|
113
|
+
`feedAddOn` gives the add-on for `checkStackLayers` and for `joinStacks` of the core. It needs the date of the check and the reads:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { checkStackLayers } from "@mark1russell7/system-stack";
|
|
117
|
+
import { feedAddOn } from "@mark1russell7/stack-feeds/add-on";
|
|
118
|
+
|
|
119
|
+
const findings = checkStackLayers(stack, [feedAddOn({ today: "2026-11-16", reads })]);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`joinFeeds` joins the feed layers of the fragments of a stack. A feed, a key or an ignore record of one name in two fragments is a fault.
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { a as FeedLayer } from "./layer-B_AkCJdI.js";
|
|
2
|
+
import { t as FeedOptions } from "./states-DnhuJlh8.js";
|
|
3
|
+
import { StackJoiner } from "@mark1russell7/system-stack";
|
|
4
|
+
/**
|
|
5
|
+
* This function gives the feed add-on for a check on one date, with the reads of the feeds.
|
|
6
|
+
*
|
|
7
|
+
* - `schema` is `feed/1`, the key of the layer in `Stack.layers`.
|
|
8
|
+
* - `parse` is `parseFeeds`.
|
|
9
|
+
* - `check` is the gate `checkFeeds` with the options. A feed with no read is a fault, so give each read.
|
|
10
|
+
* - `join` is `joinFeeds`. It joins the feed layers of the fragments of a stack.
|
|
11
|
+
*
|
|
12
|
+
* @param options - The date of the check and the reads. The gate has no clock: the caller gives the date.
|
|
13
|
+
* @throws RangeError when `today` is not a date `YYYY-MM-DD`
|
|
14
|
+
*/
|
|
15
|
+
export declare function feedAddOn(options: FeedOptions): StackJoiner<FeedLayer>;
|
|
16
|
+
//# sourceMappingURL=add-on.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-on.d.ts","names":[],"sources":["../src/add-on.ts"],"mappings":";;;;;;;;;;;;;;wBAqBgB,UAAU,SAAS,cAAc,YAAY"}
|
package/build/add-on.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { l as todayNumber, r as checkFeeds, t as joinFeeds } from "./join-U6_W4HEG.js";
|
|
2
|
+
import { t as FEED_SCHEMA } from "./layer-BhRXComg.js";
|
|
3
|
+
import { parseFeeds } from "./schema.js";
|
|
4
|
+
// src/add-on.ts
|
|
5
|
+
/**
|
|
6
|
+
* This function gives the feed add-on for a check on one date, with the reads of the feeds.
|
|
7
|
+
*
|
|
8
|
+
* - `schema` is `feed/1`, the key of the layer in `Stack.layers`.
|
|
9
|
+
* - `parse` is `parseFeeds`.
|
|
10
|
+
* - `check` is the gate `checkFeeds` with the options. A feed with no read is a fault, so give each read.
|
|
11
|
+
* - `join` is `joinFeeds`. It joins the feed layers of the fragments of a stack.
|
|
12
|
+
*
|
|
13
|
+
* @param options - The date of the check and the reads. The gate has no clock: the caller gives the date.
|
|
14
|
+
* @throws RangeError when `today` is not a date `YYYY-MM-DD`
|
|
15
|
+
*/
|
|
16
|
+
function feedAddOn(options) {
|
|
17
|
+
todayNumber(options.today);
|
|
18
|
+
return {
|
|
19
|
+
schema: FEED_SCHEMA,
|
|
20
|
+
parse: parseFeeds,
|
|
21
|
+
check: (layer, stack) => checkFeeds(layer, stack, options),
|
|
22
|
+
join: joinFeeds
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export { feedAddOn };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=add-on.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-on.js","names":[],"sources":["../src/add-on.ts"],"sourcesContent":["import type { StackJoiner } from \"@mark1russell7/system-stack\";\nimport { checkFeeds } from \"./check.ts\";\nimport { joinFeeds } from \"./join.ts\";\nimport { FEED_SCHEMA, type FeedLayer } from \"./layer.ts\";\nimport { parseFeeds } from \"./schema.ts\";\nimport { todayNumber, type FeedOptions } from \"./states.ts\";\n\n// The feed add-on in the form of the layer contract. A host gives it to `checkStackLayers` and to `joinStacks` of the core.\n// This entry has the schema library, so the root entry does not import it.\n\n/**\n * This function gives the feed add-on for a check on one date, with the reads of the feeds.\n *\n * - `schema` is `feed/1`, the key of the layer in `Stack.layers`.\n * - `parse` is `parseFeeds`.\n * - `check` is the gate `checkFeeds` with the options. A feed with no read is a fault, so give each read.\n * - `join` is `joinFeeds`. It joins the feed layers of the fragments of a stack.\n *\n * @param options - The date of the check and the reads. The gate has no clock: the caller gives the date.\n * @throws RangeError when `today` is not a date `YYYY-MM-DD`\n */\nexport function feedAddOn(options: FeedOptions): StackJoiner<FeedLayer> {\n todayNumber(options.today);\n return { schema: FEED_SCHEMA, parse: parseFeeds, check: (layer, stack) => checkFeeds(layer, stack, options), join: joinFeeds };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,UAAU,SAA8C;CACtE,YAAY,QAAQ,KAAK;CACzB,OAAO;EAAE,QAAQ;EAAa,OAAO;EAAY,QAAQ,OAAO,UAAU,WAAW,OAAO,OAAO,OAAO;EAAG,MAAM;CAAU;AAC/H"}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { a as FeedLayer, c as firstFeeds, i as FeedKey, n as Feed, o as FeedRead, r as FeedIgnore, s as feedKey, t as FEED_SCHEMA } from "./layer-B_AkCJdI.js";
|
|
2
|
+
import { a as ReadCode, c as ignoreHolds, i as READ_CODES, l as readCodes, n as FeedState, o as feedCover, r as OutsideName, s as feedStates, t as FeedOptions, u as todayNumber } from "./states-DnhuJlh8.js";
|
|
3
|
+
import { Fault, LayerParse, LayerPiece, Stack } from "@mark1russell7/system-stack";
|
|
4
|
+
/** These are the codes of the faults of a feed layer and of its reads. */
|
|
5
|
+
export declare const FEED_CODES: readonly ["feed-duplicate", "feed-days", "feed-scope", "key-feed", "key-part", "key-duplicate", "ignore-feed", "ignore-date", "ignore-part", "read-feed", "read-date", "feed-none", "feed-old", "feed-unknown", "feed-outside", "feed-gone", "ignore-unused", "ignore-old"];
|
|
6
|
+
/** A code of a fault of a feed layer. */
|
|
7
|
+
export type FeedCode = (typeof FEED_CODES)[number];
|
|
8
|
+
/** A fault of a feed layer. Its field `at` is the `id` of the feed. */
|
|
9
|
+
export interface FeedFault extends Fault {
|
|
10
|
+
readonly code: FeedCode;
|
|
11
|
+
/** The name in the source, for a fault of one name. */
|
|
12
|
+
readonly key?: string | undefined;
|
|
13
|
+
/** The `id` of the part, for a fault of one part. */
|
|
14
|
+
readonly part?: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* This function gives each fault of a feed layer and of its reads. A list with no error tells that the gate passes.
|
|
18
|
+
*
|
|
19
|
+
* The records, as errors:
|
|
20
|
+
* - `feed-duplicate`: two feeds have one `id`.
|
|
21
|
+
* - `feed-days`: the largest age of a feed is not a whole number from 0.
|
|
22
|
+
* - `feed-scope`: the scope of a feed names no part.
|
|
23
|
+
* - `key-feed`, `key-part`: a key record names no feed, or no part.
|
|
24
|
+
* - `key-duplicate`: two key records name one feed and one name.
|
|
25
|
+
* - `ignore-feed`: an ignore record names no feed.
|
|
26
|
+
* - `ignore-date`: the last date of an ignore record is not a date.
|
|
27
|
+
* - `ignore-part`: an ignore record names a name of a part: a key record has it, or a part has it as its `id`.
|
|
28
|
+
*
|
|
29
|
+
* The reads, as errors:
|
|
30
|
+
* - `read-feed`: a read names no feed.
|
|
31
|
+
* - `read-date`: the date of a read is not a date, or it is after `today`.
|
|
32
|
+
*
|
|
33
|
+
* The feeds, as errors:
|
|
34
|
+
* - `feed-none`: a feed has no read. The gate has no result for the feed, so it does not pass.
|
|
35
|
+
* - `feed-old`: the newest read of a feed is older than its largest age. The gate then does not compare its names.
|
|
36
|
+
* - `feed-unknown`: the source shows a name with no part and no current ignore record. Add the part, or an ignore record.
|
|
37
|
+
* - `feed-outside`: the source shows a name of a part that the feed does not list, by its kind or by its scope.
|
|
38
|
+
* - `feed-gone`: a complete feed lists a part, and its source does not show it. The record is old, or the source lost the part.
|
|
39
|
+
* - `ignore-unused`: the source does not show the name of a current ignore record. Remove the record.
|
|
40
|
+
*
|
|
41
|
+
* The feeds, as warnings:
|
|
42
|
+
* - `ignore-old`: an ignore record ended before `today`. Its name is then a name with no record.
|
|
43
|
+
*
|
|
44
|
+
* A read with a fault does not count. The function is pure. The sequence of the faults is the feeds, the keys, the ignore records,
|
|
45
|
+
* the reads, the states of the feeds, then the old ignore records.
|
|
46
|
+
*
|
|
47
|
+
* @throws RangeError when `today` is not a date `YYYY-MM-DD`
|
|
48
|
+
*/
|
|
49
|
+
export declare function checkFeeds(layer: FeedLayer, stack: Stack, options: FeedOptions): FeedFault[];
|
|
50
|
+
/**
|
|
51
|
+
* This function joins the feed layers of the fragments of a stack into one layer.
|
|
52
|
+
*
|
|
53
|
+
* - The feeds, the key records and the ignore records are in the order of the fragments.
|
|
54
|
+
* - A feed `id` in two or more fragments is a fault, also when the feeds are equal.
|
|
55
|
+
* - A key record or an ignore record of one feed and one name in two or more fragments is a fault.
|
|
56
|
+
* - A fragment can give the keys and the ignore records of a feed of a different fragment.
|
|
57
|
+
*
|
|
58
|
+
* The joined layer has the field `keys` or `ignores` when a fragment has it. The function is pure, and it
|
|
59
|
+
* changes no layer. The gate `checkFeeds` examines the joined layer afterward.
|
|
60
|
+
*
|
|
61
|
+
* @param pieces - The layers, with the name of the fragment of each one, in the order of the fragments.
|
|
62
|
+
* @returns The joined layer, or the faults of the join.
|
|
63
|
+
*/
|
|
64
|
+
export declare function joinFeeds(pieces: readonly LayerPiece<FeedLayer>[]): LayerParse<FeedLayer>;
|
|
65
|
+
/** The date of the check of the sample. With it, the gate gives the fault that the README shows. */
|
|
66
|
+
export declare const SAMPLE_FEED_TODAY = "2026-11-16";
|
|
67
|
+
/**
|
|
68
|
+
* A sample feed layer for `SAMPLE_STACK` of the core. Each name is an example.
|
|
69
|
+
*
|
|
70
|
+
* - The statement of the payment card lists the accounts that the card pays. Its names are the names of the sellers.
|
|
71
|
+
* - The list of the devices of the network lists the hosts and the devices. A record ignores the television.
|
|
72
|
+
*/
|
|
73
|
+
export declare const SAMPLE_FEEDS: FeedLayer;
|
|
74
|
+
/**
|
|
75
|
+
* The sample reads of `SAMPLE_FEEDS`. The statement shows a seller that no record has: a new paid service.
|
|
76
|
+
* Thus the gate fails with one fault on `SAMPLE_FEED_TODAY`.
|
|
77
|
+
*/
|
|
78
|
+
export declare const SAMPLE_FEED_READS: readonly FeedRead[];
|
|
79
|
+
export { FEED_SCHEMA, Feed, FeedIgnore, FeedKey, FeedLayer, FeedOptions, FeedRead, FeedState, OutsideName, READ_CODES, ReadCode, feedCover, feedKey, feedStates, firstFeeds, ignoreHolds, readCodes, todayNumber };
|
|
80
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/check.ts","../src/join.ts","../src/sample.ts"],"mappings":";;;;qBAOa;;YAyCD,mBAAmB;;iBAGd,kBAAkB;WACxB,MAAM;;WAEN;;WAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyCK,WAAW,OAAO,WAAW,OAAO,OAAO,SAAS,cAAc;;;;;;;;;;;;;;;wBC9ElE,UAAU,iBAAiB,WAAW,eAAe,WAAW;;qBChBnE;;;;;;;qBAQA,cAAc;;;;;qBAiBd,4BAA4B"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { n as feedKey, r as firstFeeds, t as FEED_SCHEMA } from "./layer-BhRXComg.js";
|
|
2
|
+
import { a as feedCover, c as readCodes, i as READ_CODES, l as todayNumber, n as FEED_CODES, o as feedStates, r as checkFeeds, s as ignoreHolds, t as joinFeeds } from "./join-U6_W4HEG.js";
|
|
3
|
+
// src/sample.ts
|
|
4
|
+
/** The date of the check of the sample. With it, the gate gives the fault that the README shows. */
|
|
5
|
+
const SAMPLE_FEED_TODAY = "2026-11-16";
|
|
6
|
+
/**
|
|
7
|
+
* A sample feed layer for `SAMPLE_STACK` of the core. Each name is an example.
|
|
8
|
+
*
|
|
9
|
+
* - The statement of the payment card lists the accounts that the card pays. Its names are the names of the sellers.
|
|
10
|
+
* - The list of the devices of the network lists the hosts and the devices. A record ignores the television.
|
|
11
|
+
*/
|
|
12
|
+
const SAMPLE_FEEDS = {
|
|
13
|
+
schema: FEED_SCHEMA,
|
|
14
|
+
feeds: [{
|
|
15
|
+
id: "card-statement",
|
|
16
|
+
name: "The sellers on the statement of the payment card",
|
|
17
|
+
kinds: ["account"],
|
|
18
|
+
scope: "card",
|
|
19
|
+
days: 31
|
|
20
|
+
}, {
|
|
21
|
+
id: "devices",
|
|
22
|
+
name: "The devices of the network",
|
|
23
|
+
kinds: ["host", "device"],
|
|
24
|
+
days: 7
|
|
25
|
+
}],
|
|
26
|
+
keys: [{
|
|
27
|
+
feed: "card-statement",
|
|
28
|
+
key: "CLOUD PROVIDER",
|
|
29
|
+
part: "cloud-account"
|
|
30
|
+
}, {
|
|
31
|
+
feed: "card-statement",
|
|
32
|
+
key: "CALL SERVICE",
|
|
33
|
+
part: "call-account"
|
|
34
|
+
}],
|
|
35
|
+
ignores: [{
|
|
36
|
+
feed: "devices",
|
|
37
|
+
key: "tv",
|
|
38
|
+
reason: "The television is on the network, and no function needs it.",
|
|
39
|
+
until: "2027-06-30"
|
|
40
|
+
}]
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The sample reads of `SAMPLE_FEEDS`. The statement shows a seller that no record has: a new paid service.
|
|
44
|
+
* Thus the gate fails with one fault on `SAMPLE_FEED_TODAY`.
|
|
45
|
+
*/
|
|
46
|
+
const SAMPLE_FEED_READS = [{
|
|
47
|
+
feed: "card-statement",
|
|
48
|
+
date: "2026-11-01",
|
|
49
|
+
keys: [
|
|
50
|
+
"CLOUD PROVIDER",
|
|
51
|
+
"CALL SERVICE",
|
|
52
|
+
"MUSIC STREAM"
|
|
53
|
+
]
|
|
54
|
+
}, {
|
|
55
|
+
feed: "devices",
|
|
56
|
+
date: "2026-11-15",
|
|
57
|
+
keys: [
|
|
58
|
+
"phone",
|
|
59
|
+
"home-host",
|
|
60
|
+
"cloud-host",
|
|
61
|
+
"tv"
|
|
62
|
+
]
|
|
63
|
+
}];
|
|
64
|
+
export { FEED_CODES, FEED_SCHEMA, READ_CODES, SAMPLE_FEEDS, SAMPLE_FEED_READS, SAMPLE_FEED_TODAY, checkFeeds, feedCover, feedKey, feedStates, firstFeeds, ignoreHolds, joinFeeds, readCodes, todayNumber };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/sample.ts"],"sourcesContent":["import { FEED_SCHEMA, type FeedLayer, type FeedRead } from \"./layer.ts\";\n\n/** The date of the check of the sample. With it, the gate gives the fault that the README shows. */\nexport const SAMPLE_FEED_TODAY = \"2026-11-16\";\n\n/**\n * A sample feed layer for `SAMPLE_STACK` of the core. Each name is an example.\n *\n * - The statement of the payment card lists the accounts that the card pays. Its names are the names of the sellers.\n * - The list of the devices of the network lists the hosts and the devices. A record ignores the television.\n */\nexport const SAMPLE_FEEDS: FeedLayer = {\n schema: FEED_SCHEMA,\n feeds: [\n { id: \"card-statement\", name: \"The sellers on the statement of the payment card\", kinds: [\"account\"], scope: \"card\", days: 31 },\n { id: \"devices\", name: \"The devices of the network\", kinds: [\"host\", \"device\"], days: 7 },\n ],\n keys: [\n { feed: \"card-statement\", key: \"CLOUD PROVIDER\", part: \"cloud-account\" },\n { feed: \"card-statement\", key: \"CALL SERVICE\", part: \"call-account\" },\n ],\n ignores: [{ feed: \"devices\", key: \"tv\", reason: \"The television is on the network, and no function needs it.\", until: \"2027-06-30\" }],\n};\n\n/**\n * The sample reads of `SAMPLE_FEEDS`. The statement shows a seller that no record has: a new paid service.\n * Thus the gate fails with one fault on `SAMPLE_FEED_TODAY`.\n */\nexport const SAMPLE_FEED_READS: readonly FeedRead[] = [\n { feed: \"card-statement\", date: \"2026-11-01\", keys: [\"CLOUD PROVIDER\", \"CALL SERVICE\", \"MUSIC STREAM\"] },\n { feed: \"devices\", date: \"2026-11-15\", keys: [\"phone\", \"home-host\", \"cloud-host\", \"tv\"] },\n];\n"],"mappings":";;;;AAGA,MAAa,oBAAoB;;;;;;;AAQjC,MAAa,eAA0B;CACrC,QAAQ;CACR,OAAO,CACL;EAAE,IAAI;EAAkB,MAAM;EAAoD,OAAO,CAAC,SAAS;EAAG,OAAO;EAAQ,MAAM;CAAG,GAC9H;EAAE,IAAI;EAAW,MAAM;EAA8B,OAAO,CAAC,QAAQ,QAAQ;EAAG,MAAM;CAAE,CAC1F;CACA,MAAM,CACJ;EAAE,MAAM;EAAkB,KAAK;EAAkB,MAAM;CAAgB,GACvE;EAAE,MAAM;EAAkB,KAAK;EAAgB,MAAM;CAAe,CACtE;CACA,SAAS,CAAC;EAAE,MAAM;EAAW,KAAK;EAAM,QAAQ;EAA+D,OAAO;CAAa,CAAC;AACtI;;;;;AAMA,MAAa,oBAAyC,CACpD;CAAE,MAAM;CAAkB,MAAM;CAAc,MAAM;EAAC;EAAkB;EAAgB;CAAc;AAAE,GACvG;CAAE,MAAM;CAAW,MAAM;CAAc,MAAM;EAAC;EAAS;EAAa;EAAc;CAAI;AAAE,CAC1F"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { n as feedKey, r as firstFeeds, t as FEED_SCHEMA } from "./layer-BhRXComg.js";
|
|
2
|
+
import { dayNumber, joinRecords, partNeeds, partsById } from "@mark1russell7/system-stack";
|
|
3
|
+
// src/states.ts
|
|
4
|
+
/** These are the codes of the faults of a read. */
|
|
5
|
+
const READ_CODES = ["read-feed", "read-date"];
|
|
6
|
+
/**
|
|
7
|
+
* This function gives the parts of a stack that a feed lists: the parts of its kinds, in its scope.
|
|
8
|
+
* A part with a scope needs the part of the scope directly. The parts are in the sequence of the stack, and each `id` comes one time.
|
|
9
|
+
*/
|
|
10
|
+
function feedCover(feed, stack) {
|
|
11
|
+
const kinds = new Set(feed.kinds);
|
|
12
|
+
return [...partsById(stack).values()].filter((part) => kinds.has(part.kind) && (feed.scope === void 0 || partNeeds(part).includes(feed.scope)));
|
|
13
|
+
}
|
|
14
|
+
/** This function gives the number of the day of the date of the check, or it throws. */
|
|
15
|
+
function todayNumber(today) {
|
|
16
|
+
const day = dayNumber(today);
|
|
17
|
+
if (day === void 0) throw new RangeError(`The date "${today}" is not a date of the form YYYY-MM-DD.`);
|
|
18
|
+
return day;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* This function gives the fault of each read, in the sequence of the reads. A read with no fault gives `undefined`.
|
|
22
|
+
*
|
|
23
|
+
* - `read-feed`: the read names no feed of the layer.
|
|
24
|
+
* - `read-date`: the date of the read is not a date, or it is after the date of the check.
|
|
25
|
+
*
|
|
26
|
+
* @throws RangeError when `today` is not a date `YYYY-MM-DD`
|
|
27
|
+
*/
|
|
28
|
+
function readCodes(layer, reads, today) {
|
|
29
|
+
const day = todayNumber(today);
|
|
30
|
+
const feeds = new Set(layer.feeds.map((feed) => feed.id));
|
|
31
|
+
return reads.map((read) => {
|
|
32
|
+
if (!feeds.has(read.feed)) return "read-feed";
|
|
33
|
+
const date = dayNumber(read.date);
|
|
34
|
+
if (date === void 0 || date > day) return "read-date";
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** This function tells if an ignore record holds on a day: it has no last date, or its last date is not before the day. */
|
|
38
|
+
function ignoreHolds(ignore, day) {
|
|
39
|
+
if (ignore.until === void 0) return true;
|
|
40
|
+
const until = dayNumber(ignore.until);
|
|
41
|
+
return until !== void 0 && until >= day;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* This function gives the state of each feed of a layer on the date of the check, in the sequence of the feeds.
|
|
45
|
+
*
|
|
46
|
+
* - The newest read of a feed is the read with the latest date and no fault. Of two reads of one date, the last read counts.
|
|
47
|
+
* - A name gives a part through a key record of the feed, or else through the part with that `id`.
|
|
48
|
+
* - A name with no part goes to `ignored` when a current ignore record names it, and to `unknown` when no record names it.
|
|
49
|
+
* - A part that the feed does not list goes to `outside`. A part that the feed lists goes to `shown`.
|
|
50
|
+
* - A complete feed puts each part that it lists and the read does not show into `gone`.
|
|
51
|
+
*
|
|
52
|
+
* The function is pure. It gives the first feed of each `id`.
|
|
53
|
+
*
|
|
54
|
+
* @throws RangeError when `today` is not a date `YYYY-MM-DD`
|
|
55
|
+
*/
|
|
56
|
+
function feedStates(layer, stack, options) {
|
|
57
|
+
const today = todayNumber(options.today);
|
|
58
|
+
const codes = readCodes(layer, options.reads, options.today);
|
|
59
|
+
const newest = /* @__PURE__ */ new Map();
|
|
60
|
+
options.reads.forEach((read, index) => {
|
|
61
|
+
if (codes[index] !== void 0) return;
|
|
62
|
+
const day = dayNumber(read.date) ?? 0;
|
|
63
|
+
const last = newest.get(read.feed);
|
|
64
|
+
if (last === void 0 || day >= last.day) newest.set(read.feed, {
|
|
65
|
+
read,
|
|
66
|
+
day
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
const parts = partsById(stack);
|
|
70
|
+
const keys = /* @__PURE__ */ new Map();
|
|
71
|
+
for (const key of layer.keys ?? []) {
|
|
72
|
+
const name = feedKey(key.feed, key.key);
|
|
73
|
+
if (!keys.has(name)) keys.set(name, key.part);
|
|
74
|
+
}
|
|
75
|
+
const ignores = new Set((layer.ignores ?? []).filter((ignore) => ignoreHolds(ignore, today)).map((ignore) => feedKey(ignore.feed, ignore.key)));
|
|
76
|
+
return firstFeeds(layer).map((feed) => {
|
|
77
|
+
const last = newest.get(feed.id);
|
|
78
|
+
if (last === void 0) return {
|
|
79
|
+
feed: feed.id,
|
|
80
|
+
old: false,
|
|
81
|
+
shown: [],
|
|
82
|
+
unknown: [],
|
|
83
|
+
outside: [],
|
|
84
|
+
ignored: [],
|
|
85
|
+
gone: []
|
|
86
|
+
};
|
|
87
|
+
const age = today - last.day;
|
|
88
|
+
const cover = feedCover(feed, stack);
|
|
89
|
+
const listed = new Set(cover.map((part) => part.id));
|
|
90
|
+
const shown = [];
|
|
91
|
+
const seen = /* @__PURE__ */ new Set();
|
|
92
|
+
const unknown = [];
|
|
93
|
+
const outside = [];
|
|
94
|
+
const ignored = [];
|
|
95
|
+
for (const key of new Set(last.read.keys)) {
|
|
96
|
+
const name = feedKey(feed.id, key);
|
|
97
|
+
const part = keys.get(name) ?? key;
|
|
98
|
+
if (!parts.has(part)) (ignores.has(name) ? ignored : unknown).push(key);
|
|
99
|
+
else if (!listed.has(part)) outside.push({
|
|
100
|
+
key,
|
|
101
|
+
part
|
|
102
|
+
});
|
|
103
|
+
else if (!seen.has(part)) {
|
|
104
|
+
seen.add(part);
|
|
105
|
+
shown.push(part);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const gone = feed.complete === false ? [] : cover.map((part) => part.id).filter((id) => !seen.has(id));
|
|
109
|
+
return {
|
|
110
|
+
feed: feed.id,
|
|
111
|
+
date: last.read.date,
|
|
112
|
+
age,
|
|
113
|
+
old: age > feed.days,
|
|
114
|
+
shown,
|
|
115
|
+
unknown,
|
|
116
|
+
outside,
|
|
117
|
+
ignored,
|
|
118
|
+
gone
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
// src/check.ts
|
|
123
|
+
/** These are the codes of the faults of a feed layer and of its reads. */
|
|
124
|
+
const FEED_CODES = [
|
|
125
|
+
"feed-duplicate",
|
|
126
|
+
"feed-days",
|
|
127
|
+
"feed-scope",
|
|
128
|
+
"key-feed",
|
|
129
|
+
"key-part",
|
|
130
|
+
"key-duplicate",
|
|
131
|
+
"ignore-feed",
|
|
132
|
+
"ignore-date",
|
|
133
|
+
"ignore-part",
|
|
134
|
+
"read-feed",
|
|
135
|
+
"read-date",
|
|
136
|
+
"feed-none",
|
|
137
|
+
"feed-old",
|
|
138
|
+
"feed-unknown",
|
|
139
|
+
"feed-outside",
|
|
140
|
+
"feed-gone",
|
|
141
|
+
"ignore-unused",
|
|
142
|
+
"ignore-old"
|
|
143
|
+
];
|
|
144
|
+
/** This function gives a list of texts for a message, for example `"a", "b"`. */
|
|
145
|
+
function names(list) {
|
|
146
|
+
return list.map((item) => `"${item}"`).join(", ");
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* This function gives each fault of a feed layer and of its reads. A list with no error tells that the gate passes.
|
|
150
|
+
*
|
|
151
|
+
* The records, as errors:
|
|
152
|
+
* - `feed-duplicate`: two feeds have one `id`.
|
|
153
|
+
* - `feed-days`: the largest age of a feed is not a whole number from 0.
|
|
154
|
+
* - `feed-scope`: the scope of a feed names no part.
|
|
155
|
+
* - `key-feed`, `key-part`: a key record names no feed, or no part.
|
|
156
|
+
* - `key-duplicate`: two key records name one feed and one name.
|
|
157
|
+
* - `ignore-feed`: an ignore record names no feed.
|
|
158
|
+
* - `ignore-date`: the last date of an ignore record is not a date.
|
|
159
|
+
* - `ignore-part`: an ignore record names a name of a part: a key record has it, or a part has it as its `id`.
|
|
160
|
+
*
|
|
161
|
+
* The reads, as errors:
|
|
162
|
+
* - `read-feed`: a read names no feed.
|
|
163
|
+
* - `read-date`: the date of a read is not a date, or it is after `today`.
|
|
164
|
+
*
|
|
165
|
+
* The feeds, as errors:
|
|
166
|
+
* - `feed-none`: a feed has no read. The gate has no result for the feed, so it does not pass.
|
|
167
|
+
* - `feed-old`: the newest read of a feed is older than its largest age. The gate then does not compare its names.
|
|
168
|
+
* - `feed-unknown`: the source shows a name with no part and no current ignore record. Add the part, or an ignore record.
|
|
169
|
+
* - `feed-outside`: the source shows a name of a part that the feed does not list, by its kind or by its scope.
|
|
170
|
+
* - `feed-gone`: a complete feed lists a part, and its source does not show it. The record is old, or the source lost the part.
|
|
171
|
+
* - `ignore-unused`: the source does not show the name of a current ignore record. Remove the record.
|
|
172
|
+
*
|
|
173
|
+
* The feeds, as warnings:
|
|
174
|
+
* - `ignore-old`: an ignore record ended before `today`. Its name is then a name with no record.
|
|
175
|
+
*
|
|
176
|
+
* A read with a fault does not count. The function is pure. The sequence of the faults is the feeds, the keys, the ignore records,
|
|
177
|
+
* the reads, the states of the feeds, then the old ignore records.
|
|
178
|
+
*
|
|
179
|
+
* @throws RangeError when `today` is not a date `YYYY-MM-DD`
|
|
180
|
+
*/
|
|
181
|
+
function checkFeeds(layer, stack, options) {
|
|
182
|
+
const today = todayNumber(options.today);
|
|
183
|
+
const faults = [];
|
|
184
|
+
const add = (level, code, at, message, more = {}) => {
|
|
185
|
+
faults.push({
|
|
186
|
+
level,
|
|
187
|
+
code,
|
|
188
|
+
at,
|
|
189
|
+
message,
|
|
190
|
+
...more
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
const parts = partsById(stack);
|
|
194
|
+
const feeds = /* @__PURE__ */ new Set();
|
|
195
|
+
for (const feed of layer.feeds) {
|
|
196
|
+
const at = feed.id;
|
|
197
|
+
if (feeds.has(at)) {
|
|
198
|
+
add("error", "feed-duplicate", at, `Two feeds have the id "${at}".`);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
feeds.add(at);
|
|
202
|
+
if (!Number.isInteger(feed.days) || feed.days < 0) add("error", "feed-days", at, `The largest age ${String(feed.days)} of the feed "${at}" is not a whole number of days from 0.`);
|
|
203
|
+
if (feed.scope !== void 0 && !parts.has(feed.scope)) add("error", "feed-scope", at, `The scope of the feed "${at}" is "${feed.scope}", which is no part of the stack.`, { part: feed.scope });
|
|
204
|
+
}
|
|
205
|
+
const keys = /* @__PURE__ */ new Set();
|
|
206
|
+
for (const key of layer.keys ?? []) {
|
|
207
|
+
const at = key.feed;
|
|
208
|
+
const name = feedKey(key.feed, key.key);
|
|
209
|
+
if (keys.has(name)) {
|
|
210
|
+
add("error", "key-duplicate", at, `Two key records name the name "${key.key}" of the feed "${at}".`, { key: key.key });
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
keys.add(name);
|
|
214
|
+
if (!feeds.has(at)) add("error", "key-feed", at, `A key record names the feed "${at}", which the layer does not have.`, { key: key.key });
|
|
215
|
+
if (!parts.has(key.part)) add("error", "key-part", at, `The key record of the name "${key.key}" of the feed "${at}" names "${key.part}", which is no part of the stack.`, {
|
|
216
|
+
key: key.key,
|
|
217
|
+
part: key.part
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
for (const ignore of layer.ignores ?? []) {
|
|
221
|
+
const at = ignore.feed;
|
|
222
|
+
if (!feeds.has(at)) add("error", "ignore-feed", at, `An ignore record names the feed "${at}", which the layer does not have.`, { key: ignore.key });
|
|
223
|
+
if (ignore.until !== void 0 && dayNumber(ignore.until) === void 0) add("error", "ignore-date", at, `The last date "${ignore.until}" of the ignore record of "${ignore.key}" is not a date of the form YYYY-MM-DD.`, { key: ignore.key });
|
|
224
|
+
if (keys.has(feedKey(ignore.feed, ignore.key)) || parts.has(ignore.key)) add("error", "ignore-part", at, `An ignore record names "${ignore.key}" of the feed "${at}", and that name gives a part. Remove the record.`, { key: ignore.key });
|
|
225
|
+
}
|
|
226
|
+
const codes = readCodes(layer, options.reads, options.today);
|
|
227
|
+
options.reads.forEach((read, index) => {
|
|
228
|
+
const at = read.feed;
|
|
229
|
+
if (codes[index] === "read-feed") add("error", "read-feed", at, `A read names the feed "${at}", which the layer does not have.`);
|
|
230
|
+
if (codes[index] === "read-date") add("error", "read-date", at, `The date "${read.date}" of a read of the feed "${at}" is not a date of the form YYYY-MM-DD, or it is after the date of the check, ${options.today}.`);
|
|
231
|
+
});
|
|
232
|
+
const records = new Map(firstFeeds(layer).map((feed) => [feed.id, feed]));
|
|
233
|
+
for (const state of feedStates(layer, stack, options)) {
|
|
234
|
+
const at = state.feed;
|
|
235
|
+
const feed = records.get(at);
|
|
236
|
+
if (state.date === void 0) {
|
|
237
|
+
add("error", "feed-none", at, `The feed "${at}" has no read. The gate has no result for it.`);
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (state.old) {
|
|
241
|
+
const days = feed?.days ?? 0;
|
|
242
|
+
add("error", "feed-old", at, `The newest read of the feed "${at}" is from ${state.date}, ${String(state.age)} days before the check. The largest age is ${String(days)} days.`);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
for (const key of state.unknown) add("error", "feed-unknown", at, `The feed "${at}" shows "${key}", and no part or ignore record has that name.`, { key });
|
|
246
|
+
for (const { key, part } of state.outside) {
|
|
247
|
+
const scope = feed?.scope === void 0 ? "" : ` in the scope "${feed.scope}"`;
|
|
248
|
+
add("error", "feed-outside", at, `The feed "${at}" shows "${key}", which gives the part "${part}". The feed lists only the parts of the kinds ${names(feed?.kinds ?? [])}${scope}.`, {
|
|
249
|
+
key,
|
|
250
|
+
part
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
for (const part of state.gone) add("error", "feed-gone", at, `The feed "${at}" lists the part "${part}", and its read of ${state.date} does not show it.`, { part });
|
|
254
|
+
const shown = new Set(state.ignored);
|
|
255
|
+
for (const ignore of layer.ignores ?? []) {
|
|
256
|
+
if (ignore.feed !== at || !ignoreHolds(ignore, today) || shown.has(ignore.key)) continue;
|
|
257
|
+
if (keys.has(feedKey(ignore.feed, ignore.key)) || parts.has(ignore.key)) continue;
|
|
258
|
+
add("error", "ignore-unused", at, `The feed "${at}" does not show "${ignore.key}", which an ignore record names. Remove the record.`, { key: ignore.key });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
for (const ignore of layer.ignores ?? []) {
|
|
262
|
+
if (ignore.until === void 0 || dayNumber(ignore.until) === void 0 || ignoreHolds(ignore, today)) continue;
|
|
263
|
+
add("warning", "ignore-old", ignore.feed, `The ignore record of "${ignore.key}" of the feed "${ignore.feed}" ended on ${ignore.until}.`, { key: ignore.key });
|
|
264
|
+
}
|
|
265
|
+
return faults;
|
|
266
|
+
}
|
|
267
|
+
// src/join.ts
|
|
268
|
+
/**
|
|
269
|
+
* This function joins the feed layers of the fragments of a stack into one layer.
|
|
270
|
+
*
|
|
271
|
+
* - The feeds, the key records and the ignore records are in the order of the fragments.
|
|
272
|
+
* - A feed `id` in two or more fragments is a fault, also when the feeds are equal.
|
|
273
|
+
* - A key record or an ignore record of one feed and one name in two or more fragments is a fault.
|
|
274
|
+
* - A fragment can give the keys and the ignore records of a feed of a different fragment.
|
|
275
|
+
*
|
|
276
|
+
* The joined layer has the field `keys` or `ignores` when a fragment has it. The function is pure, and it
|
|
277
|
+
* changes no layer. The gate `checkFeeds` examines the joined layer afterward.
|
|
278
|
+
*
|
|
279
|
+
* @param pieces - The layers, with the name of the fragment of each one, in the order of the fragments.
|
|
280
|
+
* @returns The joined layer, or the faults of the join.
|
|
281
|
+
*/
|
|
282
|
+
function joinFeeds(pieces) {
|
|
283
|
+
const feeds = joinRecords(pieces, (layer) => layer.feeds, (feed) => feed.id, "feed");
|
|
284
|
+
const keys = joinRecords(pieces, (layer) => layer.keys, (key) => feedKey(key.feed, key.key), "key record of the feed and the name");
|
|
285
|
+
const ignores = joinRecords(pieces, (layer) => layer.ignores, (ignore) => feedKey(ignore.feed, ignore.key), "ignore record of the feed and the name");
|
|
286
|
+
const errors = [
|
|
287
|
+
...feeds.errors,
|
|
288
|
+
...keys.errors,
|
|
289
|
+
...ignores.errors
|
|
290
|
+
];
|
|
291
|
+
if (errors.length > 0) return {
|
|
292
|
+
ok: false,
|
|
293
|
+
errors
|
|
294
|
+
};
|
|
295
|
+
const withKeys = pieces.some((piece) => piece.layer.keys !== void 0);
|
|
296
|
+
const withIgnores = pieces.some((piece) => piece.layer.ignores !== void 0);
|
|
297
|
+
return {
|
|
298
|
+
ok: true,
|
|
299
|
+
layer: {
|
|
300
|
+
schema: FEED_SCHEMA,
|
|
301
|
+
feeds: feeds.items,
|
|
302
|
+
...withKeys ? { keys: keys.items } : {},
|
|
303
|
+
...withIgnores ? { ignores: ignores.items } : {}
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
export { feedCover as a, readCodes as c, READ_CODES as i, todayNumber as l, FEED_CODES as n, feedStates as o, checkFeeds as r, ignoreHolds as s, joinFeeds as t };
|
|
308
|
+
|
|
309
|
+
//# sourceMappingURL=join-U6_W4HEG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join-U6_W4HEG.js","names":[],"sources":["../src/states.ts","../src/check.ts","../src/join.ts"],"sourcesContent":["import { dayNumber, partNeeds, partsById, type Part, type Stack } from \"@mark1russell7/system-stack\";\nimport { feedKey, firstFeeds, type Feed, type FeedIgnore, type FeedLayer, type FeedRead } from \"./layer.ts\";\n\n// The states of the feeds: the newest read of each feed, and the comparison of its names with the records of the stack.\n\n/** The options of the states and of the gate. */\nexport interface FeedOptions {\n /** The date of the check, as `YYYY-MM-DD`. The functions have no clock: the caller gives the date. */\n readonly today: string;\n /** The reads of the feeds. A program makes them from each source. */\n readonly reads: readonly FeedRead[];\n}\n\n/** These are the codes of the faults of a read. */\nexport const READ_CODES: readonly [\"read-feed\", \"read-date\"] = [\"read-feed\", \"read-date\"];\n\n/** A code of a fault of a read. */\nexport type ReadCode = (typeof READ_CODES)[number];\n\n/**\n * A name of a read with a part that the feed does not list. The kind of the part is not a kind of the feed, or the part is out\n * of its scope.\n */\nexport interface OutsideName {\n /** The name in the source. */\n readonly key: string;\n /** The `id` of the part of the name. */\n readonly part: string;\n}\n\n/** The state of one feed on the date of the check. */\nexport interface FeedState {\n /** The `id` of the feed. */\n readonly feed: string;\n /** The date of the newest read with no fault. A feed with no read has no date, and its lists are empty. */\n readonly date?: string | undefined;\n /** The age of the newest read, in days. */\n readonly age?: number | undefined;\n /** This value tells that the newest read is older than the largest age of the feed. */\n readonly old: boolean;\n /** The parts that the newest read shows, in the sequence of the read. Each part comes one time. */\n readonly shown: readonly string[];\n /** The names of the newest read with no part and no current ignore record. */\n readonly unknown: readonly string[];\n /** The names of the newest read with a part that the feed does not list. */\n readonly outside: readonly OutsideName[];\n /** The names of the newest read that a current ignore record covers. */\n readonly ignored: readonly string[];\n /** The parts that the feed lists and the newest read does not show. A feed that is not complete has none. */\n readonly gone: readonly string[];\n}\n\n/**\n * This function gives the parts of a stack that a feed lists: the parts of its kinds, in its scope.\n * A part with a scope needs the part of the scope directly. The parts are in the sequence of the stack, and each `id` comes one time.\n */\nexport function feedCover(feed: Feed, stack: Stack): Part[] {\n const kinds = new Set(feed.kinds);\n return [...partsById(stack).values()].filter((part) => kinds.has(part.kind) && (feed.scope === undefined || partNeeds(part).includes(feed.scope)));\n}\n\n/** This function gives the number of the day of the date of the check, or it throws. */\nexport function todayNumber(today: string): number {\n const day = dayNumber(today);\n if (day === undefined) throw new RangeError(`The date \"${today}\" is not a date of the form YYYY-MM-DD.`);\n return day;\n}\n\n/**\n * This function gives the fault of each read, in the sequence of the reads. A read with no fault gives `undefined`.\n *\n * - `read-feed`: the read names no feed of the layer.\n * - `read-date`: the date of the read is not a date, or it is after the date of the check.\n *\n * @throws RangeError when `today` is not a date `YYYY-MM-DD`\n */\nexport function readCodes(layer: FeedLayer, reads: readonly FeedRead[], today: string): (ReadCode | undefined)[] {\n const day = todayNumber(today);\n const feeds = new Set(layer.feeds.map((feed) => feed.id));\n return reads.map((read) => {\n if (!feeds.has(read.feed)) return \"read-feed\";\n const date = dayNumber(read.date);\n if (date === undefined || date > day) return \"read-date\";\n return undefined;\n });\n}\n\n/** This function tells if an ignore record holds on a day: it has no last date, or its last date is not before the day. */\nexport function ignoreHolds(ignore: FeedIgnore, day: number): boolean {\n if (ignore.until === undefined) return true;\n const until = dayNumber(ignore.until);\n return until !== undefined && until >= day;\n}\n\n/**\n * This function gives the state of each feed of a layer on the date of the check, in the sequence of the feeds.\n *\n * - The newest read of a feed is the read with the latest date and no fault. Of two reads of one date, the last read counts.\n * - A name gives a part through a key record of the feed, or else through the part with that `id`.\n * - A name with no part goes to `ignored` when a current ignore record names it, and to `unknown` when no record names it.\n * - A part that the feed does not list goes to `outside`. A part that the feed lists goes to `shown`.\n * - A complete feed puts each part that it lists and the read does not show into `gone`.\n *\n * The function is pure. It gives the first feed of each `id`.\n *\n * @throws RangeError when `today` is not a date `YYYY-MM-DD`\n */\nexport function feedStates(layer: FeedLayer, stack: Stack, options: FeedOptions): FeedState[] {\n const today = todayNumber(options.today);\n const codes = readCodes(layer, options.reads, options.today);\n const newest = new Map<string, { readonly read: FeedRead; readonly day: number }>();\n options.reads.forEach((read, index) => {\n if (codes[index] !== undefined) return;\n const day = dayNumber(read.date) ?? 0;\n const last = newest.get(read.feed);\n if (last === undefined || day >= last.day) newest.set(read.feed, { read, day });\n });\n const parts = partsById(stack);\n const keys = new Map<string, string>();\n for (const key of layer.keys ?? []) {\n const name = feedKey(key.feed, key.key);\n if (!keys.has(name)) keys.set(name, key.part);\n }\n const ignores = new Set((layer.ignores ?? []).filter((ignore) => ignoreHolds(ignore, today)).map((ignore) => feedKey(ignore.feed, ignore.key)));\n\n return firstFeeds(layer).map((feed): FeedState => {\n const last = newest.get(feed.id);\n if (last === undefined) return { feed: feed.id, old: false, shown: [], unknown: [], outside: [], ignored: [], gone: [] };\n const age = today - last.day;\n const cover = feedCover(feed, stack);\n const listed = new Set(cover.map((part) => part.id));\n const shown: string[] = [];\n const seen = new Set<string>();\n const unknown: string[] = [];\n const outside: OutsideName[] = [];\n const ignored: string[] = [];\n for (const key of new Set(last.read.keys)) {\n const name = feedKey(feed.id, key);\n const part = keys.get(name) ?? key;\n if (!parts.has(part)) {\n (ignores.has(name) ? ignored : unknown).push(key);\n } else if (!listed.has(part)) {\n outside.push({ key, part });\n } else if (!seen.has(part)) {\n seen.add(part);\n shown.push(part);\n }\n }\n const gone = feed.complete === false ? [] : cover.map((part) => part.id).filter((id) => !seen.has(id));\n return { feed: feed.id, date: last.read.date, age, old: age > feed.days, shown, unknown, outside, ignored, gone };\n });\n}\n","import { dayNumber, partsById, type Fault, type FaultLevel, type Stack } from \"@mark1russell7/system-stack\";\nimport { feedKey, firstFeeds, type FeedLayer } from \"./layer.ts\";\nimport { feedStates, ignoreHolds, readCodes, todayNumber, type FeedOptions } from \"./states.ts\";\n\n// The gate of the feeds. A gate that passes tells that each feed has a new read, and that each read agrees with the records.\n\n/** These are the codes of the faults of a feed layer and of its reads. */\nexport const FEED_CODES: readonly [\n \"feed-duplicate\",\n \"feed-days\",\n \"feed-scope\",\n \"key-feed\",\n \"key-part\",\n \"key-duplicate\",\n \"ignore-feed\",\n \"ignore-date\",\n \"ignore-part\",\n \"read-feed\",\n \"read-date\",\n \"feed-none\",\n \"feed-old\",\n \"feed-unknown\",\n \"feed-outside\",\n \"feed-gone\",\n \"ignore-unused\",\n \"ignore-old\",\n] = [\n \"feed-duplicate\",\n \"feed-days\",\n \"feed-scope\",\n \"key-feed\",\n \"key-part\",\n \"key-duplicate\",\n \"ignore-feed\",\n \"ignore-date\",\n \"ignore-part\",\n \"read-feed\",\n \"read-date\",\n \"feed-none\",\n \"feed-old\",\n \"feed-unknown\",\n \"feed-outside\",\n \"feed-gone\",\n \"ignore-unused\",\n \"ignore-old\",\n];\n\n/** A code of a fault of a feed layer. */\nexport type FeedCode = (typeof FEED_CODES)[number];\n\n/** A fault of a feed layer. Its field `at` is the `id` of the feed. */\nexport interface FeedFault extends Fault {\n readonly code: FeedCode;\n /** The name in the source, for a fault of one name. */\n readonly key?: string | undefined;\n /** The `id` of the part, for a fault of one part. */\n readonly part?: string | undefined;\n}\n\n/** This function gives a list of texts for a message, for example `\"a\", \"b\"`. */\nfunction names(list: readonly string[]): string {\n return list.map((item) => `\"${item}\"`).join(\", \");\n}\n\n/**\n * This function gives each fault of a feed layer and of its reads. A list with no error tells that the gate passes.\n *\n * The records, as errors:\n * - `feed-duplicate`: two feeds have one `id`.\n * - `feed-days`: the largest age of a feed is not a whole number from 0.\n * - `feed-scope`: the scope of a feed names no part.\n * - `key-feed`, `key-part`: a key record names no feed, or no part.\n * - `key-duplicate`: two key records name one feed and one name.\n * - `ignore-feed`: an ignore record names no feed.\n * - `ignore-date`: the last date of an ignore record is not a date.\n * - `ignore-part`: an ignore record names a name of a part: a key record has it, or a part has it as its `id`.\n *\n * The reads, as errors:\n * - `read-feed`: a read names no feed.\n * - `read-date`: the date of a read is not a date, or it is after `today`.\n *\n * The feeds, as errors:\n * - `feed-none`: a feed has no read. The gate has no result for the feed, so it does not pass.\n * - `feed-old`: the newest read of a feed is older than its largest age. The gate then does not compare its names.\n * - `feed-unknown`: the source shows a name with no part and no current ignore record. Add the part, or an ignore record.\n * - `feed-outside`: the source shows a name of a part that the feed does not list, by its kind or by its scope.\n * - `feed-gone`: a complete feed lists a part, and its source does not show it. The record is old, or the source lost the part.\n * - `ignore-unused`: the source does not show the name of a current ignore record. Remove the record.\n *\n * The feeds, as warnings:\n * - `ignore-old`: an ignore record ended before `today`. Its name is then a name with no record.\n *\n * A read with a fault does not count. The function is pure. The sequence of the faults is the feeds, the keys, the ignore records,\n * the reads, the states of the feeds, then the old ignore records.\n *\n * @throws RangeError when `today` is not a date `YYYY-MM-DD`\n */\nexport function checkFeeds(layer: FeedLayer, stack: Stack, options: FeedOptions): FeedFault[] {\n const today = todayNumber(options.today);\n const faults: FeedFault[] = [];\n const add = (level: FaultLevel, code: FeedCode, at: string, message: string, more: { readonly key?: string; readonly part?: string } = {}): void => {\n faults.push({ level, code, at, message, ...more });\n };\n const parts = partsById(stack);\n\n const feeds = new Set<string>();\n for (const feed of layer.feeds) {\n const at = feed.id;\n if (feeds.has(at)) {\n add(\"error\", \"feed-duplicate\", at, `Two feeds have the id \"${at}\".`);\n continue;\n }\n feeds.add(at);\n if (!Number.isInteger(feed.days) || feed.days < 0) add(\"error\", \"feed-days\", at, `The largest age ${String(feed.days)} of the feed \"${at}\" is not a whole number of days from 0.`);\n if (feed.scope !== undefined && !parts.has(feed.scope)) add(\"error\", \"feed-scope\", at, `The scope of the feed \"${at}\" is \"${feed.scope}\", which is no part of the stack.`, { part: feed.scope });\n }\n\n const keys = new Set<string>();\n for (const key of layer.keys ?? []) {\n const at = key.feed;\n const name = feedKey(key.feed, key.key);\n if (keys.has(name)) {\n add(\"error\", \"key-duplicate\", at, `Two key records name the name \"${key.key}\" of the feed \"${at}\".`, { key: key.key });\n continue;\n }\n keys.add(name);\n if (!feeds.has(at)) add(\"error\", \"key-feed\", at, `A key record names the feed \"${at}\", which the layer does not have.`, { key: key.key });\n if (!parts.has(key.part)) add(\"error\", \"key-part\", at, `The key record of the name \"${key.key}\" of the feed \"${at}\" names \"${key.part}\", which is no part of the stack.`, { key: key.key, part: key.part });\n }\n\n for (const ignore of layer.ignores ?? []) {\n const at = ignore.feed;\n if (!feeds.has(at)) add(\"error\", \"ignore-feed\", at, `An ignore record names the feed \"${at}\", which the layer does not have.`, { key: ignore.key });\n if (ignore.until !== undefined && dayNumber(ignore.until) === undefined) {\n add(\"error\", \"ignore-date\", at, `The last date \"${ignore.until}\" of the ignore record of \"${ignore.key}\" is not a date of the form YYYY-MM-DD.`, { key: ignore.key });\n }\n if (keys.has(feedKey(ignore.feed, ignore.key)) || parts.has(ignore.key)) {\n add(\"error\", \"ignore-part\", at, `An ignore record names \"${ignore.key}\" of the feed \"${at}\", and that name gives a part. Remove the record.`, { key: ignore.key });\n }\n }\n\n const codes = readCodes(layer, options.reads, options.today);\n options.reads.forEach((read, index) => {\n const at = read.feed;\n if (codes[index] === \"read-feed\") add(\"error\", \"read-feed\", at, `A read names the feed \"${at}\", which the layer does not have.`);\n if (codes[index] === \"read-date\") add(\"error\", \"read-date\", at, `The date \"${read.date}\" of a read of the feed \"${at}\" is not a date of the form YYYY-MM-DD, or it is after the date of the check, ${options.today}.`);\n });\n\n const records = new Map(firstFeeds(layer).map((feed) => [feed.id, feed]));\n for (const state of feedStates(layer, stack, options)) {\n const at = state.feed;\n const feed = records.get(at);\n if (state.date === undefined) {\n add(\"error\", \"feed-none\", at, `The feed \"${at}\" has no read. The gate has no result for it.`);\n continue;\n }\n if (state.old) {\n const days = feed?.days ?? 0;\n add(\"error\", \"feed-old\", at, `The newest read of the feed \"${at}\" is from ${state.date}, ${String(state.age)} days before the check. The largest age is ${String(days)} days.`);\n continue;\n }\n for (const key of state.unknown) add(\"error\", \"feed-unknown\", at, `The feed \"${at}\" shows \"${key}\", and no part or ignore record has that name.`, { key });\n for (const { key, part } of state.outside) {\n const scope = feed?.scope === undefined ? \"\" : ` in the scope \"${feed.scope}\"`;\n add(\"error\", \"feed-outside\", at, `The feed \"${at}\" shows \"${key}\", which gives the part \"${part}\". The feed lists only the parts of the kinds ${names(feed?.kinds ?? [])}${scope}.`, { key, part });\n }\n for (const part of state.gone) add(\"error\", \"feed-gone\", at, `The feed \"${at}\" lists the part \"${part}\", and its read of ${state.date} does not show it.`, { part });\n const shown = new Set(state.ignored);\n for (const ignore of layer.ignores ?? []) {\n if (ignore.feed !== at || !ignoreHolds(ignore, today) || shown.has(ignore.key)) continue;\n if (keys.has(feedKey(ignore.feed, ignore.key)) || parts.has(ignore.key)) continue;\n add(\"error\", \"ignore-unused\", at, `The feed \"${at}\" does not show \"${ignore.key}\", which an ignore record names. Remove the record.`, { key: ignore.key });\n }\n }\n\n for (const ignore of layer.ignores ?? []) {\n if (ignore.until === undefined || dayNumber(ignore.until) === undefined || ignoreHolds(ignore, today)) continue;\n add(\"warning\", \"ignore-old\", ignore.feed, `The ignore record of \"${ignore.key}\" of the feed \"${ignore.feed}\" ended on ${ignore.until}.`, { key: ignore.key });\n }\n return faults;\n}\n","import { joinRecords, type LayerParse, type LayerPiece } from \"@mark1russell7/system-stack\";\nimport { FEED_SCHEMA, feedKey, type FeedLayer } from \"./layer.ts\";\n\n// The join of the feed layers of the fragments of a stack, for example one file of feeds for each owner.\n\n/**\n * This function joins the feed layers of the fragments of a stack into one layer.\n *\n * - The feeds, the key records and the ignore records are in the order of the fragments.\n * - A feed `id` in two or more fragments is a fault, also when the feeds are equal.\n * - A key record or an ignore record of one feed and one name in two or more fragments is a fault.\n * - A fragment can give the keys and the ignore records of a feed of a different fragment.\n *\n * The joined layer has the field `keys` or `ignores` when a fragment has it. The function is pure, and it\n * changes no layer. The gate `checkFeeds` examines the joined layer afterward.\n *\n * @param pieces - The layers, with the name of the fragment of each one, in the order of the fragments.\n * @returns The joined layer, or the faults of the join.\n */\nexport function joinFeeds(pieces: readonly LayerPiece<FeedLayer>[]): LayerParse<FeedLayer> {\n const feeds = joinRecords(\n pieces,\n (layer) => layer.feeds,\n (feed) => feed.id,\n \"feed\",\n );\n const keys = joinRecords(\n pieces,\n (layer) => layer.keys,\n (key) => feedKey(key.feed, key.key),\n \"key record of the feed and the name\",\n );\n const ignores = joinRecords(\n pieces,\n (layer) => layer.ignores,\n (ignore) => feedKey(ignore.feed, ignore.key),\n \"ignore record of the feed and the name\",\n );\n const errors = [...feeds.errors, ...keys.errors, ...ignores.errors];\n if (errors.length > 0) return { ok: false, errors };\n const withKeys = pieces.some((piece) => piece.layer.keys !== undefined);\n const withIgnores = pieces.some((piece) => piece.layer.ignores !== undefined);\n return {\n ok: true,\n layer: {\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,OAAO,IAAI,iBAAiB,OAAO,KAAK,aAAa,OAAO,MAAM,IAAI,EAAE,KAAK,OAAO,IAAI,CAAC;CAC9J;CACA,OAAO;AACT;;;;;;;;;;;;;;;;ACjKA,SAAgB,UAAU,QAAiE;CACzF,MAAM,QAAQ,YACZ,SACC,UAAU,MAAM,QAChB,SAAS,KAAK,IACf,MACF;CACA,MAAM,OAAO,YACX,SACC,UAAU,MAAM,OAChB,QAAQ,QAAQ,IAAI,MAAM,IAAI,GAAG,GAClC,qCACF;CACA,MAAM,UAAU,YACd,SACC,UAAU,MAAM,UAChB,WAAW,QAAQ,OAAO,MAAM,OAAO,GAAG,GAC3C,wCACF;CACA,MAAM,SAAS;EAAC,GAAG,MAAM;EAAQ,GAAG,KAAK;EAAQ,GAAG,QAAQ;CAAM;CAClE,IAAI,OAAO,SAAS,GAAG,OAAO;EAAE,IAAI;EAAO;CAAO;CAClD,MAAM,WAAW,OAAO,MAAM,UAAU,MAAM,MAAM,SAAS,KAAA,CAAS;CACtE,MAAM,cAAc,OAAO,MAAM,UAAU,MAAM,MAAM,YAAY,KAAA,CAAS;CAC5E,OAAO;EACL,IAAI;EACJ,OAAO;GACL,QAAQ;GACR,OAAO,MAAM;GACb,GAAI,WAAW,EAAE,MAAM,KAAK,MAAM,IAAI,CAAC;GACvC,GAAI,cAAc,EAAE,SAAS,QAAQ,MAAM,IAAI,CAAC;EAClD;CACF;AACF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** The name of the format of a feed layer. It is the key of the layer in `Stack.layers`. */
|
|
2
|
+
declare const FEED_SCHEMA = "feed/1";
|
|
3
|
+
/**
|
|
4
|
+
* A feed: a source that lists the parts of some kinds, for example the names of the secrets of one repository.
|
|
5
|
+
* A program reads the list. The read is live data: the layer keeps only the record of the feed.
|
|
6
|
+
*/
|
|
7
|
+
interface Feed {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
/** The name of the feed for a person. */
|
|
10
|
+
readonly name?: string | undefined;
|
|
11
|
+
/** The kinds of the parts that the source lists. */
|
|
12
|
+
readonly kinds: readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* The `id` of a part. With it, the source lists only the parts that need this part directly.
|
|
15
|
+
* Thus a feed of the secrets of one repository lists only the secrets that need that repository.
|
|
16
|
+
*/
|
|
17
|
+
readonly scope?: string | undefined;
|
|
18
|
+
/** The largest age of the newest read, in days. It is a whole number from 0. */
|
|
19
|
+
readonly days: number;
|
|
20
|
+
/**
|
|
21
|
+
* This value tells if the source lists each part of its kinds and its scope. The default is `true`.
|
|
22
|
+
* With `false`, a part that the read does not show is no fault.
|
|
23
|
+
*/
|
|
24
|
+
readonly complete?: boolean | undefined;
|
|
25
|
+
}
|
|
26
|
+
/** A key: the name of a part in a source, when the name is not the `id` of the part. */
|
|
27
|
+
interface FeedKey {
|
|
28
|
+
/** The `id` of the feed. */
|
|
29
|
+
readonly feed: string;
|
|
30
|
+
/** The name of the part in the source. */
|
|
31
|
+
readonly key: string;
|
|
32
|
+
/** The `id` of the part. */
|
|
33
|
+
readonly part: string;
|
|
34
|
+
}
|
|
35
|
+
/** A name that the source shows, which is no part of the stack for a reason. */
|
|
36
|
+
interface FeedIgnore {
|
|
37
|
+
/** The `id` of the feed. */
|
|
38
|
+
readonly feed: string;
|
|
39
|
+
/** The name in the source. */
|
|
40
|
+
readonly key: string;
|
|
41
|
+
/** The reason of the owner. */
|
|
42
|
+
readonly reason: string;
|
|
43
|
+
/** The last date of the record, as `YYYY-MM-DD`. After that date the gate fails for the name. A record without it has no end. */
|
|
44
|
+
readonly until?: string | undefined;
|
|
45
|
+
}
|
|
46
|
+
/** A feed layer: the feeds of a stack, the names of the parts in each source, and the names that are no parts. */
|
|
47
|
+
interface FeedLayer {
|
|
48
|
+
readonly schema: typeof FEED_SCHEMA;
|
|
49
|
+
readonly feeds: readonly Feed[];
|
|
50
|
+
readonly keys?: readonly FeedKey[] | undefined;
|
|
51
|
+
readonly ignores?: readonly FeedIgnore[] | undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A read of a feed: the names that its source shows on one date. A read is live data, and it is no record of the layer.
|
|
55
|
+
* A read has only names. Thus a read of secrets has the name of each secret, but not its value.
|
|
56
|
+
*/
|
|
57
|
+
interface FeedRead {
|
|
58
|
+
/** The `id` of the feed. */
|
|
59
|
+
readonly feed: string;
|
|
60
|
+
/** The date of the read, as `YYYY-MM-DD`. */
|
|
61
|
+
readonly date: string;
|
|
62
|
+
/** The names that the source shows. A name can come two times. */
|
|
63
|
+
readonly keys: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
/** This function gives the first feed of each `id` of a layer, in the sequence of the records. */
|
|
66
|
+
declare function firstFeeds(layer: FeedLayer): readonly Feed[];
|
|
67
|
+
/** This function gives one text for a feed and a name. Two different pairs give two different texts. */
|
|
68
|
+
declare function feedKey(feed: string, key: string): string;
|
|
69
|
+
export { FeedLayer as a, firstFeeds as c, FeedKey as i, Feed as n, FeedRead as o, FeedIgnore as r, feedKey as s, FEED_SCHEMA as t };
|
|
70
|
+
//# sourceMappingURL=layer-B_AkCJdI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-B_AkCJdI.d.ts","names":[],"sources":["../src/layer.ts"],"mappings":";cAIa;;;;;UAMI;WACN;;WAEA;;WAEA;;;;;WAKA;;WAEA;;;;;WAKA;;;UAIM;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;;UAIM;WACN,eAAe;WACf,gBAAgB;WAChB,gBAAgB;WAChB,mBAAmB;;;;;;UAOb;;WAEN;;WAEA;;WAEA;;;iBAIK,WAAW,OAAO,qBAAqB;;iBAUvC,QAAQ,cAAc"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/layer.ts
|
|
2
|
+
/** The name of the format of a feed layer. It is the key of the layer in `Stack.layers`. */
|
|
3
|
+
const FEED_SCHEMA = "feed/1";
|
|
4
|
+
/** This function gives the first feed of each `id` of a layer, in the sequence of the records. */
|
|
5
|
+
function firstFeeds(layer) {
|
|
6
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7
|
+
return layer.feeds.filter((feed) => {
|
|
8
|
+
if (seen.has(feed.id)) return false;
|
|
9
|
+
seen.add(feed.id);
|
|
10
|
+
return true;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/** This function gives one text for a feed and a name. Two different pairs give two different texts. */
|
|
14
|
+
function feedKey(feed, key) {
|
|
15
|
+
return JSON.stringify([feed, key]);
|
|
16
|
+
}
|
|
17
|
+
export { feedKey as n, firstFeeds as r, FEED_SCHEMA as t };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=layer-BhRXComg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-BhRXComg.js","names":[],"sources":["../src/layer.ts"],"sourcesContent":["// The records of the feed add-on. They are one layer of a stack, with the key `feed/1` in `Stack.layers`.\n// A feed is a live list of the parts of some kinds, from one source. The gate compares each list with the records.\n\n/** The name of the format of a feed layer. It is the key of the layer in `Stack.layers`. */\nexport const FEED_SCHEMA = \"feed/1\";\n\n/**\n * A feed: a source that lists the parts of some kinds, for example the names of the secrets of one repository.\n * A program reads the list. The read is live data: the layer keeps only the record of the feed.\n */\nexport interface Feed {\n readonly id: string;\n /** The name of the feed for a person. */\n readonly name?: string | undefined;\n /** The kinds of the parts that the source lists. */\n readonly kinds: readonly string[];\n /**\n * The `id` of a part. With it, the source lists only the parts that need this part directly.\n * Thus a feed of the secrets of one repository lists only the secrets that need that repository.\n */\n readonly scope?: string | undefined;\n /** The largest age of the newest read, in days. It is a whole number from 0. */\n readonly days: number;\n /**\n * This value tells if the source lists each part of its kinds and its scope. The default is `true`.\n * With `false`, a part that the read does not show is no fault.\n */\n readonly complete?: boolean | undefined;\n}\n\n/** A key: the name of a part in a source, when the name is not the `id` of the part. */\nexport interface FeedKey {\n /** The `id` of the feed. */\n readonly feed: string;\n /** The name of the part in the source. */\n readonly key: string;\n /** The `id` of the part. */\n readonly part: string;\n}\n\n/** A name that the source shows, which is no part of the stack for a reason. */\nexport interface FeedIgnore {\n /** The `id` of the feed. */\n readonly feed: string;\n /** The name in the source. */\n readonly key: string;\n /** The reason of the owner. */\n readonly reason: string;\n /** The last date of the record, as `YYYY-MM-DD`. After that date the gate fails for the name. A record without it has no end. */\n readonly until?: string | undefined;\n}\n\n/** A feed layer: the feeds of a stack, the names of the parts in each source, and the names that are no parts. */\nexport interface FeedLayer {\n readonly schema: typeof FEED_SCHEMA;\n readonly feeds: readonly Feed[];\n readonly keys?: readonly FeedKey[] | undefined;\n readonly ignores?: readonly FeedIgnore[] | undefined;\n}\n\n/**\n * A read of a feed: the names that its source shows on one date. A read is live data, and it is no record of the layer.\n * A read has only names. Thus a read of secrets has the name of each secret, but not its value.\n */\nexport interface FeedRead {\n /** The `id` of the feed. */\n readonly feed: string;\n /** The date of the read, as `YYYY-MM-DD`. */\n readonly date: string;\n /** The names that the source shows. A name can come two times. */\n readonly keys: readonly string[];\n}\n\n/** This function gives the first feed of each `id` of a layer, in the sequence of the records. */\nexport function firstFeeds(layer: FeedLayer): readonly Feed[] {\n const seen = new Set<string>();\n return layer.feeds.filter((feed) => {\n if (seen.has(feed.id)) return false;\n seen.add(feed.id);\n return true;\n });\n}\n\n/** This function gives one text for a feed and a name. Two different pairs give two different texts. */\nexport function feedKey(feed: string, key: string): string {\n return JSON.stringify([feed, key]);\n}\n"],"mappings":";;AAIA,MAAa,cAAc;;AAsE3B,SAAgB,WAAW,OAAmC;CAC5D,MAAM,uBAAO,IAAI,IAAY;CAC7B,OAAO,MAAM,MAAM,QAAQ,SAAS;EAClC,IAAI,KAAK,IAAI,KAAK,EAAE,GAAG,OAAO;EAC9B,KAAK,IAAI,KAAK,EAAE;EAChB,OAAO;CACT,CAAC;AACH;;AAGA,SAAgB,QAAQ,MAAc,KAAqB;CACzD,OAAO,KAAK,UAAU,CAAC,MAAM,GAAG,CAAC;AACnC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { a as FeedLayer, o as FeedRead } from "./layer-B_AkCJdI.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* The schema of a feed layer. It examines the form of the record: the fields, their types and the finite numbers.
|
|
5
|
+
* It refuses a field that the format does not have. `checkFeeds` examines the meaning of a layer with a correct form.
|
|
6
|
+
*/
|
|
7
|
+
export declare const feedSchema: z.ZodType<FeedLayer>;
|
|
8
|
+
/** The schema of a list of reads, for example the JSON file that a program of the feeds writes. A read has only names. */
|
|
9
|
+
export declare const feedReadsSchema: z.ZodType<readonly FeedRead[]>;
|
|
10
|
+
/** The result of the read of a feed layer: the layer, or the faults of its form. */
|
|
11
|
+
export type FeedParse = {
|
|
12
|
+
readonly ok: true;
|
|
13
|
+
readonly layer: FeedLayer;
|
|
14
|
+
} | {
|
|
15
|
+
readonly ok: false;
|
|
16
|
+
readonly errors: readonly string[];
|
|
17
|
+
};
|
|
18
|
+
/** The result of the read of a list of reads: the reads, or the faults of their form. */
|
|
19
|
+
export type FeedReadsParse = {
|
|
20
|
+
readonly ok: true;
|
|
21
|
+
readonly reads: readonly FeedRead[];
|
|
22
|
+
} | {
|
|
23
|
+
readonly ok: false;
|
|
24
|
+
readonly errors: readonly string[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* This function reads the JSON of a feed layer. It gives the layer, or the faults of its form.
|
|
28
|
+
* Each fault names its place in the record, for example `feeds.0.kinds`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseFeeds(value: unknown): FeedParse;
|
|
31
|
+
/**
|
|
32
|
+
* This function reads the JSON of a list of reads. It gives the reads, or the faults of their form.
|
|
33
|
+
* Each fault names its place in the list, for example `0.keys.2`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseFeedReads(value: unknown): FeedReadsParse;
|
|
36
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","names":[],"sources":["../src/schema.ts"],"mappings":";;;;;;qBAmCa,YAAY,EAAE,QAAQ;;qBAQtB,iBAAiB,EAAE,iBAAiB;;YAWrC;WAAuB;WAAmB,OAAO;;WAAyB;WAAoB;;;YAG9F;WAA4B;WAAmB,gBAAgB;;WAA0B;WAAoB;;;;;;wBAMzG,WAAW,iBAAiB;;;;;wBAU5B,eAAe,iBAAiB"}
|
package/build/schema.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { t as FEED_SCHEMA } from "./layer-BhRXComg.js";
|
|
2
|
+
import { formErrors } from "@mark1russell7/system-stack/schema";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
// src/schema.ts
|
|
5
|
+
const id = z.string().min(1);
|
|
6
|
+
const feed = z.strictObject({
|
|
7
|
+
id,
|
|
8
|
+
name: z.string().optional(),
|
|
9
|
+
kinds: z.array(id).min(1).readonly(),
|
|
10
|
+
scope: id.optional(),
|
|
11
|
+
days: z.number(),
|
|
12
|
+
complete: z.boolean().optional()
|
|
13
|
+
});
|
|
14
|
+
const key = z.strictObject({
|
|
15
|
+
feed: id,
|
|
16
|
+
key: id,
|
|
17
|
+
part: id
|
|
18
|
+
});
|
|
19
|
+
const ignore = z.strictObject({
|
|
20
|
+
feed: id,
|
|
21
|
+
key: id,
|
|
22
|
+
reason: z.string().min(1),
|
|
23
|
+
until: z.string().optional()
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* The schema of a feed layer. It examines the form of the record: the fields, their types and the finite numbers.
|
|
27
|
+
* It refuses a field that the format does not have. `checkFeeds` examines the meaning of a layer with a correct form.
|
|
28
|
+
*/
|
|
29
|
+
const feedSchema = z.strictObject({
|
|
30
|
+
schema: z.literal(FEED_SCHEMA),
|
|
31
|
+
feeds: z.array(feed).readonly(),
|
|
32
|
+
keys: z.array(key).readonly().optional(),
|
|
33
|
+
ignores: z.array(ignore).readonly().optional()
|
|
34
|
+
});
|
|
35
|
+
/** The schema of a list of reads, for example the JSON file that a program of the feeds writes. A read has only names. */
|
|
36
|
+
const feedReadsSchema = z.array(z.strictObject({
|
|
37
|
+
feed: id,
|
|
38
|
+
date: z.string(),
|
|
39
|
+
keys: z.array(id).readonly()
|
|
40
|
+
})).readonly();
|
|
41
|
+
/**
|
|
42
|
+
* This function reads the JSON of a feed layer. It gives the layer, or the faults of its form.
|
|
43
|
+
* Each fault names its place in the record, for example `feeds.0.kinds`.
|
|
44
|
+
*/
|
|
45
|
+
function parseFeeds(value) {
|
|
46
|
+
const read = feedSchema.safeParse(value);
|
|
47
|
+
if (read.success) return {
|
|
48
|
+
ok: true,
|
|
49
|
+
layer: read.data
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
ok: false,
|
|
53
|
+
errors: formErrors(FEED_SCHEMA, read.error.issues)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* This function reads the JSON of a list of reads. It gives the reads, or the faults of their form.
|
|
58
|
+
* Each fault names its place in the list, for example `0.keys.2`.
|
|
59
|
+
*/
|
|
60
|
+
function parseFeedReads(value) {
|
|
61
|
+
const read = feedReadsSchema.safeParse(value);
|
|
62
|
+
if (read.success) return {
|
|
63
|
+
ok: true,
|
|
64
|
+
reads: read.data
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
ok: false,
|
|
68
|
+
errors: formErrors("feed reads", read.error.issues)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export { feedReadsSchema, feedSchema, parseFeedReads, parseFeeds };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../src/schema.ts"],"sourcesContent":["import { formErrors } from \"@mark1russell7/system-stack/schema\";\nimport { z } from \"zod\";\nimport { FEED_SCHEMA, type FeedLayer, type FeedRead } from \"./layer.ts\";\n\n// The zod schemas of a feed layer and of its reads, and the read of their JSON. This module is the entry `/schema` of the package.\n// The root entry has no zod, so a page that only runs the gate gets no schema library.\n\nconst id = z.string().min(1);\n\nconst feed = z.strictObject({\n id,\n name: z.string().optional(),\n kinds: z.array(id).min(1).readonly(),\n scope: id.optional(),\n days: z.number(),\n complete: z.boolean().optional(),\n});\n\nconst key = z.strictObject({\n feed: id,\n key: id,\n part: id,\n});\n\nconst ignore = z.strictObject({\n feed: id,\n key: id,\n reason: z.string().min(1),\n until: z.string().optional(),\n});\n\n/**\n * The schema of a feed layer. It examines the form of the record: the fields, their types and the finite numbers.\n * It refuses a field that the format does not have. `checkFeeds` examines the meaning of a layer with a correct form.\n */\nexport const feedSchema: z.ZodType<FeedLayer> = z.strictObject({\n schema: z.literal(FEED_SCHEMA),\n feeds: z.array(feed).readonly(),\n keys: z.array(key).readonly().optional(),\n ignores: z.array(ignore).readonly().optional(),\n});\n\n/** The schema of a list of reads, for example the JSON file that a program of the feeds writes. A read has only names. */\nexport const feedReadsSchema: z.ZodType<readonly FeedRead[]> = z\n .array(\n z.strictObject({\n feed: id,\n date: z.string(),\n keys: z.array(id).readonly(),\n }),\n )\n .readonly();\n\n/** The result of the read of a feed layer: the layer, or the faults of its form. */\nexport type FeedParse = { readonly ok: true; readonly layer: FeedLayer } | { readonly ok: false; readonly errors: readonly string[] };\n\n/** The result of the read of a list of reads: the reads, or the faults of their form. */\nexport type FeedReadsParse = { readonly ok: true; readonly reads: readonly FeedRead[] } | { readonly ok: false; readonly errors: readonly string[] };\n\n/**\n * This function reads the JSON of a feed layer. It gives the layer, or the faults of its form.\n * Each fault names its place in the record, for example `feeds.0.kinds`.\n */\nexport function parseFeeds(value: unknown): FeedParse {\n const read = feedSchema.safeParse(value);\n if (read.success) return { ok: true, layer: read.data };\n return { ok: false, errors: formErrors(FEED_SCHEMA, read.error.issues) };\n}\n\n/**\n * This function reads the JSON of a list of reads. It gives the reads, or the faults of their form.\n * Each fault names its place in the list, for example `0.keys.2`.\n */\nexport function parseFeedReads(value: unknown): FeedReadsParse {\n const read = feedReadsSchema.safeParse(value);\n if (read.success) return { ok: true, reads: read.data };\n return { ok: false, errors: formErrors(\"feed reads\", read.error.issues) };\n}\n"],"mappings":";;;;AAOA,MAAM,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAE3B,MAAM,OAAO,EAAE,aAAa;CAC1B;CACA,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CACnC,OAAO,GAAG,SAAS;CACnB,MAAM,EAAE,OAAO;CACf,UAAU,EAAE,QAAQ,CAAC,CAAC,SAAS;AACjC,CAAC;AAED,MAAM,MAAM,EAAE,aAAa;CACzB,MAAM;CACN,KAAK;CACL,MAAM;AACR,CAAC;AAED,MAAM,SAAS,EAAE,aAAa;CAC5B,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACxB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;AAC7B,CAAC;;;;;AAMD,MAAa,aAAmC,EAAE,aAAa;CAC7D,QAAQ,EAAE,QAAQ,WAAW;CAC7B,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,SAAS;CAC9B,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CACvC,SAAS,EAAE,MAAM,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;AAC/C,CAAC;;AAGD,MAAa,kBAAkD,EAC5D,MACC,EAAE,aAAa;CACb,MAAM;CACN,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS;AAC7B,CAAC,CACH,CAAC,CACA,SAAS;;;;;AAYZ,SAAgB,WAAW,OAA2B;CACpD,MAAM,OAAO,WAAW,UAAU,KAAK;CACvC,IAAI,KAAK,SAAS,OAAO;EAAE,IAAI;EAAM,OAAO,KAAK;CAAK;CACtD,OAAO;EAAE,IAAI;EAAO,QAAQ,WAAW,aAAa,KAAK,MAAM,MAAM;CAAE;AACzE;;;;;AAMA,SAAgB,eAAe,OAAgC;CAC7D,MAAM,OAAO,gBAAgB,UAAU,KAAK;CAC5C,IAAI,KAAK,SAAS,OAAO;EAAE,IAAI;EAAM,OAAO,KAAK;CAAK;CACtD,OAAO;EAAE,IAAI;EAAO,QAAQ,WAAW,cAAc,KAAK,MAAM,MAAM;CAAE;AAC1E"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { a as FeedLayer, n as Feed, o as FeedRead, r as FeedIgnore } from "./layer-B_AkCJdI.js";
|
|
2
|
+
import { Part, Stack } from "@mark1russell7/system-stack";
|
|
3
|
+
/** The options of the states and of the gate. */
|
|
4
|
+
interface FeedOptions {
|
|
5
|
+
/** The date of the check, as `YYYY-MM-DD`. The functions have no clock: the caller gives the date. */
|
|
6
|
+
readonly today: string;
|
|
7
|
+
/** The reads of the feeds. A program makes them from each source. */
|
|
8
|
+
readonly reads: readonly FeedRead[];
|
|
9
|
+
}
|
|
10
|
+
/** These are the codes of the faults of a read. */
|
|
11
|
+
declare const READ_CODES: readonly ["read-feed", "read-date"];
|
|
12
|
+
/** A code of a fault of a read. */
|
|
13
|
+
type ReadCode = (typeof READ_CODES)[number];
|
|
14
|
+
/**
|
|
15
|
+
* A name of a read with a part that the feed does not list. The kind of the part is not a kind of the feed, or the part is out
|
|
16
|
+
* of its scope.
|
|
17
|
+
*/
|
|
18
|
+
interface OutsideName {
|
|
19
|
+
/** The name in the source. */
|
|
20
|
+
readonly key: string;
|
|
21
|
+
/** The `id` of the part of the name. */
|
|
22
|
+
readonly part: string;
|
|
23
|
+
}
|
|
24
|
+
/** The state of one feed on the date of the check. */
|
|
25
|
+
interface FeedState {
|
|
26
|
+
/** The `id` of the feed. */
|
|
27
|
+
readonly feed: string;
|
|
28
|
+
/** The date of the newest read with no fault. A feed with no read has no date, and its lists are empty. */
|
|
29
|
+
readonly date?: string | undefined;
|
|
30
|
+
/** The age of the newest read, in days. */
|
|
31
|
+
readonly age?: number | undefined;
|
|
32
|
+
/** This value tells that the newest read is older than the largest age of the feed. */
|
|
33
|
+
readonly old: boolean;
|
|
34
|
+
/** The parts that the newest read shows, in the sequence of the read. Each part comes one time. */
|
|
35
|
+
readonly shown: readonly string[];
|
|
36
|
+
/** The names of the newest read with no part and no current ignore record. */
|
|
37
|
+
readonly unknown: readonly string[];
|
|
38
|
+
/** The names of the newest read with a part that the feed does not list. */
|
|
39
|
+
readonly outside: readonly OutsideName[];
|
|
40
|
+
/** The names of the newest read that a current ignore record covers. */
|
|
41
|
+
readonly ignored: readonly string[];
|
|
42
|
+
/** The parts that the feed lists and the newest read does not show. A feed that is not complete has none. */
|
|
43
|
+
readonly gone: readonly string[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* This function gives the parts of a stack that a feed lists: the parts of its kinds, in its scope.
|
|
47
|
+
* A part with a scope needs the part of the scope directly. The parts are in the sequence of the stack, and each `id` comes one time.
|
|
48
|
+
*/
|
|
49
|
+
declare function feedCover(feed: Feed, stack: Stack): Part[];
|
|
50
|
+
/** This function gives the number of the day of the date of the check, or it throws. */
|
|
51
|
+
declare function todayNumber(today: string): number;
|
|
52
|
+
/**
|
|
53
|
+
* This function gives the fault of each read, in the sequence of the reads. A read with no fault gives `undefined`.
|
|
54
|
+
*
|
|
55
|
+
* - `read-feed`: the read names no feed of the layer.
|
|
56
|
+
* - `read-date`: the date of the read is not a date, or it is after the date of the check.
|
|
57
|
+
*
|
|
58
|
+
* @throws RangeError when `today` is not a date `YYYY-MM-DD`
|
|
59
|
+
*/
|
|
60
|
+
declare function readCodes(layer: FeedLayer, reads: readonly FeedRead[], today: string): (ReadCode | undefined)[];
|
|
61
|
+
/** This function tells if an ignore record holds on a day: it has no last date, or its last date is not before the day. */
|
|
62
|
+
declare function ignoreHolds(ignore: FeedIgnore, day: number): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* This function gives the state of each feed of a layer on the date of the check, in the sequence of the feeds.
|
|
65
|
+
*
|
|
66
|
+
* - The newest read of a feed is the read with the latest date and no fault. Of two reads of one date, the last read counts.
|
|
67
|
+
* - A name gives a part through a key record of the feed, or else through the part with that `id`.
|
|
68
|
+
* - A name with no part goes to `ignored` when a current ignore record names it, and to `unknown` when no record names it.
|
|
69
|
+
* - A part that the feed does not list goes to `outside`. A part that the feed lists goes to `shown`.
|
|
70
|
+
* - A complete feed puts each part that it lists and the read does not show into `gone`.
|
|
71
|
+
*
|
|
72
|
+
* The function is pure. It gives the first feed of each `id`.
|
|
73
|
+
*
|
|
74
|
+
* @throws RangeError when `today` is not a date `YYYY-MM-DD`
|
|
75
|
+
*/
|
|
76
|
+
declare function feedStates(layer: FeedLayer, stack: Stack, options: FeedOptions): FeedState[];
|
|
77
|
+
export { ReadCode as a, ignoreHolds as c, READ_CODES as i, readCodes as l, FeedState as n, feedCover as o, OutsideName as r, feedStates as s, FeedOptions as t, todayNumber as u };
|
|
78
|
+
//# sourceMappingURL=states-DnhuJlh8.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"states-DnhuJlh8.d.ts","names":[],"sources":["../src/states.ts"],"mappings":";;;UAMiB;;WAEN;;WAEA,gBAAgB;;;cAId;;KAGD,mBAAmB;;;;;UAMd;;WAEN;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA,kBAAkB;;WAElB;;WAEA;;;;;;iBAOK,UAAU,MAAM,MAAM,OAAO,QAAQ;;iBAMrC,YAAY;;;;;;;;;iBAcZ,UAAU,OAAO,WAAW,gBAAgB,YAAY,iBAAiB;;iBAYzE,YAAY,QAAQ,YAAY;;;;;;;;;;;;;;iBAmBhC,WAAW,OAAO,WAAW,OAAO,OAAO,SAAS,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,75 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package",
|
|
2
3
|
"name": "@mark1russell7/stack-feeds",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
4
|
+
"version": "0.1.1",
|
|
5
|
+
"description": "The live lists of a system stack: each feed lists the parts of some kinds from one source, and a gate fails when a record is old or a list is old. An add-on of system-stack.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mark1russell7/system-stack.git",
|
|
10
|
+
"directory": "packages/stack-feeds"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://mark1russell7.github.io/system-stack/",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/mark1russell7/system-stack/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"feed",
|
|
18
|
+
"inventory",
|
|
19
|
+
"drift",
|
|
20
|
+
"freshness",
|
|
21
|
+
"reconcile",
|
|
22
|
+
"gate",
|
|
23
|
+
"system-stack"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./build/index.js",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./build/index.d.ts",
|
|
31
|
+
"import": "./build/index.js",
|
|
32
|
+
"default": "./build/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./schema": {
|
|
35
|
+
"types": "./build/schema.d.ts",
|
|
36
|
+
"import": "./build/schema.js",
|
|
37
|
+
"default": "./build/schema.js"
|
|
38
|
+
},
|
|
39
|
+
"./add-on": {
|
|
40
|
+
"types": "./build/add-on.d.ts",
|
|
41
|
+
"import": "./build/add-on.js",
|
|
42
|
+
"default": "./build/add-on.js"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"build"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@mark1russell7/system-stack": "0.1.6",
|
|
51
|
+
"zod": "^4.6.7"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@mark1russell7/cue": "^2.0.0",
|
|
55
|
+
"@types/node": "^26.6.5",
|
|
56
|
+
"@vitest/coverage-v8": "^5.0.3",
|
|
57
|
+
"fast-check": "^4.10.2",
|
|
58
|
+
"tsdown": "^0.23.1",
|
|
59
|
+
"typescript": "^7.0.2",
|
|
60
|
+
"vitest": "^5.0.3"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=22"
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsdown",
|
|
70
|
+
"test": "vitest run",
|
|
71
|
+
"test:watch": "vitest",
|
|
72
|
+
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.test.json"
|
|
73
|
+
},
|
|
74
|
+
"types": "./build/index.d.ts"
|
|
6
75
|
}
|