@pattern-stack/codegen 0.16.1 → 0.17.0

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/consumer-skills/entities/families-and-queries.md +5 -3
  3. package/dist/{chunk-DGYTSCKN.js → chunk-3MAZ4TQH.js} +13 -13
  4. package/dist/{chunk-5LXOJGO2.js → chunk-3VEVGL74.js} +5 -5
  5. package/dist/{chunk-Y7GDG744.js → chunk-4GLNY5V6.js} +5 -5
  6. package/dist/{chunk-RUSUZZAF.js → chunk-4MVGAMUA.js} +4 -4
  7. package/dist/{chunk-T6SCOJF4.js → chunk-7LKAMLV4.js} +4 -4
  8. package/dist/{chunk-T4YJRD22.js → chunk-BULPAAD3.js} +4 -4
  9. package/dist/{chunk-QSJ3J4HE.js → chunk-CDLWYZVQ.js} +4 -4
  10. package/dist/{chunk-XWBK3XJK.js → chunk-DCCZB4UC.js} +4 -4
  11. package/dist/{chunk-DLG62MQY.js → chunk-DTXH24LR.js} +6 -6
  12. package/dist/{chunk-AYC2HEAL.js → chunk-GJDEPTPY.js} +7 -7
  13. package/dist/{chunk-2WDX6I7T.js → chunk-IOQMMH6C.js} +16 -6
  14. package/dist/{chunk-2WDX6I7T.js.map → chunk-IOQMMH6C.js.map} +1 -1
  15. package/dist/{chunk-BOPZWRJK.js → chunk-JYBFPNBJ.js} +8 -8
  16. package/dist/chunk-JYBFPNBJ.js.map +1 -0
  17. package/dist/{chunk-CRBVI4GE.js → chunk-L3VJ47BU.js} +3 -3
  18. package/dist/chunk-MKWQKKK7.js +72 -0
  19. package/dist/chunk-MKWQKKK7.js.map +1 -0
  20. package/dist/{chunk-TDEHU73T.js → chunk-OGIZXGPY.js} +4 -4
  21. package/dist/{chunk-JM3T27ZW.js → chunk-OITTYGJS.js} +4 -4
  22. package/dist/{chunk-IT6FRTEW.js → chunk-OTR44OH6.js} +10 -10
  23. package/dist/{chunk-24WXSC3C.js → chunk-P3AYBRP6.js} +7 -7
  24. package/dist/{chunk-TKVTEUBD.js → chunk-RHYNACZS.js} +3 -3
  25. package/dist/{chunk-YK5JEVLX.js → chunk-SR7F3TJY.js} +4 -4
  26. package/dist/{chunk-H6FO2ZDJ.js → chunk-UTNWFHJF.js} +7 -7
  27. package/dist/{chunk-LQ6PYFU6.js → chunk-Z7PQCAVK.js} +4 -4
  28. package/dist/runtime/base-classes/activity-entity-repository.d.ts +39 -7
  29. package/dist/runtime/base-classes/activity-entity-repository.js +1 -1
  30. package/dist/runtime/base-classes/activity-entity-service.d.ts +12 -10
  31. package/dist/runtime/base-classes/activity-entity-service.js +1 -1
  32. package/dist/runtime/base-classes/index.js +23 -23
  33. package/dist/runtime/shared/openapi/index.js +5 -5
  34. package/dist/runtime/shared/openapi/registry.js +2 -2
  35. package/dist/runtime/subsystems/auth/auth.module.js +2 -2
  36. package/dist/runtime/subsystems/auth/index.js +8 -8
  37. package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js +3 -3
  38. package/dist/runtime/subsystems/bridge/bridge.module.js +14 -14
  39. package/dist/runtime/subsystems/bridge/index.js +14 -14
  40. package/dist/runtime/subsystems/cache/cache.module.js +1 -1
  41. package/dist/runtime/subsystems/cache/index.js +3 -3
  42. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +3 -3
  43. package/dist/runtime/subsystems/events/event-bus.memory-backend.js +2 -2
  44. package/dist/runtime/subsystems/events/events.module.js +5 -5
  45. package/dist/runtime/subsystems/events/index.js +5 -5
  46. package/dist/runtime/subsystems/index.js +101 -101
  47. package/dist/runtime/subsystems/integration/execute-integration.use-case.js +2 -2
  48. package/dist/runtime/subsystems/integration/index.js +41 -41
  49. package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js +2 -2
  50. package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js +2 -2
  51. package/dist/runtime/subsystems/integration/integration.module.js +5 -5
  52. package/dist/runtime/subsystems/jobs/index.js +35 -35
  53. package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js +5 -5
  54. package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js +3 -3
  55. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +2 -2
  56. package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js +3 -3
  57. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +2 -2
  58. package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js +3 -3
  59. package/dist/runtime/subsystems/jobs/job-worker.js +2 -2
  60. package/dist/runtime/subsystems/jobs/job-worker.module.js +11 -11
  61. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +9 -9
  62. package/dist/runtime/subsystems/storage/index.js +5 -5
  63. package/dist/runtime/subsystems/storage/storage.module.js +3 -3
  64. package/dist/src/cli/index.js +14 -14
  65. package/dist/src/index.d.ts +23 -8
  66. package/dist/src/index.js +12 -12
  67. package/package.json +2 -1
  68. package/runtime/base-classes/activity-entity-repository.ts +72 -13
  69. package/runtime/base-classes/activity-entity-service.ts +14 -12
  70. package/src/patterns/library/activity.pattern.ts +40 -10
  71. package/dist/chunk-BOPZWRJK.js.map +0 -1
  72. package/dist/chunk-XCEI7NUH.js +0 -41
  73. package/dist/chunk-XCEI7NUH.js.map +0 -1
  74. /package/dist/{chunk-DGYTSCKN.js.map → chunk-3MAZ4TQH.js.map} +0 -0
  75. /package/dist/{chunk-5LXOJGO2.js.map → chunk-3VEVGL74.js.map} +0 -0
  76. /package/dist/{chunk-Y7GDG744.js.map → chunk-4GLNY5V6.js.map} +0 -0
  77. /package/dist/{chunk-RUSUZZAF.js.map → chunk-4MVGAMUA.js.map} +0 -0
  78. /package/dist/{chunk-T6SCOJF4.js.map → chunk-7LKAMLV4.js.map} +0 -0
  79. /package/dist/{chunk-T4YJRD22.js.map → chunk-BULPAAD3.js.map} +0 -0
  80. /package/dist/{chunk-QSJ3J4HE.js.map → chunk-CDLWYZVQ.js.map} +0 -0
  81. /package/dist/{chunk-XWBK3XJK.js.map → chunk-DCCZB4UC.js.map} +0 -0
  82. /package/dist/{chunk-DLG62MQY.js.map → chunk-DTXH24LR.js.map} +0 -0
  83. /package/dist/{chunk-AYC2HEAL.js.map → chunk-GJDEPTPY.js.map} +0 -0
  84. /package/dist/{chunk-CRBVI4GE.js.map → chunk-L3VJ47BU.js.map} +0 -0
  85. /package/dist/{chunk-TDEHU73T.js.map → chunk-OGIZXGPY.js.map} +0 -0
  86. /package/dist/{chunk-JM3T27ZW.js.map → chunk-OITTYGJS.js.map} +0 -0
  87. /package/dist/{chunk-IT6FRTEW.js.map → chunk-OTR44OH6.js.map} +0 -0
  88. /package/dist/{chunk-24WXSC3C.js.map → chunk-P3AYBRP6.js.map} +0 -0
  89. /package/dist/{chunk-TKVTEUBD.js.map → chunk-RHYNACZS.js.map} +0 -0
  90. /package/dist/{chunk-YK5JEVLX.js.map → chunk-SR7F3TJY.js.map} +0 -0
  91. /package/dist/{chunk-H6FO2ZDJ.js.map → chunk-UTNWFHJF.js.map} +0 -0
  92. /package/dist/{chunk-LQ6PYFU6.js.map → chunk-Z7PQCAVK.js.map} +0 -0
@@ -11,26 +11,26 @@ var ActivityEntityService = class extends BaseService {
11
11
  return this.repository.findByDateRange(start, end);
12
12
  }
13
13
  /**
14
- * Find all activities for a specific user.
14
+ * Find all activities for a specific user (actor / owner scoping).
15
15
  */
16
16
  findByUser(userId) {
17
17
  return this.repository.findByUserId(userId);
18
18
  }
19
19
  /**
20
- * Find all activities for a specific opportunity.
20
+ * Find all activities for a specific subject (config-driven FK column).
21
21
  */
22
- findByOpportunity(opportunityId) {
23
- return this.repository.findByOpportunityId(opportunityId);
22
+ findBySubject(subjectId) {
23
+ return this.repository.findBySubjectId(subjectId);
24
24
  }
25
25
  /**
26
- * Find the most recent activities for an opportunity.
26
+ * Find the most recent activities for a subject.
27
27
  */
28
- findRecent(opportunityId, limit) {
29
- return this.repository.findRecentByOpportunityId(opportunityId, limit);
28
+ findRecent(subjectId, limit) {
29
+ return this.repository.findRecentBySubjectId(subjectId, limit);
30
30
  }
31
31
  };
32
32
 
33
33
  export {
34
34
  ActivityEntityService
35
35
  };
36
- //# sourceMappingURL=chunk-BOPZWRJK.js.map
36
+ //# sourceMappingURL=chunk-JYBFPNBJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../runtime/base-classes/activity-entity-service.ts"],"sourcesContent":["/**\n * ActivityEntityService<TRepo, TEntity>\n *\n * Family-specific base service for activity / interaction entities. Delegates\n * to an activity repository that provides date-range, actor (`user_id`), and\n * config-driven subject queries. The subject FK column is resolved inside the\n * repository from its `patternConfig` (ADR-031 §4) — the service is\n * subject-name-agnostic. See ACTIVITY-SUBJECT-1.\n */\nimport { BaseService, type IBaseRepository } from './base-service';\n\nexport interface IActivityEntityRepository<TEntity> extends IBaseRepository<TEntity> {\n findByDateRange(start: Date, end: Date): Promise<TEntity[]>;\n findByUserId(userId: string): Promise<TEntity[]>;\n findBySubjectId(subjectId: string): Promise<TEntity[]>;\n findRecentBySubjectId(subjectId: string, limit?: number): Promise<TEntity[]>;\n}\n\nexport abstract class ActivityEntityService<\n TRepo extends IActivityEntityRepository<TEntity>,\n TEntity,\n> extends BaseService<TRepo, TEntity> {\n /**\n * Find activities within a date range (inclusive).\n */\n findByDateRange(start: Date, end: Date): Promise<TEntity[]> {\n return this.repository.findByDateRange(start, end);\n }\n\n /**\n * Find all activities for a specific user (actor / owner scoping).\n */\n findByUser(userId: string): Promise<TEntity[]> {\n return this.repository.findByUserId(userId);\n }\n\n /**\n * Find all activities for a specific subject (config-driven FK column).\n */\n findBySubject(subjectId: string): Promise<TEntity[]> {\n return this.repository.findBySubjectId(subjectId);\n }\n\n /**\n * Find the most recent activities for a subject.\n */\n findRecent(subjectId: string, limit?: number): Promise<TEntity[]> {\n return this.repository.findRecentBySubjectId(subjectId, limit);\n }\n}\n"],"mappings":";;;;;AAkBO,IAAe,wBAAf,cAGG,YAA4B;AAAA;AAAA;AAAA;AAAA,EAIpC,gBAAgB,OAAa,KAA+B;AAC1D,WAAO,KAAK,WAAW,gBAAgB,OAAO,GAAG;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW,QAAoC;AAC7C,WAAO,KAAK,WAAW,aAAa,MAAM;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA,EAKA,cAAc,WAAuC;AACnD,WAAO,KAAK,WAAW,gBAAgB,SAAS;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW,WAAmB,OAAoC;AAChE,WAAO,KAAK,WAAW,sBAAsB,WAAW,KAAK;AAAA,EAC/D;AACF;","names":[]}
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-4DOJBQTP.js";
16
16
  import {
17
17
  BridgeOutboxDrainHook
18
- } from "./chunk-DLG62MQY.js";
18
+ } from "./chunk-DTXH24LR.js";
19
19
  import {
20
20
  BridgeDeliveryHandler
21
21
  } from "./chunk-NXNVTXKG.js";
@@ -24,7 +24,7 @@ import {
24
24
  } from "./chunk-NXXDZ6ZF.js";
25
25
  import {
26
26
  JOB_WORKER_MODULE_OPTIONS
27
- } from "./chunk-AYC2HEAL.js";
27
+ } from "./chunk-GJDEPTPY.js";
28
28
  import {
29
29
  BRIDGE_DELIVERY_REPO,
30
30
  BRIDGE_MODULE_OPTIONS,
@@ -119,4 +119,4 @@ BridgeModule = __decorateClass([
119
119
  export {
120
120
  BridgeModule
121
121
  };
122
- //# sourceMappingURL=chunk-CRBVI4GE.js.map
122
+ //# sourceMappingURL=chunk-L3VJ47BU.js.map
@@ -0,0 +1,72 @@
1
+ import {
2
+ BaseRepository
3
+ } from "./chunk-J6KZS54B.js";
4
+
5
+ // runtime/base-classes/activity-entity-repository.ts
6
+ import { eq, between, desc } from "drizzle-orm";
7
+ var toCamel = (snake) => snake.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
8
+ var ActivityEntityRepository = class extends BaseRepository {
9
+ /**
10
+ * Per-entity Activity config. The template emits this from `config:
11
+ * { Activity: {...} }`; entities that only use date-range / user scoping omit
12
+ * it (and must not call the subject finders).
13
+ */
14
+ patternConfig;
15
+ /**
16
+ * camelCase key for the recency-ordering column. Defaults to `occurredAt`
17
+ * (column `occurred_at`); override via `patternConfig.occurredAt`.
18
+ */
19
+ get occurredAtColumn() {
20
+ const snake = this.patternConfig?.occurredAt ?? "occurred_at";
21
+ return toCamel(snake);
22
+ }
23
+ /**
24
+ * camelCase key for the subject FK column, resolved from `patternConfig`:
25
+ * `subjectColumn` (explicit) → `<subject>_id` (derived). Throws when neither
26
+ * is configured — the subject finders are unusable without it, and a clear
27
+ * error beats a silent `undefined` column index.
28
+ */
29
+ get subjectColumn() {
30
+ const explicit = this.patternConfig?.subjectColumn;
31
+ if (explicit) return toCamel(explicit);
32
+ const subject = this.patternConfig?.subject;
33
+ if (subject) return toCamel(`${subject}_id`);
34
+ throw new Error(
35
+ "ActivityEntityRepository: subject finders require a subject column. Set `config: { Activity: { subject: '<entity>' } }` (\u2192 <entity>_id) or `config: { Activity: { subjectColumn: '<column>' } }` on the entity YAML."
36
+ );
37
+ }
38
+ /**
39
+ * Find activities within a date range (inclusive), by the recency column.
40
+ */
41
+ async findByDateRange(start, end) {
42
+ const rows = await this.baseQuery().where(between(this.table[this.occurredAtColumn], start, end));
43
+ return rows;
44
+ }
45
+ /**
46
+ * Find all activities for a specific user (actor / owner scoping).
47
+ */
48
+ async findByUserId(userId) {
49
+ const rows = await this.baseQuery().where(eq(this.table["userId"], userId));
50
+ return rows;
51
+ }
52
+ /**
53
+ * Find all activities for a specific subject (config-driven FK column).
54
+ */
55
+ async findBySubjectId(subjectId) {
56
+ const rows = await this.baseQuery().where(eq(this.table[this.subjectColumn], subjectId));
57
+ return rows;
58
+ }
59
+ /**
60
+ * Find the most recent activities for a subject, ordered by the recency
61
+ * column descending.
62
+ */
63
+ async findRecentBySubjectId(subjectId, limit = 10) {
64
+ const rows = await this.baseQuery().where(eq(this.table[this.subjectColumn], subjectId)).orderBy(desc(this.table[this.occurredAtColumn])).limit(limit);
65
+ return rows;
66
+ }
67
+ };
68
+
69
+ export {
70
+ ActivityEntityRepository
71
+ };
72
+ //# sourceMappingURL=chunk-MKWQKKK7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../runtime/base-classes/activity-entity-repository.ts"],"sourcesContent":["/**\n * ActivityEntityRepository<TEntity>\n *\n * Family-specific base for activity / interaction entities (emails, calls,\n * meetings, messages, transcripts). Adds date-range queries, actor (`user_id`)\n * scoping, recency ordering, and **config-driven subject scoping** — the\n * subject FK column is resolved from the concrete repo's `patternConfig`\n * (ADR-031 §4) rather than hardcoded, so the same base serves a CRM\n * `opportunity`-scoped activity and a swe-brain `person`-scoped interaction.\n *\n * Concrete repos extend this and declare their table + behaviors, and (when\n * they use the subject finders) a `patternConfig` carrying `subject` /\n * `subjectColumn` / `occurredAt`. The template emits that property from the\n * entity's `config: { Activity: {...} }` block. See ACTIVITY-SUBJECT-1.\n */\nimport { eq, between, desc } from 'drizzle-orm';\nimport { BaseRepository } from './base-repository';\n\n/**\n * Per-entity Activity config (matches `ActivityPatternConfigSchema` in\n * `src/patterns/library/activity.pattern.ts`). Carried on the concrete repo as\n * `patternConfig` and read here to resolve column names at runtime.\n */\nexport interface ActivityPatternConfig {\n /** Subject entity name → derives the FK column `<subject>_id`. */\n subject?: string;\n /** Explicit snake_case FK column, when it does not follow `<subject>_id`. */\n subjectColumn?: string;\n /** snake_case recency-ordering column; defaults to `occurred_at`. */\n occurredAt?: string;\n}\n\nconst toCamel = (snake: string): string =>\n snake.replace(/_([a-z0-9])/g, (_, c: string) => c.toUpperCase());\n\nexport abstract class ActivityEntityRepository<TEntity> extends BaseRepository<TEntity> {\n /**\n * Per-entity Activity config. The template emits this from `config:\n * { Activity: {...} }`; entities that only use date-range / user scoping omit\n * it (and must not call the subject finders).\n */\n protected readonly patternConfig?: ActivityPatternConfig;\n\n /**\n * camelCase key for the recency-ordering column. Defaults to `occurredAt`\n * (column `occurred_at`); override via `patternConfig.occurredAt`.\n */\n protected get occurredAtColumn(): string {\n const snake = this.patternConfig?.occurredAt ?? 'occurred_at';\n return toCamel(snake);\n }\n\n /**\n * camelCase key for the subject FK column, resolved from `patternConfig`:\n * `subjectColumn` (explicit) → `<subject>_id` (derived). Throws when neither\n * is configured — the subject finders are unusable without it, and a clear\n * error beats a silent `undefined` column index.\n */\n protected get subjectColumn(): string {\n const explicit = this.patternConfig?.subjectColumn;\n if (explicit) return toCamel(explicit);\n const subject = this.patternConfig?.subject;\n if (subject) return toCamel(`${subject}_id`);\n throw new Error(\n 'ActivityEntityRepository: subject finders require a subject column. ' +\n \"Set `config: { Activity: { subject: '<entity>' } }` (→ <entity>_id) \" +\n \"or `config: { Activity: { subjectColumn: '<column>' } }` on the entity YAML.\",\n );\n }\n\n /**\n * Find activities within a date range (inclusive), by the recency column.\n */\n async findByDateRange(start: Date, end: Date): Promise<TEntity[]> {\n const rows = await this.baseQuery()\n .where(between(this.table[this.occurredAtColumn], start, end));\n return rows as TEntity[];\n }\n\n /**\n * Find all activities for a specific user (actor / owner scoping).\n */\n async findByUserId(userId: string): Promise<TEntity[]> {\n const rows = await this.baseQuery()\n .where(eq(this.table['userId'], userId));\n return rows as TEntity[];\n }\n\n /**\n * Find all activities for a specific subject (config-driven FK column).\n */\n async findBySubjectId(subjectId: string): Promise<TEntity[]> {\n const rows = await this.baseQuery()\n .where(eq(this.table[this.subjectColumn], subjectId));\n return rows as TEntity[];\n }\n\n /**\n * Find the most recent activities for a subject, ordered by the recency\n * column descending.\n */\n async findRecentBySubjectId(subjectId: string, limit = 10): Promise<TEntity[]> {\n const rows = await this.baseQuery()\n .where(eq(this.table[this.subjectColumn], subjectId))\n .orderBy(desc(this.table[this.occurredAtColumn]))\n .limit(limit);\n return rows as TEntity[];\n }\n}\n"],"mappings":";;;;;AAeA,SAAS,IAAI,SAAS,YAAY;AAiBlC,IAAM,UAAU,CAAC,UACf,MAAM,QAAQ,gBAAgB,CAAC,GAAG,MAAc,EAAE,YAAY,CAAC;AAE1D,IAAe,2BAAf,cAAyD,eAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnB,IAAc,mBAA2B;AACvC,UAAM,QAAQ,KAAK,eAAe,cAAc;AAChD,WAAO,QAAQ,KAAK;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAc,gBAAwB;AACpC,UAAM,WAAW,KAAK,eAAe;AACrC,QAAI,SAAU,QAAO,QAAQ,QAAQ;AACrC,UAAM,UAAU,KAAK,eAAe;AACpC,QAAI,QAAS,QAAO,QAAQ,GAAG,OAAO,KAAK;AAC3C,UAAM,IAAI;AAAA,MACR;AAAA,IAGF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,gBAAgB,OAAa,KAA+B;AAChE,UAAM,OAAO,MAAM,KAAK,UAAU,EAC/B,MAAM,QAAQ,KAAK,MAAM,KAAK,gBAAgB,GAAG,OAAO,GAAG,CAAC;AAC/D,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAAa,QAAoC;AACrD,UAAM,OAAO,MAAM,KAAK,UAAU,EAC/B,MAAM,GAAG,KAAK,MAAM,QAAQ,GAAG,MAAM,CAAC;AACzC,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,gBAAgB,WAAuC;AAC3D,UAAM,OAAO,MAAM,KAAK,UAAU,EAC/B,MAAM,GAAG,KAAK,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;AACtD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,sBAAsB,WAAmB,QAAQ,IAAwB;AAC7E,UAAM,OAAO,MAAM,KAAK,UAAU,EAC/B,MAAM,GAAG,KAAK,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC,EACnD,QAAQ,KAAK,KAAK,MAAM,KAAK,gBAAgB,CAAC,CAAC,EAC/C,MAAM,KAAK;AACd,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,3 +1,6 @@
1
+ import {
2
+ assertTenantId
3
+ } from "./chunk-MZ6GV4YF.js";
1
4
  import {
2
5
  INTEGRATION_CHANGE_SOURCE,
3
6
  INTEGRATION_CURSOR_STORE,
@@ -6,9 +9,6 @@ import {
6
9
  INTEGRATION_RUN_RECORDER,
7
10
  INTEGRATION_SINK
8
11
  } from "./chunk-S7C6TIIF.js";
9
- import {
10
- assertTenantId
11
- } from "./chunk-MZ6GV4YF.js";
12
12
  import {
13
13
  __decorateClass,
14
14
  __decorateParam
@@ -219,4 +219,4 @@ ExecuteIntegrationUseCase = __decorateClass([
219
219
  export {
220
220
  ExecuteIntegrationUseCase
221
221
  };
222
- //# sourceMappingURL=chunk-TDEHU73T.js.map
222
+ //# sourceMappingURL=chunk-OGIZXGPY.js.map
@@ -1,6 +1,3 @@
1
- import {
2
- jobRuns
3
- } from "./chunk-OKXZ63IA.js";
4
1
  import {
5
2
  JOB_HANDLER_REGISTRY
6
3
  } from "./chunk-CO6LUM72.js";
@@ -9,6 +6,9 @@ import {
9
6
  JOB_RUN_SERVICE,
10
7
  JOB_STEP_SERVICE
11
8
  } from "./chunk-ZPL74UQN.js";
9
+ import {
10
+ jobRuns
11
+ } from "./chunk-OKXZ63IA.js";
12
12
  import {
13
13
  JOBS_WAKE_CHANNEL,
14
14
  PgNotifyListener
@@ -518,4 +518,4 @@ export {
518
518
  buildStaleSweepQuery,
519
519
  JobWorker
520
520
  };
521
- //# sourceMappingURL=chunk-JM3T27ZW.js.map
521
+ //# sourceMappingURL=chunk-OITTYGJS.js.map
@@ -1,12 +1,3 @@
1
- import {
2
- jobRuns,
3
- jobSteps,
4
- jobs
5
- } from "./chunk-OKXZ63IA.js";
6
- import {
7
- JOBS_LISTEN_NOTIFY,
8
- JOBS_MULTI_TENANT
9
- } from "./chunk-ZPL74UQN.js";
10
1
  import {
11
2
  JobCollisionError,
12
3
  JobNotReplayableError,
@@ -14,6 +5,15 @@ import {
14
5
  JobTypeNotFoundError,
15
6
  MissingTenantIdError
16
7
  } from "./chunk-T4BIIU5E.js";
8
+ import {
9
+ JOBS_LISTEN_NOTIFY,
10
+ JOBS_MULTI_TENANT
11
+ } from "./chunk-ZPL74UQN.js";
12
+ import {
13
+ jobRuns,
14
+ jobSteps,
15
+ jobs
16
+ } from "./chunk-OKXZ63IA.js";
17
17
  import {
18
18
  JOBS_WAKE_CHANNEL,
19
19
  pgNotify
@@ -372,4 +372,4 @@ export {
372
372
  evaluateKeyTemplate,
373
373
  DrizzleJobOrchestrator
374
374
  };
375
- //# sourceMappingURL=chunk-IT6FRTEW.js.map
375
+ //# sourceMappingURL=chunk-OTR44OH6.js.map
@@ -1,15 +1,18 @@
1
+ import {
2
+ DrizzleIntegrationRunRecorder
3
+ } from "./chunk-SR7F3TJY.js";
1
4
  import {
2
5
  MemoryRunRecorder
3
6
  } from "./chunk-EO2QPOKH.js";
4
7
  import {
5
8
  PostgresCursorStore
6
- } from "./chunk-XWBK3XJK.js";
9
+ } from "./chunk-DCCZB4UC.js";
7
10
  import {
8
11
  MemoryCursorStore
9
12
  } from "./chunk-AHV4GDYM.js";
10
13
  import {
11
- DrizzleIntegrationRunRecorder
12
- } from "./chunk-YK5JEVLX.js";
14
+ DeepEqualDiffer
15
+ } from "./chunk-36U5UGIO.js";
13
16
  import {
14
17
  INTEGRATION_CURSOR_STORE,
15
18
  INTEGRATION_FIELD_DIFFER,
@@ -17,9 +20,6 @@ import {
17
20
  INTEGRATION_MULTI_TENANT,
18
21
  INTEGRATION_RUN_RECORDER
19
22
  } from "./chunk-S7C6TIIF.js";
20
- import {
21
- DeepEqualDiffer
22
- } from "./chunk-36U5UGIO.js";
23
23
  import {
24
24
  __decorateClass
25
25
  } from "./chunk-2E224ZSN.js";
@@ -78,4 +78,4 @@ IntegrationModule = __decorateClass([
78
78
  export {
79
79
  IntegrationModule
80
80
  };
81
- //# sourceMappingURL=chunk-24WXSC3C.js.map
81
+ //# sourceMappingURL=chunk-P3AYBRP6.js.map
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-GM3RMJIJ.js";
4
4
  import {
5
5
  DrizzleEventBus
6
- } from "./chunk-H6FO2ZDJ.js";
6
+ } from "./chunk-UTNWFHJF.js";
7
7
  import {
8
8
  MemoryEventBus
9
- } from "./chunk-LQ6PYFU6.js";
9
+ } from "./chunk-Z7PQCAVK.js";
10
10
  import {
11
11
  EVENTS_MODULE_OPTIONS,
12
12
  EVENTS_MULTI_TENANT,
@@ -152,4 +152,4 @@ EventsModule = __decorateClass([
152
152
  export {
153
153
  EventsModule
154
154
  };
155
- //# sourceMappingURL=chunk-TKVTEUBD.js.map
155
+ //# sourceMappingURL=chunk-RHYNACZS.js.map
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  FieldDiffSchema
3
3
  } from "./chunk-SQDOBLBP.js";
4
- import {
5
- INTEGRATION_MULTI_TENANT
6
- } from "./chunk-S7C6TIIF.js";
7
4
  import {
8
5
  assertTenantId
9
6
  } from "./chunk-MZ6GV4YF.js";
@@ -12,6 +9,9 @@ import {
12
9
  integrationRuns,
13
10
  integrationSubscriptions
14
11
  } from "./chunk-HNWZFNKP.js";
12
+ import {
13
+ INTEGRATION_MULTI_TENANT
14
+ } from "./chunk-S7C6TIIF.js";
15
15
  import {
16
16
  DRIZZLE
17
17
  } from "./chunk-U64T4YZE.js";
@@ -127,4 +127,4 @@ DrizzleIntegrationRunRecorder = __decorateClass([
127
127
  export {
128
128
  DrizzleIntegrationRunRecorder
129
129
  };
130
- //# sourceMappingURL=chunk-YK5JEVLX.js.map
130
+ //# sourceMappingURL=chunk-SR7F3TJY.js.map
@@ -1,22 +1,22 @@
1
- import {
2
- BRIDGE_OUTBOX_DRAIN_HOOK
3
- } from "./chunk-4LH67P4U.js";
4
1
  import {
5
2
  EVENTS_WAKE_CHANNEL,
6
3
  PgNotifyListener,
7
4
  pgNotify
8
5
  } from "./chunk-MYQIQ27N.js";
6
+ import {
7
+ BRIDGE_OUTBOX_DRAIN_HOOK
8
+ } from "./chunk-4LH67P4U.js";
9
9
  import {
10
10
  domainEvents
11
11
  } from "./chunk-OFRRBC7M.js";
12
- import {
13
- EVENTS_MODULE_OPTIONS
14
- } from "./chunk-H5NH7KPE.js";
15
12
  import {
16
13
  clampEventLimit,
17
14
  decodeEventCursor,
18
15
  encodeEventCursor
19
16
  } from "./chunk-UQ5EHOH2.js";
17
+ import {
18
+ EVENTS_MODULE_OPTIONS
19
+ } from "./chunk-H5NH7KPE.js";
20
20
  import {
21
21
  DRIZZLE
22
22
  } from "./chunk-U64T4YZE.js";
@@ -393,4 +393,4 @@ DrizzleEventBus = __decorateClass([
393
393
  export {
394
394
  DrizzleEventBus
395
395
  };
396
- //# sourceMappingURL=chunk-H6FO2ZDJ.js.map
396
+ //# sourceMappingURL=chunk-UTNWFHJF.js.map
@@ -1,11 +1,11 @@
1
- import {
2
- EVENTS_MODULE_OPTIONS
3
- } from "./chunk-H5NH7KPE.js";
4
1
  import {
5
2
  clampEventLimit,
6
3
  decodeEventCursor,
7
4
  encodeEventCursor
8
5
  } from "./chunk-UQ5EHOH2.js";
6
+ import {
7
+ EVENTS_MODULE_OPTIONS
8
+ } from "./chunk-H5NH7KPE.js";
9
9
  import {
10
10
  __decorateClass,
11
11
  __decorateParam
@@ -197,4 +197,4 @@ MemoryEventBus = __decorateClass([
197
197
  export {
198
198
  MemoryEventBus
199
199
  };
200
- //# sourceMappingURL=chunk-LQ6PYFU6.js.map
200
+ //# sourceMappingURL=chunk-Z7PQCAVK.js.map
@@ -4,23 +4,55 @@ import 'drizzle-orm';
4
4
  import '../types/drizzle.js';
5
5
  import 'drizzle-orm/node-postgres';
6
6
 
7
+ /**
8
+ * Per-entity Activity config (matches `ActivityPatternConfigSchema` in
9
+ * `src/patterns/library/activity.pattern.ts`). Carried on the concrete repo as
10
+ * `patternConfig` and read here to resolve column names at runtime.
11
+ */
12
+ interface ActivityPatternConfig {
13
+ /** Subject entity name → derives the FK column `<subject>_id`. */
14
+ subject?: string;
15
+ /** Explicit snake_case FK column, when it does not follow `<subject>_id`. */
16
+ subjectColumn?: string;
17
+ /** snake_case recency-ordering column; defaults to `occurred_at`. */
18
+ occurredAt?: string;
19
+ }
7
20
  declare abstract class ActivityEntityRepository<TEntity> extends BaseRepository<TEntity> {
8
21
  /**
9
- * Find activities within a date range (inclusive).
22
+ * Per-entity Activity config. The template emits this from `config:
23
+ * { Activity: {...} }`; entities that only use date-range / user scoping omit
24
+ * it (and must not call the subject finders).
25
+ */
26
+ protected readonly patternConfig?: ActivityPatternConfig;
27
+ /**
28
+ * camelCase key for the recency-ordering column. Defaults to `occurredAt`
29
+ * (column `occurred_at`); override via `patternConfig.occurredAt`.
30
+ */
31
+ protected get occurredAtColumn(): string;
32
+ /**
33
+ * camelCase key for the subject FK column, resolved from `patternConfig`:
34
+ * `subjectColumn` (explicit) → `<subject>_id` (derived). Throws when neither
35
+ * is configured — the subject finders are unusable without it, and a clear
36
+ * error beats a silent `undefined` column index.
37
+ */
38
+ protected get subjectColumn(): string;
39
+ /**
40
+ * Find activities within a date range (inclusive), by the recency column.
10
41
  */
11
42
  findByDateRange(start: Date, end: Date): Promise<TEntity[]>;
12
43
  /**
13
- * Find all activities for a specific user.
44
+ * Find all activities for a specific user (actor / owner scoping).
14
45
  */
15
46
  findByUserId(userId: string): Promise<TEntity[]>;
16
47
  /**
17
- * Find all activities for a specific opportunity.
48
+ * Find all activities for a specific subject (config-driven FK column).
18
49
  */
19
- findByOpportunityId(opportunityId: string): Promise<TEntity[]>;
50
+ findBySubjectId(subjectId: string): Promise<TEntity[]>;
20
51
  /**
21
- * Find the most recent activities for an opportunity, ordered by occurredAt desc.
52
+ * Find the most recent activities for a subject, ordered by the recency
53
+ * column descending.
22
54
  */
23
- findRecentByOpportunityId(opportunityId: string, limit?: number): Promise<TEntity[]>;
55
+ findRecentBySubjectId(subjectId: string, limit?: number): Promise<TEntity[]>;
24
56
  }
25
57
 
26
- export { ActivityEntityRepository };
58
+ export { ActivityEntityRepository, type ActivityPatternConfig };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ActivityEntityRepository
3
- } from "../../chunk-XCEI7NUH.js";
3
+ } from "../../chunk-MKWQKKK7.js";
4
4
  import "../../chunk-J6KZS54B.js";
5
5
  import "../../chunk-ZUKFQL6E.js";
6
6
  import "../../chunk-2E224ZSN.js";
@@ -6,16 +6,18 @@ import 'drizzle-orm/node-postgres';
6
6
  /**
7
7
  * ActivityEntityService<TRepo, TEntity>
8
8
  *
9
- * Family-specific base service for activity entities.
10
- * Delegates to an activity repository that provides date-range,
11
- * user, and opportunity queries.
9
+ * Family-specific base service for activity / interaction entities. Delegates
10
+ * to an activity repository that provides date-range, actor (`user_id`), and
11
+ * config-driven subject queries. The subject FK column is resolved inside the
12
+ * repository from its `patternConfig` (ADR-031 §4) — the service is
13
+ * subject-name-agnostic. See ACTIVITY-SUBJECT-1.
12
14
  */
13
15
 
14
16
  interface IActivityEntityRepository<TEntity> extends IBaseRepository<TEntity> {
15
17
  findByDateRange(start: Date, end: Date): Promise<TEntity[]>;
16
18
  findByUserId(userId: string): Promise<TEntity[]>;
17
- findByOpportunityId(opportunityId: string): Promise<TEntity[]>;
18
- findRecentByOpportunityId(opportunityId: string, limit?: number): Promise<TEntity[]>;
19
+ findBySubjectId(subjectId: string): Promise<TEntity[]>;
20
+ findRecentBySubjectId(subjectId: string, limit?: number): Promise<TEntity[]>;
19
21
  }
20
22
  declare abstract class ActivityEntityService<TRepo extends IActivityEntityRepository<TEntity>, TEntity> extends BaseService<TRepo, TEntity> {
21
23
  /**
@@ -23,17 +25,17 @@ declare abstract class ActivityEntityService<TRepo extends IActivityEntityReposi
23
25
  */
24
26
  findByDateRange(start: Date, end: Date): Promise<TEntity[]>;
25
27
  /**
26
- * Find all activities for a specific user.
28
+ * Find all activities for a specific user (actor / owner scoping).
27
29
  */
28
30
  findByUser(userId: string): Promise<TEntity[]>;
29
31
  /**
30
- * Find all activities for a specific opportunity.
32
+ * Find all activities for a specific subject (config-driven FK column).
31
33
  */
32
- findByOpportunity(opportunityId: string): Promise<TEntity[]>;
34
+ findBySubject(subjectId: string): Promise<TEntity[]>;
33
35
  /**
34
- * Find the most recent activities for an opportunity.
36
+ * Find the most recent activities for a subject.
35
37
  */
36
- findRecent(opportunityId: string, limit?: number): Promise<TEntity[]>;
38
+ findRecent(subjectId: string, limit?: number): Promise<TEntity[]>;
37
39
  }
38
40
 
39
41
  export { ActivityEntityService, type IActivityEntityRepository };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ActivityEntityService
3
- } from "../../chunk-BOPZWRJK.js";
3
+ } from "../../chunk-JYBFPNBJ.js";
4
4
  import "../../chunk-W72PRNJY.js";
5
5
  import "../../chunk-KYR3B3OW.js";
6
6
  import "../../chunk-2E224ZSN.js";
@@ -1,9 +1,3 @@
1
- import {
2
- KnowledgeEntityRepository
3
- } from "../../chunk-NN7XZEGF.js";
4
- import {
5
- KnowledgeEntityService
6
- } from "../../chunk-AS3NAZB6.js";
7
1
  import {
8
2
  MetadataEntityRepository
9
3
  } from "../../chunk-7KOW6PU6.js";
@@ -13,10 +7,6 @@ import {
13
7
  import {
14
8
  WithAnalytics
15
9
  } from "../../chunk-IBGER4YK.js";
16
- import {
17
- BaseFindByIdUseCase,
18
- BaseListUseCase
19
- } from "../../chunk-EXVDJMIY.js";
20
10
  import {
21
11
  IntegratedEntityRepository
22
12
  } from "../../chunk-OTDN3OUQ.js";
@@ -29,23 +19,24 @@ import {
29
19
  parseCompositeExternalId
30
20
  } from "../../chunk-2FTZLDBP.js";
31
21
  import {
32
- ActivityEntityRepository
33
- } from "../../chunk-XCEI7NUH.js";
22
+ KnowledgeEntityRepository
23
+ } from "../../chunk-NN7XZEGF.js";
34
24
  import {
35
- BaseRepository
36
- } from "../../chunk-J6KZS54B.js";
25
+ KnowledgeEntityService
26
+ } from "../../chunk-AS3NAZB6.js";
37
27
  import {
38
- requireRequester,
39
- requireRequesterScope,
40
- tryGetRequester,
41
- withOrgScope,
42
- withRequester,
43
- withSuperuserScope,
44
- withUserScope
45
- } from "../../chunk-ZUKFQL6E.js";
28
+ ActivityEntityRepository
29
+ } from "../../chunk-MKWQKKK7.js";
46
30
  import {
47
31
  ActivityEntityService
48
- } from "../../chunk-BOPZWRJK.js";
32
+ } from "../../chunk-JYBFPNBJ.js";
33
+ import {
34
+ BaseFindByIdUseCase,
35
+ BaseListUseCase
36
+ } from "../../chunk-EXVDJMIY.js";
37
+ import {
38
+ BaseRepository
39
+ } from "../../chunk-J6KZS54B.js";
49
40
  import {
50
41
  BaseService
51
42
  } from "../../chunk-W72PRNJY.js";
@@ -56,6 +47,15 @@ import {
56
47
  emitSafely,
57
48
  entitySnapshot
58
49
  } from "../../chunk-KYR3B3OW.js";
50
+ import {
51
+ requireRequester,
52
+ requireRequesterScope,
53
+ tryGetRequester,
54
+ withOrgScope,
55
+ withRequester,
56
+ withSuperuserScope,
57
+ withUserScope
58
+ } from "../../chunk-ZUKFQL6E.js";
59
59
  import "../../chunk-2E224ZSN.js";
60
60
  export {
61
61
  ActivityEntityRepository,
@@ -3,15 +3,15 @@ import {
3
3
  } from "../../../chunk-PSXUNOVU.js";
4
4
  import {
5
5
  OpenApiRegistry
6
- } from "../../../chunk-Y7GDG744.js";
7
- import {
8
- ERROR_RESPONSE_SCHEMA_NAME,
9
- errorResponseSchema
10
- } from "../../../chunk-SOVM2VEK.js";
6
+ } from "../../../chunk-4GLNY5V6.js";
11
7
  import {
12
8
  DuplicateSchemaError,
13
9
  OpenApiPeerDepMissingError
14
10
  } from "../../../chunk-YSLTTQLC.js";
11
+ import {
12
+ ERROR_RESPONSE_SCHEMA_NAME,
13
+ errorResponseSchema
14
+ } from "../../../chunk-SOVM2VEK.js";
15
15
  import "../../../chunk-2E224ZSN.js";
16
16
  export {
17
17
  DuplicateSchemaError,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  OpenApiRegistry
3
- } from "../../../chunk-Y7GDG744.js";
4
- import "../../../chunk-SOVM2VEK.js";
3
+ } from "../../../chunk-4GLNY5V6.js";
5
4
  import "../../../chunk-YSLTTQLC.js";
5
+ import "../../../chunk-SOVM2VEK.js";
6
6
  import "../../../chunk-2E224ZSN.js";
7
7
  export {
8
8
  OpenApiRegistry
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  AuthModule
3
- } from "../../../chunk-T6SCOJF4.js";
3
+ } from "../../../chunk-7LKAMLV4.js";
4
4
  import "../../../chunk-IP4OO26U.js";
5
- import "../../../chunk-SZVPIHWE.js";
6
5
  import "../../../chunk-N5OTOWTP.js";
7
6
  import "../../../chunk-QLTJSCE6.js";
8
7
  import "../../../chunk-BPARRK6F.js";
8
+ import "../../../chunk-SZVPIHWE.js";
9
9
  import "../../../chunk-6XY6ZMMD.js";
10
10
  import "../../../chunk-NPFPZ2HO.js";
11
11
  import "../../../chunk-GYGNEQSC.js";