@diagonal-hq/cli 0.33.3 → 0.33.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/README.md CHANGED
@@ -661,6 +661,7 @@ export default defineNotificationSchedule({
661
661
  This sends the Standard welcome 7 days after each active member's `joined_on`.
662
662
 
663
663
  - `offsets` holds one to 30 distinct ISO 8601 durations in days, hours, or minutes: `'-P30D'` is 30 days before, `'P0D'` is the day, `'-PT2H'` is 2 hours before in exact timing. A duration without a sign counts after the date, so `'P7D'` and `'+P7D'` are the same offset.
664
+ - `stageIds` is optional: one distinct id for each offset, in the order of `offsets`, with letters, digits, `_`, and `-` and at most 100 characters each. A notification keeps its stage id when its offset changes, so it keeps its edits, hold, and history. Without `stageIds`, an offset that stays keeps its id, and a changed offset takes the id of a removed offset. A save from the schedule page writes `stageIds`.
664
665
  - `timing` defaults to `'day'`, which sends at 8 a.m. in the workspace timezone on the day, so `'-PT2H'` sends at 6 a.m. `'exact'` sends at the time of a datetime field or the start of an event schedule field, plus the offset.
665
666
  - `filters` is optional. It is a filter tree, `{ operator, conditions }`, with the shape of a policy `filter`. See [Policies](#policies).
666
667
  - `automaticFilters` is optional and has the shape of `filters`. Of the records that match `filters`, the schedule makes and sends notifications on its own only for the records that also match `automaticFilters`. Staff can still send to the other records from the schedule page. Leave it out to send on its own to every record that matches `filters`. For example, `automaticFilters: { operator: 'and', conditions: [{ field: 'renewal_notice_mode', operator: '=', value: 'automatic' }] }` sends on its own only to the members who chose automatic renewal notices.
@@ -669,7 +670,7 @@ This sends the Standard welcome 7 days after each active member's `joined_on`.
669
670
 
670
671
  A deployed schedule is a System Notification. It sends with no staff identity. `filters` decides who gets it, and `automaticFilters` decides who gets it without a staff action. A file cannot name a person to send as. Staff actions on one generated notification, such as **Send now** or an edit, still act as the person who clicks.
671
672
 
672
- A deploy writes the schedule into the workspace and makes its upcoming notifications. A later deploy updates the same schedule. An offset that stays in the list keeps its notifications, with their edits and holds. When the file is gone, the publish deletes the schedule, as **Delete** on the schedule page does: the notifications that were not sent are archived, and the send history stays. A publish never pauses or enables a schedule. Staff can still pause it on the schedule page, which shows the other fields as read-only, with the path of the file.
673
+ A deploy writes the schedule into the workspace and makes its upcoming notifications. A later deploy updates the same schedule. An offset that stays in the list keeps its notifications, with their edits and holds. When the file is gone, the publish deletes the schedule, as **Delete** on the schedule page does: the notifications that were not sent are archived, and the send history stays. A publish never pauses or enables a schedule. Staff pause and resume it on the schedule page, and that changes no file. A save or a delete on the schedule page, through the API, or through MCP commits the schedule file and deploys it.
673
674
 
674
675
  ### Send from a workflow
675
676
 
package/dist/cli.mjs CHANGED
@@ -312520,9 +312520,13 @@ var GENERATED_NOTIFICATION_TYPES_MODULE = "@app/generated/notification-types";
312520
312520
  var NOTIFICATION_TYPES_EXPORT = "NotificationTypes";
312521
312521
  var TYPE_PATH = /^notifications\/([^/]+)\/type\.ts$/;
312522
312522
  var TEMPLATE_PATH = /^notifications\/([^/]+)\/([^/]+)\.template\.ts$/;
312523
+ var SCHEDULE_PATH = /^notifications\/[^/]+\/[^/]+\.schedule\.ts$/;
312523
312524
  function notificationFolder(path) {
312524
312525
  return path.split("/")[1];
312525
312526
  }
312527
+ function isNotificationSchedulePath(path) {
312528
+ return SCHEDULE_PATH.test(path);
312529
+ }
312526
312530
  function templateSlugOf(path) {
312527
312531
  return TEMPLATE_PATH.exec(path)[2];
312528
312532
  }
@@ -315043,6 +315047,20 @@ function buildMigrations({ migrations, ...input }) {
315043
315047
  };
315044
315048
  }
315045
315049
 
315050
+ // scripts/lib/runtime-build/navigation-menu-file.mjs
315051
+ init_define_globalThis_DIAGONAL_SDK_RUNTIME();
315052
+
315053
+ // scripts/lib/runtime-build/source-literal.mjs
315054
+ init_define_globalThis_DIAGONAL_SDK_RUNTIME();
315055
+ function quotedLiteral(value) {
315056
+ return `'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'").replaceAll("\r", "\\r").replaceAll("\n", "\\n").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029")}'`;
315057
+ }
315058
+
315059
+ // scripts/lib/runtime-build/navigation-menu-file.mjs
315060
+ function isMenuFile(path) {
315061
+ return /^navigation\/[^/]+\.ts$/.test(path) && !/\.(test|spec|d)\.ts$/.test(path);
315062
+ }
315063
+
315046
315064
  // scripts/lib/runtime-build/notification-files.mjs
315047
315065
  init_define_globalThis_DIAGONAL_SDK_RUNTIME();
315048
315066
  import { posix as posix3 } from "node:path";
@@ -315068,6 +315086,7 @@ var SCHEDULE_PROPERTIES = [
315068
315086
  "dateField",
315069
315087
  "timing",
315070
315088
  "offsets",
315089
+ "stageIds",
315071
315090
  "filters",
315072
315091
  "automaticFilters",
315073
315092
  "recipient",
@@ -315079,6 +315098,7 @@ var MAX_VARIABLES = 100;
315079
315098
  var RECIPIENT_MAX_LENGTH = 255;
315080
315099
  var VARIABLE_PATH_MAX_LENGTH = 500;
315081
315100
  var VARIABLE_PATH_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_.-]*$/;
315101
+ var STAGE_ID_PATTERN = /^[a-zA-Z0-9_-]{1,100}$/;
315082
315102
  var DATE_FIELD_TYPES = ["date", "datetime", "event_schedule"];
315083
315103
  var EXACT_TIMING_FIELD_TYPES2 = ["datetime", "event_schedule"];
315084
315104
  var SINGULAR_RELATIONS = ["belongs_to", "has_one"];
@@ -315139,6 +315159,26 @@ function readVariablePaths(value, node, report) {
315139
315159
  }
315140
315160
  return Object.keys(variables).length === entries.length ? variables : null;
315141
315161
  }
315162
+ function readStageIds(value, offsets, node, report) {
315163
+ if (value.stageIds === void 0) {
315164
+ return null;
315165
+ }
315166
+ const stageIdsNode = nodeAt(node, "stageIds");
315167
+ const stageIds = value.stageIds;
315168
+ if (!Array.isArray(stageIds) || stageIds.some((id) => typeof id !== "string" || !STAGE_ID_PATTERN.test(id))) {
315169
+ report(stageIdsNode, '"stageIds" must be a list of ids of letters, digits, "_", and "-", with at most 100 characters each');
315170
+ return null;
315171
+ }
315172
+ if (new Set(stageIds).size !== stageIds.length) {
315173
+ report(stageIdsNode, "The stage ids must be distinct");
315174
+ return null;
315175
+ }
315176
+ if (offsets !== null && stageIds.length !== offsets.length) {
315177
+ report(stageIdsNode, `"stageIds" must have one id for each offset: ${offsets.length}`);
315178
+ return null;
315179
+ }
315180
+ return stageIds;
315181
+ }
315142
315182
  function readFilters(value, key, node, report) {
315143
315183
  const filters = value[key] ?? null;
315144
315184
  if (filters !== null) {
@@ -315174,6 +315214,10 @@ function buildSchedule(file2, value, node, report, context) {
315174
315214
  `"recipient" must be a path of relations from the source record, for example 'member'`
315175
315215
  );
315176
315216
  }
315217
+ const offsets = readOffsets(value.offsets, nodeAt(node, "offsets"), report, {
315218
+ max: MAX_OFFSETS,
315219
+ unsignedAfter: true
315220
+ });
315177
315221
  return {
315178
315222
  path: file2.path,
315179
315223
  uid: checkedUid(file2),
@@ -315185,10 +315229,8 @@ function buildSchedule(file2, value, node, report, context) {
315185
315229
  resource: readSource(value, node, report, context),
315186
315230
  dateField,
315187
315231
  timing,
315188
- offsets: readOffsets(value.offsets, nodeAt(node, "offsets"), report, {
315189
- max: MAX_OFFSETS,
315190
- unsignedAfter: true
315191
- }),
315232
+ offsets,
315233
+ stageIds: readStageIds(value, offsets, node, report),
315192
315234
  filters,
315193
315235
  automaticFilters,
315194
315236
  recipient,
@@ -315377,6 +315419,7 @@ function resolveSchedules(schedules, definitions, context, diagnostics) {
315377
315419
  date_field: schedule.dateField,
315378
315420
  timing: schedule.timing,
315379
315421
  offsets: schedule.offsets,
315422
+ stage_ids: schedule.stageIds,
315380
315423
  filters: schedule.filters,
315381
315424
  automatic_filters: schedule.automaticFilters,
315382
315425
  recipient_path: schedule.recipient,
@@ -319387,12 +319430,6 @@ function seoReadProblem({ key, read: read2, inTemplate }, bindings, resourcesByS
319387
319430
  return null;
319388
319431
  }
319389
319432
 
319390
- // scripts/lib/runtime-build/source-literal.mjs
319391
- init_define_globalThis_DIAGONAL_SDK_RUNTIME();
319392
- function quotedLiteral(value) {
319393
- return `'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'").replaceAll("\r", "\\r").replaceAll("\n", "\\n").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029")}'`;
319394
- }
319395
-
319396
319433
  // scripts/lib/runtime-build/page-options-migration.mjs
319397
319434
  function movableMetaValue(value) {
319398
319435
  if (value !== null && typeof value !== "string" && !isPlainObject2(value)) {
@@ -321974,7 +322011,6 @@ function declaredHost(domainKey, primaryDomain) {
321974
322011
  var CONFIG_PATH2 = "diagonal.config.ts";
321975
322012
  var NOTIFICATION_TYPE_PATTERN = /^notifications\/[^/]+\/type\.ts$/;
321976
322013
  var NOTIFICATION_TEMPLATE_PATTERN = /^notifications\/[^/]+\/[^/]+\.template\.ts$/;
321977
- var NOTIFICATION_SCHEDULE_PATTERN = /^notifications\/[^/]+\/[^/]+\.schedule\.ts$/;
321978
322014
  var EMAIL_LAYOUT_PATTERN = /^email-layouts\/[^/]+\/layout\.ts$/;
321979
322015
  var IGNORED_DIRECTORIES = /* @__PURE__ */ new Set(["vendor"]);
321980
322016
  var COMPONENT_NAME_PATTERN = /^[A-Z][A-Za-z0-9]*$/;
@@ -322194,7 +322230,7 @@ function classify(path) {
322194
322230
  if (NOTIFICATION_TEMPLATE_PATTERN.test(path)) {
322195
322231
  return "notification_template";
322196
322232
  }
322197
- return NOTIFICATION_SCHEDULE_PATTERN.test(path) ? "notification_schedule" : "ignored";
322233
+ return isNotificationSchedulePath(path) ? "notification_schedule" : "ignored";
322198
322234
  case "email-layouts":
322199
322235
  return EMAIL_LAYOUT_PATTERN.test(path) ? "email_layout" : "ignored";
322200
322236
  case "record-bindings":
@@ -322768,7 +322804,7 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
322768
322804
  const files = listCheckoutFiles(root, IGNORED_DIRECTORIES);
322769
322805
  const moduleUidDefinitions = [];
322770
322806
  for (const path of files) {
322771
- const type = moduleEntityType(path);
322807
+ const type = moduleEntityType(path) ?? (isMenuFile(path) ? "menu" : null);
322772
322808
  const definition = type === null ? null : moduleUidDefinition(type, path, readFileSync13(join17(root, path), "utf8"));
322773
322809
  if (definition !== null) {
322774
322810
  moduleUidDefinitions.push(definition);
package/dist/index.d.ts CHANGED
@@ -1267,6 +1267,15 @@ export type NotificationScheduleDefinition = UidOption & {
1267
1267
  * before in exact timing). A duration without a sign counts after the date.
1268
1268
  */
1269
1269
  offsets: readonly string[];
1270
+ /**
1271
+ * One distinct stable id for each offset, in the order of `offsets`: letters,
1272
+ * digits, `_`, and `-`, up to 100 characters. A notification keeps its stage
1273
+ * id when you change its offset, so it keeps its edits, hold, and history.
1274
+ * Without `stageIds`, an offset that stays keeps its id, and a changed offset
1275
+ * takes the id of a removed offset. The app writes `stageIds` when it saves
1276
+ * the schedule.
1277
+ */
1278
+ stageIds?: readonly string[];
1270
1279
  /** Only the source records that match, for automatic and staff sends. */
1271
1280
  filters?: FilterGroup;
1272
1281
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/cli",
3
- "version": "0.33.3",
3
+ "version": "0.33.5",
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": {