@diagonal-hq/cli 0.33.3 → 0.33.4
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 +2 -1
- package/dist/cli.mjs +34 -6
- package/dist/index.d.ts +9 -0
- package/package.json +1 -1
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
|
|
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
|
}
|
|
@@ -315068,6 +315072,7 @@ var SCHEDULE_PROPERTIES = [
|
|
|
315068
315072
|
"dateField",
|
|
315069
315073
|
"timing",
|
|
315070
315074
|
"offsets",
|
|
315075
|
+
"stageIds",
|
|
315071
315076
|
"filters",
|
|
315072
315077
|
"automaticFilters",
|
|
315073
315078
|
"recipient",
|
|
@@ -315079,6 +315084,7 @@ var MAX_VARIABLES = 100;
|
|
|
315079
315084
|
var RECIPIENT_MAX_LENGTH = 255;
|
|
315080
315085
|
var VARIABLE_PATH_MAX_LENGTH = 500;
|
|
315081
315086
|
var VARIABLE_PATH_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_.-]*$/;
|
|
315087
|
+
var STAGE_ID_PATTERN = /^[a-zA-Z0-9_-]{1,100}$/;
|
|
315082
315088
|
var DATE_FIELD_TYPES = ["date", "datetime", "event_schedule"];
|
|
315083
315089
|
var EXACT_TIMING_FIELD_TYPES2 = ["datetime", "event_schedule"];
|
|
315084
315090
|
var SINGULAR_RELATIONS = ["belongs_to", "has_one"];
|
|
@@ -315139,6 +315145,26 @@ function readVariablePaths(value, node, report) {
|
|
|
315139
315145
|
}
|
|
315140
315146
|
return Object.keys(variables).length === entries.length ? variables : null;
|
|
315141
315147
|
}
|
|
315148
|
+
function readStageIds(value, offsets, node, report) {
|
|
315149
|
+
if (value.stageIds === void 0) {
|
|
315150
|
+
return null;
|
|
315151
|
+
}
|
|
315152
|
+
const stageIdsNode = nodeAt(node, "stageIds");
|
|
315153
|
+
const stageIds = value.stageIds;
|
|
315154
|
+
if (!Array.isArray(stageIds) || stageIds.some((id) => typeof id !== "string" || !STAGE_ID_PATTERN.test(id))) {
|
|
315155
|
+
report(stageIdsNode, '"stageIds" must be a list of ids of letters, digits, "_", and "-", with at most 100 characters each');
|
|
315156
|
+
return null;
|
|
315157
|
+
}
|
|
315158
|
+
if (new Set(stageIds).size !== stageIds.length) {
|
|
315159
|
+
report(stageIdsNode, "The stage ids must be distinct");
|
|
315160
|
+
return null;
|
|
315161
|
+
}
|
|
315162
|
+
if (offsets !== null && stageIds.length !== offsets.length) {
|
|
315163
|
+
report(stageIdsNode, `"stageIds" must have one id for each offset: ${offsets.length}`);
|
|
315164
|
+
return null;
|
|
315165
|
+
}
|
|
315166
|
+
return stageIds;
|
|
315167
|
+
}
|
|
315142
315168
|
function readFilters(value, key, node, report) {
|
|
315143
315169
|
const filters = value[key] ?? null;
|
|
315144
315170
|
if (filters !== null) {
|
|
@@ -315174,6 +315200,10 @@ function buildSchedule(file2, value, node, report, context) {
|
|
|
315174
315200
|
`"recipient" must be a path of relations from the source record, for example 'member'`
|
|
315175
315201
|
);
|
|
315176
315202
|
}
|
|
315203
|
+
const offsets = readOffsets(value.offsets, nodeAt(node, "offsets"), report, {
|
|
315204
|
+
max: MAX_OFFSETS,
|
|
315205
|
+
unsignedAfter: true
|
|
315206
|
+
});
|
|
315177
315207
|
return {
|
|
315178
315208
|
path: file2.path,
|
|
315179
315209
|
uid: checkedUid(file2),
|
|
@@ -315185,10 +315215,8 @@ function buildSchedule(file2, value, node, report, context) {
|
|
|
315185
315215
|
resource: readSource(value, node, report, context),
|
|
315186
315216
|
dateField,
|
|
315187
315217
|
timing,
|
|
315188
|
-
offsets
|
|
315189
|
-
|
|
315190
|
-
unsignedAfter: true
|
|
315191
|
-
}),
|
|
315218
|
+
offsets,
|
|
315219
|
+
stageIds: readStageIds(value, offsets, node, report),
|
|
315192
315220
|
filters,
|
|
315193
315221
|
automaticFilters,
|
|
315194
315222
|
recipient,
|
|
@@ -315377,6 +315405,7 @@ function resolveSchedules(schedules, definitions, context, diagnostics) {
|
|
|
315377
315405
|
date_field: schedule.dateField,
|
|
315378
315406
|
timing: schedule.timing,
|
|
315379
315407
|
offsets: schedule.offsets,
|
|
315408
|
+
stage_ids: schedule.stageIds,
|
|
315380
315409
|
filters: schedule.filters,
|
|
315381
315410
|
automatic_filters: schedule.automaticFilters,
|
|
315382
315411
|
recipient_path: schedule.recipient,
|
|
@@ -321974,7 +322003,6 @@ function declaredHost(domainKey, primaryDomain) {
|
|
|
321974
322003
|
var CONFIG_PATH2 = "diagonal.config.ts";
|
|
321975
322004
|
var NOTIFICATION_TYPE_PATTERN = /^notifications\/[^/]+\/type\.ts$/;
|
|
321976
322005
|
var NOTIFICATION_TEMPLATE_PATTERN = /^notifications\/[^/]+\/[^/]+\.template\.ts$/;
|
|
321977
|
-
var NOTIFICATION_SCHEDULE_PATTERN = /^notifications\/[^/]+\/[^/]+\.schedule\.ts$/;
|
|
321978
322006
|
var EMAIL_LAYOUT_PATTERN = /^email-layouts\/[^/]+\/layout\.ts$/;
|
|
321979
322007
|
var IGNORED_DIRECTORIES = /* @__PURE__ */ new Set(["vendor"]);
|
|
321980
322008
|
var COMPONENT_NAME_PATTERN = /^[A-Z][A-Za-z0-9]*$/;
|
|
@@ -322194,7 +322222,7 @@ function classify(path) {
|
|
|
322194
322222
|
if (NOTIFICATION_TEMPLATE_PATTERN.test(path)) {
|
|
322195
322223
|
return "notification_template";
|
|
322196
322224
|
}
|
|
322197
|
-
return
|
|
322225
|
+
return isNotificationSchedulePath(path) ? "notification_schedule" : "ignored";
|
|
322198
322226
|
case "email-layouts":
|
|
322199
322227
|
return EMAIL_LAYOUT_PATTERN.test(path) ? "email_layout" : "ignored";
|
|
322200
322228
|
case "record-bindings":
|
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
|
/**
|