@diagonal-hq/cli 0.33.5 → 0.33.6

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
@@ -598,7 +598,57 @@ export default defineNotificationTemplate({
598
598
  });
599
599
  ```
600
600
 
601
- A file can use three generators: `date.current` and `time.current`, which take no settings, and `workspace.login_url`, which takes the resource whose members sign in. The template editor also offers `page.url`, `workflow.url`, and `calendar.generate_link`. They need a page, a workflow, or a variable binding that a file cannot hold yet, so the check refuses them.
601
+ A file can use six generators, the same as the template editor:
602
+
603
+ - `date.current` and `time.current` take no settings.
604
+ - `workspace.login_url` takes the resource whose members sign in.
605
+ - `page.url` takes `page: Pages.<Name>.uid` from `@app/generated/pages` and `params`, a value for each route parameter.
606
+ - `workflow.url` takes `workflow: Workflows.<Name>.uid` from `@app/generated/workflows` and `params`. The workflow must have a `request` trigger.
607
+ - `calendar.generate_link` takes `type` (`'google'`, `'apple'`, or `'outlook'`), `resource`, an eventable resource as `Resources.<Name>.slug`, and `record`, the event record.
608
+
609
+ A route parameter and `record` are a string, or `{ variable: '<path>' }`, which reads a value of the send when the notification renders. The path starts with a variable of the type, or with `record`, the recipient, such as `{ variable: 'record.id' }` or `{ variable: 'first_event.id' }`.
610
+
611
+ ```ts
612
+ import { Pages } from '@app/generated/pages';
613
+ import { Resources } from '@app/generated/resources';
614
+ import { Workflows } from '@app/generated/workflows';
615
+ import { defineNotificationTemplate } from '@diagonal-hq/cli';
616
+
617
+ export default defineNotificationTemplate({
618
+ uid: '019a4d6e-6c3d-7e4f-8a5b-8c9d0e1f2a3b',
619
+ name: 'Event invite',
620
+ email: {
621
+ subject: 'You are invited to {{ first_event.title }}',
622
+ fields: {
623
+ content:
624
+ '<p><a href="{{ ref.profile }}">Your profile</a> · <a href="{{ ref.rsvp }}">RSVP</a> · <a href="{{ ref.calendar }}">Add to Google Calendar</a></p>'
625
+ }
626
+ },
627
+ references: {
628
+ profile: {
629
+ label: 'Profile',
630
+ generator: 'page.url',
631
+ settings: { page: Pages.Members_$Id.uid, params: { id: { variable: 'record.id' } } }
632
+ },
633
+ rsvp: {
634
+ label: 'RSVP',
635
+ generator: 'workflow.url',
636
+ settings: { workflow: Workflows.Rsvp.uid, params: { event: { variable: 'first_event.id' } } }
637
+ },
638
+ calendar: {
639
+ label: 'Add to Google Calendar',
640
+ generator: 'calendar.generate_link',
641
+ settings: {
642
+ type: 'google',
643
+ resource: Resources.Events.slug,
644
+ record: { variable: 'first_event.id' }
645
+ }
646
+ }
647
+ }
648
+ });
649
+ ```
650
+
651
+ The deploy stores each reference as the template editor stores it, so a send renders the same link. The page id of a page file is its uid, and the workflow id comes from the active deployment.
602
652
 
603
653
  An email layout is the frame that templates fill in. Each field is a slot that a template fills with Liquid.
604
654
 
@@ -724,7 +774,8 @@ The editor checks the shape of each definition. `diagonal check` and the build a
724
774
  - A type's `recipient` resource declares the Notifiable capability. When a template of the type has an email, the resource maps `email_field`. When a template has an SMS, the resource maps `phone_field`. The resource check makes sure that `email_field` names an `email` field and `phone_field` names a `phone` or `text` field.
725
775
  - A type has at least one template, and its `defaultTemplate` names one of them.
726
776
  - A template's folder has a `type.ts`. A template has no `type`. A template has an email, an SMS, or both. An email `subject` has 1 to 10,000 characters. `email.layout` names a layout of the workspace files, or `'default'`. An email's `fields` match the fields of its layout and fill each required field. A layout field key differs from `record` and from each variable key of the template's type. The built-in layout has the field `content`. An SMS `body` is not empty.
727
- - A template has at most 50 references. A reference key starts with a lowercase letter, has only a-z, 0-9, and `_`, and has at most 64 characters. A label has at most 255 characters. The generator is one that a file can deploy.
777
+ - A template has at most 50 references. A reference key starts with a lowercase letter, has only a-z, 0-9, and `_`, and has at most 64 characters. A label has at most 255 characters.
778
+ - A `page.url` or `workflow.url` reference names a page or a workflow of the workspace. An unknown `Pages` or `Workflows` name is an error at its line and column. `params` has a value for each required route parameter of the page or workflow and no other name. A `workflow.url` workflow has a `request` trigger. A `calendar.generate_link` resource has the `eventable` capability. The first segment of a `{ variable }` path is a variable of the type, or `record` when the type has a `recipient`.
728
779
  - A layout's slug and its folder name are not `default`, and its `body` is not empty. A layout field key starts with a letter or `_` and has only letters, digits, and `_`. Each field has a `label` of at most 255 characters.
729
780
  - A schedule has a `name` of 1 to 255 characters. Its `type` names a type of the workspace files that has a `recipient`, and its `template` names a template of that type that has an email. `source.resource` is a resource of the workspace. A schedule's `filters` is a filter tree with a known operator in each condition.
730
781
  - A schedule's `dateField` is a date, datetime, or event schedule field of the source resource. Exact timing needs a datetime or event schedule field. `offsets` holds 1 to 30 distinct durations.
package/dist/cli.mjs CHANGED
@@ -311278,6 +311278,20 @@ function workflowMetadata(ast) {
311278
311278
  }
311279
311279
  return metadata;
311280
311280
  }
311281
+ function workflowListing(ast) {
311282
+ const read2 = workflowMetadata(ast);
311283
+ const trigger = propertyNodes(
311284
+ propertyNodes(workflowConfigObject(ast) ?? void 0).get("trigger")?.value
311285
+ );
311286
+ const isRequest = read2.trigger === "request";
311287
+ const method = isRequest ? stringLiteral4(trigger.get("method")?.value) ?? "GET" : null;
311288
+ return {
311289
+ name: read2.name ?? null,
311290
+ workflow_type: read2.trigger === void 0 ? null : TRIGGERS[read2.trigger].type,
311291
+ route: isRequest ? stringLiteral4(trigger.get("path")?.value) : null,
311292
+ method: method === null ? null : method.toUpperCase()
311293
+ };
311294
+ }
311281
311295
  function configUid(configObject) {
311282
311296
  try {
311283
311297
  return readUid(configObject);
@@ -315065,6 +315079,13 @@ function isMenuFile(path) {
315065
315079
  init_define_globalThis_DIAGONAL_SDK_RUNTIME();
315066
315080
  import { posix as posix3 } from "node:path";
315067
315081
 
315082
+ // scripts/lib/runtime-build/calendar-link-types.json
315083
+ var calendar_link_types_default = [
315084
+ "apple",
315085
+ "google",
315086
+ "outlook"
315087
+ ];
315088
+
315068
315089
  // scripts/lib/runtime-build/notification-generators.json
315069
315090
  var notification_generators_default = [
315070
315091
  "page.url",
@@ -315432,11 +315453,7 @@ function resolveSchedules(schedules, definitions, context, diagnostics) {
315432
315453
 
315433
315454
  // scripts/lib/runtime-build/notification-files.mjs
315434
315455
  var NOTIFICATION_REFERENCE_GENERATORS = notification_generators_default;
315435
- var DEPLOYABLE_REFERENCE_GENERATORS = [
315436
- "date.current",
315437
- "time.current",
315438
- "workspace.login_url"
315439
- ];
315456
+ var CALENDAR_LINK_TYPES = calendar_link_types_default;
315440
315457
  var NOTIFICATION_DIRECTORIES = ["notifications", "email-layouts"];
315441
315458
  var BUILT_IN_LAYOUT_FIELDS = {
315442
315459
  content: { label: "Content", description: null, required: true }
@@ -315453,6 +315470,7 @@ var VARIABLE_KEY_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
315453
315470
  var RESERVED_VARIABLE_KEYS = /* @__PURE__ */ new Set(["record", "ref"]);
315454
315471
  var REFERENCE_KEY_PATTERN = /^[a-z][a-z0-9_]*$/;
315455
315472
  var REFERENCE_KEY_MAX_LENGTH = 64;
315473
+ var VARIABLE_PATH_PATTERN2 = /^[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z0-9_]+)*$/;
315456
315474
  var STORED_FIELD_OPTIONS = [
315457
315475
  "guard",
315458
315476
  "default",
@@ -315949,6 +315967,112 @@ function readSms(file2, sms, node, report, context) {
315949
315967
  checkAssetReferences(body.text, body.origin, { html: false }, context, report);
315950
315968
  return { body: body.text };
315951
315969
  }
315970
+ function readBindable(item, node, report, label) {
315971
+ if (typeof item === "string" && item.trim() !== "") {
315972
+ return item;
315973
+ }
315974
+ if (isPlainObject3(item) && Object.keys(item).join() === "variable" && typeof item.variable === "string" && VARIABLE_PATH_PATTERN2.test(item.variable)) {
315975
+ return { variable: item.variable };
315976
+ }
315977
+ report(node, `${label} must be a non-empty string or { variable: '<variable>.<field>' }`);
315978
+ return null;
315979
+ }
315980
+ function readRouteParams(key, settings, settingsNode, report, { route, target }) {
315981
+ const paramsNode = nodeAt(settingsNode, "params");
315982
+ const params = settings.params ?? /* @__PURE__ */ Object.create(null);
315983
+ if (!isPlainObject3(params)) {
315984
+ report(paramsNode, `"settings.params" of reference "${key}" must be an object of route parameters by name`);
315985
+ return null;
315986
+ }
315987
+ const names2 = route === null ? null : routeParamNames(route);
315988
+ const before = report.count();
315989
+ const values = /* @__PURE__ */ Object.create(null);
315990
+ for (const [name, item] of Object.entries(params)) {
315991
+ if (names2 !== null && !names2.includes(name) && !names2.includes(`${name}?`)) {
315992
+ report(
315993
+ keyNodeAt(paramsNode, name),
315994
+ `${target} has no route parameter "${name}". Its route is "${route}"`
315995
+ );
315996
+ continue;
315997
+ }
315998
+ const value = readBindable(item, nodeAt(paramsNode, name), report, `Route parameter "${name}" of reference "${key}"`);
315999
+ if (value !== null) {
316000
+ values[name] = value;
316001
+ }
316002
+ }
316003
+ for (const name of names2 ?? []) {
316004
+ if (!name.endsWith("?") && !Object.hasOwn(params, name)) {
316005
+ report(
316006
+ settings.params === void 0 ? settingsNode : paramsNode,
316007
+ `Reference "${key}" needs a value for the route parameter "${name}" of ${target}, whose route is "${route}". Add params: { ${name}: { variable: '<variable>.<field>' } }`
316008
+ );
316009
+ }
316010
+ }
316011
+ return report.count() === before ? values : null;
316012
+ }
316013
+ function readPageSettings(key, settings, settingsNode, report, context) {
316014
+ const pageNode = nodeAt(settingsNode, "page");
316015
+ const page = typeof settings.page === "string" ? context.pagesByUid.get(settings.page) : void 0;
316016
+ if (page === void 0) {
316017
+ report(
316018
+ settings.page === void 0 ? settingsNode : pageNode,
316019
+ `Reference "${key}" needs settings.page: Pages.<Name>.uid from ${GENERATED_PAGES_MODULE}`
316020
+ );
316021
+ return null;
316022
+ }
316023
+ const params = readRouteParams(key, settings, settingsNode, report, { route: page.route, target: `Pages.${page.name}` });
316024
+ return params === null ? null : { page: settings.page, params };
316025
+ }
316026
+ function readWorkflowSettings(key, settings, settingsNode, report, context) {
316027
+ const workflowNode = nodeAt(settingsNode, "workflow");
316028
+ const workflow = typeof settings.workflow === "string" ? context.workflowsByUid.get(settings.workflow) : void 0;
316029
+ if (workflow === void 0) {
316030
+ report(
316031
+ settings.workflow === void 0 ? settingsNode : workflowNode,
316032
+ `Reference "${key}" needs settings.workflow: Workflows.<Name>.uid from ${GENERATED_WORKFLOWS_MODULE}`
316033
+ );
316034
+ return null;
316035
+ }
316036
+ if (workflow.trigger !== "request") {
316037
+ report(workflowNode, `Workflows.${workflow.name} is not a request workflow, so it has no URL. Use a workflow with trigger: { type: 'request' }`);
316038
+ return null;
316039
+ }
316040
+ const params = readRouteParams(key, settings, settingsNode, report, { route: workflow.route, target: `Workflows.${workflow.name}` });
316041
+ return params === null ? null : { workflow: settings.workflow, params };
316042
+ }
316043
+ function readCalendarSettings(key, settings, settingsNode, report, context) {
316044
+ if (!CALENDAR_LINK_TYPES.includes(settings.type)) {
316045
+ report(
316046
+ settings.type === void 0 ? settingsNode : nodeAt(settingsNode, "type"),
316047
+ `Reference "${key}" needs settings.type: one of ${CALENDAR_LINK_TYPES.map((type) => `'${type}'`).join(", ")}`
316048
+ );
316049
+ return null;
316050
+ }
316051
+ const resourceNode = nodeAt(settingsNode, "resource");
316052
+ const resource = readResource(settings.resource, resourceNode ?? settingsNode, report, `Reference "${key}" "settings.resource"`, context);
316053
+ if (resource === null) {
316054
+ return null;
316055
+ }
316056
+ const definition = context.resourcesBySlug?.get(resource);
316057
+ if (context.resourcesBySlug !== null && definition?.capabilities.eventable === void 0) {
316058
+ report(
316059
+ resourceNode,
316060
+ `Reference "${key}" "settings.resource": the resource "${resource}" is not eventable. Add capabilities.eventable to ${definition?.path ?? `the resource "${resource}"`}`
316061
+ );
316062
+ return null;
316063
+ }
316064
+ if (settings.record === void 0) {
316065
+ report(settingsNode, `Reference "${key}" needs settings.record: { variable: '<variable>.id' }`);
316066
+ return null;
316067
+ }
316068
+ const record = readBindable(settings.record, nodeAt(settingsNode, "record"), report, `"settings.record" of reference "${key}"`);
316069
+ return record === null ? null : { type: settings.type, resource, resource_uid: resourceUid(resource, context), record };
316070
+ }
316071
+ var REFERENCE_SETTINGS = {
316072
+ "page.url": { properties: ["page", "params"], read: readPageSettings },
316073
+ "workflow.url": { properties: ["workflow", "params"], read: readWorkflowSettings },
316074
+ "calendar.generate_link": { properties: ["type", "resource", "record"], read: readCalendarSettings }
316075
+ };
315952
316076
  function readReferenceSettings(key, reference, node, report, context) {
315953
316077
  const settingsNode = nodeAt(node, "settings");
315954
316078
  const settings = reference.settings ?? {};
@@ -315973,6 +316097,15 @@ function readReferenceSettings(key, reference, node, report, context) {
315973
316097
  );
315974
316098
  return resource === null ? null : { resource, resource_uid: resourceUid(resource, context) };
315975
316099
  }
316100
+ const target = REFERENCE_SETTINGS[reference.generator];
316101
+ if (target !== void 0) {
316102
+ const before = report.count();
316103
+ checkProperties(settings, target.properties, settingsNode ?? node, `${reference.generator} setting`, report);
316104
+ if (report.count() > before) {
316105
+ return null;
316106
+ }
316107
+ return target.read(key, settings, settingsNode ?? node, report, context);
316108
+ }
315976
316109
  if (Object.keys(settings).length > 0) {
315977
316110
  report(settingsNode, `${reference.generator} takes no settings`);
315978
316111
  return null;
@@ -316027,10 +316160,6 @@ function readReferences(value, node, report, context) {
316027
316160
  );
316028
316161
  continue;
316029
316162
  }
316030
- if (!DEPLOYABLE_REFERENCE_GENERATORS.includes(generator)) {
316031
- report(generatorNode, `${generator} cannot be deployed from a file-based workspace yet`);
316032
- continue;
316033
- }
316034
316163
  const settings = readReferenceSettings(key, reference, itemNode, report, context);
316035
316164
  if (report.count() === before && settings !== null) {
316036
316165
  references[key] = { label, generator, settings };
@@ -316051,9 +316180,33 @@ function buildTemplate(file2, value, node, report, context) {
316051
316180
  email: value.email === void 0 ? null : readEmail(file2, value.email, nodeAt(node, "email"), report, context),
316052
316181
  sms: value.sms === void 0 ? null : readSms(file2, value.sms, nodeAt(node, "sms"), report, context),
316053
316182
  references: readReferences(value, node, report, context),
316054
- nodes: { email: nodeAt(node, "email"), sms: nodeAt(node, "sms") }
316183
+ nodes: { email: nodeAt(node, "email"), sms: nodeAt(node, "sms"), references: nodeAt(node, "references") }
316055
316184
  };
316056
316185
  }
316186
+ function variableBindingDiagnostics(template, type) {
316187
+ const roots = type.variables.map((variable) => variable.key);
316188
+ if (type.recipient_resource !== null) {
316189
+ roots.push("record");
316190
+ }
316191
+ const diagnostics = [];
316192
+ for (const [key, reference] of Object.entries(template.references)) {
316193
+ const settingsNode = nodeAt(nodeAt(template.nodes.references, key), "settings");
316194
+ const bindings = reference.generator === "calendar.generate_link" ? [[reference.settings.record, nodeAt(settingsNode, "record")]] : Object.entries(reference.settings.params ?? {}).map(([name, value]) => [value, nodeAt(nodeAt(settingsNode, "params"), name)]);
316195
+ for (const [value, node] of bindings) {
316196
+ if (!isPlainObject3(value) || roots.includes(value.variable.split(".")[0])) {
316197
+ continue;
316198
+ }
316199
+ diagnostics.push(
316200
+ diagnosticAt(
316201
+ template.path,
316202
+ nodeAt(node, "variable") ?? node,
316203
+ roots.length === 0 ? `"${value.variable}" names no variable. The notification type "${type.slug}" has no variables and no recipient` : `"${value.variable}" names no variable of the notification type "${type.slug}". Start the path with one of: ${roots.join(", ")}`
316204
+ )
316205
+ );
316206
+ }
316207
+ }
316208
+ return diagnostics;
316209
+ }
316057
316210
  function readLayoutFields(value, node, report) {
316058
316211
  if (value.fields === void 0) {
316059
316212
  return {};
@@ -316149,9 +316302,12 @@ function readDefinition(file2, context, report) {
316149
316302
  notificationTypesBinding(file2.ast, context.notificationTypes.entries),
316150
316303
  emailLayoutsBinding(file2.ast, context.emailLayouts.entries)
316151
316304
  ].filter((binding) => binding !== null);
316305
+ const template = definitionKind.kind === "template";
316152
316306
  const { value } = staticObject(definition, {
316153
316307
  fieldBuilders: true,
316154
316308
  resources: resourcesBinding(file2.ast, context.names),
316309
+ pages: template ? pagesBinding(file2.ast, context.pages.entries, context.pages.pathsByName) : null,
316310
+ workflows: template ? workflowsBinding(file2.ast, context.workflows.entries, context.workflows.names) : null,
316155
316311
  generatedEntries: [...generatedEntries, ...recordBindingsBinding(file2.ast, context.recordBindingEntries ?? {})]
316156
316312
  });
316157
316313
  if (definitionKind.kind === "template" && value.type !== void 0) {
@@ -316220,6 +316376,8 @@ function checkNotificationFiles(files, {
316220
316376
  unreadFiles = [],
316221
316377
  notificationTypes = { names: /* @__PURE__ */ new Map(), entries: {} },
316222
316378
  emailLayouts = { names: /* @__PURE__ */ new Map(), entries: {} },
316379
+ pages = { entries: {}, pathsByName: /* @__PURE__ */ new Map() },
316380
+ workflows = { entries: {}, names: { pathsByName: /* @__PURE__ */ new Map() }, routesByPath: /* @__PURE__ */ new Map() },
316223
316381
  assets = [],
316224
316382
  assetCatalog = null
316225
316383
  }) {
@@ -316227,6 +316385,15 @@ function checkNotificationFiles(files, {
316227
316385
  const context = {
316228
316386
  recordBindingEntries,
316229
316387
  names: names2,
316388
+ pages,
316389
+ pagesByUid: indexPagesByUid(pages.entries),
316390
+ workflows,
316391
+ workflowsByUid: new Map(
316392
+ Object.entries(workflows.entries).filter(([, workflow]) => workflow.uid !== null).map(([name, workflow]) => [
316393
+ workflow.uid,
316394
+ { name, trigger: workflow.trigger ?? null, route: workflows.routesByPath.get(workflows.names.pathsByName.get(name)) ?? null }
316395
+ ])
316396
+ ),
316230
316397
  resources,
316231
316398
  resourceSlugs: resourcesComplete ? new Set([...resources, ...builtInResources].map((resource) => resource.slug)) : null,
316232
316399
  resourceUids: new Map(resources.map((resource) => [resource.slug, resource.uid ?? null])),
@@ -316305,6 +316472,12 @@ function checkNotificationFiles(files, {
316305
316472
  fail("template", template);
316306
316473
  continue;
316307
316474
  }
316475
+ const bindingDiagnostics = variableBindingDiagnostics(template, type);
316476
+ if (bindingDiagnostics.length > 0) {
316477
+ diagnostics.push(...bindingDiagnostics);
316478
+ fail("template", template);
316479
+ continue;
316480
+ }
316308
316481
  templates.push({
316309
316482
  path: template.path,
316310
316483
  uid: template.uid,
@@ -322513,7 +322686,10 @@ function readWorkflowReferences(root, files, diagnostics) {
322513
322686
  throw error;
322514
322687
  }
322515
322688
  });
322516
- return workflowReferences(workflowFiles, diagnostics);
322689
+ return {
322690
+ ...workflowReferences(workflowFiles, diagnostics),
322691
+ routesByPath: new Map(workflowFiles.map(({ path, ast }) => [path, ast === null ? null : workflowListing(ast).route]))
322692
+ };
322517
322693
  }
322518
322694
  function lintUnits(units, resources, pages, diagnostics, assetsComplete, domainsComplete) {
322519
322695
  const catalogs = {
@@ -322565,7 +322741,7 @@ function buildPageEntries(root, files, write, diagnostics) {
322565
322741
  };
322566
322742
  }
322567
322743
  var NOTIFICATION_KINDS = new Set(Object.keys(NOTIFICATION_DEFINITIONS));
322568
- function buildNotifications(root, files, { writeSource, names: names2, resources, builtInResources, recordBindingEntries, resourcesComplete, assets, assetCatalog, diagnostics }) {
322744
+ function buildNotifications(root, files, { writeSource, names: names2, resources, builtInResources, recordBindingEntries, resourcesComplete, pages, workflows, assets, assetCatalog, diagnostics }) {
322569
322745
  const paths = files.filter((path) => NOTIFICATION_KINDS.has(classify(path)));
322570
322746
  const read2 = [];
322571
322747
  const unreadFiles = [];
@@ -322603,6 +322779,8 @@ function buildNotifications(root, files, { writeSource, names: names2, resources
322603
322779
  builtInResources,
322604
322780
  recordBindingEntries,
322605
322781
  resourcesComplete,
322782
+ pages,
322783
+ workflows,
322606
322784
  assets,
322607
322785
  assetCatalog,
322608
322786
  unreadFiles,
@@ -322741,7 +322919,12 @@ function uidDefinitionNodes(kind, path, ast) {
322741
322919
  case "notification_schedule":
322742
322920
  case "email_layout": {
322743
322921
  const { type, define: define2 } = NOTIFICATION_DEFINITIONS[kind];
322744
- const extraImports = kind === "email_layout" ? [GENERATED_RESOURCES_MODULE] : [GENERATED_RESOURCES_MODULE, GENERATED_NOTIFICATION_TYPES_MODULE, GENERATED_EMAIL_LAYOUTS_MODULE];
322922
+ const extraImports = kind === "email_layout" ? [GENERATED_RESOURCES_MODULE] : [
322923
+ GENERATED_RESOURCES_MODULE,
322924
+ GENERATED_NOTIFICATION_TYPES_MODULE,
322925
+ GENERATED_EMAIL_LAYOUTS_MODULE,
322926
+ ...kind === "notification_template" ? [GENERATED_PAGES_MODULE, GENERATED_WORKFLOWS_MODULE] : []
322927
+ ];
322745
322928
  const { declaration } = defaultExportOf(ast, { extraImports: [...extraImports, GENERATED_RECORD_BINDINGS_MODULE] });
322746
322929
  return [{ type, node: expectDefineCall(declaration, define2, 1)[0] }];
322747
322930
  }
@@ -323179,6 +323362,7 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
323179
323362
  if (files.includes(CONFIG_PATH2)) {
323180
323363
  buildFile(CONFIG_PATH2);
323181
323364
  }
323365
+ const workflows = readWorkflowReferences(root, otherFiles, diagnostics);
323182
323366
  const notifications = buildNotifications(root, files, {
323183
323367
  writeSource,
323184
323368
  names: names2,
@@ -323186,12 +323370,13 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
323186
323370
  builtInResources: BUILT_IN_RESOURCES,
323187
323371
  recordBindingEntries: recordBindings.entries,
323188
323372
  resourcesComplete,
323373
+ pages: generatedPages,
323374
+ workflows,
323189
323375
  assets: assetsComplete ? output.assets : null,
323190
323376
  assetCatalog,
323191
323377
  diagnostics
323192
323378
  });
323193
323379
  const notificationCheck = notifications.check;
323194
- const workflows = readWorkflowReferences(root, otherFiles, diagnostics);
323195
323380
  writeGeneratedModule(
323196
323381
  root,
323197
323382
  GENERATED_WORKFLOWS_PATH,
package/dist/index.d.ts CHANGED
@@ -1154,11 +1154,17 @@ export declare function defineNotificationType<const T extends NotificationTypeD
1154
1154
  type: T
1155
1155
  ): T;
1156
1156
 
1157
+ /**
1158
+ * A value that the notification reads when it renders: a string, or
1159
+ * `{ variable: '<path>' }`, a path in the values of the send. The path starts
1160
+ * with a variable of the type, or with `record`, the recipient, such as
1161
+ * `{ variable: 'record.id' }`.
1162
+ */
1163
+ export type NotificationBoundValue = string | { variable: string };
1164
+
1157
1165
  /**
1158
1166
  * A server generator that a template reads as `{{ ref.<key> }}`. A file can
1159
- * deploy `date.current`, `time.current`, and `workspace.login_url`. The
1160
- * `page.url`, `workflow.url`, and `calendar.generate_link` generators of the
1161
- * template editor cannot be deployed from a file yet.
1167
+ * use every generator of the template editor.
1162
1168
  */
1163
1169
  export type NotificationReference =
1164
1170
  | { label: string; generator: 'date.current' | 'time.current' }
@@ -1167,6 +1173,37 @@ export type NotificationReference =
1167
1173
  generator: 'workspace.login_url';
1168
1174
  /** The resource whose members sign in, as `Resources.<Name>.slug`. */
1169
1175
  settings: { resource: ResourceReference };
1176
+ }
1177
+ | {
1178
+ label: string;
1179
+ generator: 'page.url';
1180
+ settings: {
1181
+ /** The page, as `Pages.<Name>.uid` from `@app/generated/pages`. */
1182
+ page: string;
1183
+ /** A value for each required route parameter of the page. */
1184
+ params?: { readonly [param: string]: NotificationBoundValue };
1185
+ };
1186
+ }
1187
+ | {
1188
+ label: string;
1189
+ generator: 'workflow.url';
1190
+ settings: {
1191
+ /** A workflow with a `request` trigger, as `Workflows.<Name>.uid` from `@app/generated/workflows`. */
1192
+ workflow: string;
1193
+ /** A value for each required route parameter of the workflow. */
1194
+ params?: { readonly [param: string]: NotificationBoundValue };
1195
+ };
1196
+ }
1197
+ | {
1198
+ label: string;
1199
+ generator: 'calendar.generate_link';
1200
+ settings: {
1201
+ type: 'apple' | 'google' | 'outlook';
1202
+ /** An eventable resource, as `Resources.<Name>.slug`. */
1203
+ resource: ResourceReference;
1204
+ /** The event record, such as `{ variable: 'first_event.id' }`. */
1205
+ record: NotificationBoundValue;
1206
+ };
1170
1207
  };
1171
1208
 
1172
1209
  export type NotificationTemplateEmail = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/cli",
3
- "version": "0.33.5",
3
+ "version": "0.33.6",
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": {