@aigile/engine 0.2.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-item-features.d.ts +33 -0
- package/dist/action-item-features.d.ts.map +1 -0
- package/dist/action-item-features.js +113 -0
- package/dist/action-item-features.js.map +1 -0
- package/dist/action-items.d.ts +234 -0
- package/dist/action-items.d.ts.map +1 -0
- package/dist/action-items.js +722 -0
- package/dist/action-items.js.map +1 -0
- package/dist/action-sources.d.ts +44 -0
- package/dist/action-sources.d.ts.map +1 -0
- package/dist/action-sources.js +141 -0
- package/dist/action-sources.js.map +1 -0
- package/dist/agent-roles.d.ts +9 -0
- package/dist/agent-roles.d.ts.map +1 -0
- package/dist/agent-roles.js +18 -0
- package/dist/agent-roles.js.map +1 -0
- package/dist/agent-tasks.d.ts +36 -0
- package/dist/agent-tasks.d.ts.map +1 -0
- package/dist/agent-tasks.js +151 -0
- package/dist/agent-tasks.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +26 -6
- package/dist/agents/orchestrator.d.ts.map +1 -1
- package/dist/agents/orchestrator.js +95 -45
- package/dist/agents/orchestrator.js.map +1 -1
- package/dist/agents/spec-analyst.d.ts +81 -13
- package/dist/agents/spec-analyst.d.ts.map +1 -1
- package/dist/agents/spec-analyst.js +350 -89
- package/dist/agents/spec-analyst.js.map +1 -1
- package/dist/ai-service.d.ts +40 -0
- package/dist/ai-service.d.ts.map +1 -1
- package/dist/ai-service.js +94 -9
- package/dist/ai-service.js.map +1 -1
- package/dist/api-tokens.d.ts +67 -0
- package/dist/api-tokens.d.ts.map +1 -0
- package/dist/api-tokens.js +89 -0
- package/dist/api-tokens.js.map +1 -0
- package/dist/attachments/extract.d.ts +26 -0
- package/dist/attachments/extract.d.ts.map +1 -0
- package/dist/attachments/extract.js +160 -0
- package/dist/attachments/extract.js.map +1 -0
- package/dist/attachments/fixtures.d.ts +9 -0
- package/dist/attachments/fixtures.d.ts.map +1 -0
- package/dist/attachments/fixtures.js +58 -0
- package/dist/attachments/fixtures.js.map +1 -0
- package/dist/attachments/service.d.ts +71 -0
- package/dist/attachments/service.d.ts.map +1 -0
- package/dist/attachments/service.js +220 -0
- package/dist/attachments/service.js.map +1 -0
- package/dist/build-service.d.ts +1 -1
- package/dist/build-service.d.ts.map +1 -1
- package/dist/build-service.js +9 -4
- package/dist/build-service.js.map +1 -1
- package/dist/change-events.d.ts +110 -0
- package/dist/change-events.d.ts.map +1 -0
- package/dist/change-events.js +238 -0
- package/dist/change-events.js.map +1 -0
- package/dist/change-sets.d.ts +110 -0
- package/dist/change-sets.d.ts.map +1 -0
- package/dist/change-sets.js +188 -0
- package/dist/change-sets.js.map +1 -0
- package/dist/command-runner.d.ts.map +1 -1
- package/dist/command-runner.js +2 -1
- package/dist/command-runner.js.map +1 -1
- package/dist/conversations.d.ts +2 -1
- package/dist/conversations.d.ts.map +1 -1
- package/dist/conversations.js +1 -1
- package/dist/conversations.js.map +1 -1
- package/dist/data-access.d.ts +9 -2
- package/dist/data-access.d.ts.map +1 -1
- package/dist/data-access.js +38 -6
- package/dist/data-access.js.map +1 -1
- package/dist/decisions.d.ts +56 -0
- package/dist/decisions.d.ts.map +1 -0
- package/dist/decisions.js +76 -0
- package/dist/decisions.js.map +1 -0
- package/dist/deliverables.d.ts +96 -0
- package/dist/deliverables.d.ts.map +1 -0
- package/dist/deliverables.js +344 -0
- package/dist/deliverables.js.map +1 -0
- package/dist/designs.d.ts +30 -0
- package/dist/designs.d.ts.map +1 -0
- package/dist/designs.js +154 -0
- package/dist/designs.js.map +1 -0
- package/dist/git-host.d.ts +10 -0
- package/dist/git-host.d.ts.map +1 -1
- package/dist/git-host.js +30 -2
- package/dist/git-host.js.map +1 -1
- package/dist/grounding.d.ts +9 -0
- package/dist/grounding.d.ts.map +1 -0
- package/dist/grounding.js +12 -0
- package/dist/grounding.js.map +1 -0
- package/dist/index.d.ts +35 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/dist/jira-features.d.ts +142 -0
- package/dist/jira-features.d.ts.map +1 -0
- package/dist/jira-features.js +366 -0
- package/dist/jira-features.js.map +1 -0
- package/dist/milestones.js +1 -1
- package/dist/milestones.js.map +1 -1
- package/dist/pull-request-sync.d.ts.map +1 -1
- package/dist/pull-request-sync.js +10 -6
- package/dist/pull-request-sync.js.map +1 -1
- package/dist/questions.d.ts +100 -10
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +211 -22
- package/dist/questions.js.map +1 -1
- package/dist/related.d.ts +26 -0
- package/dist/related.d.ts.map +1 -0
- package/dist/related.js +64 -0
- package/dist/related.js.map +1 -0
- package/dist/release-gates.d.ts +16 -0
- package/dist/release-gates.d.ts.map +1 -0
- package/dist/release-gates.js +47 -0
- package/dist/release-gates.js.map +1 -0
- package/dist/reviews.d.ts.map +1 -1
- package/dist/reviews.js +4 -3
- package/dist/reviews.js.map +1 -1
- package/dist/router.d.ts +2 -2
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js.map +1 -1
- package/dist/scheduler.d.ts +41 -5
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +109 -7
- package/dist/scheduler.js.map +1 -1
- package/dist/services.d.ts +760 -15
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +402 -20
- package/dist/services.js.map +1 -1
- package/dist/source-sync.d.ts +136 -0
- package/dist/source-sync.d.ts.map +1 -0
- package/dist/source-sync.js +370 -0
- package/dist/source-sync.js.map +1 -0
- package/dist/sources/front-matter.d.ts +20 -0
- package/dist/sources/front-matter.d.ts.map +1 -0
- package/dist/sources/front-matter.js +57 -0
- package/dist/sources/front-matter.js.map +1 -0
- package/dist/sources/git.d.ts +80 -0
- package/dist/sources/git.d.ts.map +1 -0
- package/dist/sources/git.js +338 -0
- package/dist/sources/git.js.map +1 -0
- package/dist/sources/http.d.ts +54 -0
- package/dist/sources/http.d.ts.map +1 -0
- package/dist/sources/http.js +79 -0
- package/dist/sources/http.js.map +1 -0
- package/dist/spec-cache.d.ts +54 -0
- package/dist/spec-cache.d.ts.map +1 -0
- package/dist/spec-cache.js +133 -0
- package/dist/spec-cache.js.map +1 -0
- package/dist/spec-links.d.ts +68 -0
- package/dist/spec-links.d.ts.map +1 -0
- package/dist/spec-links.js +144 -0
- package/dist/spec-links.js.map +1 -0
- package/dist/spec-reader.d.ts +44 -0
- package/dist/spec-reader.d.ts.map +1 -0
- package/dist/spec-reader.js +81 -0
- package/dist/spec-reader.js.map +1 -0
- package/dist/spec-resolver.d.ts +13 -1
- package/dist/spec-resolver.d.ts.map +1 -1
- package/dist/spec-resolver.js +45 -8
- package/dist/spec-resolver.js.map +1 -1
- package/dist/spec-tools.d.ts +10 -0
- package/dist/spec-tools.d.ts.map +1 -0
- package/dist/spec-tools.js +103 -0
- package/dist/spec-tools.js.map +1 -0
- package/dist/task-scope.d.ts +11 -0
- package/dist/task-scope.d.ts.map +1 -0
- package/dist/task-scope.js +11 -0
- package/dist/task-scope.js.map +1 -0
- package/dist/telemetry.d.ts +34 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +72 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/template.d.ts +341 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +142 -0
- package/dist/template.js.map +1 -0
- package/dist/tool-sandbox.d.ts.map +1 -1
- package/dist/tool-sandbox.js +2 -2
- package/dist/tool-sandbox.js.map +1 -1
- package/dist/tracks.d.ts +3 -3
- package/dist/tracks.js +1 -1
- package/dist/tracks.js.map +1 -1
- package/dist/verifier.d.ts.map +1 -1
- package/dist/verifier.js +8 -7
- package/dist/verifier.js.map +1 -1
- package/dist/vscode-connect.d.ts +48 -0
- package/dist/vscode-connect.d.ts.map +1 -0
- package/dist/vscode-connect.js +105 -0
- package/dist/vscode-connect.js.map +1 -0
- package/package.json +14 -3
- package/prompts/agent-task.contract.md +9 -0
- package/prompts/orchestrator.brief.md +17 -0
- package/prompts/orchestrator.contract.md +7 -0
- package/prompts/spec-analyst.brief.md +19 -0
- package/prompts/spec-analyst.contract.md +5 -0
- package/prompts/spec-analyst.sweep.md +2 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { execFile, spawn } from 'node:child_process';
|
|
2
|
+
import { mkdir, rm, stat } from 'node:fs/promises';
|
|
3
|
+
import { basename, join, posix } from 'node:path';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
import { SourceConflictError } from '@aigile/core';
|
|
6
|
+
import { Checkout } from '../checkout.js';
|
|
7
|
+
import { parseRemote } from '../git-host.js';
|
|
8
|
+
import { listOf, parseFrontMatter, titleOf } from './front-matter.js';
|
|
9
|
+
const exec = promisify(execFile);
|
|
10
|
+
/**
|
|
11
|
+
* A Git repository of Markdown as a spec source. Every `*.md` under `path`
|
|
12
|
+
* on `branch` is a document: its external id is the path, its version the
|
|
13
|
+
* last commit that touched it, its author that commit's author, its title the
|
|
14
|
+
* front matter `title` or its first heading. Front matter `organizations`,
|
|
15
|
+
* `projects` and `roles` (ids) replace the defaults for that document. The
|
|
16
|
+
* clone keeps no working tree; a sync is one fetch and reads from the ref,
|
|
17
|
+
* with the same hardening as the Engineer's checkouts.
|
|
18
|
+
*/
|
|
19
|
+
export class GitSpecSource {
|
|
20
|
+
opts;
|
|
21
|
+
kind = 'git';
|
|
22
|
+
id;
|
|
23
|
+
capabilities;
|
|
24
|
+
ref;
|
|
25
|
+
constructor(opts) {
|
|
26
|
+
this.opts = opts;
|
|
27
|
+
this.id = opts.id;
|
|
28
|
+
this.ref = `refs/remotes/origin/${opts.branch}`;
|
|
29
|
+
this.capabilities = { history: true, write: !opts.readOnly };
|
|
30
|
+
}
|
|
31
|
+
/** One file at a commit (the branch's tip when none); null when the commit or the file is not there. */
|
|
32
|
+
async read(externalId, version) {
|
|
33
|
+
if (!isSpecFile(externalId) || (version !== undefined && !/^[0-9a-f]{4,40}$/i.test(version)))
|
|
34
|
+
return null;
|
|
35
|
+
await this.init();
|
|
36
|
+
const at = version ?? (await this.git(['rev-parse', this.ref])).trim();
|
|
37
|
+
try {
|
|
38
|
+
return await this.item(externalId, at);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** The commits that touched a file, newest first. */
|
|
45
|
+
async versions(externalId) {
|
|
46
|
+
if (!isSpecFile(externalId))
|
|
47
|
+
return [];
|
|
48
|
+
await this.init();
|
|
49
|
+
const out = await this.git(['log', '--format=%H%x00%an%x00%ae%x00%aI%x00%s%x1e', this.ref, '--', externalId]);
|
|
50
|
+
return out
|
|
51
|
+
.split('\x1e')
|
|
52
|
+
.map((r) => r.trim())
|
|
53
|
+
.filter(Boolean)
|
|
54
|
+
.map((r) => {
|
|
55
|
+
const [version = '', name = '', email = '', date = '', subject = ''] = r.split('\0');
|
|
56
|
+
return { version, timestamp: date && !Number.isNaN(Date.parse(date)) ? new Date(date).toISOString() : '', author: name ? { name, email: email || null } : null, message: subject };
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** Save one document: one commit (see `writeMany`). */
|
|
60
|
+
async write(doc) {
|
|
61
|
+
const [result] = await this.writeMany([doc], doc.message, doc.author);
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Save several documents as one commit on the branch and push it, without
|
|
66
|
+
* a working tree: each blob is written, the tree built from the branch's
|
|
67
|
+
* tip with a temporary index, the commit made with the person as author
|
|
68
|
+
* and the installation as committer, the ref pushed. A document whose
|
|
69
|
+
* file moved past its `baseVersion` is a conflict; a push that loses the
|
|
70
|
+
* race is retried once from the new tip when none of the files moved.
|
|
71
|
+
*/
|
|
72
|
+
async writeMany(docs, message, author) {
|
|
73
|
+
if (this.opts.readOnly)
|
|
74
|
+
throw new Error(`source ${this.id} is read-only`);
|
|
75
|
+
if (docs.length === 0)
|
|
76
|
+
return [];
|
|
77
|
+
await this.init();
|
|
78
|
+
await this.git(['fetch', '--quiet', 'origin', `+refs/heads/${this.opts.branch}:${this.ref}`]);
|
|
79
|
+
const paths = [];
|
|
80
|
+
for (const doc of docs) {
|
|
81
|
+
const externalId = doc.externalId ?? (await this.freshPath(doc.title, paths));
|
|
82
|
+
if (!isSpecFile(externalId))
|
|
83
|
+
throw new Error(`${externalId} is not a Markdown file under the source's path`);
|
|
84
|
+
if (doc.remove && !doc.externalId)
|
|
85
|
+
throw new Error('a removal names the document');
|
|
86
|
+
paths.push(externalId);
|
|
87
|
+
}
|
|
88
|
+
const attempt = async () => {
|
|
89
|
+
const tip = (await this.git(['rev-parse', this.ref])).trim();
|
|
90
|
+
for (const [k, doc] of docs.entries()) {
|
|
91
|
+
if (!doc.externalId)
|
|
92
|
+
continue;
|
|
93
|
+
const last = (await this.git(['log', '-1', '--format=%H', tip, '--', paths[k]])).trim();
|
|
94
|
+
if (doc.baseVersion && last && last !== doc.baseVersion)
|
|
95
|
+
throw new SourceConflictError(paths[k], doc.baseVersion, last);
|
|
96
|
+
}
|
|
97
|
+
const index = join(this.opts.dir, '.git', `aigile-index-${process.pid}-${Date.now()}`);
|
|
98
|
+
const env = { GIT_INDEX_FILE: index };
|
|
99
|
+
try {
|
|
100
|
+
await this.git(['read-tree', tip], env);
|
|
101
|
+
for (const [k, doc] of docs.entries()) {
|
|
102
|
+
const path = paths[k];
|
|
103
|
+
if (doc.remove) {
|
|
104
|
+
await this.git(['update-index', '--force-remove', '--', path], env);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const current = doc.externalId ? await this.show(tip, path) : null;
|
|
108
|
+
const blob = (await this.gitStdin(['hash-object', '-w', '--stdin'], withFrontMatter(current, doc.title, doc.content))).trim();
|
|
109
|
+
await this.git(['update-index', '--add', '--cacheinfo', `100644,${blob},${path}`], env);
|
|
110
|
+
}
|
|
111
|
+
const tree = (await this.git(['write-tree'], env)).trim();
|
|
112
|
+
const committer = this.opts.committer ?? { name: 'aigile', email: 'aigile@localhost' };
|
|
113
|
+
const who = author?.email ? { name: author.name, email: author.email } : committer;
|
|
114
|
+
const text = author && !author.email ? `${message}\n\nAuthored-by: ${author.name}` : message;
|
|
115
|
+
const commit = (await this.gitStdin(['commit-tree', tree, '-p', tip], text, { GIT_AUTHOR_NAME: who.name, GIT_AUTHOR_EMAIL: who.email, GIT_COMMITTER_NAME: committer.name, GIT_COMMITTER_EMAIL: committer.email })).trim();
|
|
116
|
+
await this.git(['push', '--quiet', 'origin', `${commit}:refs/heads/${this.opts.branch}`]);
|
|
117
|
+
await this.git(['update-ref', this.ref, commit]);
|
|
118
|
+
return paths.map((externalId) => ({ externalId, version: commit, url: this.urlFor(externalId) }));
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
await rm(index, { force: true });
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
try {
|
|
125
|
+
return await attempt();
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
if (err instanceof SourceConflictError || !/rejected|non-fast-forward|fetch first/i.test(String(err)))
|
|
129
|
+
throw err;
|
|
130
|
+
await this.git(['fetch', '--quiet', 'origin', `+refs/heads/${this.opts.branch}:${this.ref}`]);
|
|
131
|
+
return attempt();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async show(at, file) {
|
|
135
|
+
try {
|
|
136
|
+
return await this.git(['show', `${at}:${file}`]);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** A new file's path under the source's path, from the title; a suffix when it is taken (or already in this batch). */
|
|
143
|
+
async freshPath(title, taken = []) {
|
|
144
|
+
const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 64) || 'spec';
|
|
145
|
+
const prefix = this.prefix();
|
|
146
|
+
const tip = (await this.git(['rev-parse', this.ref])).trim();
|
|
147
|
+
for (let n = 0;; n++) {
|
|
148
|
+
const candidate = `${prefix ? `${prefix}/` : ''}${slug}${n ? `-${n + 1}` : ''}.md`;
|
|
149
|
+
if (!taken.includes(candidate) && (await this.show(tip, candidate)) === null)
|
|
150
|
+
return candidate;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async init() {
|
|
154
|
+
if (await this.cloned())
|
|
155
|
+
return;
|
|
156
|
+
await mkdir(this.opts.dir, { recursive: true });
|
|
157
|
+
await this.git(['clone', '--no-checkout', '--single-branch', '--branch', this.opts.branch, '--', this.opts.url, '.']);
|
|
158
|
+
}
|
|
159
|
+
async changes(cursor) {
|
|
160
|
+
await this.init();
|
|
161
|
+
await this.git(['fetch', '--quiet', '--prune', 'origin', `+refs/heads/${this.opts.branch}:${this.ref}`]);
|
|
162
|
+
const head = (await this.git(['rev-parse', this.ref])).trim();
|
|
163
|
+
if (cursor === head)
|
|
164
|
+
return { items: [], removed: [], full: false, cursor: head };
|
|
165
|
+
const prefix = this.prefix();
|
|
166
|
+
const pathspec = prefix ? ['--', prefix] : [];
|
|
167
|
+
let full = cursor === null;
|
|
168
|
+
let changed = [];
|
|
169
|
+
let removed = [];
|
|
170
|
+
if (!full) {
|
|
171
|
+
try {
|
|
172
|
+
const diff = await this.git(['diff', '--name-status', '-z', '--no-renames', cursor, head, ...pathspec]);
|
|
173
|
+
const parts = diff.split('\0');
|
|
174
|
+
for (let i = 0; i + 1 < parts.length; i += 2) {
|
|
175
|
+
const status = parts[i];
|
|
176
|
+
const file = parts[i + 1];
|
|
177
|
+
if (!status || !file || !isSpecFile(file))
|
|
178
|
+
continue;
|
|
179
|
+
if (status.startsWith('D'))
|
|
180
|
+
removed.push(file);
|
|
181
|
+
else
|
|
182
|
+
changed.push(file);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// The cursor is not in this history any more (a rewrite, a re-clone): take everything.
|
|
187
|
+
full = true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const files = (await this.git(['ls-tree', '-r', '-z', '--name-only', head, ...pathspec])).split('\0').filter((f) => f && isSpecFile(f));
|
|
191
|
+
// An index file coming or going moves its folder's documents in the outline: list everything again.
|
|
192
|
+
if (!full && [...changed, ...removed].some(isIndexFile))
|
|
193
|
+
full = true;
|
|
194
|
+
if (full) {
|
|
195
|
+
changed = files;
|
|
196
|
+
removed = [];
|
|
197
|
+
}
|
|
198
|
+
const all = new Set(files);
|
|
199
|
+
const items = [];
|
|
200
|
+
for (const file of changed)
|
|
201
|
+
items.push(await this.item(file, head, all));
|
|
202
|
+
return { items, removed, full, cursor: head };
|
|
203
|
+
}
|
|
204
|
+
async item(file, head, files) {
|
|
205
|
+
const [text, log] = await Promise.all([this.git(['show', `${head}:${file}`]), this.git(['log', '-1', '--format=%H%x00%an%x00%ae%x00%aI', head, '--', file])]);
|
|
206
|
+
const [sha, name, email, date] = log.trim().split('\0');
|
|
207
|
+
const fm = parseFrontMatter(text);
|
|
208
|
+
const own = fm.present && (fm.data.organizations !== undefined || fm.data.projects !== undefined || fm.data.roles !== undefined);
|
|
209
|
+
return {
|
|
210
|
+
externalId: file,
|
|
211
|
+
title: titleOf(fm, basename(file).replace(/\.(md|markdown)$/i, '')),
|
|
212
|
+
content: fm.body.replace(/^\s*\n/, ''),
|
|
213
|
+
author: name ? { name, email: email || null } : null,
|
|
214
|
+
version: sha || head,
|
|
215
|
+
updatedAt: date && !Number.isNaN(Date.parse(date)) ? new Date(date).toISOString() : new Date().toISOString(),
|
|
216
|
+
url: this.urlFor(file),
|
|
217
|
+
mappings: own
|
|
218
|
+
? { organizationIds: listOf(fm.data.organizations) ?? [], projectIds: listOf(fm.data.projects) ?? [], roleIds: listOf(fm.data.roles) ?? [] }
|
|
219
|
+
: null,
|
|
220
|
+
...(files ? { parentExternalId: outlineParent(file, files), order: orderOf(fm.data.order) } : {}),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/** The document's page on its host, for the "edit at the source" link; null for a host aigile does not know. */
|
|
224
|
+
urlFor(file) {
|
|
225
|
+
const remote = parseRemote(this.opts.url);
|
|
226
|
+
if (!remote)
|
|
227
|
+
return null;
|
|
228
|
+
const host = remote.hostName ?? (remote.host === 'bitbucket' ? 'bitbucket.org' : remote.host === 'github' ? 'github.com' : 'gitlab.com');
|
|
229
|
+
const branch = encodeURIComponent(this.opts.branch);
|
|
230
|
+
const path = file.split('/').map(encodeURIComponent).join('/');
|
|
231
|
+
switch (remote.host) {
|
|
232
|
+
case 'github':
|
|
233
|
+
return `https://${host}/${remote.owner}/${remote.repo}/blob/${branch}/${path}`;
|
|
234
|
+
case 'bitbucket':
|
|
235
|
+
return `https://${host}/${remote.owner}/${remote.repo}/src/${branch}/${path}`;
|
|
236
|
+
case 'gitlab':
|
|
237
|
+
return `https://${host}/${remote.owner}/${remote.repo}/-/blob/${branch}/${path}`;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
prefix() {
|
|
241
|
+
const p = posix.normalize(this.opts.path.replace(/\\/g, '/')).replace(/^(\.\/|\/)+/, '').replace(/\/+$/, '');
|
|
242
|
+
return p === '.' || p === '' ? '' : p;
|
|
243
|
+
}
|
|
244
|
+
async cloned() {
|
|
245
|
+
try {
|
|
246
|
+
return (await stat(`${this.opts.dir}/.git`)).isDirectory();
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
async git(args, extra = {}) {
|
|
253
|
+
const { stdout } = await exec('git', [...Checkout.SAFE, ...args], { cwd: this.opts.dir, env: this.env(extra), maxBuffer: 64 * 1024 * 1024 });
|
|
254
|
+
return stdout;
|
|
255
|
+
}
|
|
256
|
+
gitStdin(args, input, extra = {}) {
|
|
257
|
+
return new Promise((resolve, reject) => {
|
|
258
|
+
const child = spawn('git', [...Checkout.SAFE, ...args], { cwd: this.opts.dir, env: this.env(extra) });
|
|
259
|
+
let out = '';
|
|
260
|
+
let err = '';
|
|
261
|
+
child.stdout.on('data', (d) => (out += d.toString()));
|
|
262
|
+
child.stderr.on('data', (d) => (err += d.toString()));
|
|
263
|
+
child.on('error', reject);
|
|
264
|
+
child.on('close', (code) => (code === 0 ? resolve(out) : reject(new Error(err.trim() || `git ${args[0]} exited ${code}`))));
|
|
265
|
+
child.stdin.end(input);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
env(extra) {
|
|
269
|
+
const env = { ...process.env, GIT_TERMINAL_PROMPT: '0', GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: '/dev/null', ...(this.opts.env ?? {}), ...extra };
|
|
270
|
+
delete env.GIT_CONFIG_COUNT;
|
|
271
|
+
return env;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/** The document's text for a save: the existing front matter kept with its title updated, or none when the file had none and the title is the first heading. */
|
|
275
|
+
export function withFrontMatter(current, title, content) {
|
|
276
|
+
const body = content.replace(/\s+$/, '') + '\n';
|
|
277
|
+
if (current === null) {
|
|
278
|
+
const heading = body.match(/^\s*#\s+(.+?)\s*#*\s*$/m)?.[1]?.trim();
|
|
279
|
+
return heading === title ? body : `---\ntitle: ${yamlString(title)}\n---\n\n${body}`;
|
|
280
|
+
}
|
|
281
|
+
const m = current.match(/^(?:\uFEFF)?---[ \t]*\r?\n([\s\S]*?)\r?\n?---[ \t]*(?:\r?\n|$)/);
|
|
282
|
+
if (!m) {
|
|
283
|
+
const heading = body.match(/^\s*#\s+(.+?)\s*#*\s*$/m)?.[1]?.trim();
|
|
284
|
+
return heading === title ? body : `---\ntitle: ${yamlString(title)}\n---\n\n${body}`;
|
|
285
|
+
}
|
|
286
|
+
const lines = m[1].split(/\r?\n/);
|
|
287
|
+
let seen = false;
|
|
288
|
+
const kept = lines.map((l) => {
|
|
289
|
+
if (/^title\s*:/.test(l)) {
|
|
290
|
+
seen = true;
|
|
291
|
+
return `title: ${yamlString(title)}`;
|
|
292
|
+
}
|
|
293
|
+
return l;
|
|
294
|
+
});
|
|
295
|
+
if (!seen)
|
|
296
|
+
kept.unshift(`title: ${yamlString(title)}`);
|
|
297
|
+
return `---\n${kept.join('\n')}\n---\n\n${body}`;
|
|
298
|
+
}
|
|
299
|
+
function yamlString(s) {
|
|
300
|
+
return /^[A-Za-z0-9][^:#[\]{}&*!|>'"%@`,]*$/.test(s) ? s : JSON.stringify(s);
|
|
301
|
+
}
|
|
302
|
+
/** A folder's own document: its `index.md`, else its `README.md` (any case). */
|
|
303
|
+
function isIndexFile(file) {
|
|
304
|
+
return /^(index|readme)\.(md|markdown)$/i.test(posix.basename(file));
|
|
305
|
+
}
|
|
306
|
+
/** The index file of a folder ('' for the top), preferring `index` over `README`. */
|
|
307
|
+
function indexIn(dir, files) {
|
|
308
|
+
const inDir = [...files].filter((f) => posix.dirname(f) === (dir || '.') && isIndexFile(f));
|
|
309
|
+
return inDir.find((f) => /^index\./i.test(posix.basename(f))) ?? inDir[0] ?? null;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Where a document sits in the outline (documentation/sources.md "Outlines"):
|
|
313
|
+
* a file sits under its folder's index file, an index file under the index of
|
|
314
|
+
* the nearest folder above that has one; a folder without one passes its
|
|
315
|
+
* documents up. Null at the top.
|
|
316
|
+
*/
|
|
317
|
+
export function outlineParent(file, files) {
|
|
318
|
+
const own = posix.dirname(file) === '.' ? '' : posix.dirname(file);
|
|
319
|
+
let dir = own;
|
|
320
|
+
if (indexIn(own, files) === file)
|
|
321
|
+
dir = own === '' ? null : posix.dirname(own) === '.' ? '' : posix.dirname(own);
|
|
322
|
+
while (dir !== null) {
|
|
323
|
+
const index = indexIn(dir, files);
|
|
324
|
+
if (index && index !== file)
|
|
325
|
+
return index;
|
|
326
|
+
dir = dir === '' ? null : posix.dirname(dir) === '.' ? '' : posix.dirname(dir);
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
/** A front-matter `order:` as a number, or null. */
|
|
331
|
+
function orderOf(value) {
|
|
332
|
+
const n = typeof value === 'string' ? Number(value) : NaN;
|
|
333
|
+
return Number.isFinite(n) ? n : null;
|
|
334
|
+
}
|
|
335
|
+
function isSpecFile(file) {
|
|
336
|
+
return /\.(md|markdown)$/i.test(file) && !file.split('/').some((part) => part.startsWith('.'));
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/sources/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAqBjC;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IAMK;IALpB,IAAI,GAAG,KAAK,CAAC;IACb,EAAE,CAAS;IACX,YAAY,CAAqB;IACzB,GAAG,CAAS;IAE7B,YAA6B,IAA0B;QAA1B,SAAI,GAAJ,IAAI,CAAsB;QACrD,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,GAAG,GAAG,uBAAuB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChD,IAAI,CAAC,YAAY,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAA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C,CAAC,CAAC,CAAC,IAAI,CAAC;AACvC,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { SourceChanges, SpecSource } from '@aigile/core';
|
|
2
|
+
export interface HttpSpecSourceOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
url: string;
|
|
5
|
+
token: string | undefined;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
fetchImpl?: typeof fetch;
|
|
8
|
+
}
|
|
9
|
+
/** What a service hands the HTTP source: a document in aigile's own contract. */
|
|
10
|
+
export interface HttpDocument {
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
/** Markdown. */
|
|
14
|
+
content: string;
|
|
15
|
+
/** The document's version; when absent, a hash of the title and content stands in. */
|
|
16
|
+
version?: string | number;
|
|
17
|
+
updatedAt?: string;
|
|
18
|
+
author?: {
|
|
19
|
+
name: string;
|
|
20
|
+
email?: string | null;
|
|
21
|
+
} | null;
|
|
22
|
+
url?: string | null;
|
|
23
|
+
organizations?: string[];
|
|
24
|
+
projects?: string[];
|
|
25
|
+
roles?: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Any service as a spec source over one endpoint (documentation/sources.md
|
|
29
|
+
* "The HTTP source"). `GET url` (with `?since=<cursor>` after the first sync)
|
|
30
|
+
* returns either a JSON array of documents, taken as the whole source, or
|
|
31
|
+
* `{ items, removed?, cursor?, full? }` when the service can say what changed.
|
|
32
|
+
* A bearer token from the environment, extra headers from the config.
|
|
33
|
+
*/
|
|
34
|
+
export declare class HttpSpecSource implements SpecSource {
|
|
35
|
+
private readonly opts;
|
|
36
|
+
readonly kind = "http";
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly capabilities: import("@aigile/core").SourceCapabilities;
|
|
39
|
+
private readonly fetchImpl;
|
|
40
|
+
constructor(opts: HttpSpecSourceOptions);
|
|
41
|
+
init(): Promise<void>;
|
|
42
|
+
changes(cursor: string | null): Promise<SourceChanges>;
|
|
43
|
+
private item;
|
|
44
|
+
}
|
|
45
|
+
/** A source kind that is designed (its config validates) but not built: it reports itself once and mirrors nothing. */
|
|
46
|
+
export declare class StubSpecSource implements SpecSource {
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly kind: string;
|
|
49
|
+
readonly capabilities: import("@aigile/core").SourceCapabilities;
|
|
50
|
+
constructor(id: string, kind: string);
|
|
51
|
+
init(): Promise<void>;
|
|
52
|
+
changes(): Promise<SourceChanges>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/sources/http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAc,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1E,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACxD,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;GAMG;AACH,qBAAa,cAAe,YAAW,UAAU;IAMnC,OAAO,CAAC,QAAQ,CAAC,IAAI;IALjC,QAAQ,CAAC,IAAI,UAAU;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,YAAY,4CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;gBAEZ,IAAI,EAAE,qBAAqB;IAKlD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAErB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC;IAkB5D,OAAO,CAAC,IAAI;CAmBb;AAED,uHAAuH;AACvH,qBAAa,cAAe,YAAW,UAAU;IAG7C,QAAQ,CAAC,EAAE,EAAE,MAAM;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAHvB,QAAQ,CAAC,YAAY,4CAAa;gBAEvB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM;IAEjB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAGrB,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;CAGxC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { SYNC_ONLY } from '@aigile/core';
|
|
3
|
+
/**
|
|
4
|
+
* Any service as a spec source over one endpoint (documentation/sources.md
|
|
5
|
+
* "The HTTP source"). `GET url` (with `?since=<cursor>` after the first sync)
|
|
6
|
+
* returns either a JSON array of documents, taken as the whole source, or
|
|
7
|
+
* `{ items, removed?, cursor?, full? }` when the service can say what changed.
|
|
8
|
+
* A bearer token from the environment, extra headers from the config.
|
|
9
|
+
*/
|
|
10
|
+
export class HttpSpecSource {
|
|
11
|
+
opts;
|
|
12
|
+
kind = 'http';
|
|
13
|
+
id;
|
|
14
|
+
capabilities = SYNC_ONLY;
|
|
15
|
+
fetchImpl;
|
|
16
|
+
constructor(opts) {
|
|
17
|
+
this.opts = opts;
|
|
18
|
+
this.id = opts.id;
|
|
19
|
+
this.fetchImpl = opts.fetchImpl ?? fetch;
|
|
20
|
+
}
|
|
21
|
+
async init() { }
|
|
22
|
+
async changes(cursor) {
|
|
23
|
+
const url = new URL(this.opts.url);
|
|
24
|
+
if (cursor)
|
|
25
|
+
url.searchParams.set('since', cursor);
|
|
26
|
+
const res = await this.fetchImpl(url, { headers: { Accept: 'application/json', ...(this.opts.headers ?? {}), ...(this.opts.token ? { Authorization: `Bearer ${this.opts.token}` } : {}) } });
|
|
27
|
+
if (!res.ok)
|
|
28
|
+
throw new Error(`HTTP source ${this.id}: ${url.pathname} returned HTTP ${res.status}`);
|
|
29
|
+
const body = (await res.json());
|
|
30
|
+
const envelope = Array.isArray(body) ? { items: body, full: true } : body;
|
|
31
|
+
if (!Array.isArray(envelope.items))
|
|
32
|
+
throw new Error(`HTTP source ${this.id}: the response is neither an array of documents nor { items: [...] }`);
|
|
33
|
+
const items = envelope.items.map((d, i) => this.item(d, i));
|
|
34
|
+
const full = Array.isArray(body) ? true : envelope.full === undefined ? !cursor : Boolean(envelope.full);
|
|
35
|
+
return {
|
|
36
|
+
items,
|
|
37
|
+
removed: Array.isArray(envelope.removed) ? envelope.removed.filter((r) => typeof r === 'string') : [],
|
|
38
|
+
full,
|
|
39
|
+
cursor: typeof envelope.cursor === 'string' && envelope.cursor ? envelope.cursor : null,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
item(raw, index) {
|
|
43
|
+
const d = (raw ?? {});
|
|
44
|
+
const id = d.id !== undefined && d.id !== null ? String(d.id) : '';
|
|
45
|
+
if (!id || typeof d.title !== 'string' || !d.title.trim())
|
|
46
|
+
throw new Error(`HTTP source ${this.id}: document ${index} needs an id and a title`);
|
|
47
|
+
const content = typeof d.content === 'string' ? d.content : '';
|
|
48
|
+
const version = d.version !== undefined && d.version !== null && String(d.version) ? String(d.version) : createHash('sha256').update(`${d.title}\0${content}`).digest('hex').slice(0, 16);
|
|
49
|
+
const own = d.organizations !== undefined || d.projects !== undefined || d.roles !== undefined;
|
|
50
|
+
const list = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === 'string') : []);
|
|
51
|
+
return {
|
|
52
|
+
externalId: id,
|
|
53
|
+
title: d.title.trim(),
|
|
54
|
+
content,
|
|
55
|
+
author: d.author && typeof d.author.name === 'string' && d.author.name ? { name: d.author.name, email: typeof d.author.email === 'string' && d.author.email ? d.author.email : null } : null,
|
|
56
|
+
version,
|
|
57
|
+
updatedAt: typeof d.updatedAt === 'string' && !Number.isNaN(Date.parse(d.updatedAt)) ? new Date(d.updatedAt).toISOString() : new Date().toISOString(),
|
|
58
|
+
url: typeof d.url === 'string' && d.url ? d.url : null,
|
|
59
|
+
mappings: own ? { organizationIds: list(d.organizations), projectIds: list(d.projects), roleIds: list(d.roles) } : null,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** A source kind that is designed (its config validates) but not built: it reports itself once and mirrors nothing. */
|
|
64
|
+
export class StubSpecSource {
|
|
65
|
+
id;
|
|
66
|
+
kind;
|
|
67
|
+
capabilities = SYNC_ONLY;
|
|
68
|
+
constructor(id, kind) {
|
|
69
|
+
this.id = id;
|
|
70
|
+
this.kind = kind;
|
|
71
|
+
}
|
|
72
|
+
async init() {
|
|
73
|
+
throw new Error(`the ${this.kind} source is designed but not built yet (documentation/plugins.md "Planned"); nothing is mirrored from ${this.id}`);
|
|
74
|
+
}
|
|
75
|
+
async changes() {
|
|
76
|
+
return { items: [], removed: [], full: false, cursor: null };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/sources/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA0BzC;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IAMI;IALpB,IAAI,GAAG,MAAM,CAAC;IACd,EAAE,CAAS;IACX,YAAY,GAAG,SAAS,CAAC;IACjB,SAAS,CAAe;IAEzC,YAA6B,IAA2B;QAA3B,SAAI,GAAJ,IAAI,CAAuB;QACtD,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,IAAI,KAAmB,CAAC;IAE9B,KAAK,CAAC,OAAO,CAAC,MAAqB;QACjC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,MAAM;YAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAClD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC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I,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;SACxH,CAAC;IACJ,CAAC;CACF;AAED,uHAAuH;AACvH,MAAM,OAAO,cAAc;IAGd;IACA;IAHF,YAAY,GAAG,SAAS,CAAC;IAClC,YACW,EAAU,EACV,IAAY;QADZ,OAAE,GAAF,EAAE,CAAQ;QACV,SAAI,GAAJ,IAAI,CAAQ;IACpB,CAAC;IACJ,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,CAAC,IAAI,wGAAwG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACrJ,CAAC;IACD,KAAK,CAAC,OAAO;QACX,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DataStore, SpecCache } from '@aigile/core';
|
|
2
|
+
/**
|
|
3
|
+
* The spec cache (documentation/sources.md "The model"): the versions read
|
|
4
|
+
* from the sources, disposable. Three implementations need no dependency:
|
|
5
|
+
* memory (one process, bounded), a directory (a volume: EFS, a PVC) and the
|
|
6
|
+
* datastore itself (a `cache` collection, so one configuration serves both;
|
|
7
|
+
* every entry is a write there, which a git datastore records as a commit,
|
|
8
|
+
* so prefer memory or a directory beside one). Redis is its own package.
|
|
9
|
+
*/
|
|
10
|
+
/** In one process, newest-used last; the oldest goes when the bound is reached. */
|
|
11
|
+
export declare class MemorySpecCache implements SpecCache {
|
|
12
|
+
private readonly maxEntries;
|
|
13
|
+
readonly id = "memory";
|
|
14
|
+
private readonly entries;
|
|
15
|
+
constructor(maxEntries?: number);
|
|
16
|
+
init(): Promise<void>;
|
|
17
|
+
get<T>(key: string): Promise<T | null>;
|
|
18
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
19
|
+
delete(key: string): Promise<void>;
|
|
20
|
+
keys(prefix: string): Promise<string[]>;
|
|
21
|
+
clear(prefix?: string): Promise<void>;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/** One JSON file per entry under a directory; the key is encoded so any key is a file name. */
|
|
25
|
+
export declare class FileSpecCache implements SpecCache {
|
|
26
|
+
private readonly dir;
|
|
27
|
+
readonly id = "file";
|
|
28
|
+
constructor(dir: string);
|
|
29
|
+
init(): Promise<void>;
|
|
30
|
+
private file;
|
|
31
|
+
get<T>(key: string): Promise<T | null>;
|
|
32
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
33
|
+
delete(key: string): Promise<void>;
|
|
34
|
+
keys(prefix: string): Promise<string[]>;
|
|
35
|
+
clear(prefix?: string): Promise<void>;
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/** The datastore's `cache` collection; entries are records whose id is the encoded key. */
|
|
39
|
+
export declare class DatastoreSpecCache implements SpecCache {
|
|
40
|
+
private readonly store;
|
|
41
|
+
readonly id = "datastore";
|
|
42
|
+
constructor(store: DataStore);
|
|
43
|
+
init(): Promise<void>;
|
|
44
|
+
get<T>(key: string): Promise<T | null>;
|
|
45
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
46
|
+
delete(key: string): Promise<void>;
|
|
47
|
+
keys(prefix: string): Promise<string[]>;
|
|
48
|
+
clear(prefix?: string): Promise<void>;
|
|
49
|
+
close(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
/** A key as a safe file or record name (base64url), and back. */
|
|
52
|
+
export declare function encodeKey(key: string): string;
|
|
53
|
+
export declare function decodeKey(encoded: string): string;
|
|
54
|
+
//# sourceMappingURL=spec-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-cache.d.ts","sourceRo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