@thatopen/services 0.21.0 → 0.22.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/cli.js CHANGED
@@ -6837,10 +6837,21 @@ class ProjectHistory {
6837
6837
  const name = String(folder.name ?? "");
6838
6838
  const dash = name.indexOf("-");
6839
6839
  if (dash <= 0) continue;
6840
+ const files = await this.client.listFiles({
6841
+ folderId: idOf(folder)
6842
+ });
6843
+ const names2 = files.map(
6844
+ (f) => String(f.name ?? "")
6845
+ );
6846
+ const model = names2.find((n) => n === LEGACY_MODEL_FILE) ?? names2.find(
6847
+ (n) => n.endsWith(".frag") && !n.startsWith(INTERNAL_PREFIX)
6848
+ );
6849
+ const hasAny = names2.includes(HISTORY_FILE) || names2.includes(OPS_FILE) || !!model;
6840
6850
  docs.push({
6841
6851
  source: name.slice(0, dash),
6842
6852
  docId: name.slice(dash + 1),
6843
- modelName: void 0
6853
+ modelName: model,
6854
+ ...hasAny ? {} : { empty: true }
6844
6855
  });
6845
6856
  }
6846
6857
  return docs;
@@ -7260,14 +7271,39 @@ class Recipes {
7260
7271
  return this.#registry.get(name);
7261
7272
  }
7262
7273
  /**
7263
- * Runs a recipe WITHOUT queueing anything: the dry pass. Returns the
7264
- * recipe's result — title, tallies per rule, targets — so an app can show
7265
- * what would be proposed before anybody confirms. The payload it may have
7266
- * built is discarded along with its opId.
7274
+ * Runs a recipe WITHOUT queueing anything: the dry pass. Returns a
7275
+ * {@link RecipePlan} — the result to show (title, tallies, targets) plus
7276
+ * everything {@link queue} needs to queue EXACTLY this, payload and opId
7277
+ * included, with no second run. Discard it and the plan never happened.
7267
7278
  */
7268
7279
  async plan(name, options) {
7269
- const { result } = await this.#execute(name, options);
7270
- return result;
7280
+ const { base, opId, result } = await this.#execute(name, options);
7281
+ return {
7282
+ opId,
7283
+ projectId: options.projectId,
7284
+ target: options.target,
7285
+ ...base?.guid ? { baseCommitGuid: base.guid } : {},
7286
+ result
7287
+ };
7288
+ }
7289
+ /**
7290
+ * Queues exactly what {@link plan} planned: same opId, same payload, no
7291
+ * second execution. The pair plan → confirm → queue is the UI flow; `run`
7292
+ * is the one-shot shortcut.
7293
+ */
7294
+ async queue(plan, options) {
7295
+ const targetDoc = this.client.history(plan.projectId).doc(plan.target.source, plan.target.docId);
7296
+ const suggestion = await targetDoc.suggest({
7297
+ opId: plan.opId,
7298
+ title: plan.result.title,
7299
+ verb: plan.result.verb,
7300
+ author: options.author,
7301
+ payload: plan.result.payload,
7302
+ targets: plan.result.targets,
7303
+ userId: options.userId,
7304
+ baseCommitGuid: plan.baseCommitGuid
7305
+ });
7306
+ return { suggestion, result: plan.result };
7271
7307
  }
7272
7308
  /**
7273
7309
  * Runs a recipe and queues its suggestion on the target document. Safe to