@schandlergarcia/sf-web-components 1.9.74 → 1.9.75
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.
|
@@ -89,9 +89,15 @@ The company logo is at `src/assets/images/engine_logo.png`. Import it as a modul
|
|
|
89
89
|
```jsx
|
|
90
90
|
import engineLogo from "@/assets/images/engine_logo.png";
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
// On light backgrounds:
|
|
93
|
+
<img src={engineLogo} alt="Engine" className="h-5 w-auto" />
|
|
94
|
+
|
|
95
|
+
// On dark backgrounds (slate-900 header, dark mode):
|
|
96
|
+
<img src={engineLogo} alt="Engine" className="h-5 w-auto brightness-0 invert" />
|
|
93
97
|
```
|
|
94
98
|
|
|
99
|
+
The logo is black — use `brightness-0 invert` to make it white when placed on dark surfaces.
|
|
100
|
+
|
|
95
101
|
- **Do not use external image URLs** (Unsplash, placeholder services, etc.) unless the user explicitly requests images.
|
|
96
102
|
- **Do not use other asset images** (codey-*.png, etc.) unless the user asks for them.
|
|
97
103
|
- **Preserve aspect ratio** — always use `w-auto` with a fixed height, or `h-auto` with a fixed width. Never set both `w-*` and `h-*` to fixed values on the logo or any image, as this distorts the aspect ratio.
|
|
@@ -346,10 +352,17 @@ Define schemas outside component body. Always `required: true` on mandatory fiel
|
|
|
346
352
|
|
|
347
353
|
## AI Chat & Agent
|
|
348
354
|
|
|
349
|
-
|
|
355
|
+
Two components for agent integration:
|
|
356
|
+
|
|
357
|
+
- **`ChatBar`** — command-palette strip for suggested prompts. Place between the hero map and data panels (full-width, `px-4 pt-4`), NOT in the header. Always provide 3–5 `suggestions`.
|
|
358
|
+
- **`AgentforceConversationClient`** — the real Salesforce agent. Import from `@/components/AgentforceConversationClient` and pass the agent ID. Renders as a floating widget.
|
|
359
|
+
|
|
360
|
+
```tsx
|
|
361
|
+
import { AgentforceConversationClient } from "@/components/AgentforceConversationClient";
|
|
362
|
+
|
|
363
|
+
<AgentforceConversationClient agentId="0Xxa5000000relhCAA" agentLabel="Eva" />
|
|
364
|
+
```
|
|
350
365
|
|
|
351
|
-
- Place `ChatBar` between the hero map and data panels (full-width, `px-4 pt-4`), NOT in the header
|
|
352
|
-
- Always provide 3–5 `suggestions` for starter prompts
|
|
353
366
|
- Return `components` for structured data — never markdown tables in text
|
|
354
367
|
- Always set height on `ChatPanel`
|
|
355
368
|
- Extract `onSend` handlers to module scope when shared
|
|
@@ -513,17 +526,15 @@ Instead, verify correctness by reviewing the code against the Pre-Completion Che
|
|
|
513
526
|
|
|
514
527
|
## Salesforce Metadata Patterns
|
|
515
528
|
|
|
516
|
-
This is an SFDX project (`force-app/main/default/`). When the build requires metadata changes
|
|
529
|
+
This is an SFDX project (`force-app/main/default/`). When the build requires metadata changes, write standard SFDX XML files and deploy with the Salesforce CLI.
|
|
517
530
|
|
|
518
531
|
### File locations
|
|
519
532
|
|
|
520
533
|
| Metadata type | Path pattern |
|
|
521
534
|
|---|---|
|
|
522
|
-
| Permission Set | `force-app/main/default/permissionsets/{Name}.permissionset-meta.xml` |
|
|
523
535
|
| Custom Field | `force-app/main/default/objects/{Object}/fields/{Field}.field-meta.xml` |
|
|
524
|
-
|
|
|
525
|
-
|
|
|
526
|
-
| Email Template | `force-app/main/default/email/{Folder}/{Name}.email-meta.xml` |
|
|
536
|
+
| Platform Event | `force-app/main/default/objects/{Name}__e/{Name}__e.object-meta.xml` + `fields/` |
|
|
537
|
+
| Apex Class | `force-app/main/default/classes/{Name}.cls` + `{Name}.cls-meta.xml` |
|
|
527
538
|
|
|
528
539
|
### Deploy command
|
|
529
540
|
|
|
@@ -531,16 +542,32 @@ This is an SFDX project (`force-app/main/default/`). When the build requires met
|
|
|
531
542
|
sf project deploy start --source-dir force-app/main/default/permissionsets/MyPermSet.permissionset-meta.xml
|
|
532
543
|
```
|
|
533
544
|
|
|
534
|
-
Use `--source-dir` to deploy individual files. For multiple files, point to the parent directory.
|
|
545
|
+
Use `--source-dir` to deploy individual files. For multiple files, point to the parent directory. For Apex, use `--test-level NoTestRun` during development.
|
|
546
|
+
|
|
547
|
+
### Platform Events
|
|
548
|
+
|
|
549
|
+
Platform events are structured like custom objects under `objects/{Name}__e/`. The object file defines the event (`eventType: HighVolume`), and each field gets its own file under `fields/`. Deploy the whole directory at once:
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
sf project deploy start --source-dir force-app/main/default/objects/Travel_Disruption_Alert__e
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### Apex Classes
|
|
556
|
+
|
|
557
|
+
Apex classes need two files: the `.cls` source and a `.cls-meta.xml` with API version and status. Always use `with sharing` for security. Deploy with `--test-level NoTestRun` for development:
|
|
558
|
+
|
|
559
|
+
```bash
|
|
560
|
+
sf project deploy start --source-dir force-app/main/default/classes/TravelDisruptionEventService.cls --test-level NoTestRun
|
|
561
|
+
```
|
|
535
562
|
|
|
536
563
|
### When to create metadata
|
|
537
564
|
|
|
538
|
-
During the build, proactively
|
|
565
|
+
During the build, proactively create the Salesforce metadata needed for the features you're building. If the dashboard needs field access, create a permission set. If a new field would improve the data model, create it. If automation would enhance a workflow, create a flow. Tell the user what you're creating and ask before doing it. The PRD's build prompts (section 13) include specific instructions for these interactions, with XML templates in section 14.
|
|
539
566
|
|
|
540
567
|
### Key rules
|
|
541
568
|
|
|
542
569
|
- Always use API version `62.0` or higher
|
|
543
|
-
-
|
|
544
|
-
-
|
|
570
|
+
- Platform events: use `HighVolume` event type
|
|
571
|
+
- Apex: use `with sharing`, handle `Database.SaveResult` errors when publishing events
|
|
545
572
|
- Never deploy destructive changes without explicit confirmation
|
|
546
573
|
- Never modify standard Salesforce objects' core fields — only add custom fields
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.9.75] - 2026-04-02
|
|
9
|
+
|
|
10
|
+
### Updated
|
|
11
|
+
- **PRD (engine-command-center-prd.md)** - Metadata and agent integration updates:
|
|
12
|
+
- Reframed permission set as "creating" not "flagging security" (then removed it entirely)
|
|
13
|
+
- Moved metadata instructions inside prompt blockquotes so agent executes them
|
|
14
|
+
- Added AgentforceConversationClient with `agentId="0Xxa5000000relhCAA"` to Section 9 and Prompt 3
|
|
15
|
+
- Trimmed metadata from 7 items to 3 (custom field, platform event, Apex class)
|
|
16
|
+
- Removed permission set, flow, record type, email template from prompts and Section 14
|
|
17
|
+
- Renumbered Section 14 to 14a/14b/14c
|
|
18
|
+
|
|
19
|
+
- **Builder skill (SKILL.md)** - Agent and metadata pattern updates:
|
|
20
|
+
- Updated "AI Chat & Agent" section with AgentforceConversationClient pattern and agent ID
|
|
21
|
+
- Added Platform Event and Apex Class to metadata file locations table
|
|
22
|
+
- Added deploy patterns for platform events and Apex classes
|
|
23
|
+
- Trimmed metadata table and key rules to match the 3 remaining types
|
|
24
|
+
- Removed permission set, flow, record type, email template references
|
|
25
|
+
|
|
26
|
+
**Context:** Streamlined metadata to 3 core types (custom field, platform event, Apex class) and added explicit AgentforceConversationClient integration with agent ID.
|
|
27
|
+
|
|
8
28
|
## [1.9.74] - 2026-04-02
|
|
9
29
|
|
|
10
30
|
### Added
|
|
@@ -107,7 +107,13 @@ Compact `h-12` sticky header (`bg-slate-900 dark:bg-slate-950`). No ChatBar in t
|
|
|
107
107
|
|
|
108
108
|
| Left | Right |
|
|
109
109
|
|------|-------|
|
|
110
|
-
| Engine logo (`
|
|
110
|
+
| Engine logo (`engine_logo.png`, `h-5 w-auto brightness-0 invert` to make it white on the dark header) + "ENGINE" wordmark + separator + "Travel Command Center" + "Powered by Agentforce" badge (`bg-brand-900/40 text-brand-400 rounded-full text-[10px]`) | Notification bell (badge count) + theme toggle (sun/moon) |
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import engineLogo from "@/assets/images/engine_logo.png";
|
|
114
|
+
|
|
115
|
+
<img src={engineLogo} alt="Engine" className="h-5 w-auto brightness-0 invert" />
|
|
116
|
+
```
|
|
111
117
|
|
|
112
118
|
---
|
|
113
119
|
|
|
@@ -246,9 +252,11 @@ const spendChartData = useDataSource({
|
|
|
246
252
|
|
|
247
253
|
---
|
|
248
254
|
|
|
249
|
-
## 9. Eva —
|
|
255
|
+
## 9. Eva — Agentforce Integration
|
|
250
256
|
|
|
251
|
-
|
|
257
|
+
Two components work together:
|
|
258
|
+
|
|
259
|
+
**ChatBar** — a command-palette strip below the hero map for quick suggested prompts. NOT in the header. NOT a FAB or sliding panel.
|
|
252
260
|
|
|
253
261
|
```tsx
|
|
254
262
|
<div className="px-4 pt-4">
|
|
@@ -265,6 +273,19 @@ Suggestions: "Storm warning in the Midwest — which travelers are affected?", "
|
|
|
265
273
|
|
|
266
274
|
Define `handleChat` and `CHAT_SUGGESTIONS` at module scope.
|
|
267
275
|
|
|
276
|
+
**AgentforceConversationClient** — the real Salesforce agent. Wire it with the Eva agent ID. Place it at the bottom of the dashboard component (it renders as a floating widget).
|
|
277
|
+
|
|
278
|
+
```tsx
|
|
279
|
+
import { AgentforceConversationClient } from "@/components/AgentforceConversationClient";
|
|
280
|
+
|
|
281
|
+
<AgentforceConversationClient
|
|
282
|
+
agentId="0Xxa5000000relhCAA"
|
|
283
|
+
agentLabel="Eva"
|
|
284
|
+
/>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
The `AgentforceConversationClient` is already in the codebase (commented out in `appLayout.tsx`). Uncomment it or add it directly to the dashboard with the agent ID above.
|
|
288
|
+
|
|
268
289
|
---
|
|
269
290
|
|
|
270
291
|
## 10. Salesforce Signals
|
|
@@ -327,60 +348,31 @@ Build incrementally in 3 prompts. Each prompt builds on the previous result.
|
|
|
327
348
|
> const activeMetrics = live.loading ? METRICS : live.metrics;
|
|
328
349
|
> ```
|
|
329
350
|
>
|
|
330
|
-
>
|
|
351
|
+
> After wiring the data, check if `Flight__c` has a `Weather_Impact__c` field for tracking weather disruptions — if it doesn't exist, ask me before creating it. Use the SFDX XML template from section 14a below and deploy with `sf project deploy start`.
|
|
331
352
|
|
|
332
|
-
**
|
|
333
|
-
After wiring the live data, check the field-level security for the objects being queried. The `External_Travel_Manager` permission set does not have read access to `Disruption__c.Severity__c`. Tell the user:
|
|
353
|
+
**Reference — what the agent should say and do:**
|
|
334
354
|
|
|
335
|
-
|
|
355
|
+
1. After wiring the live data, tell the user: *"I notice `Flight__c` doesn't have a field to track weather impact on individual flights. A `Weather_Impact__c` picklist would help the dashboard filter storm-affected flights. Want me to create it?"* — When confirmed, create the custom field XML from section 14a and deploy it.
|
|
336
356
|
|
|
337
|
-
|
|
357
|
+
---
|
|
338
358
|
|
|
339
|
-
|
|
359
|
+
### Add Agentforce
|
|
340
360
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
<label>External Travel Manager</label>
|
|
345
|
-
<description>Field access for the Engine Travel Command Center dashboard</description>
|
|
346
|
-
<fieldPermissions>
|
|
347
|
-
<editable>false</editable>
|
|
348
|
-
<field>Disruption__c.Severity__c</field>
|
|
349
|
-
<readable>true</readable>
|
|
350
|
-
</fieldPermissions>
|
|
351
|
-
<fieldPermissions>
|
|
352
|
-
<editable>false</editable>
|
|
353
|
-
<field>Disruption__c.Affected_Traveler_Count__c</field>
|
|
354
|
-
<readable>true</readable>
|
|
355
|
-
</fieldPermissions>
|
|
356
|
-
<fieldPermissions>
|
|
357
|
-
<editable>false</editable>
|
|
358
|
-
<field>Flight__c.Delay_Minutes__c</field>
|
|
359
|
-
<readable>true</readable>
|
|
360
|
-
</fieldPermissions>
|
|
361
|
-
<fieldPermissions>
|
|
362
|
-
<editable>false</editable>
|
|
363
|
-
<field>Flight__c.Flight_Status__c</field>
|
|
364
|
-
<readable>true</readable>
|
|
365
|
-
</fieldPermissions>
|
|
366
|
-
<fieldPermissions>
|
|
367
|
-
<editable>false</editable>
|
|
368
|
-
<field>Rebooking_Action__c.Status__c</field>
|
|
369
|
-
<readable>true</readable>
|
|
370
|
-
</fieldPermissions>
|
|
371
|
-
<hasActivationRequired>false</hasActivationRequired>
|
|
372
|
-
<license>Salesforce</license>
|
|
373
|
-
</PermissionSet>
|
|
374
|
-
```
|
|
361
|
+
> Add Eva to the dashboard. Place the ChatBar between the map and data panels using the suggestions from section 9. Wire up the `handleChat` mock response. Then add the `AgentforceConversationClient` component with `agentId="0Xxa5000000relhCAA"` and `agentLabel="Eva"` — this connects the real Salesforce agent. After adding Eva, create a `Travel_Disruption_Alert__e` platform event so disruptions can be published to the event bus in real time — ask me before creating it. Then write an Apex class `TravelDisruptionEventService` that publishes disruption records to that event — ask me before creating it. Use the SFDX templates from section 14b and 14c and deploy each with `sf project deploy start`.
|
|
362
|
+
|
|
363
|
+
**Reference — what the agent should say and do:**
|
|
375
364
|
|
|
376
|
-
|
|
365
|
+
1. After adding Eva, tell the user: *"The dashboard tracks disruptions in real time. I can create a `Travel_Disruption_Alert__e` platform event so disruption data can be published to the Salesforce event bus — other systems and automation can subscribe to it. Want me to set it up?"* — When confirmed, create the platform event and its fields from section 14b and deploy.
|
|
366
|
+
|
|
367
|
+
2. After the platform event, tell the user: *"Now I'll write an Apex service class to publish disruption records to that event bus. `TravelDisruptionEventService` will take a list of disruptions and fire platform events with the flight number, severity, and description. Want me to create it?"* — When confirmed, create the Apex class from section 14c and deploy.
|
|
368
|
+
|
|
369
|
+
---
|
|
377
370
|
|
|
378
|
-
|
|
379
|
-
After fixing the permission set, notice that `Flight__c` has no way to track weather impact on individual flights. Tell the user:
|
|
371
|
+
## 14. Metadata Reference Templates
|
|
380
372
|
|
|
381
|
-
|
|
373
|
+
Templates for the scripted metadata interactions. The agent should use these exact structures when creating files.
|
|
382
374
|
|
|
383
|
-
|
|
375
|
+
### 14a. Custom Field — `Flight__c.Weather_Impact__c`
|
|
384
376
|
|
|
385
377
|
`force-app/main/default/objects/Flight__c/fields/Weather_Impact__c.field-meta.xml`
|
|
386
378
|
|
|
@@ -404,101 +396,108 @@ When the user confirms, create:
|
|
|
404
396
|
</CustomField>
|
|
405
397
|
```
|
|
406
398
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
Also update the permission set to include read access to the new field.
|
|
410
|
-
|
|
411
|
-
---
|
|
412
|
-
|
|
413
|
-
### Add Agentforce
|
|
414
|
-
|
|
415
|
-
> Add Eva to the dashboard. Place the ChatBar between the map and data panels using the suggestions from section 9. Wire up the `handleChat` mock response.
|
|
399
|
+
Deploy: `sf project deploy start --source-dir force-app/main/default/objects/Flight__c/fields/Weather_Impact__c.field-meta.xml`
|
|
416
400
|
|
|
417
|
-
|
|
418
|
-
After adding the ChatBar, tell the user:
|
|
401
|
+
### 14b. Platform Event — `Travel_Disruption_Alert__e`
|
|
419
402
|
|
|
420
|
-
|
|
403
|
+
Create the event object and its fields:
|
|
421
404
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
`force-app/main/default/flows/Travel_Weather_Alert_Notification.flow-meta.xml`
|
|
405
|
+
`force-app/main/default/objects/Travel_Disruption_Alert__e/Travel_Disruption_Alert__e.object-meta.xml`
|
|
425
406
|
|
|
426
407
|
```xml
|
|
427
408
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
428
|
-
<
|
|
429
|
-
<
|
|
430
|
-
<
|
|
431
|
-
<description>
|
|
432
|
-
<
|
|
433
|
-
<
|
|
434
|
-
|
|
435
|
-
<object>Disruption__c</object>
|
|
436
|
-
<triggerType>RecordAfterSave</triggerType>
|
|
437
|
-
<recordTriggerType>CreateAndUpdate</recordTriggerType>
|
|
438
|
-
<filterLogic>and</filterLogic>
|
|
439
|
-
<filters>
|
|
440
|
-
<field>Disruption_Type__c</field>
|
|
441
|
-
<operator>EqualTo</operator>
|
|
442
|
-
<value><stringValue>Weather Event</stringValue></value>
|
|
443
|
-
</filters>
|
|
444
|
-
</start>
|
|
445
|
-
<interviewLabel>Travel Weather Alert {!$Flow.CurrentDateTime}</interviewLabel>
|
|
446
|
-
</Flow>
|
|
409
|
+
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
410
|
+
<label>Travel Disruption Alert</label>
|
|
411
|
+
<pluralLabel>Travel Disruption Alerts</pluralLabel>
|
|
412
|
+
<description>Published when a travel disruption is detected. Subscribers can react to real-time flight delays, weather events, and rebooking triggers.</description>
|
|
413
|
+
<deploymentStatus>Deployed</deploymentStatus>
|
|
414
|
+
<eventType>HighVolume</eventType>
|
|
415
|
+
</CustomObject>
|
|
447
416
|
```
|
|
448
417
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
**Scripted metadata interaction — Case Record Type:**
|
|
452
|
-
After creating the Flow, tell the user:
|
|
453
|
-
|
|
454
|
-
> "The 'Create a support case' prompt needs a dedicated record type. The Case object doesn't have a `Travel_Support` record type yet. Should I create it?"
|
|
455
|
-
|
|
456
|
-
When the user confirms, create:
|
|
457
|
-
|
|
458
|
-
`force-app/main/default/objects/Case/recordTypes/Travel_Support.recordType-meta.xml`
|
|
418
|
+
`force-app/main/default/objects/Travel_Disruption_Alert__e/fields/Flight_Number__c.field-meta.xml`
|
|
459
419
|
|
|
460
420
|
```xml
|
|
461
421
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
462
|
-
<
|
|
463
|
-
<fullName>
|
|
464
|
-
<label>
|
|
465
|
-
<
|
|
466
|
-
<
|
|
467
|
-
</
|
|
422
|
+
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
423
|
+
<fullName>Flight_Number__c</fullName>
|
|
424
|
+
<label>Flight Number</label>
|
|
425
|
+
<type>Text</type>
|
|
426
|
+
<length>20</length>
|
|
427
|
+
<required>false</required>
|
|
428
|
+
</CustomField>
|
|
468
429
|
```
|
|
469
430
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
**Scripted metadata interaction — Email Template:**
|
|
473
|
-
Finally, tell the user:
|
|
431
|
+
`force-app/main/default/objects/Travel_Disruption_Alert__e/fields/Severity__c.field-meta.xml`
|
|
474
432
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
433
|
+
```xml
|
|
434
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
435
|
+
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
436
|
+
<fullName>Severity__c</fullName>
|
|
437
|
+
<label>Severity</label>
|
|
438
|
+
<type>Text</type>
|
|
439
|
+
<length>20</length>
|
|
440
|
+
<required>false</required>
|
|
441
|
+
</CustomField>
|
|
442
|
+
```
|
|
478
443
|
|
|
479
|
-
`force-app/main/default/
|
|
444
|
+
`force-app/main/default/objects/Travel_Disruption_Alert__e/fields/Description__c.field-meta.xml`
|
|
480
445
|
|
|
481
446
|
```xml
|
|
482
447
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
483
|
-
<
|
|
484
|
-
<
|
|
485
|
-
<
|
|
486
|
-
<
|
|
487
|
-
<
|
|
488
|
-
<
|
|
489
|
-
<
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
Your flight {!Flight__c.Flight_Number__c} ({!Flight__c.Departure_Airport__c} → {!Flight__c.Arrival_Airport__c}) has been affected by severe weather.
|
|
448
|
+
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
449
|
+
<fullName>Description__c</fullName>
|
|
450
|
+
<label>Description</label>
|
|
451
|
+
<type>LongTextArea</type>
|
|
452
|
+
<length>1000</length>
|
|
453
|
+
<visibleLines>3</visibleLines>
|
|
454
|
+
<required>false</required>
|
|
455
|
+
</CustomField>
|
|
456
|
+
```
|
|
494
457
|
|
|
495
|
-
|
|
496
|
-
|
|
458
|
+
Deploy: `sf project deploy start --source-dir force-app/main/default/objects/Travel_Disruption_Alert__e`
|
|
459
|
+
|
|
460
|
+
### 14c. Apex Class — `TravelDisruptionEventService`
|
|
461
|
+
|
|
462
|
+
`force-app/main/default/classes/TravelDisruptionEventService.cls`
|
|
463
|
+
|
|
464
|
+
```apex
|
|
465
|
+
public with sharing class TravelDisruptionEventService {
|
|
466
|
+
|
|
467
|
+
public static void publishDisruptionAlerts(List<Disruption__c> disruptions) {
|
|
468
|
+
List<Travel_Disruption_Alert__e> events = new List<Travel_Disruption_Alert__e>();
|
|
469
|
+
|
|
470
|
+
for (Disruption__c d : disruptions) {
|
|
471
|
+
events.add(new Travel_Disruption_Alert__e(
|
|
472
|
+
Flight_Number__c = d.Flight_Number__c,
|
|
473
|
+
Severity__c = d.Severity__c,
|
|
474
|
+
Description__c = d.Description__c
|
|
475
|
+
));
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (!events.isEmpty()) {
|
|
479
|
+
List<Database.SaveResult> results = EventBus.publish(events);
|
|
480
|
+
for (Database.SaveResult sr : results) {
|
|
481
|
+
if (!sr.isSuccess()) {
|
|
482
|
+
for (Database.Error err : sr.getErrors()) {
|
|
483
|
+
System.debug(LoggingLevel.ERROR,
|
|
484
|
+
'Failed to publish Travel_Disruption_Alert__e: ' + err.getMessage());
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
```
|
|
497
492
|
|
|
498
|
-
|
|
493
|
+
`force-app/main/default/classes/TravelDisruptionEventService.cls-meta.xml`
|
|
499
494
|
|
|
500
|
-
|
|
501
|
-
|
|
495
|
+
```xml
|
|
496
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
497
|
+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
498
|
+
<apiVersion>62.0</apiVersion>
|
|
499
|
+
<status>Active</status>
|
|
500
|
+
</ApexClass>
|
|
502
501
|
```
|
|
503
502
|
|
|
504
|
-
|
|
503
|
+
Deploy: `sf project deploy start --source-dir force-app/main/default/classes/TravelDisruptionEventService.cls --test-level NoTestRun`
|
package/package.json
CHANGED