@elevasis/core 0.12.0 → 0.14.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 (50) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +9 -2
  3. package/dist/organization-model/index.d.ts +1 -1
  4. package/dist/organization-model/index.js +9 -2
  5. package/dist/test-utils/index.d.ts +480 -389
  6. package/dist/test-utils/index.js +28 -2
  7. package/package.json +1 -1
  8. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +2324 -0
  9. package/src/auth/multi-tenancy/credentials/__tests__/encryption.test.ts +217 -216
  10. package/src/auth/multi-tenancy/credentials/server/encryption.ts +5 -19
  11. package/src/auth/multi-tenancy/credentials/server/kek-loader.ts +3 -13
  12. package/src/auth/multi-tenancy/permissions.ts +12 -5
  13. package/src/business/acquisition/activity-events.test.ts +250 -0
  14. package/src/business/acquisition/activity-events.ts +84 -0
  15. package/src/business/acquisition/api-schemas.test.ts +1180 -0
  16. package/src/business/acquisition/api-schemas.ts +456 -235
  17. package/src/business/acquisition/crm-state-actions.test.ts +160 -0
  18. package/src/business/acquisition/derive-actions.test.ts +518 -0
  19. package/src/business/acquisition/derive-actions.ts +103 -0
  20. package/src/business/acquisition/index.ts +51 -11
  21. package/src/business/acquisition/stateful.ts +30 -0
  22. package/src/business/acquisition/types.ts +44 -77
  23. package/src/execution/engine/index.ts +4 -1
  24. package/src/execution/engine/tools/integration/server/adapters/apify/__tests__/apify-run-actor.integration.test.ts +1 -2
  25. package/src/execution/engine/tools/integration/server/adapters/attio/__tests__/attio-crud.integration.test.ts +363 -361
  26. package/src/execution/engine/tools/integration/server/adapters/attio/fetch/get-record/index.test.ts +162 -186
  27. package/src/execution/engine/tools/integration/server/adapters/attio/fetch/list-records/index.test.ts +316 -338
  28. package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-adapter.ts +204 -210
  29. package/src/execution/engine/tools/integration/server/adapters/resend/fetch/send-email/index.test.ts +88 -0
  30. package/src/execution/engine/tools/integration/server/adapters/resend/fetch/send-email/index.ts +141 -134
  31. package/src/execution/engine/tools/integration/server/adapters/resend/fetch/utils/types.ts +76 -75
  32. package/src/execution/engine/tools/integration/service.test.ts +34 -9
  33. package/src/execution/engine/tools/integration/service.ts +6 -3
  34. package/src/execution/engine/tools/lead-service-types.ts +90 -30
  35. package/src/execution/engine/tools/platform/acquisition/types.ts +266 -260
  36. package/src/execution/engine/tools/registry.ts +5 -4
  37. package/src/execution/engine/tools/tool-maps.ts +43 -21
  38. package/src/execution/engine/workflow/types.ts +11 -0
  39. package/src/organization-model/contracts.ts +4 -4
  40. package/src/organization-model/domains/navigation.ts +62 -62
  41. package/src/organization-model/domains/sales.ts +272 -0
  42. package/src/organization-model/organization-graph.mdx +2 -2
  43. package/src/organization-model/published.ts +21 -21
  44. package/src/organization-model/resolve.ts +21 -8
  45. package/src/platform/constants/versions.ts +1 -1
  46. package/src/reference/_generated/contracts.md +2324 -0
  47. package/src/scaffold-registry/index.ts +10 -9
  48. package/src/scaffold-registry/schema.ts +68 -62
  49. package/src/supabase/database.types.ts +2958 -2884
  50. package/src/test-utils/rls/RLSTestContext.ts +585 -553
@@ -142,9 +142,7 @@ export function compileScaffoldRegistry(): ScaffoldRegistry {
142
142
 
143
143
  const emptySources = findEmptySourcePatterns(registry, root)
144
144
  if (emptySources.length > 0) {
145
- const formatted = emptySources
146
- .map((source) => ` [${source.entryId}] ${source.pattern}`)
147
- .join('\n')
145
+ const formatted = emptySources.map((source) => ` [${source.entryId}] ${source.pattern}`).join('\n')
148
146
  throw new Error(
149
147
  `scaffold-registry: ${emptySources.length} source pattern(s) match no files or directories:\n${formatted}\n` +
150
148
  `Fix the stale source glob, create the scaffold surface, or add explicit registry support for intentional empty patterns.`
@@ -235,14 +233,17 @@ export function loadScaffoldRegistryFast(): ScaffoldRegistry {
235
233
 
236
234
  /**
237
235
  * Return all entries whose `sources` contain at least one pattern that matches
238
- * the given file path. Pattern matching is a simple substring/glob-prefix check
239
- * suitable for hook use; Step 3 will upgrade to full micromatch when the hook
240
- * is implemented.
236
+ * the given file path AND whose `excludes` contain no pattern that matches.
237
+ * Pattern matching is a simple substring/glob-prefix check suitable for hook
238
+ * use; Step 3 will upgrade to full micromatch when the hook is implemented.
241
239
  */
242
240
  export function findMatchingEntries(registry: ScaffoldRegistry, filePath: string): ScaffoldRegistryEntry[] {
243
- return registry.entries.filter((entry) =>
244
- entry.sources.some((pattern) => scaffoldPathMatchesPattern(filePath, pattern))
245
- )
241
+ return registry.entries.filter((entry) => {
242
+ const sourceMatch = entry.sources.some((pattern) => scaffoldPathMatchesPattern(filePath, pattern))
243
+ if (!sourceMatch) return false
244
+ const excluded = (entry.excludes ?? []).some((pattern) => scaffoldPathMatchesPattern(filePath, pattern))
245
+ return !excluded
246
+ })
246
247
  }
247
248
 
248
249
  // ---------------------------------------------------------------------------
@@ -1,25 +1,19 @@
1
- import { z } from 'zod'
2
-
3
- // ---------------------------------------------------------------------------
4
- // Kind taxonomy
5
- // ---------------------------------------------------------------------------
6
-
7
- /**
8
- * The kind of scaffold entry:
9
- *
10
- * - autogen: fully derivable from source; regen command is the fix
11
- * - manual-scaffold: hand-authored structure that must be updated on source change
1
+ import { z } from 'zod'
2
+
3
+ // ---------------------------------------------------------------------------
4
+ // Kind taxonomy
5
+ // ---------------------------------------------------------------------------
6
+
7
+ /**
8
+ * The kind of scaffold entry:
9
+ *
10
+ * - autogen: fully derivable from source; regen command is the fix
11
+ * - manual-scaffold: hand-authored structure that must be updated on source change
12
12
  * - sync-preservation: external-template files with a declared sync tier
13
13
  * - validator: drift-detection scripts or CI checks (meta.json pages[] validators, etc.)
14
14
  * - other: escape hatch; requires free-form notes
15
15
  */
16
- export const ScaffoldEntryKindSchema = z.enum([
17
- 'autogen',
18
- 'manual-scaffold',
19
- 'sync-preservation',
20
- 'validator',
21
- 'other'
22
- ])
16
+ export const ScaffoldEntryKindSchema = z.enum(['autogen', 'manual-scaffold', 'sync-preservation', 'validator', 'other'])
23
17
 
24
18
  export type ScaffoldEntryKind = z.infer<typeof ScaffoldEntryKindSchema>
25
19
 
@@ -55,35 +49,35 @@ export type ExternalSyncStrategy = z.infer<typeof ExternalSyncStrategySchema>
55
49
  export const ExternalSyncDeletePolicySchema = z.enum(['none', 'manifest-only'])
56
50
 
57
51
  export type ExternalSyncDeletePolicy = z.infer<typeof ExternalSyncDeletePolicySchema>
58
-
59
- // ---------------------------------------------------------------------------
60
- // Scaffold reference (a single downstream artifact that needs attention)
61
- // ---------------------------------------------------------------------------
62
-
63
- export const ScaffoldRefSchema = z.object({
64
- /**
65
- * File path, glob, or symbolic target (e.g. "docs: sync-preservation-matrix").
66
- * Symbolic targets begin with "docs:" or "autogen-target:".
67
- */
68
- path: z.string().min(1),
69
-
70
- /**
71
- * Command to regenerate, or "manual" if human judgment is required.
72
- */
73
- regen: z.string().min(1).optional(),
74
-
52
+
53
+ // ---------------------------------------------------------------------------
54
+ // Scaffold reference (a single downstream artifact that needs attention)
55
+ // ---------------------------------------------------------------------------
56
+
57
+ export const ScaffoldRefSchema = z.object({
58
+ /**
59
+ * File path, glob, or symbolic target (e.g. "docs: sync-preservation-matrix").
60
+ * Symbolic targets begin with "docs:" or "autogen-target:".
61
+ */
62
+ path: z.string().min(1),
63
+
64
+ /**
65
+ * Command to regenerate, or "manual" if human judgment is required.
66
+ */
67
+ regen: z.string().min(1).optional(),
68
+
75
69
  /**
76
70
  * Human-readable hint shown in reminder messages.
77
71
  */
78
- hint: z.string().optional()
79
- })
80
-
81
- export type ScaffoldRef = z.infer<typeof ScaffoldRefSchema>
82
-
83
- // ---------------------------------------------------------------------------
84
- // Registry entry
85
- // ---------------------------------------------------------------------------
86
-
72
+ hint: z.string().optional()
73
+ })
74
+
75
+ export type ScaffoldRef = z.infer<typeof ScaffoldRefSchema>
76
+
77
+ // ---------------------------------------------------------------------------
78
+ // Registry entry
79
+ // ---------------------------------------------------------------------------
80
+
87
81
  export const ScaffoldRegistryEntrySchema = z
88
82
  .object({
89
83
  /**
@@ -106,6 +100,18 @@ export const ScaffoldRegistryEntrySchema = z
106
100
  */
107
101
  sources: z.array(z.string().min(1)).min(1, 'At least one source pattern is required'),
108
102
 
103
+ /**
104
+ * Optional glob patterns that suppress this entry's reminder when the
105
+ * touched file matches. Applied after `sources`: a path that matches any
106
+ * `sources` pattern AND any `excludes` pattern is treated as no-match.
107
+ *
108
+ * Use case: a broad source glob (e.g. `apps/docs/content/docs/**\/*.mdx`)
109
+ * that should not fire on a sub-tree where the dependent scaffold does not
110
+ * apply (e.g. `apps/docs/content/docs/in-progress/**`, where MDX docs do
111
+ * not take meta.json files).
112
+ */
113
+ excludes: z.array(z.string().min(1)).optional(),
114
+
109
115
  /**
110
116
  * Downstream artifacts that need attention when a source changes.
111
117
  */
@@ -217,21 +223,21 @@ export const ScaffoldRegistryEntrySchema = z
217
223
  }
218
224
  }
219
225
  })
220
-
221
- export type ScaffoldRegistryEntry = z.infer<typeof ScaffoldRegistryEntrySchema>
222
-
223
- // ---------------------------------------------------------------------------
224
- // Top-level registry document
225
- // ---------------------------------------------------------------------------
226
-
227
- export const ScaffoldRegistrySchema = z.object({
228
- /**
229
- * Schema version for forward-compatibility detection.
230
- * Bump when the shape changes in a breaking way.
231
- */
232
- version: z.string().default('1'),
233
-
234
- entries: z.array(ScaffoldRegistryEntrySchema).min(1)
235
- })
236
-
237
- export type ScaffoldRegistry = z.infer<typeof ScaffoldRegistrySchema>
226
+
227
+ export type ScaffoldRegistryEntry = z.infer<typeof ScaffoldRegistryEntrySchema>
228
+
229
+ // ---------------------------------------------------------------------------
230
+ // Top-level registry document
231
+ // ---------------------------------------------------------------------------
232
+
233
+ export const ScaffoldRegistrySchema = z.object({
234
+ /**
235
+ * Schema version for forward-compatibility detection.
236
+ * Bump when the shape changes in a breaking way.
237
+ */
238
+ version: z.string().default('1'),
239
+
240
+ entries: z.array(ScaffoldRegistryEntrySchema).min(1)
241
+ })
242
+
243
+ export type ScaffoldRegistry = z.infer<typeof ScaffoldRegistrySchema>