@diagonal-hq/cli 0.41.7 → 0.42.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.mjs CHANGED
@@ -9210,8 +9210,10 @@ function readWorkflowConfigFile(path, source) {
9210
9210
  const properties = new Map(
9211
9211
  node.properties.filter((property2) => property2.type === "ObjectProperty").map((property2) => [propertyKey(property2), property2])
9212
9212
  );
9213
+ const { uid, slug = null } = workflowMetadata(ast);
9213
9214
  return {
9214
- uid: workflowMetadata(ast).uid,
9215
+ uid,
9216
+ slug,
9215
9217
  name: literalString(properties.get("name") ?? properties.get("title")),
9216
9218
  description: literalString(properties.get("description"))
9217
9219
  };
@@ -9371,6 +9373,9 @@ function optionsOf2(changes, properties, references2) {
9371
9373
  }
9372
9374
  options.description = changes.description === null || changes.description.trim() === "" ? null : changes.description;
9373
9375
  }
9376
+ if (changes.slug !== void 0) {
9377
+ options.slug = changes.slug === null ? null : nonEmptyString(changes.slug, "slug");
9378
+ }
9374
9379
  if (changes.trigger !== void 0) {
9375
9380
  options.trigger = triggerOf(changes.trigger, references2);
9376
9381
  }
@@ -9385,6 +9390,34 @@ function optionsOf2(changes, properties, references2) {
9385
9390
  }
9386
9391
  return options;
9387
9392
  }
9393
+ function routeEdits(source, properties, changes) {
9394
+ if (changes.route === void 0) {
9395
+ return [];
9396
+ }
9397
+ if (changes.trigger !== void 0) {
9398
+ throw new SourceError('A workflow config write changes "trigger" or "route", not both.');
9399
+ }
9400
+ const route = nonEmptyString(changes.route, "route");
9401
+ const trigger = properties.get("trigger");
9402
+ const literal5 = trigger?.type === "ObjectProperty" && trigger.value.type === "ObjectExpression";
9403
+ const type = literal5 ? literalString(
9404
+ trigger.value.properties.find(
9405
+ (property2) => property2.type === "ObjectProperty" && propertyKey(property2) === "type"
9406
+ )
9407
+ ) : null;
9408
+ if (type !== "request") {
9409
+ throw new SourceError(
9410
+ "The workflow has no request trigger written as an object literal, so the app cannot change its route. Edit the trigger in Files."
9411
+ );
9412
+ }
9413
+ return objectPatchEdits(
9414
+ source,
9415
+ trigger.value,
9416
+ { path: route.startsWith("/") ? route : `/${route}` },
9417
+ "trigger",
9418
+ 0
9419
+ );
9420
+ }
9388
9421
  function importEdits2(ast, { imports, locals }) {
9389
9422
  const modules = [
9390
9423
  ["resources", RESOURCES_EXPORT, GENERATED_RESOURCES_MODULE],
@@ -9421,6 +9454,7 @@ function writeWorkflowConfigFile(path, source, changes, resources = []) {
9421
9454
  const options = optionsOf2(changes, properties, references2);
9422
9455
  const written = applySourceEdits(source, [
9423
9456
  ...objectPatchEdits(source, node, options, "config", 0),
9457
+ ...routeEdits(source, properties, changes),
9424
9458
  ...importEdits2(ast, references2)
9425
9459
  ]);
9426
9460
  if (readWorkflowConfigFile(path, written).uid !== before) {
@@ -9432,7 +9466,7 @@ function writeWorkflowConfigFile(path, source, changes, resources = []) {
9432
9466
  // scripts/lib/runtime-build/source-adapters/workflow-config.mjs
9433
9467
  var workflowConfigAdapter = Object.freeze({
9434
9468
  contextFields: ["resources", "resource_slugs"],
9435
- writeFields: ["name", "description", "trigger", "run_as", "authorizer"],
9469
+ writeFields: ["name", "slug", "description", "trigger", "route", "run_as", "authorizer"],
9436
9470
  accepts: isWorkflowConfigPath,
9437
9471
  identity: (data) => data.uid,
9438
9472
  read({ path, source }) {
@@ -10875,7 +10909,7 @@ async function checkSources() {
10875
10909
  if (existsSync4(DATA_FILE) && existsSync4(SDK_FILE)) {
10876
10910
  return { dataFile: DATA_FILE, sdkFile: SDK_FILE };
10877
10911
  }
10878
- const { checkData, scriptSdk } = await import("./cli-check-data-7TKAM34J.mjs");
10912
+ const { checkData, scriptSdk } = await import("./cli-check-data-WEDRC3FA.mjs");
10879
10913
  return { data: checkData(), sdk: scriptSdk() };
10880
10914
  }
10881
10915
  function isScriptTestPath(path) {
package/dist/index.d.ts CHANGED
@@ -1003,9 +1003,11 @@ export type RequestTrigger = {
1003
1003
  method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
1004
1004
  /**
1005
1005
  * The domain of the workflow, as `Domains.<Name>.key` from `@app/generated/domains`.
1006
- * The workflow answers only on that domain's active hostname, and on no host
1007
- * while the domain has no active hostname. Without `domain`, or on the primary
1008
- * domain, it answers on the primary hostname.
1006
+ * The workflow answers only on that domain's active hostname. While the
1007
+ * domain has no active hostname, a workflow on the primary domain answers on
1008
+ * the assigned workspace host. A workflow on a domain with `fallback: 'primary'`
1009
+ * answers on the primary host. Other bound workflows answer on no host.
1010
+ * Without `domain`, the workflow follows the primary domain.
1009
1011
  */
1010
1012
  domain?: string | null;
1011
1013
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/cli",
3
- "version": "0.41.7",
3
+ "version": "0.42.0",
4
4
  "description": "The diagonal CLI and the configuration helpers for file-based Diagonal workspaces.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {