clivly 0.17.1 → 0.19.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 (46) hide show
  1. package/README.md +15 -6
  2. package/{adapter-C63F9VZL.d.mts → adapter-BXykDFyG.d.mts} +1 -1
  3. package/{adapter-OO5g17qF.d.cts → adapter-BiUN_I3u.d.cts} +1 -1
  4. package/{auth-adapter-COMP0Fud.d.cts → auth-adapter-BNvri2gX.d.mts} +1 -1
  5. package/{auth-adapter-ZlhllVpm.d.mts → auth-adapter-D2MUT1Hk.d.cts} +1 -1
  6. package/auth-better-auth.d.cts +1 -1
  7. package/auth-better-auth.d.mts +1 -1
  8. package/auth-clerk.d.cts +1 -1
  9. package/auth-clerk.d.mts +1 -1
  10. package/auth-workos.d.cts +1 -1
  11. package/auth-workos.d.mts +1 -1
  12. package/core-adapter.d.cts +1 -1
  13. package/core-adapter.d.mts +1 -1
  14. package/core-auth-adapter.d.cts +1 -1
  15. package/core-auth-adapter.d.mts +1 -1
  16. package/core-types.d.cts +2 -2
  17. package/core-types.d.mts +2 -2
  18. package/core.d.cts +4 -4
  19. package/core.d.mts +4 -4
  20. package/drizzle.cjs +51 -2
  21. package/drizzle.d.cts +34 -2
  22. package/drizzle.d.mts +34 -2
  23. package/drizzle.mjs +50 -3
  24. package/index.cjs +64 -8
  25. package/index.mjs +64 -8
  26. package/internal-adapter.d.cts +1 -1
  27. package/internal-adapter.d.mts +1 -1
  28. package/internal-auth-adapter.d.cts +1 -1
  29. package/internal-auth-adapter.d.mts +1 -1
  30. package/internal-types.d.cts +2 -2
  31. package/internal-types.d.mts +2 -2
  32. package/internal.d.cts +4 -4
  33. package/internal.d.mts +4 -4
  34. package/{namespace-probe-BHk3NcyI.d.cts → namespace-probe-C1tm5rGh.d.cts} +92 -4
  35. package/{namespace-probe-Dt_HXcI-.d.mts → namespace-probe-ah2awcHO.d.mts} +92 -4
  36. package/package.json +1 -1
  37. package/{sdk-BZSTXPyK.cjs → sdk-BEHVvB18.cjs} +261 -31
  38. package/{sdk-KzHpSf7F.mjs → sdk-ChyrSl32.mjs} +261 -31
  39. package/sdk.cjs +1 -1
  40. package/sdk.d.cts +2 -2
  41. package/sdk.d.mts +2 -2
  42. package/sdk.mjs +1 -1
  43. package/{types-CQ2DgEH7.d.cts → types-C08UluBS.d.cts} +22 -1
  44. package/{types-C9_2vW5a.d.mts → types-CZsSYbeC.d.mts} +22 -1
  45. package/vite.d.cts +1 -1
  46. package/vite.d.mts +1 -1
package/README.md CHANGED
@@ -286,7 +286,7 @@ It answers two questions under two headings:
286
286
  - **This project** — the local ladder, run here on your machine: credential →
287
287
  Clivly reachable → `clivly.config` loads → `clivly.config` is edge-safe →
288
288
  sync cursor persists → boot hook wired → setup checks → dashboard-authored
289
- objects → sync trigger URL.
289
+ objects → sync trigger URL → sync trigger secret.
290
290
 
291
291
  ```text
292
292
  Clivly status
@@ -299,8 +299,8 @@ Workspace
299
299
  🔒 Let Clivly start a sync
300
300
 
301
301
  This project
302
- ✅ Step 1 of 9 · API key present
303
- ✅ Step 2 of 9 · Clivly reachable — Acme
302
+ ✅ Step 1 of 10 · API key present
303
+ ✅ Step 2 of 10 · Clivly reachable — Acme
304
304
  ...
305
305
  ```
306
306
 
@@ -334,6 +334,14 @@ reported as unusable. Fresh `init`/`login` env files leave the variable empty an
334
334
  show the URL shape only in a comment, so the setup check agrees with the SDK's
335
335
  platform discovery instead of treating documentation as configuration.
336
336
 
337
+ **Sync trigger secret** is new in `0.18.0`, and it **fails** when
338
+ `CLIVLY_SYNC_TRIGGER_SECRET` is not set. From 0.18.0 a route with no secret
339
+ refuses every request with `403 signature_required`, Clivly's "Run sync"
340
+ included, so a missing secret is a broken setup, not a risk. It warns instead
341
+ when `syncTrigger.allowUnsigned` is on, and is skipped against a host app whose
342
+ installed `clivly` is older than 0.18. `init` and `login` always name both
343
+ credentials together, so a deploy does not copy the key without the secret.
344
+
337
345
  If the Workspace section reads
338
346
  `⚠️ This Clivly server does not report setup progress`, or names a rejected key
339
347
  or an unreachable host, that means the question could not be asked — not that
@@ -452,7 +460,8 @@ logs nothing, and the dashboard reports "Host app rejected the preview (500)"
452
460
  against an app that never saw the request.
453
461
 
454
462
  `clivly dev` checks for this before claiming the tunnel works: it sends an
455
- unsigned request to the trigger path, which a Clivly route refuses with `401`.
463
+ unsigned request to the trigger path, which a Clivly route refuses with `401`
464
+ (or `403 signature_required` when the app has no signing secret yet).
456
465
  Anything else means the tunnel reaches something that is not your app, and the
457
466
  command warns instead of confirming:
458
467
 
@@ -503,8 +512,8 @@ work, and are kept because output and docs have recommended them — but prefer
503
512
  | Alias | Equivalent scope |
504
513
  | --- | --- |
505
514
  | `clivly ping` | Credential + reachability |
506
- | `clivly connect` | The above, plus config and trigger URL |
507
- | `clivly doctor` | Config, edge safety, boot hook and setup checks |
515
+ | `clivly connect` | The above, plus config, trigger URL and trigger secret |
516
+ | `clivly doctor` | Config, edge safety, boot hook, setup checks and trigger secret |
508
517
 
509
518
  Each prints a deprecation notice, then the steps it covers, renumbered to its own
510
519
  scope:
@@ -1,4 +1,4 @@
1
- import { A as UpdateCompanyInput, C as RecordSource, D as TaskFilters, M as UpdateDealInput, N as UpdateTaskInput, T as Task, a as Contact, c as CreateActivityInput, d as CreateDealInput, f as CreateTaskInput, i as CompanyFilters, j as UpdateContactInput, l as CreateCompanyInput, m as Deal, o as ContactFilters, r as Company, t as Activity, u as CreateContactInput, v as Page, y as PageRequest } from "./types-C9_2vW5a.mjs";
1
+ import { E as Task, M as UpdateContactInput, N as UpdateDealInput, O as TaskFilters, P as UpdateTaskInput, a as Contact, b as PageRequest, d as CreateContactInput, f as CreateDealInput, h as Deal, i as CompanyFilters, j as UpdateCompanyInput, l as CreateActivityInput, o as ContactFilters, p as CreateTaskInput, r as Company, t as Activity, u as CreateCompanyInput, w as RecordSource, y as Page } from "./types-CZsSYbeC.mjs";
2
2
  /**
3
3
  * The contract every ORM implementation fulfils. `packages/drizzle` is the first
4
4
  * implementation; Prisma/Kysely/TypeORM can follow without changes to consumers.
@@ -1,4 +1,4 @@
1
- import { A as UpdateCompanyInput, C as RecordSource, D as TaskFilters, M as UpdateDealInput, N as UpdateTaskInput, T as Task, a as Contact, c as CreateActivityInput, d as CreateDealInput, f as CreateTaskInput, i as CompanyFilters, j as UpdateContactInput, l as CreateCompanyInput, m as Deal, o as ContactFilters, r as Company, t as Activity, u as CreateContactInput, v as Page, y as PageRequest } from "./types-CQ2DgEH7.cjs";
1
+ import { E as Task, M as UpdateContactInput, N as UpdateDealInput, O as TaskFilters, P as UpdateTaskInput, a as Contact, b as PageRequest, d as CreateContactInput, f as CreateDealInput, h as Deal, i as CompanyFilters, j as UpdateCompanyInput, l as CreateActivityInput, o as ContactFilters, p as CreateTaskInput, r as Company, t as Activity, u as CreateCompanyInput, w as RecordSource, y as Page } from "./types-C08UluBS.cjs";
2
2
  /**
3
3
  * The contract every ORM implementation fulfils. `packages/drizzle` is the first
4
4
  * implementation; Prisma/Kysely/TypeORM can follow without changes to consumers.
@@ -1,4 +1,4 @@
1
- import { p as CrmRole } from "./types-CQ2DgEH7.cjs";
1
+ import { m as CrmRole } from "./types-CZsSYbeC.mjs";
2
2
  interface ClivlyUser {
3
3
  email: string;
4
4
  id: string;
@@ -1,4 +1,4 @@
1
- import { p as CrmRole } from "./types-C9_2vW5a.mjs";
1
+ import { m as CrmRole } from "./types-C08UluBS.cjs";
2
2
  interface ClivlyUser {
3
3
  email: string;
4
4
  id: string;
@@ -1,4 +1,4 @@
1
- import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-COMP0Fud.cjs";
1
+ import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-D2MUT1Hk.cjs";
2
2
  interface BetterAuthLikeUser {
3
3
  email?: string | null;
4
4
  id: string;
@@ -1,4 +1,4 @@
1
- import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-ZlhllVpm.mjs";
1
+ import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-BNvri2gX.mjs";
2
2
  interface BetterAuthLikeUser {
3
3
  email?: string | null;
4
4
  id: string;
package/auth-clerk.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-COMP0Fud.cjs";
1
+ import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-D2MUT1Hk.cjs";
2
2
  interface ClerkLikeUser {
3
3
  emailAddresses?: Array<{
4
4
  id: string;
package/auth-clerk.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-ZlhllVpm.mjs";
1
+ import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-BNvri2gX.mjs";
2
2
  interface ClerkLikeUser {
3
3
  emailAddresses?: Array<{
4
4
  id: string;
package/auth-workos.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-COMP0Fud.cjs";
1
+ import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-D2MUT1Hk.cjs";
2
2
  interface WorkOSLikeUser {
3
3
  email: string;
4
4
  firstName?: string | null;
package/auth-workos.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-ZlhllVpm.mjs";
1
+ import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-BNvri2gX.mjs";
2
2
  interface WorkOSLikeUser {
3
3
  email: string;
4
4
  firstName?: string | null;
@@ -1,2 +1,2 @@
1
- import { t as CRMAdapter } from "./adapter-OO5g17qF.cjs";
1
+ import { t as CRMAdapter } from "./adapter-BiUN_I3u.cjs";
2
2
  export { CRMAdapter };
@@ -1,2 +1,2 @@
1
- import { t as CRMAdapter } from "./adapter-C63F9VZL.mjs";
1
+ import { t as CRMAdapter } from "./adapter-BXykDFyG.mjs";
2
2
  export { CRMAdapter };
@@ -1,2 +1,2 @@
1
- import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-COMP0Fud.cjs";
1
+ import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-D2MUT1Hk.cjs";
2
2
  export { ClivlyAuthAdapter, ClivlyUser, CrmMembership, MembershipResolver, authCustom };
@@ -1,2 +1,2 @@
1
- import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-ZlhllVpm.mjs";
1
+ import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-BNvri2gX.mjs";
2
2
  export { ClivlyAuthAdapter, ClivlyUser, CrmMembership, MembershipResolver, authCustom };
package/core-types.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as UpdateCompanyInput, C as RecordSource, D as TaskFilters, E as TaskEntityType, F as isClosedStageType, M as UpdateDealInput, N as UpdateTaskInput, O as TaskPriority, P as ValueInterval, S as PipelineStageConfig, T as Task, _ as OPEN_STAGE_TYPE, a as Contact, b as PipelineConfig, c as CreateActivityInput, d as CreateDealInput, f as CreateTaskInput, g as Note, h as DealStage, i as CompanyFilters, j as UpdateContactInput, k as TaskStatus, l as CreateCompanyInput, m as Deal, n as ActivityType, o as ContactFilters, p as CrmRole, r as Company, s as ContactStatus, t as Activity, u as CreateContactInput, v as Page, w as StageType, x as PipelineKind, y as PageRequest } from "./types-CQ2DgEH7.cjs";
2
- export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, Page, PageRequest, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
1
+ import { A as TaskStatus, C as PipelineStageConfig, D as TaskEntityType, E as Task, F as ValueInterval, I as isClosedStageType, M as UpdateContactInput, N as UpdateDealInput, O as TaskFilters, P as UpdateTaskInput, S as PipelineKind, T as StageType, _ as Note, a as Contact, b as PageRequest, c as ContactStatus, d as CreateContactInput, f as CreateDealInput, g as DealStage, h as Deal, i as CompanyFilters, j as UpdateCompanyInput, k as TaskPriority, l as CreateActivityInput, m as CrmRole, n as ActivityType, o as ContactFilters, p as CreateTaskInput, r as Company, s as ContactSource, t as Activity, u as CreateCompanyInput, v as OPEN_STAGE_TYPE, w as RecordSource, x as PipelineConfig, y as Page } from "./types-C08UluBS.cjs";
2
+ export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactSource, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, Page, PageRequest, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
package/core-types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as UpdateCompanyInput, C as RecordSource, D as TaskFilters, E as TaskEntityType, F as isClosedStageType, M as UpdateDealInput, N as UpdateTaskInput, O as TaskPriority, P as ValueInterval, S as PipelineStageConfig, T as Task, _ as OPEN_STAGE_TYPE, a as Contact, b as PipelineConfig, c as CreateActivityInput, d as CreateDealInput, f as CreateTaskInput, g as Note, h as DealStage, i as CompanyFilters, j as UpdateContactInput, k as TaskStatus, l as CreateCompanyInput, m as Deal, n as ActivityType, o as ContactFilters, p as CrmRole, r as Company, s as ContactStatus, t as Activity, u as CreateContactInput, v as Page, w as StageType, x as PipelineKind, y as PageRequest } from "./types-C9_2vW5a.mjs";
2
- export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, Page, PageRequest, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
1
+ import { A as TaskStatus, C as PipelineStageConfig, D as TaskEntityType, E as Task, F as ValueInterval, I as isClosedStageType, M as UpdateContactInput, N as UpdateDealInput, O as TaskFilters, P as UpdateTaskInput, S as PipelineKind, T as StageType, _ as Note, a as Contact, b as PageRequest, c as ContactStatus, d as CreateContactInput, f as CreateDealInput, g as DealStage, h as Deal, i as CompanyFilters, j as UpdateCompanyInput, k as TaskPriority, l as CreateActivityInput, m as CrmRole, n as ActivityType, o as ContactFilters, p as CreateTaskInput, r as Company, s as ContactSource, t as Activity, u as CreateCompanyInput, v as OPEN_STAGE_TYPE, w as RecordSource, x as PipelineConfig, y as Page } from "./types-CZsSYbeC.mjs";
2
+ export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactSource, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, Page, PageRequest, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
package/core.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { A as UpdateCompanyInput, C as RecordSource, D as TaskFilters, E as TaskEntityType, F as isClosedStageType, I as ContactSegment, L as contactSegmentSchema, M as UpdateDealInput, N as UpdateTaskInput, O as TaskPriority, P as ValueInterval, S as PipelineStageConfig, T as Task, _ as OPEN_STAGE_TYPE, a as Contact, b as PipelineConfig, c as CreateActivityInput, d as CreateDealInput, f as CreateTaskInput, g as Note, h as DealStage, i as CompanyFilters, j as UpdateContactInput, k as TaskStatus, l as CreateCompanyInput, m as Deal, n as ActivityType, o as ContactFilters, p as CrmRole, r as Company, s as ContactStatus, t as Activity, u as CreateContactInput, v as Page, w as StageType, x as PipelineKind, y as PageRequest } from "./types-CQ2DgEH7.cjs";
2
- import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-COMP0Fud.cjs";
3
- import { t as CRMAdapter } from "./adapter-OO5g17qF.cjs";
1
+ import { A as TaskStatus, C as PipelineStageConfig, D as TaskEntityType, E as Task, F as ValueInterval, I as isClosedStageType, L as ContactSegment, M as UpdateContactInput, N as UpdateDealInput, O as TaskFilters, P as UpdateTaskInput, R as contactSegmentSchema, S as PipelineKind, T as StageType, _ as Note, a as Contact, b as PageRequest, c as ContactStatus, d as CreateContactInput, f as CreateDealInput, g as DealStage, h as Deal, i as CompanyFilters, j as UpdateCompanyInput, k as TaskPriority, l as CreateActivityInput, m as CrmRole, n as ActivityType, o as ContactFilters, p as CreateTaskInput, r as Company, s as ContactSource, t as Activity, u as CreateCompanyInput, v as OPEN_STAGE_TYPE, w as RecordSource, x as PipelineConfig, y as Page } from "./types-C08UluBS.cjs";
2
+ import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-D2MUT1Hk.cjs";
3
+ import { t as CRMAdapter } from "./adapter-BiUN_I3u.cjs";
4
4
  import { A as relationshipsSchema, B as identityRefs, D as missingRequiredFields, E as filterSchema, F as ProjectionFieldBinding, I as ProjectionIdentity, L as ProjectionJoin, M as validateEntitiesConfig, N as BASE_REF, O as projectionFields, P as PROJECTION_KEY_PATTERN, R as ProjectionMapping, S as RelationshipsMap, T as entitiesConfigSchema, V as projectionSchema, _ as MATERIALIZING_CONCEPTS, a as ClivlyEntitiesConfig, b as RelationshipSpec, d as CrmConcept, g as FilterValue, h as FilterExpr, i as ClivlyConfigError, j as requiredFieldsFor, k as relationshipSchema, l as ConfigValidationError, m as DiscoveredSchemaTable, n as CRM_CONCEPTS, p as DiscoveredColumnMeta, s as ClivlyEntityConfig, t as CANONICAL_FIELDS, u as ConfigValidationResult, v as MaterializingConcept, w as defineClivlyConfig, x as RelationshipVia, y as REQUIRED_FIELDS, z as ProjectionRef } from "./entity-config-dNclLyBM.cjs";
5
5
  import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-CV7y6qox.cjs";
6
6
  import { i as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-BBppW9fp.cjs";
@@ -8,4 +8,4 @@ import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as com
8
8
  import { c as SyncAction, f as isRemovalAction, g as runSync, h as resolveActions, l as SyncResult, m as reconcile, n as MirrorRecord, o as ResolvedMembership, r as PersistAction, s as SourceRow, t as EntitySyncResult, u as SyncStore } from "./sync-engine-C7W0Gkq0.cjs";
9
9
  import { A as PerSeatValueSource, C as HostOwnedCompanyField, D as isHostOwned, E as hostOwnedFieldMessage, O as rejectedCompanyFields, S as joinFansOut, T as SourcedRecord, _ as compileProjectionJoins, a as matchesCondition, b as quoteIdent, c as columnMetaFor, d as primaryKeyColumns, f as validateProjection, g as compileProjectionIdentity, h as compileProjectionFrom, i as evaluateStage, j as computeDealValue, k as rejectedContactFields, l as coversUniqueKey, m as PREVIEW_MAX_ROWS, n as ConditionOp, o as slugify, p as validateProjectionFilter, r as EvaluableRule, s as toObjectTypeSlug, t as Condition, u as hasRichMeta, v as compileProjectionPreview, w as HostOwnedContactField, x as fanOutJoins, y as compileProjectionSelect } from "./internal-COALpgov.cjs";
10
10
  import { a as IntegrationStep, c as StepProblem, i as IntegrationStatus, l as StepState, n as IntegrationFacts, o as NextAction, r as IntegrationState, s as StepId, t as ConnectionLiveness } from "./integration-state-xK4PLm5T.cjs";
11
- export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompanyFilters, type CompileOptions, type CompiledView, type Condition, type ConditionOp, type ConfigValidationError, type ConfigValidationResult, type ConnectionLiveness, type Contact, type ContactFilters, type ContactSegment, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type EntityMappingRow, type EntitySyncResult, type EvaluableRule, type ExplainResult, type FilterExpr, type FilterValue, type HostOwnedCompanyField, type HostOwnedContactField, type IntegrationFacts, type IntegrationState, type IntegrationStatus, type IntegrationStep, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type NextAction, type Note, OPEN_STAGE_TYPE, PREVIEW_MAX_ROWS, PROJECTION_KEY_PATTERN, type Page, type PageRequest, type PerSeatValueSource, type PersistAction, type PipelineConfig, type PipelineKind, type PipelineStageConfig, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, REQUIRED_FIELDS, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type ResolvedMembership, type SourceRow, type SourcedRecord, type StageType, type StepId, type StepProblem, type StepState, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateCompanyInput, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, type ValueInterval, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, compileProjectionPreview, compileProjectionSelect, computeDealValue, contactSegmentSchema, coversUniqueKey, defineClivlyConfig, entitiesConfigSchema, evaluateStage, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, hostOwnedFieldMessage, identityRefs, isClosedStageType, isHostOwned, isRemovalAction, joinFansOut, mappingsToEntitiesConfig, matchesCondition, missingRequiredFields, primaryKeyColumns, projectionFields, projectionSchema, quoteIdent, reconcile, rejectedCompanyFields, rejectedContactFields, relationshipSchema, relationshipViaSignature, relationshipsSchema, requiredFieldsFor, resolveActions, runSync, slugify, toObjectTypeSlug, validateEntitiesConfig, validateProjection, validateProjectionFilter };
11
+ export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompanyFilters, type CompileOptions, type CompiledView, type Condition, type ConditionOp, type ConfigValidationError, type ConfigValidationResult, type ConnectionLiveness, type Contact, type ContactFilters, type ContactSegment, type ContactSource, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type EntityMappingRow, type EntitySyncResult, type EvaluableRule, type ExplainResult, type FilterExpr, type FilterValue, type HostOwnedCompanyField, type HostOwnedContactField, type IntegrationFacts, type IntegrationState, type IntegrationStatus, type IntegrationStep, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type NextAction, type Note, OPEN_STAGE_TYPE, PREVIEW_MAX_ROWS, PROJECTION_KEY_PATTERN, type Page, type PageRequest, type PerSeatValueSource, type PersistAction, type PipelineConfig, type PipelineKind, type PipelineStageConfig, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, REQUIRED_FIELDS, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type ResolvedMembership, type SourceRow, type SourcedRecord, type StageType, type StepId, type StepProblem, type StepState, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateCompanyInput, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, type ValueInterval, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, compileProjectionPreview, compileProjectionSelect, computeDealValue, contactSegmentSchema, coversUniqueKey, defineClivlyConfig, entitiesConfigSchema, evaluateStage, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, hostOwnedFieldMessage, identityRefs, isClosedStageType, isHostOwned, isRemovalAction, joinFansOut, mappingsToEntitiesConfig, matchesCondition, missingRequiredFields, primaryKeyColumns, projectionFields, projectionSchema, quoteIdent, reconcile, rejectedCompanyFields, rejectedContactFields, relationshipSchema, relationshipViaSignature, relationshipsSchema, requiredFieldsFor, resolveActions, runSync, slugify, toObjectTypeSlug, validateEntitiesConfig, validateProjection, validateProjectionFilter };
package/core.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { A as UpdateCompanyInput, C as RecordSource, D as TaskFilters, E as TaskEntityType, F as isClosedStageType, I as ContactSegment, L as contactSegmentSchema, M as UpdateDealInput, N as UpdateTaskInput, O as TaskPriority, P as ValueInterval, S as PipelineStageConfig, T as Task, _ as OPEN_STAGE_TYPE, a as Contact, b as PipelineConfig, c as CreateActivityInput, d as CreateDealInput, f as CreateTaskInput, g as Note, h as DealStage, i as CompanyFilters, j as UpdateContactInput, k as TaskStatus, l as CreateCompanyInput, m as Deal, n as ActivityType, o as ContactFilters, p as CrmRole, r as Company, s as ContactStatus, t as Activity, u as CreateContactInput, v as Page, w as StageType, x as PipelineKind, y as PageRequest } from "./types-C9_2vW5a.mjs";
2
- import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-ZlhllVpm.mjs";
3
- import { t as CRMAdapter } from "./adapter-C63F9VZL.mjs";
1
+ import { A as TaskStatus, C as PipelineStageConfig, D as TaskEntityType, E as Task, F as ValueInterval, I as isClosedStageType, L as ContactSegment, M as UpdateContactInput, N as UpdateDealInput, O as TaskFilters, P as UpdateTaskInput, R as contactSegmentSchema, S as PipelineKind, T as StageType, _ as Note, a as Contact, b as PageRequest, c as ContactStatus, d as CreateContactInput, f as CreateDealInput, g as DealStage, h as Deal, i as CompanyFilters, j as UpdateCompanyInput, k as TaskPriority, l as CreateActivityInput, m as CrmRole, n as ActivityType, o as ContactFilters, p as CreateTaskInput, r as Company, s as ContactSource, t as Activity, u as CreateCompanyInput, v as OPEN_STAGE_TYPE, w as RecordSource, x as PipelineConfig, y as Page } from "./types-CZsSYbeC.mjs";
2
+ import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-BNvri2gX.mjs";
3
+ import { t as CRMAdapter } from "./adapter-BXykDFyG.mjs";
4
4
  import { A as relationshipsSchema, B as identityRefs, D as missingRequiredFields, E as filterSchema, F as ProjectionFieldBinding, I as ProjectionIdentity, L as ProjectionJoin, M as validateEntitiesConfig, N as BASE_REF, O as projectionFields, P as PROJECTION_KEY_PATTERN, R as ProjectionMapping, S as RelationshipsMap, T as entitiesConfigSchema, V as projectionSchema, _ as MATERIALIZING_CONCEPTS, a as ClivlyEntitiesConfig, b as RelationshipSpec, d as CrmConcept, g as FilterValue, h as FilterExpr, i as ClivlyConfigError, j as requiredFieldsFor, k as relationshipSchema, l as ConfigValidationError, m as DiscoveredSchemaTable, n as CRM_CONCEPTS, p as DiscoveredColumnMeta, s as ClivlyEntityConfig, t as CANONICAL_FIELDS, u as ConfigValidationResult, v as MaterializingConcept, w as defineClivlyConfig, x as RelationshipVia, y as REQUIRED_FIELDS, z as ProjectionRef } from "./entity-config-X-KlnYXX.mjs";
5
5
  import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-Bpvgf5b8.mjs";
6
6
  import { i as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-Dmm0H6p_.mjs";
@@ -8,4 +8,4 @@ import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as com
8
8
  import { c as SyncAction, f as isRemovalAction, g as runSync, h as resolveActions, l as SyncResult, m as reconcile, n as MirrorRecord, o as ResolvedMembership, r as PersistAction, s as SourceRow, t as EntitySyncResult, u as SyncStore } from "./sync-engine-C9Q2FkR9.mjs";
9
9
  import { A as PerSeatValueSource, C as HostOwnedCompanyField, D as isHostOwned, E as hostOwnedFieldMessage, O as rejectedCompanyFields, S as joinFansOut, T as SourcedRecord, _ as compileProjectionJoins, a as matchesCondition, b as quoteIdent, c as columnMetaFor, d as primaryKeyColumns, f as validateProjection, g as compileProjectionIdentity, h as compileProjectionFrom, i as evaluateStage, j as computeDealValue, k as rejectedContactFields, l as coversUniqueKey, m as PREVIEW_MAX_ROWS, n as ConditionOp, o as slugify, p as validateProjectionFilter, r as EvaluableRule, s as toObjectTypeSlug, t as Condition, u as hasRichMeta, v as compileProjectionPreview, w as HostOwnedContactField, x as fanOutJoins, y as compileProjectionSelect } from "./internal-D3q4FPcA.mjs";
10
10
  import { a as IntegrationStep, c as StepProblem, i as IntegrationStatus, l as StepState, n as IntegrationFacts, o as NextAction, r as IntegrationState, s as StepId, t as ConnectionLiveness } from "./integration-state-xK4PLm5T.mjs";
11
- export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompanyFilters, type CompileOptions, type CompiledView, type Condition, type ConditionOp, type ConfigValidationError, type ConfigValidationResult, type ConnectionLiveness, type Contact, type ContactFilters, type ContactSegment, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type EntityMappingRow, type EntitySyncResult, type EvaluableRule, type ExplainResult, type FilterExpr, type FilterValue, type HostOwnedCompanyField, type HostOwnedContactField, type IntegrationFacts, type IntegrationState, type IntegrationStatus, type IntegrationStep, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type NextAction, type Note, OPEN_STAGE_TYPE, PREVIEW_MAX_ROWS, PROJECTION_KEY_PATTERN, type Page, type PageRequest, type PerSeatValueSource, type PersistAction, type PipelineConfig, type PipelineKind, type PipelineStageConfig, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, REQUIRED_FIELDS, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type ResolvedMembership, type SourceRow, type SourcedRecord, type StageType, type StepId, type StepProblem, type StepState, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateCompanyInput, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, type ValueInterval, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, compileProjectionPreview, compileProjectionSelect, computeDealValue, contactSegmentSchema, coversUniqueKey, defineClivlyConfig, entitiesConfigSchema, evaluateStage, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, hostOwnedFieldMessage, identityRefs, isClosedStageType, isHostOwned, isRemovalAction, joinFansOut, mappingsToEntitiesConfig, matchesCondition, missingRequiredFields, primaryKeyColumns, projectionFields, projectionSchema, quoteIdent, reconcile, rejectedCompanyFields, rejectedContactFields, relationshipSchema, relationshipViaSignature, relationshipsSchema, requiredFieldsFor, resolveActions, runSync, slugify, toObjectTypeSlug, validateEntitiesConfig, validateProjection, validateProjectionFilter };
11
+ export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompanyFilters, type CompileOptions, type CompiledView, type Condition, type ConditionOp, type ConfigValidationError, type ConfigValidationResult, type ConnectionLiveness, type Contact, type ContactFilters, type ContactSegment, type ContactSource, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type EntityMappingRow, type EntitySyncResult, type EvaluableRule, type ExplainResult, type FilterExpr, type FilterValue, type HostOwnedCompanyField, type HostOwnedContactField, type IntegrationFacts, type IntegrationState, type IntegrationStatus, type IntegrationStep, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type NextAction, type Note, OPEN_STAGE_TYPE, PREVIEW_MAX_ROWS, PROJECTION_KEY_PATTERN, type Page, type PageRequest, type PerSeatValueSource, type PersistAction, type PipelineConfig, type PipelineKind, type PipelineStageConfig, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, REQUIRED_FIELDS, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type ResolvedMembership, type SourceRow, type SourcedRecord, type StageType, type StepId, type StepProblem, type StepState, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateCompanyInput, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, type ValueInterval, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, compileProjectionPreview, compileProjectionSelect, computeDealValue, contactSegmentSchema, coversUniqueKey, defineClivlyConfig, entitiesConfigSchema, evaluateStage, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, hostOwnedFieldMessage, identityRefs, isClosedStageType, isHostOwned, isRemovalAction, joinFansOut, mappingsToEntitiesConfig, matchesCondition, missingRequiredFields, primaryKeyColumns, projectionFields, projectionSchema, quoteIdent, reconcile, rejectedCompanyFields, rejectedContactFields, relationshipSchema, relationshipViaSignature, relationshipsSchema, requiredFieldsFor, resolveActions, runSync, slugify, toObjectTypeSlug, validateEntitiesConfig, validateProjection, validateProjectionFilter };
package/drizzle.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_projection = require("./projection-By63gMC-.cjs");
2
+ const require_drizzle = require("./drizzle-C0bfX-6a.cjs");
3
3
  const require_drizzle_meta = require("./drizzle-meta-BPnRLpsB.cjs");
4
+ const require_projection = require("./projection-By63gMC-.cjs");
4
5
  const require_projection_sql = require("./projection-sql-CHz7KzNS.cjs");
5
- const require_drizzle = require("./drizzle-C0bfX-6a.cjs");
6
6
  let drizzle_orm = require("drizzle-orm");
7
7
  // ../sdk/src/drizzle-projection.ts
8
8
  /** `<ref>.<column>` — the token `fields` carries and cloud-ingest reads. */
@@ -253,10 +253,59 @@ function drizzleIntrospector(db) {
253
253
  }
254
254
  };
255
255
  }
256
+ function settle(pushed, waitUntil) {
257
+ if (waitUntil) {
258
+ waitUntil(pushed);
259
+ return;
260
+ }
261
+ return pushed;
262
+ }
263
+ /**
264
+ * Update rows of a mapped Drizzle table and push each changed row to Clivly
265
+ * immediately — `insertAndPush`'s sibling for edits (continuous sync D2). A
266
+ * changed email or plan shows in Clivly within a second instead of at the
267
+ * next pull. Pushes are fire-and-forget, exactly as for `insertAndPush`.
268
+ *
269
+ * ```ts
270
+ * const updateUser = updateAndPush(clivly, db, schema.user, { entity: "user" });
271
+ * await updateUser(eq(schema.user.id, id), { plan: "pro" }, c.executionCtx);
272
+ * ```
273
+ */
274
+ function updateAndPush(clivly, db, table, opts) {
275
+ const updatableDb = db;
276
+ return async (where, values, waitUntil) => {
277
+ const updated = await updatableDb.update(table).set(values).where(where).returning();
278
+ await settle(Promise.all(updated.map((row) => clivly.pushOne(opts.entity, toColumnKeyedRow(table, row)))).then(() => void 0), waitUntil);
279
+ return updated;
280
+ };
281
+ }
282
+ /**
283
+ * Delete rows of a mapped Drizzle table and tell Clivly at once, so their CRM
284
+ * records are archived (never deleted) within a second (continuous sync D9).
285
+ * Without it, a deletion reaches Clivly at its daily delete check. `idField`
286
+ * is the property holding the row id; it defaults to `id`.
287
+ *
288
+ * ```ts
289
+ * const deleteUser = deleteAndPush(clivly, db, schema.user, { entity: "user" });
290
+ * await deleteUser(eq(schema.user.id, id), c.executionCtx);
291
+ * ```
292
+ */
293
+ function deleteAndPush(clivly, db, table, opts) {
294
+ const deletableDb = db;
295
+ const idField = opts.idField ?? "id";
296
+ return async (where, waitUntil) => {
297
+ const deleted = await deletableDb.delete(table).where(where).returning();
298
+ const ids = deleted.map((row) => row[idField]).filter((id) => id !== null && id !== void 0).map((id) => typeof id === "number" ? id : String(id));
299
+ if (ids.length > 0) await settle(clivly.pushDelete(opts.entity, ids), waitUntil);
300
+ return deleted;
301
+ };
302
+ }
256
303
  exports.buildUniqueConstraints = require_drizzle.buildUniqueConstraints;
304
+ exports.deleteAndPush = deleteAndPush;
257
305
  exports.discoverFromDrizzle = require_drizzle.discoverFromDrizzle;
258
306
  exports.drizzleIntrospector = drizzleIntrospector;
259
307
  exports.fromDrizzle = fromDrizzle;
260
308
  exports.fromDrizzleProjection = fromDrizzleProjection;
261
309
  exports.insertAndPush = insertAndPush;
262
310
  exports.toColumnKeyedRow = toColumnKeyedRow;
311
+ exports.updateAndPush = updateAndPush;
package/drizzle.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { R as ProjectionMapping, z as ProjectionRef } from "./entity-config-dNclLyBM.cjs";
1
+ import { b as SyncSource, t as NamespaceIntrospector } from "./namespace-probe-C1tm5rGh.cjs";
2
2
  import { n as buildUniqueConstraints, r as discoverFromDrizzle } from "./drizzle-B9cjBavj.cjs";
3
- import { t as NamespaceIntrospector, v as SyncSource } from "./namespace-probe-BHk3NcyI.cjs";
3
+ import { R as ProjectionMapping, z as ProjectionRef } from "./entity-config-dNclLyBM.cjs";
4
4
  import { Table } from "drizzle-orm";
5
5
  /**
6
6
  * Build a `SyncSource` that actually executes a projection's joins.
@@ -168,4 +168,36 @@ export declare function insertAndPush(clivly: PushOneCapable, db: unknown, table
168
168
  * (`current_schema()`), so it reports exactly the tables the app can reach.
169
169
  */
170
170
  export declare function drizzleIntrospector(db: unknown): NamespaceIntrospector;
171
+ interface PushDeleteCapable {
172
+ pushDelete(entityKey: string, ids: readonly (string | number)[]): Promise<void>;
173
+ }
174
+ /**
175
+ * Update rows of a mapped Drizzle table and push each changed row to Clivly
176
+ * immediately — `insertAndPush`'s sibling for edits (continuous sync D2). A
177
+ * changed email or plan shows in Clivly within a second instead of at the
178
+ * next pull. Pushes are fire-and-forget, exactly as for `insertAndPush`.
179
+ *
180
+ * ```ts
181
+ * const updateUser = updateAndPush(clivly, db, schema.user, { entity: "user" });
182
+ * await updateUser(eq(schema.user.id, id), { plan: "pro" }, c.executionCtx);
183
+ * ```
184
+ */
185
+ export declare function updateAndPush(clivly: PushOneCapable, db: unknown, table: Table, opts: {
186
+ entity: string;
187
+ }): (where: unknown, values: Record<string, unknown>, waitUntil?: (promise: Promise<unknown>) => void) => Promise<Record<string, unknown>[]>;
188
+ /**
189
+ * Delete rows of a mapped Drizzle table and tell Clivly at once, so their CRM
190
+ * records are archived (never deleted) within a second (continuous sync D9).
191
+ * Without it, a deletion reaches Clivly at its daily delete check. `idField`
192
+ * is the property holding the row id; it defaults to `id`.
193
+ *
194
+ * ```ts
195
+ * const deleteUser = deleteAndPush(clivly, db, schema.user, { entity: "user" });
196
+ * await deleteUser(eq(schema.user.id, id), c.executionCtx);
197
+ * ```
198
+ */
199
+ export declare function deleteAndPush(clivly: PushDeleteCapable, db: unknown, table: Table, opts: {
200
+ entity: string;
201
+ idField?: string;
202
+ }): (where: unknown, waitUntil?: (promise: Promise<unknown>) => void) => Promise<Record<string, unknown>[]>;
171
203
  export { type FromDrizzleProjectionOptions, buildUniqueConstraints, discoverFromDrizzle };
package/drizzle.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { R as ProjectionMapping, z as ProjectionRef } from "./entity-config-X-KlnYXX.mjs";
1
+ import { b as SyncSource, t as NamespaceIntrospector } from "./namespace-probe-ah2awcHO.mjs";
2
2
  import { n as buildUniqueConstraints, r as discoverFromDrizzle } from "./drizzle-L5FOGe_-.mjs";
3
- import { t as NamespaceIntrospector, v as SyncSource } from "./namespace-probe-Dt_HXcI-.mjs";
3
+ import { R as ProjectionMapping, z as ProjectionRef } from "./entity-config-X-KlnYXX.mjs";
4
4
  import { Table } from "drizzle-orm";
5
5
  /**
6
6
  * Build a `SyncSource` that actually executes a projection's joins.
@@ -168,4 +168,36 @@ export declare function insertAndPush(clivly: PushOneCapable, db: unknown, table
168
168
  * (`current_schema()`), so it reports exactly the tables the app can reach.
169
169
  */
170
170
  export declare function drizzleIntrospector(db: unknown): NamespaceIntrospector;
171
+ interface PushDeleteCapable {
172
+ pushDelete(entityKey: string, ids: readonly (string | number)[]): Promise<void>;
173
+ }
174
+ /**
175
+ * Update rows of a mapped Drizzle table and push each changed row to Clivly
176
+ * immediately — `insertAndPush`'s sibling for edits (continuous sync D2). A
177
+ * changed email or plan shows in Clivly within a second instead of at the
178
+ * next pull. Pushes are fire-and-forget, exactly as for `insertAndPush`.
179
+ *
180
+ * ```ts
181
+ * const updateUser = updateAndPush(clivly, db, schema.user, { entity: "user" });
182
+ * await updateUser(eq(schema.user.id, id), { plan: "pro" }, c.executionCtx);
183
+ * ```
184
+ */
185
+ export declare function updateAndPush(clivly: PushOneCapable, db: unknown, table: Table, opts: {
186
+ entity: string;
187
+ }): (where: unknown, values: Record<string, unknown>, waitUntil?: (promise: Promise<unknown>) => void) => Promise<Record<string, unknown>[]>;
188
+ /**
189
+ * Delete rows of a mapped Drizzle table and tell Clivly at once, so their CRM
190
+ * records are archived (never deleted) within a second (continuous sync D9).
191
+ * Without it, a deletion reaches Clivly at its daily delete check. `idField`
192
+ * is the property holding the row id; it defaults to `id`.
193
+ *
194
+ * ```ts
195
+ * const deleteUser = deleteAndPush(clivly, db, schema.user, { entity: "user" });
196
+ * await deleteUser(eq(schema.user.id, id), c.executionCtx);
197
+ * ```
198
+ */
199
+ export declare function deleteAndPush(clivly: PushDeleteCapable, db: unknown, table: Table, opts: {
200
+ entity: string;
201
+ idField?: string;
202
+ }): (where: unknown, waitUntil?: (promise: Promise<unknown>) => void) => Promise<Record<string, unknown>[]>;
171
203
  export { type FromDrizzleProjectionOptions, buildUniqueConstraints, discoverFromDrizzle };
package/drizzle.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { t as BASE_REF } from "./projection-BkYXvjTr.mjs";
1
+ import { n as buildUniqueConstraints, r as discoverFromDrizzle, t as buildColumnsMeta } from "./drizzle-CZuOzIu4.mjs";
2
2
  import { t as DRIZZLE_META } from "./drizzle-meta-D00lFvAk.mjs";
3
+ import { t as BASE_REF } from "./projection-BkYXvjTr.mjs";
3
4
  import { a as compileProjectionPreview, i as compileProjectionJoins, n as compileProjectionFrom, r as compileProjectionIdentity, s as quoteIdent } from "./projection-sql-C3gZE3GS.mjs";
4
- import { n as buildUniqueConstraints, r as discoverFromDrizzle, t as buildColumnsMeta } from "./drizzle-CZuOzIu4.mjs";
5
5
  import { asc, getTableColumns, getTableName, sql } from "drizzle-orm";
6
6
  // ../sdk/src/drizzle-projection.ts
7
7
  /** `<ref>.<column>` — the token `fields` carries and cloud-ingest reads. */
@@ -252,4 +252,51 @@ function drizzleIntrospector(db) {
252
252
  }
253
253
  };
254
254
  }
255
- export { buildUniqueConstraints, discoverFromDrizzle, drizzleIntrospector, fromDrizzle, fromDrizzleProjection, insertAndPush, toColumnKeyedRow };
255
+ function settle(pushed, waitUntil) {
256
+ if (waitUntil) {
257
+ waitUntil(pushed);
258
+ return;
259
+ }
260
+ return pushed;
261
+ }
262
+ /**
263
+ * Update rows of a mapped Drizzle table and push each changed row to Clivly
264
+ * immediately — `insertAndPush`'s sibling for edits (continuous sync D2). A
265
+ * changed email or plan shows in Clivly within a second instead of at the
266
+ * next pull. Pushes are fire-and-forget, exactly as for `insertAndPush`.
267
+ *
268
+ * ```ts
269
+ * const updateUser = updateAndPush(clivly, db, schema.user, { entity: "user" });
270
+ * await updateUser(eq(schema.user.id, id), { plan: "pro" }, c.executionCtx);
271
+ * ```
272
+ */
273
+ function updateAndPush(clivly, db, table, opts) {
274
+ const updatableDb = db;
275
+ return async (where, values, waitUntil) => {
276
+ const updated = await updatableDb.update(table).set(values).where(where).returning();
277
+ await settle(Promise.all(updated.map((row) => clivly.pushOne(opts.entity, toColumnKeyedRow(table, row)))).then(() => void 0), waitUntil);
278
+ return updated;
279
+ };
280
+ }
281
+ /**
282
+ * Delete rows of a mapped Drizzle table and tell Clivly at once, so their CRM
283
+ * records are archived (never deleted) within a second (continuous sync D9).
284
+ * Without it, a deletion reaches Clivly at its daily delete check. `idField`
285
+ * is the property holding the row id; it defaults to `id`.
286
+ *
287
+ * ```ts
288
+ * const deleteUser = deleteAndPush(clivly, db, schema.user, { entity: "user" });
289
+ * await deleteUser(eq(schema.user.id, id), c.executionCtx);
290
+ * ```
291
+ */
292
+ function deleteAndPush(clivly, db, table, opts) {
293
+ const deletableDb = db;
294
+ const idField = opts.idField ?? "id";
295
+ return async (where, waitUntil) => {
296
+ const deleted = await deletableDb.delete(table).where(where).returning();
297
+ const ids = deleted.map((row) => row[idField]).filter((id) => id !== null && id !== void 0).map((id) => typeof id === "number" ? id : String(id));
298
+ if (ids.length > 0) await settle(clivly.pushDelete(opts.entity, ids), waitUntil);
299
+ return deleted;
300
+ };
301
+ }
302
+ export { buildUniqueConstraints, deleteAndPush, discoverFromDrizzle, drizzleIntrospector, fromDrizzle, fromDrizzleProjection, insertAndPush, toColumnKeyedRow, updateAndPush };
package/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require_entity_config = require("./entity-config-DiCJ6mhI.cjs");
4
- require("./mapping-score-D2TCQiOr.cjs");
5
4
  const require_entity_heuristics = require("./entity-heuristics-CIParuQe.cjs");
6
- const require_sdk = require("./sdk-BZSTXPyK.cjs");
5
+ require("./mapping-score-D2TCQiOr.cjs");
6
+ const require_sdk = require("./sdk-BEHVvB18.cjs");
7
7
  let node_child_process = require("node:child_process");
8
8
  let node_fs = require("node:fs");
9
9
  let node_module = require("node:module");
@@ -606,6 +606,14 @@ const IDENTITY_RETRY_DELAY_MS = 2e3;
606
606
  const sleep = (ms) => new Promise((resolve) => {
607
607
  setTimeout(resolve, ms);
608
608
  });
609
+ async function isSignatureRequired(response) {
610
+ try {
611
+ const body = await response.json();
612
+ return typeof body === "object" && body !== null && body.error === "signature_required";
613
+ } catch {
614
+ return false;
615
+ }
616
+ }
609
617
  /** One attempt. Separated so the retry loop stays readable. */
610
618
  async function attempt(triggerUrl, fetchImpl) {
611
619
  const controller = new AbortController();
@@ -618,7 +626,7 @@ async function attempt(triggerUrl, fetchImpl) {
618
626
  signal: controller.signal
619
627
  });
620
628
  if (response.status === 401) return "clivly";
621
- if (response.status === 403) return "host-rejected";
629
+ if (response.status === 403) return await isSignatureRequired(response) ? "clivly" : "host-rejected";
622
630
  if (response.status === 404 || response.status >= 500) return "unknown";
623
631
  return "mismatch";
624
632
  } catch {
@@ -1765,6 +1773,7 @@ function writeCredentials(options, credentials) {
1765
1773
  };
1766
1774
  for (const entry of entries) if (result.skipped.includes(entry.key)) deps.out(` • ${entry.key} already set — skipped (pass --force to overwrite)`);
1767
1775
  else deps.out(` ✓ ${entry.key}=${maskSecret(valuesByKey[entry.key] ?? "")} written to ${envFile}`);
1776
+ deps.out(`\nDeploying? Copy ${SECRET_KEY_ENV} and CLIVLY_SYNC_TRIGGER_SECRET together into every environment your app runs in — without the second, its sync route refuses every request.`);
1768
1777
  }
1769
1778
  async function runLogin(options) {
1770
1779
  const { deps } = options;
@@ -2333,6 +2342,14 @@ ${sources.join(",\n")},
2333
2342
  url: process.env.CLIVLY_SYNC_TRIGGER_URL,
2334
2343
  secret: process.env.CLIVLY_SYNC_TRIGGER_SECRET,
2335
2344
  },
2345
+ // Push a changed row to Clivly the moment your app writes it, so a new
2346
+ // signup shows in the CRM within a second instead of at the next sync.
2347
+ // Write through the helpers from "clivly/drizzle" to use it:
2348
+ // insertAndPush(clivly, db, table, { entity }) // creates
2349
+ // updateAndPush(clivly, db, table, { entity }) // edits
2350
+ // deleteAndPush(clivly, db, table, { entity }) // deletes (archived in Clivly)
2351
+ // Writes made any other way still arrive with Clivly's scheduled sync.
2352
+ sync: { instant: true },
2336
2353
  // verifyToken is optional and only needed once a Clivly Cloud consumer calls
2337
2354
  // your /clivly/auth/verify endpoint; leave it unset otherwise.
2338
2355
  });
@@ -3395,7 +3412,7 @@ const CURSOR_STORE_HINT = "Pass `cursorStore: kvCursorStore(env.MY_KV)` (exporte
3395
3412
  function cursorStoreDetail(verdict) {
3396
3413
  if (verdict.configured) return "delta syncs resume from a persisted cursor";
3397
3414
  if (verdict.edgeRuntime === null) return "in-memory (fine on a long-lived host)";
3398
- return `No \`cursorStore\` on ${verdict.edgeRuntime} — memory does not survive between invocations, so every delta sync re-reads your entire source tables.`;
3415
+ return `No \`cursorStore\` on ${verdict.edgeRuntime}. Syncs Clivly starts resume from the position Clivly keeps for you; a sync this app starts itself re-reads your entire source tables.`;
3399
3416
  }
3400
3417
  // src/edge-safety.ts
3401
3418
  const NODE_BUILTINS = /* @__PURE__ */ new Set([
@@ -3695,6 +3712,41 @@ const triggerUrlStage = {
3695
3712
  });
3696
3713
  }
3697
3714
  };
3715
+ const TRIGGER_SECRET_HINT = "Run `clivly login` to write CLIVLY_SECRET_KEY and CLIVLY_SYNC_TRIGGER_SECRET together, or copy the signing secret from Integrations → Remote sync. Every environment the app runs in needs both.";
3716
+ /**
3717
+ * Whether the trigger route can verify Clivly's requests.
3718
+ *
3719
+ * A `fail`, not a `warn`, since 0.18.0 (audit F-01): with no secret the route
3720
+ * refuses every request with a body, which is every request Clivly sends, so
3721
+ * "Run sync" cannot work at all. `allowUnsigned` without a secret is a warn —
3722
+ * the host chose to let its own cron in unsigned, but Clivly still cannot.
3723
+ */
3724
+ const triggerSecretStage = {
3725
+ id: "trigger-secret",
3726
+ label: "Sync trigger secret",
3727
+ needs: [configStage.id],
3728
+ run(ctx) {
3729
+ const trigger = ctx.sdk?.describeSyncTrigger?.();
3730
+ if (trigger?.hasSecret === void 0) return Promise.resolve({
3731
+ state: "skip",
3732
+ detail: "This app's clivly is too old to report it — upgrade to 0.18."
3733
+ });
3734
+ if (trigger.hasSecret) return Promise.resolve({
3735
+ state: "pass",
3736
+ detail: "Secret is set — the route verifies every request."
3737
+ });
3738
+ if (trigger.allowUnsigned) return Promise.resolve({
3739
+ state: "warn",
3740
+ detail: "Not set, and `allowUnsigned` is on — anyone who finds the URL can start a sync, and Clivly cannot.",
3741
+ hint: TRIGGER_SECRET_HINT
3742
+ });
3743
+ return Promise.resolve({
3744
+ state: "fail",
3745
+ detail: "CLIVLY_SYNC_TRIGGER_SECRET is not set — the sync route refuses every request, Clivly's included.",
3746
+ hint: TRIGGER_SECRET_HINT
3747
+ });
3748
+ }
3749
+ };
3698
3750
  /** The full ladder, in the order a developer completes setup. */
3699
3751
  const STATUS_STAGES = [
3700
3752
  apiKeyStage,
@@ -3804,7 +3856,8 @@ const STATUS_STAGES = [
3804
3856
  });
3805
3857
  }
3806
3858
  },
3807
- triggerUrlStage
3859
+ triggerUrlStage,
3860
+ triggerSecretStage
3808
3861
  ];
3809
3862
  function defaultLoadSdk(path) {
3810
3863
  return loadConfigSdk(path, "doctor");
@@ -3856,13 +3909,15 @@ const ALIAS_STAGE_IDS = {
3856
3909
  "runtime",
3857
3910
  "boot-hook",
3858
3911
  "setup-checks",
3859
- "derived-objects"
3912
+ "derived-objects",
3913
+ "trigger-secret"
3860
3914
  ],
3861
3915
  connect: [
3862
3916
  "api-key",
3863
3917
  "reachable",
3864
3918
  "config",
3865
- "trigger-url"
3919
+ "trigger-url",
3920
+ "trigger-secret"
3866
3921
  ]
3867
3922
  };
3868
3923
  const MARK = {
@@ -4339,7 +4394,8 @@ function previewMutations(deps, mutations, options) {
4339
4394
  }
4340
4395
  function printNextSteps(out, authComplete, loginRan, envFile, needsViteDotenv = false) {
4341
4396
  out("\nNext steps:\n");
4342
- out(loginRan ? " 1. Credentials written by `clivly login`\n" : ` 1. Add CLIVLY_SECRET_KEY to ${envFile} — create one at\n ${CREDENTIALS_LOCATION}\n (the legacy CLIVLY_API_KEY is still accepted)\n`);
4397
+ out(loginRan ? " 1. Credentials written by `clivly login`\n" : ` 1. Run \`clivly login\`, or add both of these to ${envFile}:\n CLIVLY_SECRET_KEY ${CREDENTIALS_LOCATION}\n CLIVLY_SYNC_TRIGGER_SECRET ${SYNC_SECRET_LOCATION}\n (the legacy CLIVLY_API_KEY is still accepted)\n`);
4398
+ out(" Deploying? Set CLIVLY_SECRET_KEY and CLIVLY_SYNC_TRIGGER_SECRET together\n in every environment the app runs in — without the second, its sync\n route refuses every request.\n");
4343
4399
  out(" 2. Local dev: run `clivly dev` for dashboard-triggered sync\n");
4344
4400
  out(" It tunnels your app and registers the URL for you — remote sync is\n deploy-only otherwise, so nothing is broken if you skip it. Once deployed\n to Vercel/Cloudflare/Railway/Render/Fly the URL is detected automatically;\n set CLIVLY_SYNC_TRIGGER_URL by hand only for a custom domain.\n");
4345
4401
  let step = authComplete ? 3 : 4;