@hasna/instructions 0.7.0 → 0.7.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/README.md +18 -4
- package/dist/chunks/{apply-7svah2qm.js → apply-c3sd4agz.js} +2 -2
- package/dist/chunks/{apply-jp13sa1e.js → apply-pnn7a3y7.js} +2 -2
- package/dist/chunks/{index-7m4j8a33.js → index-6jncnnw7.js} +117 -4
- package/dist/chunks/{index-4pfq42t5.js → index-aj66f6xr.js} +118 -27
- package/dist/chunks/{index-bzyxvwcd.js → index-jg8ptcwh.js} +2 -2
- package/dist/chunks/{index-arrrx0ed.js → index-mvckkf15.js} +39 -20
- package/dist/chunks/{index-1cnyjnd7.js → index-pdpg8a44.js} +2 -2
- package/dist/chunks/{index-z3ma4aqk.js → index-r7nfef2g.js} +1 -1
- package/dist/chunks/{index-fwbs6tma.js → index-ypcef3a2.js} +1 -1
- package/dist/chunks/{local-5wvv5xv3.js → local-0a9gja58.js} +141 -1
- package/dist/chunks/{local-zxa5dpf4.js → local-969ye538.js} +141 -1
- package/dist/chunks/{s3-backup-n2z4fwyh.js → s3-backup-hxe3zpfz.js} +1 -1
- package/dist/chunks/{s3-object-store-90tgbh6k.js → s3-object-store-n0s82swt.js} +1 -1
- package/dist/chunks/{sync-r8t7zsp3.js → sync-q5hvwq6e.js} +3 -3
- package/dist/chunks/{sync-2075deve.js → sync-xtkbm5br.js} +3 -3
- package/dist/cli/index.js +269 -53
- package/dist/data/config-store.d.ts +10 -2
- package/dist/data/config-store.d.ts.map +1 -1
- package/dist/db/configs.d.ts +4 -1
- package/dist/db/configs.d.ts.map +1 -1
- package/dist/db/local.d.ts +1 -1
- package/dist/db/local.d.ts.map +1 -1
- package/dist/index.js +282 -36
- package/dist/lib/compact-output.d.ts +2 -18
- package/dist/lib/compact-output.d.ts.map +1 -1
- package/dist/lib/export.d.ts.map +1 -1
- package/dist/lib/import.d.ts.map +1 -1
- package/dist/mcp/index.js +17 -17
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/sdk/index.js +27 -3
- package/dist/sdk/v1-client.d.ts +4 -3
- package/dist/sdk/v1-client.d.ts.map +1 -1
- package/dist/sdk/v1.generated.d.ts +32 -2
- package/dist/sdk/v1.generated.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +93 -7
- package/dist/server/openapi.d.ts +117 -3
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/v1.d.ts.map +1 -1
- package/dist/storage/cloud-store.d.ts +2 -15
- package/dist/storage/cloud-store.d.ts.map +1 -1
- package/dist/storage/index.js +39 -20
- package/dist/storage/s3-object-store.d.ts.map +1 -1
- package/dist/types/index.d.ts +33 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -13326,6 +13326,143 @@ function listConfigs(filter, db) {
|
|
|
13326
13326
|
const rows = d.query(`SELECT * FROM configs ${where} ORDER BY category, name`).all(...params);
|
|
13327
13327
|
return rows.map(rowToConfig);
|
|
13328
13328
|
}
|
|
13329
|
+
function listConfigsPage(filter = {}, options = {}, db) {
|
|
13330
|
+
const d = db || getDatabase();
|
|
13331
|
+
const conditions = [];
|
|
13332
|
+
const params = [];
|
|
13333
|
+
if (filter.category) {
|
|
13334
|
+
conditions.push("category = ?");
|
|
13335
|
+
params.push(filter.category);
|
|
13336
|
+
}
|
|
13337
|
+
if (filter.agent) {
|
|
13338
|
+
conditions.push("agent = ?");
|
|
13339
|
+
params.push(filter.agent);
|
|
13340
|
+
}
|
|
13341
|
+
if (filter.kind) {
|
|
13342
|
+
conditions.push("kind = ?");
|
|
13343
|
+
params.push(filter.kind);
|
|
13344
|
+
}
|
|
13345
|
+
if (filter.is_template !== undefined) {
|
|
13346
|
+
conditions.push("is_template = ?");
|
|
13347
|
+
params.push(filter.is_template ? 1 : 0);
|
|
13348
|
+
}
|
|
13349
|
+
if (filter.search) {
|
|
13350
|
+
conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
|
|
13351
|
+
const q = `%${filter.search}%`;
|
|
13352
|
+
params.push(q, q, q);
|
|
13353
|
+
}
|
|
13354
|
+
if (filter.tags?.length) {
|
|
13355
|
+
conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
|
|
13356
|
+
for (const tag of filter.tags)
|
|
13357
|
+
params.push(`%"${tag}"%`);
|
|
13358
|
+
}
|
|
13359
|
+
const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
13360
|
+
const normalized = normalizeBoundedReadOptions(options);
|
|
13361
|
+
const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
|
|
13362
|
+
const pageParams = [...params, normalized.limit, normalized.cursor];
|
|
13363
|
+
const rows = d.query(`SELECT * FROM configs ${where} ORDER BY id LIMIT ? OFFSET ?`).all(...pageParams);
|
|
13364
|
+
return boundedReadPage(rows.map(rowToConfig), total, normalized);
|
|
13365
|
+
}
|
|
13366
|
+
function listConfigIdentitiesPage(filter = {}, options = {}, db) {
|
|
13367
|
+
const d = db || getDatabase();
|
|
13368
|
+
const conditions = [];
|
|
13369
|
+
const params = [];
|
|
13370
|
+
if (filter.category) {
|
|
13371
|
+
conditions.push("category = ?");
|
|
13372
|
+
params.push(filter.category);
|
|
13373
|
+
}
|
|
13374
|
+
if (filter.agent) {
|
|
13375
|
+
conditions.push("agent = ?");
|
|
13376
|
+
params.push(filter.agent);
|
|
13377
|
+
}
|
|
13378
|
+
if (filter.kind) {
|
|
13379
|
+
conditions.push("kind = ?");
|
|
13380
|
+
params.push(filter.kind);
|
|
13381
|
+
}
|
|
13382
|
+
if (filter.is_template !== undefined) {
|
|
13383
|
+
conditions.push("is_template = ?");
|
|
13384
|
+
params.push(filter.is_template ? 1 : 0);
|
|
13385
|
+
}
|
|
13386
|
+
if (filter.search) {
|
|
13387
|
+
conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
|
|
13388
|
+
const q = `%${filter.search}%`;
|
|
13389
|
+
params.push(q, q, q);
|
|
13390
|
+
}
|
|
13391
|
+
if (filter.tags?.length) {
|
|
13392
|
+
conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
|
|
13393
|
+
for (const tag of filter.tags)
|
|
13394
|
+
params.push(`%"${tag}"%`);
|
|
13395
|
+
}
|
|
13396
|
+
const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
13397
|
+
const normalized = normalizeBoundedReadOptions(options);
|
|
13398
|
+
const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
|
|
13399
|
+
const pageParams = [...params, normalized.limit, normalized.cursor];
|
|
13400
|
+
const rows = d.query(`SELECT id, name, slug, kind, category, agent, format, is_template, version, created_at, updated_at, synced_at
|
|
13401
|
+
FROM configs ${where} ORDER BY id LIMIT ? OFFSET ?`).all(...pageParams);
|
|
13402
|
+
return boundedReadPage(rows.map((row) => ({
|
|
13403
|
+
...row,
|
|
13404
|
+
kind: row.kind,
|
|
13405
|
+
category: row.category,
|
|
13406
|
+
agent: row.agent,
|
|
13407
|
+
format: row.format,
|
|
13408
|
+
is_template: Boolean(row.is_template)
|
|
13409
|
+
})), total, normalized);
|
|
13410
|
+
}
|
|
13411
|
+
function listConfigSummariesPage(filter = {}, options = {}, db) {
|
|
13412
|
+
const d = db || getDatabase();
|
|
13413
|
+
const conditions = [];
|
|
13414
|
+
const params = [];
|
|
13415
|
+
if (filter.category) {
|
|
13416
|
+
conditions.push("category = ?");
|
|
13417
|
+
params.push(filter.category);
|
|
13418
|
+
}
|
|
13419
|
+
if (filter.agent) {
|
|
13420
|
+
conditions.push("agent = ?");
|
|
13421
|
+
params.push(filter.agent);
|
|
13422
|
+
}
|
|
13423
|
+
if (filter.kind) {
|
|
13424
|
+
conditions.push("kind = ?");
|
|
13425
|
+
params.push(filter.kind);
|
|
13426
|
+
}
|
|
13427
|
+
if (filter.is_template !== undefined) {
|
|
13428
|
+
conditions.push("is_template = ?");
|
|
13429
|
+
params.push(filter.is_template ? 1 : 0);
|
|
13430
|
+
}
|
|
13431
|
+
if (filter.search) {
|
|
13432
|
+
conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
|
|
13433
|
+
const q = `%${filter.search}%`;
|
|
13434
|
+
params.push(q, q, q);
|
|
13435
|
+
}
|
|
13436
|
+
if (filter.tags && filter.tags.length > 0) {
|
|
13437
|
+
conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
|
|
13438
|
+
for (const tag of filter.tags)
|
|
13439
|
+
params.push(`%"${tag}"%`);
|
|
13440
|
+
}
|
|
13441
|
+
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
13442
|
+
const normalized = normalizeBoundedReadOptions(options);
|
|
13443
|
+
const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
|
|
13444
|
+
const pageParams = [...params, normalized.limit, normalized.cursor];
|
|
13445
|
+
const rows = d.query(`SELECT id, name, slug, kind, category, agent, target_path, format,
|
|
13446
|
+
CASE WHEN json_valid(outputs) AND json_type(outputs) = 'array' THEN json_array_length(outputs) ELSE 0 END AS output_count, description, tags,
|
|
13447
|
+
is_template, version, updated_at
|
|
13448
|
+
FROM configs ${where} ORDER BY category, name, id LIMIT ? OFFSET ?`).all(...pageParams);
|
|
13449
|
+
return boundedReadPage(rows.map((row) => ({
|
|
13450
|
+
id: row.id,
|
|
13451
|
+
slug: row.slug,
|
|
13452
|
+
name: row.name,
|
|
13453
|
+
category: row.category,
|
|
13454
|
+
agent: row.agent,
|
|
13455
|
+
kind: row.kind,
|
|
13456
|
+
format: row.format,
|
|
13457
|
+
target_path: row.target_path,
|
|
13458
|
+
output_count: Number(row.output_count ?? 0),
|
|
13459
|
+
version: row.version,
|
|
13460
|
+
is_template: Boolean(row.is_template),
|
|
13461
|
+
updated_at: row.updated_at,
|
|
13462
|
+
description: row.description,
|
|
13463
|
+
tags: JSON.parse(row.tags || "[]")
|
|
13464
|
+
})), total, normalized);
|
|
13465
|
+
}
|
|
13329
13466
|
function updateConfig(idOrSlug, input, db) {
|
|
13330
13467
|
const d = db || getDatabase();
|
|
13331
13468
|
const existing = getConfig(idOrSlug, d);
|
|
@@ -13407,6 +13544,7 @@ var init_configs = __esm(() => {
|
|
|
13407
13544
|
init_types();
|
|
13408
13545
|
init_database();
|
|
13409
13546
|
init_snapshots();
|
|
13547
|
+
init_bounded_read();
|
|
13410
13548
|
});
|
|
13411
13549
|
|
|
13412
13550
|
// src/lib/template.ts
|
|
@@ -13847,7 +13985,10 @@ __export(exports_local, {
|
|
|
13847
13985
|
listSnapshots: () => listSnapshots,
|
|
13848
13986
|
listProfilesPage: () => listProfilesPage,
|
|
13849
13987
|
listMachines: () => listMachines,
|
|
13988
|
+
listConfigsPage: () => listConfigsPage,
|
|
13850
13989
|
listConfigs: () => listConfigs,
|
|
13990
|
+
listConfigSummariesPage: () => listConfigSummariesPage,
|
|
13991
|
+
listConfigIdentitiesPage: () => listConfigIdentitiesPage,
|
|
13851
13992
|
insertFeedback: () => insertFeedback,
|
|
13852
13993
|
getSnapshotByVersion: () => getSnapshotByVersion,
|
|
13853
13994
|
getSnapshot: () => getSnapshot,
|
|
@@ -13902,6 +14043,19 @@ function parseBoundedOrLegacyPage(value, legacyItems, options, label) {
|
|
|
13902
14043
|
const page = boundedReadPage(legacyItems.slice(normalized.cursor, normalized.cursor + normalized.limit), legacyItems.length, normalized);
|
|
13903
14044
|
return { ...page, source_bounded: false };
|
|
13904
14045
|
}
|
|
14046
|
+
function projectBoundedPage(page, project) {
|
|
14047
|
+
return {
|
|
14048
|
+
items: page.items.map(project),
|
|
14049
|
+
total: page.total,
|
|
14050
|
+
limit: page.limit,
|
|
14051
|
+
cursor: page.cursor,
|
|
14052
|
+
next_cursor: page.next_cursor,
|
|
14053
|
+
has_more: page.has_more,
|
|
14054
|
+
complete: page.complete,
|
|
14055
|
+
truncated: page.truncated,
|
|
14056
|
+
source_bounded: page.source_bounded
|
|
14057
|
+
};
|
|
14058
|
+
}
|
|
13905
14059
|
async function aggregateBoundedCollection(label, readPage, identity, options = {}) {
|
|
13906
14060
|
let lastError = null;
|
|
13907
14061
|
for (let attempt = 0;attempt < COLLECTION_READ_ATTEMPTS; attempt += 1) {
|
|
@@ -13997,6 +14151,15 @@ class LocalConfigStore {
|
|
|
13997
14151
|
async listConfigs(filter) {
|
|
13998
14152
|
return (await localStoreModule()).listConfigs(filter, this.db);
|
|
13999
14153
|
}
|
|
14154
|
+
async listConfigsPage(filter = {}, options = {}) {
|
|
14155
|
+
return (await localStoreModule()).listConfigsPage(filter, options, this.db);
|
|
14156
|
+
}
|
|
14157
|
+
async listConfigIdentitiesPage(filter = {}, options = {}) {
|
|
14158
|
+
return (await localStoreModule()).listConfigIdentitiesPage(filter, options, this.db);
|
|
14159
|
+
}
|
|
14160
|
+
async listConfigSummariesPage(filter = {}, options = {}) {
|
|
14161
|
+
return (await localStoreModule()).listConfigSummariesPage(filter, options, this.db);
|
|
14162
|
+
}
|
|
14000
14163
|
async getConfig(idOrSlug) {
|
|
14001
14164
|
return (await localStoreModule()).getConfig(idOrSlug, this.db);
|
|
14002
14165
|
}
|
|
@@ -14100,6 +14263,43 @@ class LocalConfigStore {
|
|
|
14100
14263
|
(await localStoreModule()).resetLocalDatabase();
|
|
14101
14264
|
}
|
|
14102
14265
|
}
|
|
14266
|
+
function toConfigIdentity(value) {
|
|
14267
|
+
const record = value && typeof value === "object" ? value : {};
|
|
14268
|
+
return {
|
|
14269
|
+
id: String(record.id ?? ""),
|
|
14270
|
+
name: String(record.name ?? ""),
|
|
14271
|
+
slug: String(record.slug ?? ""),
|
|
14272
|
+
kind: String(record.kind ?? ""),
|
|
14273
|
+
category: String(record.category ?? ""),
|
|
14274
|
+
agent: String(record.agent ?? ""),
|
|
14275
|
+
format: String(record.format ?? ""),
|
|
14276
|
+
is_template: Boolean(record.is_template),
|
|
14277
|
+
version: Number(record.version ?? 0),
|
|
14278
|
+
created_at: String(record.created_at ?? ""),
|
|
14279
|
+
updated_at: String(record.updated_at ?? ""),
|
|
14280
|
+
synced_at: record.synced_at == null ? null : String(record.synced_at)
|
|
14281
|
+
};
|
|
14282
|
+
}
|
|
14283
|
+
function toConfigSummary(value) {
|
|
14284
|
+
const record = value && typeof value === "object" ? value : {};
|
|
14285
|
+
const outputs = Array.isArray(record.outputs) ? record.outputs : [];
|
|
14286
|
+
return {
|
|
14287
|
+
id: String(record.id ?? ""),
|
|
14288
|
+
slug: String(record.slug ?? ""),
|
|
14289
|
+
name: String(record.name ?? ""),
|
|
14290
|
+
category: String(record.category ?? ""),
|
|
14291
|
+
agent: String(record.agent ?? ""),
|
|
14292
|
+
kind: String(record.kind ?? ""),
|
|
14293
|
+
format: String(record.format ?? ""),
|
|
14294
|
+
target_path: record.target_path == null ? null : String(record.target_path),
|
|
14295
|
+
output_count: Number(record.output_count ?? outputs.length),
|
|
14296
|
+
version: Number(record.version ?? 0),
|
|
14297
|
+
is_template: Boolean(record.is_template),
|
|
14298
|
+
...record.updated_at !== undefined ? { updated_at: String(record.updated_at) } : {},
|
|
14299
|
+
...record.description !== undefined ? { description: record.description == null ? null : String(record.description) } : {},
|
|
14300
|
+
...Array.isArray(record.tags) ? { tags: record.tags.map(String) } : {}
|
|
14301
|
+
};
|
|
14302
|
+
}
|
|
14103
14303
|
|
|
14104
14304
|
class CloudConfigStore {
|
|
14105
14305
|
mode = "api";
|
|
@@ -14121,7 +14321,7 @@ class CloudConfigStore {
|
|
|
14121
14321
|
throw err;
|
|
14122
14322
|
}
|
|
14123
14323
|
}
|
|
14124
|
-
async
|
|
14324
|
+
async listConfigsPage(filter = {}, options = {}) {
|
|
14125
14325
|
const normalized = normalizeBoundedReadOptions(options);
|
|
14126
14326
|
const params = new URLSearchParams;
|
|
14127
14327
|
if (filter.category)
|
|
@@ -14132,13 +14332,67 @@ class CloudConfigStore {
|
|
|
14132
14332
|
params.set("kind", filter.kind);
|
|
14133
14333
|
if (filter.search)
|
|
14134
14334
|
params.set("search", filter.search);
|
|
14335
|
+
for (const tag of filter.tags ?? [])
|
|
14336
|
+
params.append("tag", tag);
|
|
14135
14337
|
params.set("limit", String(normalized.limit));
|
|
14136
14338
|
params.set("cursor", String(normalized.cursor));
|
|
14137
14339
|
const { data } = await this.request("GET", `/configs?${params.toString()}`);
|
|
14138
14340
|
return parseBoundedOrLegacyPage(data, data?.configs, normalized, "config list");
|
|
14139
14341
|
}
|
|
14342
|
+
async listConfigIdentitiesPage(filter = {}, options = {}) {
|
|
14343
|
+
const normalized = normalizeBoundedReadOptions(options);
|
|
14344
|
+
const params = new URLSearchParams;
|
|
14345
|
+
if (filter.category)
|
|
14346
|
+
params.set("category", filter.category);
|
|
14347
|
+
if (filter.agent)
|
|
14348
|
+
params.set("agent", filter.agent);
|
|
14349
|
+
if (filter.kind)
|
|
14350
|
+
params.set("kind", filter.kind);
|
|
14351
|
+
if (filter.search)
|
|
14352
|
+
params.set("search", filter.search);
|
|
14353
|
+
for (const tag of filter.tags ?? [])
|
|
14354
|
+
params.append("tag", tag);
|
|
14355
|
+
params.set("view", "identity");
|
|
14356
|
+
params.set("limit", String(normalized.limit));
|
|
14357
|
+
params.set("cursor", String(normalized.cursor));
|
|
14358
|
+
const { data } = await this.request("GET", `/configs?${params.toString()}`);
|
|
14359
|
+
const page = parseBoundedOrLegacyPage(data, data?.configs, normalized, "config identity list");
|
|
14360
|
+
if (page.items.some((item) => {
|
|
14361
|
+
const record = item && typeof item === "object" ? item : {};
|
|
14362
|
+
return ["content", "target_path", "outputs", "description", "tags"].some((field) => Object.prototype.hasOwnProperty.call(record, field));
|
|
14363
|
+
})) {
|
|
14364
|
+
throw new Error("Instructions /v1 config identity projection is unavailable; deploy the identity endpoint before using compact lists");
|
|
14365
|
+
}
|
|
14366
|
+
return projectBoundedPage(page, toConfigIdentity);
|
|
14367
|
+
}
|
|
14368
|
+
async listConfigSummariesPage(filter = {}, options = {}) {
|
|
14369
|
+
const normalized = normalizeBoundedReadOptions(options);
|
|
14370
|
+
const params = new URLSearchParams;
|
|
14371
|
+
if (filter.category)
|
|
14372
|
+
params.set("category", filter.category);
|
|
14373
|
+
if (filter.agent)
|
|
14374
|
+
params.set("agent", filter.agent);
|
|
14375
|
+
if (filter.kind)
|
|
14376
|
+
params.set("kind", filter.kind);
|
|
14377
|
+
if (filter.search)
|
|
14378
|
+
params.set("search", filter.search);
|
|
14379
|
+
for (const tag of filter.tags ?? [])
|
|
14380
|
+
params.append("tag", tag);
|
|
14381
|
+
params.set("view", "summary");
|
|
14382
|
+
params.set("limit", String(normalized.limit));
|
|
14383
|
+
params.set("cursor", String(normalized.cursor));
|
|
14384
|
+
const { data } = await this.request("GET", `/configs?${params.toString()}`);
|
|
14385
|
+
const page = parseBoundedOrLegacyPage(data, data?.configs, normalized, "config summary list");
|
|
14386
|
+
if (page.items.some((item) => {
|
|
14387
|
+
const record = item && typeof item === "object" ? item : {};
|
|
14388
|
+
return Object.prototype.hasOwnProperty.call(record, "content") || Object.prototype.hasOwnProperty.call(record, "outputs");
|
|
14389
|
+
})) {
|
|
14390
|
+
throw new Error("Instructions /v1 config summary projection is unavailable; deploy the summary endpoint before using summary lists");
|
|
14391
|
+
}
|
|
14392
|
+
return projectBoundedPage(page, toConfigSummary);
|
|
14393
|
+
}
|
|
14140
14394
|
async listConfigs(filter = {}) {
|
|
14141
|
-
const configs = await aggregateBoundedCollection("config list", (cursor) => this.
|
|
14395
|
+
const configs = await aggregateBoundedCollection("config list", (cursor) => this.listConfigsPage(filter, { limit: 100, cursor }), (config) => config.id, { requireAscendingIdentity: true });
|
|
14142
14396
|
let filtered = configs;
|
|
14143
14397
|
if (filter.tags && filter.tags.length > 0) {
|
|
14144
14398
|
filtered = filtered.filter((config) => filter.tags.every((tag) => config.tags.includes(tag)));
|
|
@@ -14204,7 +14458,7 @@ class CloudConfigStore {
|
|
|
14204
14458
|
return data?.pruned ?? 0;
|
|
14205
14459
|
}
|
|
14206
14460
|
async listProfiles() {
|
|
14207
|
-
return aggregateBoundedCollection("profile list", (cursor) => this.listProfilesPage({ limit: 100, cursor }), (profile) => profile.id
|
|
14461
|
+
return aggregateBoundedCollection("profile list", (cursor) => this.listProfilesPage({ limit: 100, cursor }), (profile) => profile.id);
|
|
14208
14462
|
}
|
|
14209
14463
|
async listProfilesPage(options = {}) {
|
|
14210
14464
|
const normalized = normalizeBoundedReadOptions(options);
|
|
@@ -17972,7 +18226,12 @@ function logicalAssetLocator(locator, idToSlug) {
|
|
|
17972
18226
|
}
|
|
17973
18227
|
function logicalCollections(domain, options) {
|
|
17974
18228
|
const configs = [...domain.configs].sort((left, right) => compareText(left.slug, right.slug));
|
|
17975
|
-
const snapshots =
|
|
18229
|
+
const snapshots = domain.config_snapshots.map((snapshot) => ({
|
|
18230
|
+
config_slug: snapshot.config_slug,
|
|
18231
|
+
version: snapshot.version,
|
|
18232
|
+
content: snapshot.content,
|
|
18233
|
+
...options.includeOperationalTimestamps ? { created_at: snapshot.created_at } : {}
|
|
18234
|
+
})).sort((left, right) => compareText(left.config_slug, right.config_slug) || left.version - right.version || compareText(left.content, right.content) || compareText("created_at" in left ? left.created_at ?? "" : "", "created_at" in right ? right.created_at ?? "" : ""));
|
|
17976
18235
|
const profiles = [...domain.profiles].sort((left, right) => compareText(left.slug, right.slug));
|
|
17977
18236
|
const configBindings = [...domain.profile_config_bindings].sort((left, right) => compareText(left.profile_slug, right.profile_slug) || left.sort_order - right.sort_order || compareText(left.config_slug, right.config_slug));
|
|
17978
18237
|
const assetBindings = [...domain.profile_asset_bindings].sort((left, right) => compareText(left.profile_slug, right.profile_slug) || left.sort_order - right.sort_order || compareText(left.binding.assetKey, right.binding.assetKey));
|
|
@@ -18001,12 +18260,7 @@ function logicalCollections(domain, options) {
|
|
|
18001
18260
|
synced_at: config.synced_at
|
|
18002
18261
|
} : {}
|
|
18003
18262
|
})),
|
|
18004
|
-
config_snapshots: snapshots
|
|
18005
|
-
config_slug: snapshot.config_slug,
|
|
18006
|
-
version: snapshot.version,
|
|
18007
|
-
content: snapshot.content,
|
|
18008
|
-
...options.includeOperationalTimestamps ? { created_at: snapshot.created_at } : {}
|
|
18009
|
-
})),
|
|
18263
|
+
config_snapshots: snapshots,
|
|
18010
18264
|
profiles: profiles.map((profile) => ({
|
|
18011
18265
|
slug: profile.slug,
|
|
18012
18266
|
name: profile.name,
|
|
@@ -18130,10 +18384,11 @@ function validateInstructionsDomainArchive(value) {
|
|
|
18130
18384
|
assertUnique(typed.configs.map((row) => row.slug), "config slug");
|
|
18131
18385
|
assertUnique(typed.profiles.map((row) => row.slug), "profile slug");
|
|
18132
18386
|
assertUnique(typed.machines.map((row) => row.hostname), "machine hostname");
|
|
18133
|
-
assertUnique(typed.config_snapshots.map((row) =>
|
|
18387
|
+
assertUnique(typed.config_snapshots.map((row) => row.id), "config snapshot id");
|
|
18134
18388
|
assertUnique(typed.profile_config_bindings.map((row) => `${row.profile_slug}:${row.config_slug}`), "profile config binding");
|
|
18135
18389
|
assertUnique(typed.profile_asset_bindings.map((row) => `${row.profile_slug}:${row.binding.assetKey}`), "profile asset binding");
|
|
18136
|
-
const
|
|
18390
|
+
const configsBySlug = new Map(typed.configs.map((row) => [row.slug, row]));
|
|
18391
|
+
const configSlugs = new Set(configsBySlug.keys());
|
|
18137
18392
|
const profileSlugs = new Set(typed.profiles.map((row) => row.slug));
|
|
18138
18393
|
for (const config of typed.configs) {
|
|
18139
18394
|
assertTimestamp(config.created_at, `config ${config.slug} created_at`);
|
|
@@ -18141,24 +18396,15 @@ function validateInstructionsDomainArchive(value) {
|
|
|
18141
18396
|
assertTimestamp(config.synced_at, `config ${config.slug} synced_at`, true);
|
|
18142
18397
|
if (!Number.isSafeInteger(config.version) || config.version < 1)
|
|
18143
18398
|
throw new Error(`Invalid v2 archive: config ${config.slug} has invalid version`);
|
|
18144
|
-
const snapshots = typed.config_snapshots.filter((row) => row.config_slug === config.slug).sort((a, b) => a.version - b.version);
|
|
18145
|
-
if (snapshots.some((row) => !Number.isSafeInteger(row.version) || row.version < 1 || row.version > config.version)) {
|
|
18146
|
-
throw new Error(`Invalid v2 archive: config ${config.slug} has an invalid snapshot version`);
|
|
18147
|
-
}
|
|
18148
|
-
if (snapshots.length) {
|
|
18149
|
-
const first = snapshots[0].version;
|
|
18150
|
-
const expected = Array.from({ length: config.version - first + 1 }, (_, index) => first + index);
|
|
18151
|
-
if (canonicalDomainJson(snapshots.map((row) => row.version)) !== canonicalDomainJson(expected) || snapshots.at(-1).version !== config.version) {
|
|
18152
|
-
throw new Error(`Invalid v2 archive: snapshots for ${config.slug} must be a contiguous suffix ending at version ${config.version}`);
|
|
18153
|
-
}
|
|
18154
|
-
if (snapshots.at(-1).content !== config.content) {
|
|
18155
|
-
throw new Error(`Invalid v2 archive: latest snapshot content differs from config ${config.slug}`);
|
|
18156
|
-
}
|
|
18157
|
-
}
|
|
18158
18399
|
}
|
|
18159
18400
|
for (const row of typed.config_snapshots) {
|
|
18160
|
-
|
|
18401
|
+
const config = configsBySlug.get(row.config_slug);
|
|
18402
|
+
if (!config) {
|
|
18161
18403
|
throw new Error(`Invalid v2 archive: snapshot references missing config ${row.config_slug}`);
|
|
18404
|
+
}
|
|
18405
|
+
if (!Number.isSafeInteger(row.version) || row.version < 1 || row.version > config.version) {
|
|
18406
|
+
throw new Error(`Invalid v2 archive: config ${row.config_slug} has an invalid snapshot version`);
|
|
18407
|
+
}
|
|
18162
18408
|
assertTimestamp(row.created_at, `snapshot ${row.config_slug}@${row.version} created_at`);
|
|
18163
18409
|
}
|
|
18164
18410
|
for (const profile of typed.profiles) {
|
|
@@ -18413,14 +18659,11 @@ function configInput(config, content) {
|
|
|
18413
18659
|
};
|
|
18414
18660
|
}
|
|
18415
18661
|
async function restoreNewConfig(store, archived, domain) {
|
|
18416
|
-
const snapshots = domain.config_snapshots.filter((row) => row.config_slug === archived.slug).sort((left, right) => left.version - right.version);
|
|
18417
|
-
|
|
18418
|
-
let content = byVersion.get(1) ?? snapshots[0]?.content ?? archived.content;
|
|
18419
|
-
let restored = await store.createConfig(configInput(archived, content));
|
|
18662
|
+
const snapshots = domain.config_snapshots.filter((row) => row.config_slug === archived.slug).sort((left, right) => left.version - right.version || compareText2(left.content, right.content) || compareText2(left.id, right.id));
|
|
18663
|
+
let restored = await store.createConfig(configInput(archived, archived.content));
|
|
18420
18664
|
for (let version = 2;version <= archived.version; version++) {
|
|
18421
|
-
content = byVersion.get(version) ?? (version === archived.version ? archived.content : content);
|
|
18422
18665
|
restored = await store.updateConfig(restored.id, {
|
|
18423
|
-
content,
|
|
18666
|
+
content: archived.content,
|
|
18424
18667
|
...version === archived.version ? {
|
|
18425
18668
|
name: archived.name,
|
|
18426
18669
|
kind: archived.kind,
|
|
@@ -18436,9 +18679,12 @@ async function restoreNewConfig(store, archived, domain) {
|
|
|
18436
18679
|
} : {}
|
|
18437
18680
|
});
|
|
18438
18681
|
}
|
|
18439
|
-
await store.pruneSnapshots(restored.id,
|
|
18440
|
-
|
|
18441
|
-
|
|
18682
|
+
await store.pruneSnapshots(restored.id, 0);
|
|
18683
|
+
for (const snapshot of snapshots) {
|
|
18684
|
+
await store.createSnapshot(restored.id, snapshot.content, snapshot.version);
|
|
18685
|
+
}
|
|
18686
|
+
const restoredSnapshots = (await store.listSnapshots(restored.id)).map(({ version, content: snapshotContent }) => ({ version, content: snapshotContent })).sort((left, right) => left.version - right.version || compareText2(left.content, right.content));
|
|
18687
|
+
const expectedSnapshots = snapshots.map(({ version, content: snapshotContent }) => ({ version, content: snapshotContent })).sort((left, right) => left.version - right.version || compareText2(left.content, right.content));
|
|
18442
18688
|
if (restored.version !== archived.version || restored.content !== archived.content || canonicalDomainJson(restoredSnapshots) !== canonicalDomainJson(expectedSnapshots)) {
|
|
18443
18689
|
throw new Error(`restored config or snapshot history did not match archive for ${archived.slug}`);
|
|
18444
18690
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ApplyResult, Config, Profile } from "../types/index.js";
|
|
1
|
+
import type { ApplyResult, Config, ConfigSummary, Profile } from "../types/index.js";
|
|
2
|
+
export type { ConfigSummary } from "../types/index.js";
|
|
2
3
|
export declare const DEFAULT_LIST_LIMIT = 20;
|
|
3
4
|
export declare const MAX_LIST_LIMIT = 100;
|
|
4
5
|
export declare const MAX_LIST_CURSOR = 100000;
|
|
@@ -30,23 +31,6 @@ export declare function pagedPayload<T>(items: T[], opts?: {
|
|
|
30
31
|
}): PagedPayload<T>;
|
|
31
32
|
export declare function truncateText(value: string | null | undefined, max?: number): string;
|
|
32
33
|
export declare function truncateMiddle(value: string | null | undefined, max?: number): string;
|
|
33
|
-
export interface ConfigSummary {
|
|
34
|
-
id: string;
|
|
35
|
-
slug: string;
|
|
36
|
-
name: string;
|
|
37
|
-
category: Config["category"];
|
|
38
|
-
agent: Config["agent"];
|
|
39
|
-
kind: Config["kind"];
|
|
40
|
-
format: Config["format"];
|
|
41
|
-
target_path: string | null;
|
|
42
|
-
output_count: number;
|
|
43
|
-
version: number;
|
|
44
|
-
is_template: boolean;
|
|
45
|
-
updated_at?: string;
|
|
46
|
-
description?: string | null;
|
|
47
|
-
tags?: string[];
|
|
48
|
-
outputs?: Config["outputs"];
|
|
49
|
-
}
|
|
50
34
|
export declare function summarizeConfig(config: Config, opts?: {
|
|
51
35
|
verbose?: boolean;
|
|
52
36
|
}): ConfigSummary;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compact-output.d.ts","sourceRoot":"","sources":["../../src/lib/compact-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"compact-output.d.ts","sourceRoot":"","sources":["../../src/lib/compact-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,mBAAmB,C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AAC,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,kBAAkB,CAY5E"}
|
package/dist/lib/export.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/lib/export.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,YAAY,EACZ,+BAA+B,EAC/B,kCAAkC,EAElC,2BAA2B,EAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE/E,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,+BAA+B,CAAC;IACxC,SAAS,EAAE,kCAAkC,CAAC;CAC/C;AAyCD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE1D;
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/lib/export.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,YAAY,EACZ,+BAA+B,EAC/B,kCAAkC,EAElC,2BAA2B,EAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE/E,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,E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OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,mCAAmC,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;CACpE;AAiXD,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,aAAkB,GACvB,OAAO,CAAC,YAAY,CAAC,CAuBvB"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
syncFromDir,
|
|
8
8
|
syncToDir
|
|
9
|
-
} from "../chunks/index-
|
|
9
|
+
} from "../chunks/index-jg8ptcwh.js";
|
|
10
10
|
import {
|
|
11
11
|
applyConfigsWithReport,
|
|
12
12
|
normalizeTargetPath
|
|
13
|
-
} from "../chunks/index-
|
|
13
|
+
} from "../chunks/index-ypcef3a2.js";
|
|
14
14
|
import {
|
|
15
15
|
detectMachineContext,
|
|
16
16
|
getReportedDbPath,
|
|
@@ -18,9 +18,8 @@ import {
|
|
|
18
18
|
resolveConfigStore,
|
|
19
19
|
resolveProfileVariables,
|
|
20
20
|
summarizeApplyResult,
|
|
21
|
-
summarizeConfig,
|
|
22
21
|
summarizeProfile
|
|
23
|
-
} from "../chunks/index-
|
|
22
|
+
} from "../chunks/index-aj66f6xr.js";
|
|
24
23
|
import"../chunks/index-35z65jsa.js";
|
|
25
24
|
import"../chunks/index-3djthcm6.js";
|
|
26
25
|
import {
|
|
@@ -32,7 +31,7 @@ import {
|
|
|
32
31
|
var require_package = __commonJS((exports, module) => {
|
|
33
32
|
module.exports = {
|
|
34
33
|
name: "@hasna/instructions",
|
|
35
|
-
version: "0.7.
|
|
34
|
+
version: "0.7.1",
|
|
36
35
|
description: "AI coding agent instruction and configuration manager with fail-closed hosted clients, explicit local SQLite, native S3 backups, CLI, MCP, HTTP API, and generated SDK.",
|
|
37
36
|
type: "module",
|
|
38
37
|
main: "dist/index.js",
|
|
@@ -107,10 +106,10 @@ var require_package = __commonJS((exports, module) => {
|
|
|
107
106
|
},
|
|
108
107
|
repository: {
|
|
109
108
|
type: "git",
|
|
110
|
-
url: "
|
|
109
|
+
url: "https://github.com/hasna/apps.git",
|
|
111
110
|
directory: "apps/instructions"
|
|
112
111
|
},
|
|
113
|
-
homepage: "https://github.com/hasna/apps/tree/main/apps/instructions",
|
|
112
|
+
homepage: "https://github.com/hasna/apps/tree/main/apps/instructions#readme",
|
|
114
113
|
bugs: {
|
|
115
114
|
url: "https://github.com/hasna/apps/issues"
|
|
116
115
|
},
|
|
@@ -269,18 +268,19 @@ function buildServer() {
|
|
|
269
268
|
try {
|
|
270
269
|
switch (name) {
|
|
271
270
|
case "list_configs": {
|
|
272
|
-
const
|
|
271
|
+
const filter = {
|
|
273
272
|
category: args["category"] || undefined,
|
|
274
273
|
agent: args["agent"] || undefined,
|
|
275
274
|
kind: args["kind"] || undefined,
|
|
276
275
|
search: args["search"] || undefined
|
|
276
|
+
};
|
|
277
|
+
const bounds = { limit: args["limit"], cursor: args["cursor"] };
|
|
278
|
+
const page = Boolean(args["verbose"]) ? await store.listConfigSummariesPage(filter, bounds) : await store.listConfigIdentitiesPage(filter, bounds);
|
|
279
|
+
return ok({
|
|
280
|
+
...page,
|
|
281
|
+
count: page.items.length,
|
|
282
|
+
hint: "Use get_config with id_or_slug for full content; list_configs verbose=true adds content-free path, description, tags, and output counts."
|
|
277
283
|
});
|
|
278
|
-
const summaries = configs.map((c) => summarizeConfig(c, { verbose: Boolean(args["verbose"]) }));
|
|
279
|
-
return ok(pagedPayload(summaries, {
|
|
280
|
-
limit: args["limit"],
|
|
281
|
-
cursor: args["cursor"],
|
|
282
|
-
hint: "Use get_config with id_or_slug for full content, or list_configs verbose=true for tags/output targets."
|
|
283
|
-
}));
|
|
284
284
|
}
|
|
285
285
|
case "get_config": {
|
|
286
286
|
const c = await store.getConfig(args["id_or_slug"]);
|
|
@@ -413,7 +413,7 @@ function buildServer() {
|
|
|
413
413
|
const stats = await store.getConfigStats();
|
|
414
414
|
const allConfigs = await store.listConfigs({ kind: "file" });
|
|
415
415
|
const { existsSync: ex, readFileSync: rf } = await import("fs");
|
|
416
|
-
const { expandPath } = await import("../chunks/apply-
|
|
416
|
+
const { expandPath } = await import("../chunks/apply-c3sd4agz.js");
|
|
417
417
|
const { redactContent, redactFormatForTarget } = await import("../chunks/redact-hnq4sc4r.js");
|
|
418
418
|
let drifted = 0, missing = 0, templates = 0;
|
|
419
419
|
const driftedSlugs = [];
|
|
@@ -445,7 +445,7 @@ function buildServer() {
|
|
|
445
445
|
});
|
|
446
446
|
}
|
|
447
447
|
case "sync_known": {
|
|
448
|
-
const { syncKnown } = await import("../chunks/sync-
|
|
448
|
+
const { syncKnown } = await import("../chunks/sync-q5hvwq6e.js");
|
|
449
449
|
const result = await syncKnown({
|
|
450
450
|
store,
|
|
451
451
|
agent: args["agent"] || undefined,
|
|
@@ -454,7 +454,7 @@ function buildServer() {
|
|
|
454
454
|
return ok(result);
|
|
455
455
|
}
|
|
456
456
|
case "sync_project": {
|
|
457
|
-
const { syncProject } = await import("../chunks/sync-
|
|
457
|
+
const { syncProject } = await import("../chunks/sync-q5hvwq6e.js");
|
|
458
458
|
const dir = args["project_dir"] || process.cwd();
|
|
459
459
|
const result = await syncProject({ store, projectDir: dir });
|
|
460
460
|
return ok(result);
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AA6EnE,wBAAgB,WAAW,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AA6EnE,wBAAgB,WAAW,IAAI,MAAM,CA4WpC"}
|
package/dist/sdk/index.js
CHANGED
|
@@ -1065,6 +1065,25 @@ function configIdentity(value) {
|
|
|
1065
1065
|
synced_at: value.synced_at == null ? null : String(value.synced_at)
|
|
1066
1066
|
};
|
|
1067
1067
|
}
|
|
1068
|
+
function configSummary(value) {
|
|
1069
|
+
const outputs = Array.isArray(value.outputs) ? value.outputs : [];
|
|
1070
|
+
return {
|
|
1071
|
+
id: String(value.id ?? ""),
|
|
1072
|
+
name: String(value.name ?? ""),
|
|
1073
|
+
slug: String(value.slug ?? ""),
|
|
1074
|
+
kind: String(value.kind ?? ""),
|
|
1075
|
+
category: String(value.category ?? ""),
|
|
1076
|
+
agent: String(value.agent ?? ""),
|
|
1077
|
+
target_path: value.target_path == null ? null : String(value.target_path),
|
|
1078
|
+
format: String(value.format ?? ""),
|
|
1079
|
+
output_count: Number(value.output_count ?? outputs.length),
|
|
1080
|
+
description: value.description == null ? null : String(value.description),
|
|
1081
|
+
tags: Array.isArray(value.tags) ? value.tags.map(String) : [],
|
|
1082
|
+
is_template: Boolean(value.is_template),
|
|
1083
|
+
version: Number(value.version ?? 0),
|
|
1084
|
+
updated_at: String(value.updated_at ?? "")
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1068
1087
|
function profileIdentity(value) {
|
|
1069
1088
|
return {
|
|
1070
1089
|
id: String(value.id ?? ""),
|
|
@@ -1076,8 +1095,12 @@ function profileIdentity(value) {
|
|
|
1076
1095
|
}
|
|
1077
1096
|
function normalizeLegacyPage(value, alias, query, project) {
|
|
1078
1097
|
const record = value && typeof value === "object" ? value : {};
|
|
1079
|
-
if (Array.isArray(record.items))
|
|
1080
|
-
|
|
1098
|
+
if (Array.isArray(record.items)) {
|
|
1099
|
+
if (!project)
|
|
1100
|
+
return value;
|
|
1101
|
+
const items2 = record.items.map(project);
|
|
1102
|
+
return { ...record, [alias]: items2, items: items2, count: items2.length };
|
|
1103
|
+
}
|
|
1081
1104
|
const legacy = record[alias];
|
|
1082
1105
|
if (!Array.isArray(legacy)) {
|
|
1083
1106
|
throw new Error(`Instructions V1 ${alias} response is neither bounded nor a complete legacy array`);
|
|
@@ -1111,7 +1134,8 @@ class InstructionsV1Client extends GeneratedInstructionsV1Client {
|
|
|
1111
1134
|
}
|
|
1112
1135
|
async listConfigs(query, init) {
|
|
1113
1136
|
const response = await super.listConfigs(query, init);
|
|
1114
|
-
|
|
1137
|
+
const project = query?.view === "identity" ? configIdentity : query?.view === "summary" ? configSummary : undefined;
|
|
1138
|
+
return normalizeLegacyPage(response, "configs", query, project);
|
|
1115
1139
|
}
|
|
1116
1140
|
async listProfiles(query, init) {
|
|
1117
1141
|
const response = await super.listProfiles(query, init);
|