@newhomestar/sdk 0.7.17 → 0.7.19

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/events.d.ts CHANGED
@@ -1,7 +1,15 @@
1
1
  /** Full request body for POST /events/queue */
2
2
  export interface QueueEventPayload {
3
- entity_type: string;
4
- action: string;
3
+ /**
4
+ * Fully-qualified event slug — preferred way to identify the event.
5
+ * e.g. "nova_ticketing_service.ticket_created"
6
+ * When provided, entity_type and action are not required.
7
+ */
8
+ event_slug?: string;
9
+ /** Legacy: entity category. Use event_slug instead. */
10
+ entity_type?: string;
11
+ /** Legacy: event action. Use event_slug instead. */
12
+ action?: string;
5
13
  /** Auto-stamped from NOVA_SERVICE_SLUG if not provided */
6
14
  source_service?: string;
7
15
  /** ISO 8601 — when the event actually happened (defaults to now()) */
package/dist/events.js CHANGED
@@ -185,30 +185,10 @@ export async function withServiceEventOutbox(db, reqOrCallback, maybeCallback) {
185
185
  const callbackResult = await callback(tx, emit);
186
186
  // Write one outbox row per staged emit
187
187
  for (const staged of stagedEmits) {
188
- // ── Derive entity_type + action from topic string ──────────────────
189
- // Supports dot notation ("employee.created" → entity_type=employee, action=created)
190
- // dotted path ("hris.employee.created" → entity_type=hris.employee, action=created)
191
- // UPPER_SNAKE ("EMPLOYEE_CREATED" → entity_type=employee, action=created)
192
- // bare string ("employee" → entity_type=employee, action=event)
193
- let entity_type;
194
- let action;
195
- if (staged.topic.includes('.')) {
196
- const lastDot = staged.topic.lastIndexOf('.');
197
- entity_type = staged.topic.slice(0, lastDot);
198
- action = staged.topic.slice(lastDot + 1);
199
- }
200
- else if (staged.topic.includes('_')) {
201
- const firstUnderscore = staged.topic.indexOf('_');
202
- entity_type = staged.topic.slice(0, firstUnderscore).toLowerCase();
203
- action = staged.topic.slice(firstUnderscore + 1).toLowerCase().replace(/_/g, '.');
204
- }
205
- else {
206
- entity_type = staged.topic.toLowerCase();
207
- action = 'event';
208
- }
188
+ // Pass the topic directly as event_slug no decomposition needed.
189
+ // The Events Service uses event_slug to look up the event_type and fan-out.
209
190
  const fullPayload = {
210
- entity_type,
211
- action,
191
+ event_slug: staged.topic,
212
192
  source_service: serviceSlug ?? undefined,
213
193
  attributes: staged.payload,
214
194
  metadata: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newhomestar/sdk",
3
- "version": "0.7.17",
3
+ "version": "0.7.19",
4
4
  "description": "Type-safe SDK for building Nova pipelines (workers & functions)",
5
5
  "homepage": "https://github.com/newhomestar/nova-node-sdk#readme",
6
6
  "bugs": {