@prestack/thread 0.0.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.
Files changed (248) hide show
  1. package/CHANGELOG.md +192 -0
  2. package/dist/attach.d.ts +1 -0
  3. package/dist/attach.js +1 -0
  4. package/dist/core/actor.d.ts +12 -0
  5. package/dist/core/actor.js +8 -0
  6. package/dist/core/asking.d.ts +180 -0
  7. package/dist/core/asking.js +1109 -0
  8. package/dist/core/attach.d.ts +54 -0
  9. package/dist/core/attach.js +510 -0
  10. package/dist/core/chain.d.ts +16 -0
  11. package/dist/core/chain.js +114 -0
  12. package/dist/core/cli.d.ts +2 -0
  13. package/dist/core/cli.js +1682 -0
  14. package/dist/core/condition.d.ts +52 -0
  15. package/dist/core/condition.js +198 -0
  16. package/dist/core/descend.d.ts +81 -0
  17. package/dist/core/descend.js +879 -0
  18. package/dist/core/finding.d.ts +12 -0
  19. package/dist/core/finding.js +23 -0
  20. package/dist/core/generators/meta.d.ts +2 -0
  21. package/dist/core/generators/meta.js +823 -0
  22. package/dist/core/init.d.ts +15 -0
  23. package/dist/core/init.js +134 -0
  24. package/dist/core/invoked.d.ts +9 -0
  25. package/dist/core/invoked.js +41 -0
  26. package/dist/core/round.d.ts +1 -0
  27. package/dist/core/round.js +57 -0
  28. package/dist/core/rows.d.ts +26 -0
  29. package/dist/core/rows.js +354 -0
  30. package/dist/core/scope.d.ts +6 -0
  31. package/dist/core/scope.js +12 -0
  32. package/dist/core/thread.d.ts +26 -0
  33. package/dist/core/thread.js +5 -0
  34. package/dist/core/tree.d.ts +12 -0
  35. package/dist/core/tree.js +56 -0
  36. package/dist/core/types.d.ts +49 -0
  37. package/dist/core/types.js +311 -0
  38. package/dist/derivation/attach.d.ts +2 -0
  39. package/dist/derivation/attach.js +61 -0
  40. package/dist/derivation/generators/build.d.ts +16 -0
  41. package/dist/derivation/generators/build.js +217 -0
  42. package/dist/derivation/generators/check.d.ts +18 -0
  43. package/dist/derivation/generators/check.js +78 -0
  44. package/dist/derivation/generators/derivation.d.ts +3 -0
  45. package/dist/derivation/generators/derivation.js +273 -0
  46. package/dist/derivation/generators/determinism.d.ts +20 -0
  47. package/dist/derivation/generators/determinism.js +110 -0
  48. package/dist/derivation/generators/release.d.ts +3 -0
  49. package/dist/derivation/generators/release.js +183 -0
  50. package/dist/derivation/makers/release.d.ts +1 -0
  51. package/dist/derivation/makers/release.js +107 -0
  52. package/dist/derivation/release.d.ts +10 -0
  53. package/dist/derivation/release.js +12 -0
  54. package/dist/integrations/attach.d.ts +6 -0
  55. package/dist/integrations/attach.js +177 -0
  56. package/dist/integrations/generators/read.d.ts +1 -0
  57. package/dist/integrations/generators/read.js +92 -0
  58. package/dist/integrations/generators/sdk.d.ts +1 -0
  59. package/dist/integrations/generators/sdk.js +148 -0
  60. package/dist/integrations/generators/secret.d.ts +1 -0
  61. package/dist/integrations/generators/secret.js +233 -0
  62. package/dist/integrations/generators/target.d.ts +1 -0
  63. package/dist/integrations/generators/target.js +765 -0
  64. package/dist/integrations/generators/vault.d.ts +1 -0
  65. package/dist/integrations/generators/vault.js +164 -0
  66. package/dist/integrations/sdk.d.ts +6 -0
  67. package/dist/integrations/sdk.js +151 -0
  68. package/dist/integrations/secret.d.ts +16 -0
  69. package/dist/integrations/secret.js +30 -0
  70. package/dist/integrations/target.d.ts +49 -0
  71. package/dist/integrations/target.js +225 -0
  72. package/dist/integrations/vault.d.ts +12 -0
  73. package/dist/integrations/vault.js +104 -0
  74. package/dist/integrity/attach.d.ts +2 -0
  75. package/dist/integrity/attach.js +213 -0
  76. package/dist/integrity/check-threads.d.ts +10 -0
  77. package/dist/integrity/check-threads.js +153 -0
  78. package/dist/integrity/constraint.d.ts +16 -0
  79. package/dist/integrity/constraint.js +1105 -0
  80. package/dist/integrity/generators/compiler.d.ts +1 -0
  81. package/dist/integrity/generators/compiler.js +130 -0
  82. package/dist/integrity/generators/gate.d.ts +1 -0
  83. package/dist/integrity/generators/gate.js +172 -0
  84. package/dist/integrity/generators/issues.d.ts +1 -0
  85. package/dist/integrity/generators/issues.js +100 -0
  86. package/dist/integrity/generators/publish.d.ts +1 -0
  87. package/dist/integrity/generators/publish.js +186 -0
  88. package/dist/integrity/generators/rule.d.ts +2 -0
  89. package/dist/integrity/generators/rule.js +213 -0
  90. package/dist/integrity/generators/seal.d.ts +4 -0
  91. package/dist/integrity/generators/seal.js +101 -0
  92. package/dist/integrity/generators/trial.d.ts +39 -0
  93. package/dist/integrity/generators/trial.js +254 -0
  94. package/dist/integrity/lint.d.ts +50 -0
  95. package/dist/integrity/lint.js +161 -0
  96. package/dist/integrity/lsp/bin.d.ts +2 -0
  97. package/dist/integrity/lsp/bin.js +35 -0
  98. package/dist/integrity/lsp/diagnostics.d.ts +25 -0
  99. package/dist/integrity/lsp/diagnostics.js +57 -0
  100. package/dist/integrity/lsp/findings.d.ts +20 -0
  101. package/dist/integrity/lsp/findings.js +39 -0
  102. package/dist/integrity/lsp/lint.d.ts +7 -0
  103. package/dist/integrity/lsp/lint.js +95 -0
  104. package/dist/integrity/lsp/protocol.d.ts +20 -0
  105. package/dist/integrity/lsp/protocol.js +57 -0
  106. package/dist/integrity/lsp/server.d.ts +15 -0
  107. package/dist/integrity/lsp/server.js +171 -0
  108. package/dist/integrity/sealed.d.ts +1 -0
  109. package/dist/integrity/sealed.js +56 -0
  110. package/dist/integrity/slopnator.d.ts +90 -0
  111. package/dist/integrity/slopnator.js +267 -0
  112. package/dist/integrity/slopnators/sl_broken_lineage.d.ts +2 -0
  113. package/dist/integrity/slopnators/sl_broken_lineage.js +35 -0
  114. package/dist/integrity/slopnators/sl_declared_elsewhere.d.ts +2 -0
  115. package/dist/integrity/slopnators/sl_declared_elsewhere.js +33 -0
  116. package/dist/integrity/slopnators/sl_derived_drift.d.ts +8 -0
  117. package/dist/integrity/slopnators/sl_derived_drift.js +91 -0
  118. package/dist/integrity/slopnators/sl_hardcoded_style.d.ts +2 -0
  119. package/dist/integrity/slopnators/sl_hardcoded_style.js +46 -0
  120. package/dist/integrity/slopnators/sl_inert_island.d.ts +2 -0
  121. package/dist/integrity/slopnators/sl_inert_island.js +85 -0
  122. package/dist/integrity/slopnators/sl_inert_slopnator.d.ts +2 -0
  123. package/dist/integrity/slopnators/sl_inert_slopnator.js +76 -0
  124. package/dist/integrity/slopnators/sl_missing_row.d.ts +2 -0
  125. package/dist/integrity/slopnators/sl_missing_row.js +180 -0
  126. package/dist/integrity/slopnators/sl_no_barrel.d.ts +2 -0
  127. package/dist/integrity/slopnators/sl_no_barrel.js +41 -0
  128. package/dist/integrity/slopnators/sl_no_child_process.d.ts +2 -0
  129. package/dist/integrity/slopnators/sl_no_child_process.js +61 -0
  130. package/dist/integrity/slopnators/sl_no_comment.d.ts +2 -0
  131. package/dist/integrity/slopnators/sl_no_comment.js +41 -0
  132. package/dist/integrity/slopnators/sl_no_dispatch_bypass.d.ts +2 -0
  133. package/dist/integrity/slopnators/sl_no_dispatch_bypass.js +301 -0
  134. package/dist/integrity/slopnators/sl_no_import_cycle.d.ts +2 -0
  135. package/dist/integrity/slopnators/sl_no_import_cycle.js +42 -0
  136. package/dist/integrity/slopnators/sl_no_such_command.d.ts +2 -0
  137. package/dist/integrity/slopnators/sl_no_such_command.js +55 -0
  138. package/dist/integrity/slopnators/sl_only_takes_a_literal.d.ts +2 -0
  139. package/dist/integrity/slopnators/sl_only_takes_a_literal.js +59 -0
  140. package/dist/integrity/slopnators/sl_secret_literal.d.ts +2 -0
  141. package/dist/integrity/slopnators/sl_secret_literal.js +89 -0
  142. package/dist/integrity/slopnators/sl_stale_path.d.ts +2 -0
  143. package/dist/integrity/slopnators/sl_stale_path.js +92 -0
  144. package/dist/integrity/slopnators/sl_twice_meant.d.ts +2 -0
  145. package/dist/integrity/slopnators/sl_twice_meant.js +30 -0
  146. package/dist/integrity/slopnators/sl_twice_parented.d.ts +2 -0
  147. package/dist/integrity/slopnators/sl_twice_parented.js +34 -0
  148. package/dist/integrity/slopnators/sl_undeclared_crossing.d.ts +2 -0
  149. package/dist/integrity/slopnators/sl_undeclared_crossing.js +78 -0
  150. package/dist/integrity/slopnators/sl_undeclared_destination.d.ts +2 -0
  151. package/dist/integrity/slopnators/sl_undeclared_destination.js +56 -0
  152. package/dist/integrity/slopnators/sl_undeclared_element.d.ts +2 -0
  153. package/dist/integrity/slopnators/sl_undeclared_element.js +34 -0
  154. package/dist/integrity/slopnators/sl_undeclared_node.d.ts +2 -0
  155. package/dist/integrity/slopnators/sl_undeclared_node.js +59 -0
  156. package/dist/integrity/slopnators/sl_undeclared_operation.d.ts +2 -0
  157. package/dist/integrity/slopnators/sl_undeclared_operation.js +120 -0
  158. package/dist/integrity/slopnators/sl_undeclared_variant.d.ts +2 -0
  159. package/dist/integrity/slopnators/sl_undeclared_variant.js +117 -0
  160. package/dist/integrity/slopnators/sl_undescribed.d.ts +2 -0
  161. package/dist/integrity/slopnators/sl_undescribed.js +54 -0
  162. package/dist/integrity/slopnators/sl_ungoverned_island.d.ts +2 -0
  163. package/dist/integrity/slopnators/sl_ungoverned_island.js +58 -0
  164. package/dist/integrity/slopnators/sl_unkept_rows.d.ts +2 -0
  165. package/dist/integrity/slopnators/sl_unkept_rows.js +104 -0
  166. package/dist/integrity/slopnators/sl_unnamed_island.d.ts +2 -0
  167. package/dist/integrity/slopnators/sl_unnamed_island.js +37 -0
  168. package/dist/integrity/slopnators/sl_unpaired_member.d.ts +2 -0
  169. package/dist/integrity/slopnators/sl_unpaired_member.js +114 -0
  170. package/dist/integrity/slopnators/sl_unpaired_slopnator.d.ts +2 -0
  171. package/dist/integrity/slopnators/sl_unpaired_slopnator.js +60 -0
  172. package/dist/integrity/slopnators/sl_unprefixed_member.d.ts +2 -0
  173. package/dist/integrity/slopnators/sl_unprefixed_member.js +126 -0
  174. package/dist/integrity/slopnators/sl_unseamed_reach.d.ts +2 -0
  175. package/dist/integrity/slopnators/sl_unseamed_reach.js +73 -0
  176. package/dist/integrity/slopnators/sl_unthreaded.d.ts +56 -0
  177. package/dist/integrity/slopnators/sl_unthreaded.js +352 -0
  178. package/dist/integrity/slopnators/sl_untranslated_key.d.ts +2 -0
  179. package/dist/integrity/slopnators/sl_untranslated_key.js +157 -0
  180. package/dist/integrity/slopnators/sl_unversioned.d.ts +2 -0
  181. package/dist/integrity/slopnators/sl_unversioned.js +31 -0
  182. package/dist/integrity/sweep.d.ts +24 -0
  183. package/dist/integrity/sweep.js +264 -0
  184. package/dist/knowledge/attach.d.ts +2 -0
  185. package/dist/knowledge/attach.js +339 -0
  186. package/dist/knowledge/generators/docsgen.d.ts +1 -0
  187. package/dist/knowledge/generators/docsgen.js +145 -0
  188. package/dist/knowledge/generators/glossary.d.ts +1 -0
  189. package/dist/knowledge/generators/glossary.js +56 -0
  190. package/dist/knowledge/generators/skills.d.ts +1 -0
  191. package/dist/knowledge/generators/skills.js +222 -0
  192. package/dist/knowledge/glossary.d.ts +6 -0
  193. package/dist/knowledge/glossary.js +1 -0
  194. package/dist/operations/access.d.ts +27 -0
  195. package/dist/operations/access.js +61 -0
  196. package/dist/operations/attach.d.ts +6 -0
  197. package/dist/operations/attach.js +414 -0
  198. package/dist/operations/capabilities.d.ts +37 -0
  199. package/dist/operations/capabilities.js +35 -0
  200. package/dist/operations/cost.d.ts +14 -0
  201. package/dist/operations/cost.js +37 -0
  202. package/dist/operations/dispatch.d.ts +14 -0
  203. package/dist/operations/dispatch.js +327 -0
  204. package/dist/operations/error-results.d.ts +4 -0
  205. package/dist/operations/error-results.js +25 -0
  206. package/dist/operations/errors/catalog.d.ts +58 -0
  207. package/dist/operations/errors/catalog.js +91 -0
  208. package/dist/operations/errors/classes.d.ts +73 -0
  209. package/dist/operations/errors/classes.js +22 -0
  210. package/dist/operations/errors/errors.d.ts +52 -0
  211. package/dist/operations/errors/errors.js +257 -0
  212. package/dist/operations/generators/capability.d.ts +5 -0
  213. package/dist/operations/generators/capability.js +603 -0
  214. package/dist/operations/generators/compile.d.ts +2 -0
  215. package/dist/operations/generators/compile.js +541 -0
  216. package/dist/operations/generators/grant.d.ts +1 -0
  217. package/dist/operations/generators/grant.js +267 -0
  218. package/dist/operations/generators/operation.d.ts +1 -0
  219. package/dist/operations/generators/operation.js +811 -0
  220. package/dist/operations/generators/permits.d.ts +1 -0
  221. package/dist/operations/generators/permits.js +196 -0
  222. package/dist/operations/generators/seed.d.ts +20 -0
  223. package/dist/operations/generators/seed.js +285 -0
  224. package/dist/operations/generators/trial.d.ts +53 -0
  225. package/dist/operations/generators/trial.js +376 -0
  226. package/dist/operations/http.d.ts +30 -0
  227. package/dist/operations/http.js +121 -0
  228. package/dist/operations/makers/capability.d.ts +1 -0
  229. package/dist/operations/makers/capability.js +117 -0
  230. package/dist/operations/makers/trial.d.ts +1 -0
  231. package/dist/operations/makers/trial.js +413 -0
  232. package/dist/operations/memory.d.ts +104 -0
  233. package/dist/operations/memory.js +365 -0
  234. package/dist/operations/metering.d.ts +55 -0
  235. package/dist/operations/metering.js +247 -0
  236. package/dist/operations/nodes.d.ts +35 -0
  237. package/dist/operations/nodes.js +15 -0
  238. package/dist/operations/operations.d.ts +18 -0
  239. package/dist/operations/operations.js +5 -0
  240. package/dist/operations/queue-policy.d.ts +3 -0
  241. package/dist/operations/queue-policy.js +8 -0
  242. package/dist/operations/result.d.ts +19 -0
  243. package/dist/operations/result.js +10 -0
  244. package/dist/operations/seams.d.ts +239 -0
  245. package/dist/operations/seams.js +45 -0
  246. package/dist/operations/store.d.ts +14 -0
  247. package/dist/operations/store.js +1 -0
  248. package/package.json +16 -0
@@ -0,0 +1,52 @@
1
+ import { type Actor } from './actor.ts';
2
+ export declare const COMPARE_OPS: readonly ["eq", "neq", "lt", "lte", "gt", "gte", "in", "has"];
3
+ export type CompareOp = (typeof COMPARE_OPS)[number];
4
+ export declare const AGGREGATIONS: readonly ["count", "sum", "min", "max", "avg"];
5
+ export declare const ACTOR_FACTS: readonly ["id", "roles", "entitlements", ...("run" | "address" | "device" | "replay")[]];
6
+ export declare const AGO: RegExp;
7
+ export type Operand = {
8
+ readonly value: string | number | boolean | null;
9
+ } | {
10
+ readonly field: string;
11
+ } | {
12
+ readonly was: string;
13
+ } | {
14
+ readonly outer: string;
15
+ } | {
16
+ readonly actor: (typeof ACTOR_FACTS)[number];
17
+ } | {
18
+ readonly now: true;
19
+ } | {
20
+ readonly ago: string;
21
+ } | {
22
+ readonly agg: {
23
+ readonly of: string;
24
+ readonly how: (typeof AGGREGATIONS)[number];
25
+ readonly field?: string;
26
+ readonly where?: Condition;
27
+ };
28
+ };
29
+ export type Condition = {
30
+ readonly all: readonly Condition[];
31
+ } | {
32
+ readonly any: readonly Condition[];
33
+ } | {
34
+ readonly not: Condition;
35
+ } | {
36
+ readonly is: Operand;
37
+ readonly op: CompareOp;
38
+ readonly than: Operand;
39
+ };
40
+ export declare function walkOperands(condition: Condition, take: (one: Operand) => void): void;
41
+ export declare function mentionsActor(condition: Condition): boolean;
42
+ export declare function agoSeconds(ago: string): number | undefined;
43
+ export declare function satisfies(condition: Condition, actor: Actor): boolean;
44
+ export declare const CONDITION_ANSWERS: readonly ["is", "than", "field", "value", "actor", "ago", "of", "how", "over", "op", "when", "joins"];
45
+ export declare function conditioned(ask: (key: string, question: string) => Promise<string>, say: (line: string) => void, subject: {
46
+ readonly id: string;
47
+ readonly fields: readonly string[];
48
+ }, all: readonly {
49
+ readonly id: string;
50
+ readonly fields: readonly string[];
51
+ }[]): Promise<Condition | undefined>;
52
+ export declare function said(one: unknown): string;
@@ -0,0 +1,198 @@
1
+ import { ENVIRONMENT } from "./actor.js";
2
+ export const COMPARE_OPS = ['eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'in', 'has'];
3
+ export const AGGREGATIONS = ['count', 'sum', 'min', 'max', 'avg'];
4
+ export const ACTOR_FACTS = ['id', 'roles', 'entitlements', ...ENVIRONMENT.map(([fact]) => fact)];
5
+ export const AGO = /^[1-9][0-9]*[smhd]$/;
6
+ export function walkOperands(condition, take) {
7
+ if ('all' in condition) {
8
+ for (const one of condition.all)
9
+ walkOperands(one, take);
10
+ return;
11
+ }
12
+ if ('any' in condition) {
13
+ for (const one of condition.any)
14
+ walkOperands(one, take);
15
+ return;
16
+ }
17
+ if ('not' in condition) {
18
+ walkOperands(condition.not, take);
19
+ return;
20
+ }
21
+ for (const side of [condition.is, condition.than]) {
22
+ take(side);
23
+ if ('agg' in side && side.agg.where !== undefined)
24
+ walkOperands(side.agg.where, take);
25
+ }
26
+ }
27
+ export function mentionsActor(condition) {
28
+ let found = false;
29
+ walkOperands(condition, (one) => {
30
+ if ('actor' in one)
31
+ found = true;
32
+ });
33
+ return found;
34
+ }
35
+ export function agoSeconds(ago) {
36
+ if (!AGO.test(ago))
37
+ return undefined;
38
+ const size = Number(ago.slice(0, -1));
39
+ const unit = ago.slice(-1);
40
+ return size * (unit === 's' ? 1 : unit === 'm' ? 60 : unit === 'h' ? 3_600 : 86_400);
41
+ }
42
+ export function satisfies(condition, actor) {
43
+ if ('all' in condition)
44
+ return condition.all.every((one) => satisfies(one, actor));
45
+ if ('any' in condition)
46
+ return condition.any.some((one) => satisfies(one, actor));
47
+ if ('not' in condition)
48
+ return !satisfies(condition.not, actor);
49
+ const reads = (one) => {
50
+ if ('value' in one)
51
+ return one.value;
52
+ if ('actor' in one)
53
+ return actor[one.actor];
54
+ return undefined;
55
+ };
56
+ const left = reads(condition.is);
57
+ const right = reads(condition.than);
58
+ if (left === undefined || right === undefined)
59
+ return false;
60
+ const op = condition.op;
61
+ if (op === 'in')
62
+ return Array.isArray(right) && right.includes(left);
63
+ if (op === 'has')
64
+ return Array.isArray(left) && left.includes(right);
65
+ if (op === 'eq')
66
+ return left === right;
67
+ if (op === 'neq')
68
+ return left !== right;
69
+ if (typeof left !== typeof right)
70
+ return false;
71
+ if (typeof left !== 'number' && typeof left !== 'string')
72
+ return false;
73
+ const other = right;
74
+ if (op === 'lt')
75
+ return left < other;
76
+ if (op === 'lte')
77
+ return left <= other;
78
+ if (op === 'gt')
79
+ return left > other;
80
+ return left >= other;
81
+ }
82
+ export const CONDITION_ANSWERS = ['is', 'than', 'field', 'value', 'actor', 'ago', 'of', 'how', 'over', 'op', 'when', 'joins'];
83
+ const OPERAND_WORDS = ['field', 'value', 'actor', 'now', 'ago', 'agg'];
84
+ async function sided(ask, say, subject, all, which) {
85
+ for (;;) {
86
+ const kind = await ask(which, ` ${which} — ${OPERAND_WORDS.join(', ')}: `);
87
+ if (kind === 'field') {
88
+ const id = await ask('field', ` which field — ${subject.fields.join(', ')}: `);
89
+ if (!subject.fields.includes(id)) {
90
+ say(` "${subject.id}" declares no \`${id}\`.\n`);
91
+ continue;
92
+ }
93
+ return { field: id };
94
+ }
95
+ if (kind === 'value') {
96
+ const raw = await ask('value', ' the value (text, a number, true, false, null): ');
97
+ if (raw === 'null')
98
+ return { value: null };
99
+ if (raw === 'true' || raw === 'false')
100
+ return { value: raw === 'true' };
101
+ const asNumber = Number(raw);
102
+ return { value: raw !== '' && Number.isFinite(asNumber) ? asNumber : raw };
103
+ }
104
+ if (kind === 'actor') {
105
+ const fact = await ask('actor', ` which — ${ACTOR_FACTS.join(', ')}: `);
106
+ if (!ACTOR_FACTS.includes(fact)) {
107
+ say(` an actor has ${ACTOR_FACTS.join(', ')} and nothing else.\n`);
108
+ continue;
109
+ }
110
+ return { actor: fact };
111
+ }
112
+ if (kind === 'now')
113
+ return { now: true };
114
+ if (kind === 'ago') {
115
+ const span = await ask('ago', ' how long — e.g. 30d, 12h, 15m, 45s: ');
116
+ if (!AGO.test(span)) {
117
+ say(' a span is a number and one of s, m, h, d.\n');
118
+ continue;
119
+ }
120
+ return { ago: span };
121
+ }
122
+ if (kind === 'agg') {
123
+ const of = await ask('of', ` over which entity — ${all.map((one) => one.id).join(', ')}: `);
124
+ const target = all.find((one) => one.id === of);
125
+ if (target === undefined) {
126
+ say(` nothing declares \`${of}\`.\n`);
127
+ continue;
128
+ }
129
+ const how = await ask('how', ` how — ${AGGREGATIONS.join(', ')}: `);
130
+ if (!AGGREGATIONS.includes(how)) {
131
+ say(` an aggregation is ${AGGREGATIONS.join(', ')}.\n`);
132
+ continue;
133
+ }
134
+ if (how === 'count')
135
+ return { agg: { of, how: 'count' } };
136
+ const over = await ask('over', ` over which field of ${of} — ${target.fields.join(', ')}: `);
137
+ if (!target.fields.includes(over)) {
138
+ say(` "${of}" declares no \`${over}\`.\n`);
139
+ continue;
140
+ }
141
+ return { agg: { of, how: how, field: over } };
142
+ }
143
+ say(` there is no side called "${kind}".\n`);
144
+ }
145
+ }
146
+ async function compared(ask, say, subject, all) {
147
+ for (;;) {
148
+ const is = await sided(ask, say, subject, all, 'is');
149
+ const op = await ask('op', ` op — ${COMPARE_OPS.join(', ')}: `);
150
+ if (!COMPARE_OPS.includes(op)) {
151
+ say(` \`${op}\` is not a comparison this provider carries.\n`);
152
+ continue;
153
+ }
154
+ const than = await sided(ask, say, subject, all, 'than');
155
+ return { is, op: op, than };
156
+ }
157
+ }
158
+ export async function conditioned(ask, say, subject, all) {
159
+ const held = [];
160
+ let joiner = 'all';
161
+ for (;;) {
162
+ if (held.length === 0) {
163
+ const wanted = await ask('when', ' state a condition — y/n: ');
164
+ if (!wanted.toLowerCase().startsWith('y'))
165
+ return undefined;
166
+ }
167
+ held.push(await compared(ask, say, subject, all));
168
+ const next = await ask('joins', ' and, or, done: ');
169
+ if (next === 'done' || next === '')
170
+ break;
171
+ if (next === 'and')
172
+ joiner = 'all';
173
+ else if (next === 'or')
174
+ joiner = 'any';
175
+ else {
176
+ say(' say and, or, or done.\n');
177
+ break;
178
+ }
179
+ }
180
+ if (held.length === 0)
181
+ return undefined;
182
+ const first = held[0];
183
+ return held.length === 1 ? first : joiner === 'all' ? { all: held } : { any: held };
184
+ }
185
+ import { quoted } from "./rows.js";
186
+ export function said(one) {
187
+ if (typeof one === 'string')
188
+ return quoted(one);
189
+ if (one === null)
190
+ return 'null';
191
+ if (typeof one === 'boolean' || typeof one === 'number')
192
+ return String(one);
193
+ if (Array.isArray(one))
194
+ return `[${one.map((each) => said(each)).join(', ')}]`;
195
+ if (typeof one === 'object')
196
+ return `{ ${Object.entries(one).map(([key, held]) => `${key}: ${said(held)}`).join(', ')} }`;
197
+ return String(one);
198
+ }
@@ -0,0 +1,81 @@
1
+ import ts from 'typescript';
2
+ import type { Finding } from './finding.ts';
3
+ export declare const ROOT: string;
4
+ export declare const TREE: string;
5
+ export declare const THREAD_AT: string;
6
+ export declare const LISTS: readonly ["declares", "derives", "seeds"];
7
+ export interface Row {
8
+ readonly at?: string;
9
+ readonly id?: string;
10
+ readonly describes?: string;
11
+ readonly by?: string;
12
+ readonly runs?: string;
13
+ readonly requires?: readonly string[];
14
+ readonly takes?: readonly string[];
15
+ readonly type: string;
16
+ readonly shape?: ts.Type;
17
+ readonly fields: ReadonlyMap<string, ts.Expression>;
18
+ readonly where: string;
19
+ }
20
+ export interface Pass {
21
+ readonly threaded: ReadonlyMap<string, readonly {
22
+ readonly list: 'declares' | 'derives' | 'seeds';
23
+ readonly by: string;
24
+ readonly row: Row;
25
+ }[]>;
26
+ readonly mentioned: ReadonlyMap<string, readonly string[]>;
27
+ readonly derived: ReadonlyMap<string, Row>;
28
+ readonly stated: ReadonlyMap<string, Row>;
29
+ readonly coined: ReadonlyMap<string, {
30
+ readonly said: readonly string[];
31
+ readonly under: string;
32
+ readonly from: readonly string[];
33
+ }>;
34
+ readonly broken: readonly Finding[];
35
+ readonly findings: readonly Finding[];
36
+ readonly declarations: number;
37
+ readonly rows: number;
38
+ readonly sources: readonly string[];
39
+ }
40
+ export type { Finding };
41
+ export declare function under(pass: Pass, id: string, root: string, seen?: Set<string>): boolean;
42
+ export declare function sources(): readonly string[];
43
+ export declare function configured(): {
44
+ readonly options: ts.CompilerOptions;
45
+ readonly from: string;
46
+ readonly trouble?: string;
47
+ };
48
+ export declare function uncompiled(): readonly Finding[];
49
+ export declare function read(at: string): string | undefined;
50
+ export declare function shapesNamed(): ReadonlyMap<string, readonly string[]>;
51
+ export declare function threading(): ReadonlySet<string>;
52
+ export declare function shapeFields(named: string, inside?: string): readonly {
53
+ readonly name: string;
54
+ readonly required: boolean;
55
+ readonly list: boolean;
56
+ readonly map: boolean;
57
+ readonly worded: boolean;
58
+ readonly guide: string;
59
+ }[];
60
+ export interface Field {
61
+ readonly name: string;
62
+ readonly required: boolean;
63
+ readonly list: boolean;
64
+ readonly map: boolean;
65
+ readonly boolean: boolean;
66
+ readonly worded: boolean;
67
+ readonly guide: string;
68
+ }
69
+ export declare function listShape(at: string, list: string): string | undefined;
70
+ export declare function listFields(at: string, list: string): readonly Field[];
71
+ export declare function rowShape(at: string, list: string): string | undefined;
72
+ interface Held {
73
+ readonly name: string;
74
+ readonly type: string;
75
+ readonly shape: ts.Type;
76
+ readonly node: ts.ObjectLiteralExpression;
77
+ }
78
+ export declare function nodesIn(at: string): readonly Held[];
79
+ export declare function reached(): readonly string[];
80
+ export declare function forget(): void;
81
+ export declare function descend(): Pass;