@sanity/ailf 4.0.3 → 4.0.5
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/orchestration/load-pipeline-tasks.d.ts +6 -0
- package/dist/orchestration/load-pipeline-tasks.js +7 -2
- package/dist/orchestration/steps/fetch-docs-step.js +10 -4
- package/dist/orchestration/steps/generate-configs-step.d.ts +6 -5
- package/dist/orchestration/steps/generate-configs-step.js +29 -13
- package/package.json +1 -1
|
@@ -22,6 +22,12 @@ export interface LoadPipelineTasksOptions {
|
|
|
22
22
|
mode: string;
|
|
23
23
|
/** Optional extra directory for repo-based tasks (--repo-tasks-path) */
|
|
24
24
|
repoTasksPath?: string;
|
|
25
|
+
/**
|
|
26
|
+
* When `"repo"`, load ONLY from `repoTasksPath` and skip the AILF
|
|
27
|
+
* bundled `tasks/${mode}/` directory. Mirrors the composition-root
|
|
28
|
+
* contract for `taskSourceType: "repo"` (see composition-root.ts).
|
|
29
|
+
*/
|
|
30
|
+
taskSourceType?: "content-lake" | "repo";
|
|
25
31
|
}
|
|
26
32
|
/**
|
|
27
33
|
* Load task definitions from the filesystem, matching the pipeline's
|
|
@@ -26,8 +26,13 @@ import { resolveVendoredSubdir } from "../pipeline/compiler/config-loader.js";
|
|
|
26
26
|
* match the requested mode are excluded.
|
|
27
27
|
*/
|
|
28
28
|
export async function loadPipelineTasks(opts) {
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
const dirs = [];
|
|
30
|
+
if (opts.taskSourceType !== "repo") {
|
|
31
|
+
dirs.push(resolveVendoredSubdir(opts.rootDir, `tasks/${opts.mode}`));
|
|
32
|
+
}
|
|
33
|
+
else if (!opts.repoTasksPath) {
|
|
34
|
+
throw new Error('taskSourceType "repo" requires repoTasksPath to be set (no AILF defaults loaded in repo-only mode)');
|
|
35
|
+
}
|
|
31
36
|
if (opts.repoTasksPath) {
|
|
32
37
|
const repoDir = resolve(opts.repoTasksPath);
|
|
33
38
|
if (!dirs.includes(repoDir)) {
|
|
@@ -34,11 +34,16 @@ export class FetchDocsStep {
|
|
|
34
34
|
// a mismatch where configs reference context files that were never
|
|
35
35
|
// fetched.
|
|
36
36
|
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
37
|
+
// Adapter path: ctx.taskSource handles both content-lake and repo modes.
|
|
38
|
+
// The composition root wires the right adapter (ContentLakeTaskSource
|
|
39
|
+
// or RepoTaskSource) per taskSourceType. RepoTaskSource loads BOTH
|
|
40
|
+
// .yaml and .task.ts files — necessary for external-consumer evals
|
|
41
|
+
// that materialize inline tasks as YAML (W0148).
|
|
42
|
+
// Filesystem path: load from .task.ts files (legacy unset path —
|
|
43
|
+
// AILF defaults from tasks/${mode}/ + optional repoTasksPath augment).
|
|
40
44
|
let allTasks;
|
|
41
|
-
if (ctx.config.taskSourceType === "content-lake"
|
|
45
|
+
if (ctx.config.taskSourceType === "content-lake" ||
|
|
46
|
+
ctx.config.taskSourceType === "repo") {
|
|
42
47
|
const filter = {
|
|
43
48
|
...(ctx.config.areas?.length ? { areas: ctx.config.areas } : {}),
|
|
44
49
|
...(ctx.config.tasks?.length ? { taskIds: ctx.config.tasks } : {}),
|
|
@@ -51,6 +56,7 @@ export class FetchDocsStep {
|
|
|
51
56
|
rootDir: ctx.config.rootDir,
|
|
52
57
|
mode: ctx.config.mode,
|
|
53
58
|
repoTasksPath: ctx.config.repoTasksPath,
|
|
59
|
+
taskSourceType: ctx.config.taskSourceType,
|
|
54
60
|
});
|
|
55
61
|
}
|
|
56
62
|
// Bridge: narrow to literacy tasks for canonical doc access
|
|
@@ -19,13 +19,14 @@ export declare class GenerateConfigsStep implements PipelineStep {
|
|
|
19
19
|
private compileSingleMode;
|
|
20
20
|
private loadTasks;
|
|
21
21
|
/**
|
|
22
|
-
* Load tasks
|
|
22
|
+
* Load tasks via ctx.taskSource (the composition-root-wired adapter).
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* Used for both `taskSourceType === "content-lake"` (ContentLakeTaskSource)
|
|
25
|
+
* and `taskSourceType === "repo"` (RepoTaskSource). Filtering by
|
|
26
|
+
* area/task/tag is delegated to the adapter — ContentLakeTaskSource
|
|
27
|
+
* pushes it into the GROQ query, RepoTaskSource applies it in-memory.
|
|
27
28
|
*/
|
|
28
|
-
private
|
|
29
|
+
private loadTasksFromAdapter;
|
|
29
30
|
/**
|
|
30
31
|
* Load tasks from filesystem .task.ts files.
|
|
31
32
|
*
|
|
@@ -209,23 +209,30 @@ export class GenerateConfigsStep {
|
|
|
209
209
|
// Task loading — unified for all modes
|
|
210
210
|
// ---------------------------------------------------------------------------
|
|
211
211
|
async loadTasks(ctx, mode, state) {
|
|
212
|
-
//
|
|
213
|
-
//
|
|
214
|
-
// Studio-owned
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
// Adapter path — use ctx.taskSource. The composition root wires the
|
|
213
|
+
// right adapter for each taskSourceType:
|
|
214
|
+
// - "content-lake" → ContentLakeTaskSource (Studio-owned ailf.task docs)
|
|
215
|
+
// - "repo" → RepoTaskSource (loads .yaml AND .task.ts from repoTasksPath)
|
|
216
|
+
// Routing both through ctx.taskSource keeps the orchestration step
|
|
217
|
+
// file-format-agnostic (W0148: external-consumer evals materialize
|
|
218
|
+
// inline tasks as .yaml, which loadPipelineTasks can't read).
|
|
219
|
+
if (ctx.config.taskSourceType === "content-lake" ||
|
|
220
|
+
ctx.config.taskSourceType === "repo") {
|
|
221
|
+
return this.loadTasksFromAdapter(ctx, state);
|
|
217
222
|
}
|
|
218
|
-
// Filesystem path — load from .task.ts files (
|
|
223
|
+
// Filesystem path — load from .task.ts files (legacy unset path:
|
|
224
|
+
// AILF defaults from tasks/${mode}/ + optional repoTasksPath augment).
|
|
219
225
|
return this.loadTasksFromFilesystem(ctx, mode, state);
|
|
220
226
|
}
|
|
221
227
|
/**
|
|
222
|
-
* Load tasks
|
|
228
|
+
* Load tasks via ctx.taskSource (the composition-root-wired adapter).
|
|
223
229
|
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
230
|
+
* Used for both `taskSourceType === "content-lake"` (ContentLakeTaskSource)
|
|
231
|
+
* and `taskSourceType === "repo"` (RepoTaskSource). Filtering by
|
|
232
|
+
* area/task/tag is delegated to the adapter — ContentLakeTaskSource
|
|
233
|
+
* pushes it into the GROQ query, RepoTaskSource applies it in-memory.
|
|
227
234
|
*/
|
|
228
|
-
async
|
|
235
|
+
async loadTasksFromAdapter(ctx, state) {
|
|
229
236
|
const filter = {
|
|
230
237
|
...(ctx.config.areas?.length ? { areas: ctx.config.areas } : {}),
|
|
231
238
|
...(ctx.config.tasks?.length ? { taskIds: ctx.config.tasks } : {}),
|
|
@@ -259,8 +266,17 @@ export class GenerateConfigsStep {
|
|
|
259
266
|
// Discover task files from the mode-specific directory and --repo-tasks-path.
|
|
260
267
|
// Use vendored copies in dist/ when @sanity/ailf-core isn't resolvable
|
|
261
268
|
// (i.e., running outside the monorepo via npx).
|
|
262
|
-
|
|
263
|
-
|
|
269
|
+
//
|
|
270
|
+
// When taskSourceType === "repo", skip the AILF-bundled tasks/${mode}/
|
|
271
|
+
// directory and load ONLY from repoTasksPath. Mirrors the composition-root
|
|
272
|
+
// contract for repo-only mode (see composition-root.ts:392-405).
|
|
273
|
+
const dirs = [];
|
|
274
|
+
if (ctx.config.taskSourceType !== "repo") {
|
|
275
|
+
dirs.push(resolveVendoredSubdir(ctx.config.rootDir, `tasks/${mode}`));
|
|
276
|
+
}
|
|
277
|
+
else if (!ctx.config.repoTasksPath) {
|
|
278
|
+
throw new Error('taskSourceType "repo" requires repoTasksPath to be set (no AILF defaults loaded in repo-only mode)');
|
|
279
|
+
}
|
|
264
280
|
// Also search --repo-tasks-path (e.g., .ailf/tasks/) for repo-based tasks
|
|
265
281
|
if (ctx.config.repoTasksPath) {
|
|
266
282
|
const repoDir = resolve(ctx.config.repoTasksPath);
|