clivly 0.11.0 → 0.13.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.
- package/{adapter-BWrOtOw5.d.mts → adapter-DTMeGGsl.d.cts} +19 -1
- package/{adapter-Bd5HjLYa.d.cts → adapter-DhPBRNpi.d.mts} +19 -1
- package/{auth-adapter-C3BQpc-q.d.cts → auth-adapter-C6rDx3XH.d.mts} +1 -1
- package/{auth-adapter-D54ajbl7.d.mts → auth-adapter-Csk9KkvI.d.cts} +1 -1
- package/auth-better-auth.d.cts +1 -1
- package/auth-better-auth.d.mts +1 -1
- package/auth-clerk.d.cts +1 -1
- package/auth-clerk.d.mts +1 -1
- package/auth-workos.d.cts +1 -1
- package/auth-workos.d.mts +1 -1
- package/core-adapter.d.cts +1 -1
- package/core-adapter.d.mts +1 -1
- package/core-auth-adapter.d.cts +1 -1
- package/core-auth-adapter.d.mts +1 -1
- package/core-types.d.cts +2 -2
- package/core-types.d.mts +2 -2
- package/core.cjs +2 -1
- package/core.d.cts +5 -5
- package/core.d.mts +5 -5
- package/core.mjs +2 -2
- package/drizzle.cjs +66 -0
- package/drizzle.d.cts +66 -1
- package/drizzle.d.mts +66 -1
- package/drizzle.mjs +65 -1
- package/index.cjs +1 -1
- package/index.mjs +1 -1
- package/{internal-CRIgf9jS.cjs → internal-BxtvxF7Z.cjs} +34 -0
- package/{internal-Bjpq7S2G.d.mts → internal-Cmx7Zevf.d.mts} +36 -1
- package/internal-adapter.d.cts +1 -1
- package/internal-adapter.d.mts +1 -1
- package/internal-auth-adapter.d.cts +1 -1
- package/internal-auth-adapter.d.mts +1 -1
- package/internal-types.d.cts +2 -2
- package/internal-types.d.mts +2 -2
- package/{internal-v6P9MZY1.mjs → internal-u0Bks5Gr.mjs} +29 -1
- package/{internal-D9kqkhPs.d.cts → internal-vH5Rlg6Q.d.cts} +36 -1
- package/internal.cjs +2 -1
- package/internal.d.cts +5 -5
- package/internal.d.mts +5 -5
- package/internal.mjs +2 -2
- package/{namespace-probe-CNQKSmxz.d.mts → namespace-probe-DykR0kgh.d.mts} +42 -0
- package/{namespace-probe-C5RLl74M.d.cts → namespace-probe-H7yWc0JV.d.cts} +42 -0
- package/package.json +1 -1
- package/{sdk-C-Pjxj2y.mjs → sdk-B-dp1tZN.mjs} +38 -1
- package/{sdk-BvGSxBQc.cjs → sdk-DKfKhJD_.cjs} +38 -1
- package/sdk.cjs +1 -1
- package/sdk.d.cts +1 -1
- package/sdk.d.mts +1 -1
- package/sdk.mjs +1 -1
- package/{types-D08UzDqe.d.mts → types-B17TWEOL.d.cts} +37 -1
- package/{types-D08UzDqe.d.cts → types-B17TWEOL.d.mts} +37 -1
- package/vite.d.cts +1 -1
- package/vite.d.mts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
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-B17TWEOL.cjs";
|
|
2
2
|
//#region ../core/src/adapter.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The contract every ORM implementation fulfils. `packages/drizzle` is the first
|
|
@@ -58,6 +58,24 @@ interface CRMAdapter {
|
|
|
58
58
|
source?: RecordSource;
|
|
59
59
|
}): Promise<Deal[]>;
|
|
60
60
|
getTasks(orgId: string, filters?: TaskFilters): Promise<Task[]>;
|
|
61
|
+
/**
|
|
62
|
+
* One page of companies, newest first.
|
|
63
|
+
*
|
|
64
|
+
* Separate from `getCompanies` rather than a `limit` on `CompanyFilters`,
|
|
65
|
+
* and that is the whole point: an optional field on a shared filter type is
|
|
66
|
+
* silently inheritable, and the callers that must never inherit it are the
|
|
67
|
+
* ones where truncation corrupts data rather than merely hiding rows.
|
|
68
|
+
* `importContacts` builds its dedup set from the unpaged read — a truncated
|
|
69
|
+
* set resurrects a contact archived as a duplicate. A distinct method makes
|
|
70
|
+
* "this call is paginated" a decision at every call site.
|
|
71
|
+
*/
|
|
72
|
+
listCompaniesPage(orgId: string, filters?: CompanyFilters, page?: PageRequest): Promise<Page<Company>>;
|
|
73
|
+
/** One page of contacts, newest first. See {@link CRMAdapter.listCompaniesPage}. */
|
|
74
|
+
listContactsPage(orgId: string, filters?: ContactFilters, page?: PageRequest): Promise<Page<Contact>>;
|
|
75
|
+
/** One page of deals, newest first. See {@link CRMAdapter.listCompaniesPage}. */
|
|
76
|
+
listDealsPage(orgId: string, filters?: {
|
|
77
|
+
source?: RecordSource;
|
|
78
|
+
}, page?: PageRequest): Promise<Page<Deal>>;
|
|
61
79
|
/**
|
|
62
80
|
* Move a deal to `stage` and reorder it directly after `afterId` (null = top
|
|
63
81
|
* of the column). The adapter computes the fractional `position` from the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
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-B17TWEOL.mjs";
|
|
2
2
|
//#region ../core/src/adapter.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The contract every ORM implementation fulfils. `packages/drizzle` is the first
|
|
@@ -58,6 +58,24 @@ interface CRMAdapter {
|
|
|
58
58
|
source?: RecordSource;
|
|
59
59
|
}): Promise<Deal[]>;
|
|
60
60
|
getTasks(orgId: string, filters?: TaskFilters): Promise<Task[]>;
|
|
61
|
+
/**
|
|
62
|
+
* One page of companies, newest first.
|
|
63
|
+
*
|
|
64
|
+
* Separate from `getCompanies` rather than a `limit` on `CompanyFilters`,
|
|
65
|
+
* and that is the whole point: an optional field on a shared filter type is
|
|
66
|
+
* silently inheritable, and the callers that must never inherit it are the
|
|
67
|
+
* ones where truncation corrupts data rather than merely hiding rows.
|
|
68
|
+
* `importContacts` builds its dedup set from the unpaged read — a truncated
|
|
69
|
+
* set resurrects a contact archived as a duplicate. A distinct method makes
|
|
70
|
+
* "this call is paginated" a decision at every call site.
|
|
71
|
+
*/
|
|
72
|
+
listCompaniesPage(orgId: string, filters?: CompanyFilters, page?: PageRequest): Promise<Page<Company>>;
|
|
73
|
+
/** One page of contacts, newest first. See {@link CRMAdapter.listCompaniesPage}. */
|
|
74
|
+
listContactsPage(orgId: string, filters?: ContactFilters, page?: PageRequest): Promise<Page<Contact>>;
|
|
75
|
+
/** One page of deals, newest first. See {@link CRMAdapter.listCompaniesPage}. */
|
|
76
|
+
listDealsPage(orgId: string, filters?: {
|
|
77
|
+
source?: RecordSource;
|
|
78
|
+
}, page?: PageRequest): Promise<Page<Deal>>;
|
|
61
79
|
/**
|
|
62
80
|
* Move a deal to `stage` and reorder it directly after `afterId` (null = top
|
|
63
81
|
* of the column). The adapter computes the fractional `position` from the
|
package/auth-better-auth.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-
|
|
1
|
+
import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-Csk9KkvI.cjs";
|
|
2
2
|
//#region ../auth-better-auth/src/map.d.ts
|
|
3
3
|
interface BetterAuthLikeUser {
|
|
4
4
|
email?: string | null;
|
package/auth-better-auth.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-
|
|
1
|
+
import { n as ClivlyUser, t as ClivlyAuthAdapter } from "./auth-adapter-C6rDx3XH.mjs";
|
|
2
2
|
//#region ../auth-better-auth/src/map.d.ts
|
|
3
3
|
interface BetterAuthLikeUser {
|
|
4
4
|
email?: string | null;
|
package/auth-clerk.d.cts
CHANGED
package/auth-clerk.d.mts
CHANGED
package/auth-workos.d.cts
CHANGED
package/auth-workos.d.mts
CHANGED
package/core-adapter.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as CRMAdapter } from "./adapter-
|
|
1
|
+
import { t as CRMAdapter } from "./adapter-DTMeGGsl.cjs";
|
|
2
2
|
export { CRMAdapter };
|
package/core-adapter.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as CRMAdapter } from "./adapter-
|
|
1
|
+
import { t as CRMAdapter } from "./adapter-DhPBRNpi.mjs";
|
|
2
2
|
export { CRMAdapter };
|
package/core-auth-adapter.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-
|
|
1
|
+
import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-Csk9KkvI.cjs";
|
|
2
2
|
export { ClivlyAuthAdapter, ClivlyUser, CrmMembership, MembershipResolver, authCustom };
|
package/core-auth-adapter.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-
|
|
1
|
+
import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-C6rDx3XH.mjs";
|
|
2
2
|
export { ClivlyAuthAdapter, ClivlyUser, CrmMembership, MembershipResolver, authCustom };
|
package/core-types.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
|
|
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-B17TWEOL.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 };
|
package/core-types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
|
|
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-B17TWEOL.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 };
|
package/core.cjs
CHANGED
|
@@ -3,7 +3,7 @@ const require_projection = require("./projection-BELgANG2.cjs");
|
|
|
3
3
|
const require_entity_config = require("./entity-config-BI4RYNKL.cjs");
|
|
4
4
|
const require_mappings_config = require("./mappings-config-BCsRLohT.cjs");
|
|
5
5
|
const require_auth_adapter = require("./auth-adapter-CiEXcweZ.cjs");
|
|
6
|
-
const require_internal = require("./internal-
|
|
6
|
+
const require_internal = require("./internal-BxtvxF7Z.cjs");
|
|
7
7
|
const require_mapping_form = require("./mapping-form-BpfON_ME.cjs");
|
|
8
8
|
const require_projection_sql = require("./projection-sql-DuCtFE9t.cjs");
|
|
9
9
|
const require_view_compiler = require("./view-compiler-xiwm5iar.cjs");
|
|
@@ -33,6 +33,7 @@ exports.compileProjectionIdentity = require_projection_sql.compileProjectionIden
|
|
|
33
33
|
exports.compileProjectionJoins = require_projection_sql.compileProjectionJoins;
|
|
34
34
|
exports.compileProjectionPreview = require_projection_sql.compileProjectionPreview;
|
|
35
35
|
exports.compileProjectionSelect = require_projection_sql.compileProjectionSelect;
|
|
36
|
+
exports.computeDealValue = require_internal.computeDealValue;
|
|
36
37
|
exports.coversUniqueKey = require_entity_config.coversUniqueKey;
|
|
37
38
|
exports.defineClivlyConfig = require_entity_config.defineClivlyConfig;
|
|
38
39
|
exports.entitiesConfigSchema = require_entity_config.entitiesConfigSchema;
|
package/core.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
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-ApnT5j3X.cjs";
|
|
2
|
-
import { A as
|
|
3
|
-
import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-
|
|
4
|
-
import { t as CRMAdapter } from "./adapter-
|
|
2
|
+
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-B17TWEOL.cjs";
|
|
3
|
+
import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-Csk9KkvI.cjs";
|
|
4
|
+
import { t as CRMAdapter } from "./adapter-DTMeGGsl.cjs";
|
|
5
5
|
import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-XsLLCqW_.cjs";
|
|
6
6
|
import { i as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-iJzbcUMp.cjs";
|
|
7
7
|
import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-Cq8apvZ4.cjs";
|
|
8
8
|
import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-V3_UutGv.cjs";
|
|
9
|
-
import { 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, 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-
|
|
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-vH5Rlg6Q.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-BA4c0RbD.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 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 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 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, coversUniqueKey, defineClivlyConfig, entitiesConfigSchema, evaluateStage, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, hostOwnedFieldMessage, identityRefs, isClosedStageType, isHostOwned, joinFansOut, mappingsToEntitiesConfig, matchesCondition, missingRequiredFields, primaryKeyColumns, projectionFields, projectionSchema, quoteIdent, reconcile, rejectedCompanyFields, rejectedContactFields, relationshipSchema, relationshipViaSignature, relationshipsSchema, requiredFieldsFor, 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 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 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, coversUniqueKey, defineClivlyConfig, entitiesConfigSchema, evaluateStage, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, hostOwnedFieldMessage, identityRefs, isClosedStageType, isHostOwned, joinFansOut, mappingsToEntitiesConfig, matchesCondition, missingRequiredFields, primaryKeyColumns, projectionFields, projectionSchema, quoteIdent, reconcile, rejectedCompanyFields, rejectedContactFields, relationshipSchema, relationshipViaSignature, relationshipsSchema, requiredFieldsFor, runSync, slugify, toObjectTypeSlug, validateEntitiesConfig, validateProjection, validateProjectionFilter };
|
package/core.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
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-CKcj4-M_.mjs";
|
|
2
|
-
import { A as
|
|
3
|
-
import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-
|
|
4
|
-
import { t as CRMAdapter } from "./adapter-
|
|
2
|
+
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-B17TWEOL.mjs";
|
|
3
|
+
import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-C6rDx3XH.mjs";
|
|
4
|
+
import { t as CRMAdapter } from "./adapter-DhPBRNpi.mjs";
|
|
5
5
|
import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-Btn-7gzv.mjs";
|
|
6
6
|
import { i as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-D6_oCi2Q.mjs";
|
|
7
7
|
import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-CwKVoK1w.mjs";
|
|
8
8
|
import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine--M9EaONC.mjs";
|
|
9
|
-
import { 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, 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-
|
|
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-Cmx7Zevf.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-BA4c0RbD.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 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 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 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, coversUniqueKey, defineClivlyConfig, entitiesConfigSchema, evaluateStage, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, hostOwnedFieldMessage, identityRefs, isClosedStageType, isHostOwned, joinFansOut, mappingsToEntitiesConfig, matchesCondition, missingRequiredFields, primaryKeyColumns, projectionFields, projectionSchema, quoteIdent, reconcile, rejectedCompanyFields, rejectedContactFields, relationshipSchema, relationshipViaSignature, relationshipsSchema, requiredFieldsFor, 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 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 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, coversUniqueKey, defineClivlyConfig, entitiesConfigSchema, evaluateStage, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, hostOwnedFieldMessage, identityRefs, isClosedStageType, isHostOwned, joinFansOut, mappingsToEntitiesConfig, matchesCondition, missingRequiredFields, primaryKeyColumns, projectionFields, projectionSchema, quoteIdent, reconcile, rejectedCompanyFields, rejectedContactFields, relationshipSchema, relationshipViaSignature, relationshipsSchema, requiredFieldsFor, runSync, slugify, toObjectTypeSlug, validateEntitiesConfig, validateProjection, validateProjectionFilter };
|
package/core.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { i as projectionSchema, n as PROJECTION_KEY_PATTERN, r as identityRefs,
|
|
|
2
2
|
import { C as hasRichMeta, S as coversUniqueKey, _ as validateProjection, a as MATERIALIZING_CONCEPTS, b as joinFansOut, c as defineClivlyConfig, d as missingRequiredFields, f as projectionFields, g as validateEntitiesConfig, h as requiredFieldsFor, i as ClivlyConfigError, l as entitiesConfigSchema, m as relationshipsSchema, n as CRM_CONCEPTS, o as REQUIRED_FIELDS, p as relationshipSchema, t as CANONICAL_FIELDS, u as filterSchema, v as validateProjectionFilter, w as primaryKeyColumns, x as columnMetaFor, y as fanOutJoins } from "./entity-config-Ccfb2IL9.mjs";
|
|
3
3
|
import { n as mappingsToEntitiesConfig } from "./mappings-config-CwQNQ6bA.mjs";
|
|
4
4
|
import { t as authCustom } from "./auth-adapter-gfVDxf3d.mjs";
|
|
5
|
-
import { a as hostOwnedFieldMessage, c as rejectedContactFields, i as toObjectTypeSlug, n as matchesCondition, o as isHostOwned, r as slugify, s as rejectedCompanyFields, t as evaluateStage } from "./internal-
|
|
5
|
+
import { a as hostOwnedFieldMessage, c as rejectedContactFields, i as toObjectTypeSlug, l as computeDealValue, n as matchesCondition, o as isHostOwned, r as slugify, s as rejectedCompanyFields, t as evaluateStage } from "./internal-u0Bks5Gr.mjs";
|
|
6
6
|
import { n as buildRelationships, r as relationshipViaSignature, t as buildFilterFromDiscriminator } from "./mapping-form-DigkuvFc.mjs";
|
|
7
7
|
import { a as compileProjectionPreview, i as compileProjectionJoins, n as compileProjectionFrom, o as compileProjectionSelect, r as compileProjectionIdentity, s as quoteIdent, t as PREVIEW_MAX_ROWS } from "./projection-sql-DweUaWRc.mjs";
|
|
8
8
|
import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-C-6RydKK.mjs";
|
|
@@ -12,4 +12,4 @@ import { t as warnDeprecatedSubpath } from "./deprecate-subpath-CmvZtCpE.mjs";
|
|
|
12
12
|
//#region src/core.ts
|
|
13
13
|
warnDeprecatedSubpath("clivly/core", "clivly/sdk", "Import \"defineClivlyConfig\" and its config types from \"clivly/sdk\"; import everything else from \"clivly/internal\" (no stability guarantee — see STABILITY.md).");
|
|
14
14
|
//#endregion
|
|
15
|
-
export { BASE_REF, CANONICAL_FIELDS, CRM_CONCEPTS, ClivlyConfigError, DEFAULT_VIEW_PREFIX, MATERIALIZING_CONCEPTS, OPEN_STAGE_TYPE, PREVIEW_MAX_ROWS, PROJECTION_KEY_PATTERN, REQUIRED_FIELDS, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, compileProjectionPreview, compileProjectionSelect, coversUniqueKey, defineClivlyConfig, entitiesConfigSchema, evaluateStage, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, hostOwnedFieldMessage, identityRefs, isClosedStageType, isHostOwned, joinFansOut, mappingsToEntitiesConfig, matchesCondition, missingRequiredFields, primaryKeyColumns, projectionFields, projectionSchema, quoteIdent, reconcile, rejectedCompanyFields, rejectedContactFields, relationshipSchema, relationshipViaSignature, relationshipsSchema, requiredFieldsFor, runSync, slugify, toObjectTypeSlug, validateEntitiesConfig, validateProjection, validateProjectionFilter };
|
|
15
|
+
export { BASE_REF, CANONICAL_FIELDS, CRM_CONCEPTS, ClivlyConfigError, DEFAULT_VIEW_PREFIX, MATERIALIZING_CONCEPTS, OPEN_STAGE_TYPE, PREVIEW_MAX_ROWS, PROJECTION_KEY_PATTERN, REQUIRED_FIELDS, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, compileProjectionPreview, compileProjectionSelect, computeDealValue, coversUniqueKey, defineClivlyConfig, entitiesConfigSchema, evaluateStage, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, hostOwnedFieldMessage, identityRefs, isClosedStageType, isHostOwned, joinFansOut, mappingsToEntitiesConfig, matchesCondition, missingRequiredFields, primaryKeyColumns, projectionFields, projectionSchema, quoteIdent, reconcile, rejectedCompanyFields, rejectedContactFields, relationshipSchema, relationshipViaSignature, relationshipsSchema, requiredFieldsFor, runSync, slugify, toObjectTypeSlug, validateEntitiesConfig, validateProjection, validateProjectionFilter };
|
package/drizzle.cjs
CHANGED
|
@@ -142,6 +142,7 @@ function fromDrizzle(db, table, opts) {
|
|
|
142
142
|
const idColumnName = idColumn.name;
|
|
143
143
|
const source = {
|
|
144
144
|
entity: opts.entity,
|
|
145
|
+
...opts.pushSource === void 0 ? {} : { pushSource: opts.pushSource },
|
|
145
146
|
cursorField: cursorColumnName,
|
|
146
147
|
idField: idColumnName,
|
|
147
148
|
fetchPage: ({ since, limit }) => drizzleDb.select(projection).from(table).where(since ? drizzle_orm.sql`(${cursorColumn}, ${idColumn}) > (${since.time}, ${since.id})` : void 0).orderBy((0, drizzle_orm.asc)(cursorColumn), (0, drizzle_orm.asc)(idColumn)).limit(limit),
|
|
@@ -163,6 +164,69 @@ function fromDrizzle(db, table, opts) {
|
|
|
163
164
|
return source;
|
|
164
165
|
}
|
|
165
166
|
/**
|
|
167
|
+
* Insert a row into a mapped Drizzle table and push it to Clivly immediately
|
|
168
|
+
* — the "one call does both" instant-push API (see
|
|
169
|
+
* docs/reviews/2026-09-19-near-real-time-sync-plan.md, question 1). Returns
|
|
170
|
+
* only after the write completes; the push itself is fire-and-forget (see
|
|
171
|
+
* `pushOne`), so this resolves at the same time a plain `db.insert(...)`
|
|
172
|
+
* would.
|
|
173
|
+
*
|
|
174
|
+
* Created once per mapped table, mirroring `fromDrizzle`'s own convention —
|
|
175
|
+
* no per-call table-to-entity lookup, so a table two entities share (e.g.
|
|
176
|
+
* `user` for both `user` and `organizationOwner`) is never ambiguous:
|
|
177
|
+
* ```ts
|
|
178
|
+
* const insertUser = insertAndPush(clivly, db, schema.user, { entity: "user" });
|
|
179
|
+
* // in the signup handler:
|
|
180
|
+
* const created = await insertUser(newUserValues, c.executionCtx);
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* `waitUntil`, when provided (Hono exposes it as `c.executionCtx.waitUntil`),
|
|
184
|
+
* extends the request's lifetime past the response so the push survives on
|
|
185
|
+
* Cloudflare Workers and similar runtimes, which otherwise kill background
|
|
186
|
+
* work the instant a response is sent. Omit it on a long-lived process where
|
|
187
|
+
* nothing tears the request down early.
|
|
188
|
+
*
|
|
189
|
+
* Table property keys are translated to real database column names before
|
|
190
|
+
* the push — the same translation `fromDrizzle` performs on `fetchPage` rows
|
|
191
|
+
* — because a raw `.returning()` result is keyed by Drizzle property name
|
|
192
|
+
* (`fullName`), and every consumer downstream of a push (the fieldMap, the
|
|
193
|
+
* cloud's ingest) addresses columns by their database name (`full_name`).
|
|
194
|
+
* Skipping this would silently push empty fields with no error anywhere.
|
|
195
|
+
*/
|
|
196
|
+
/**
|
|
197
|
+
* Translate a Drizzle-property-keyed row (e.g. a `.returning()` result, or a
|
|
198
|
+
* plain unprojected `select()`) to real database column names — the same
|
|
199
|
+
* translation `fromDrizzle` performs on `fetchPage` rows. Every consumer
|
|
200
|
+
* downstream of a push (the fieldMap, the cloud's ingest) addresses columns
|
|
201
|
+
* by their database name (`full_name`), not the property name (`fullName`);
|
|
202
|
+
* skipping this would silently push empty fields with no error anywhere.
|
|
203
|
+
*
|
|
204
|
+
* Exported so a host can build the same translated row from a table it read
|
|
205
|
+
* some other way — e.g. re-querying a row inside an auth library's own
|
|
206
|
+
* lifecycle hook, where there is no `insertAndPush` call site to wrap
|
|
207
|
+
* because the library performs the insert internally.
|
|
208
|
+
*/
|
|
209
|
+
function toColumnKeyedRow(table, row) {
|
|
210
|
+
const columns = (0, drizzle_orm.getTableColumns)(table);
|
|
211
|
+
const columnNameByPropertyKey = /* @__PURE__ */ new Map();
|
|
212
|
+
for (const [propertyKey, column] of Object.entries(columns)) columnNameByPropertyKey.set(propertyKey, column.name);
|
|
213
|
+
const out = {};
|
|
214
|
+
for (const [propertyKey, value] of Object.entries(row)) out[columnNameByPropertyKey.get(propertyKey) ?? propertyKey] = value;
|
|
215
|
+
return out;
|
|
216
|
+
}
|
|
217
|
+
function insertAndPush(clivly, db, table, opts) {
|
|
218
|
+
const insertableDb = db;
|
|
219
|
+
return async (values, waitUntil) => {
|
|
220
|
+
const [created] = await insertableDb.insert(table).values(values).returning();
|
|
221
|
+
if (!created) throw new Error(`insertAndPush: insert into "${(0, drizzle_orm.getTableName)(table)}" returned no row.`);
|
|
222
|
+
const row = toColumnKeyedRow(table, created);
|
|
223
|
+
const pushed = clivly.pushOne(opts.entity, row);
|
|
224
|
+
if (waitUntil) waitUntil(pushed);
|
|
225
|
+
else await pushed;
|
|
226
|
+
return created;
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
166
230
|
* Build a `NamespaceIntrospector` from any Drizzle client that exposes
|
|
167
231
|
* `.execute()`. Reads `information_schema` in the connection's default schema
|
|
168
232
|
* (`current_schema()`), so it reports exactly the tables the app can reach.
|
|
@@ -197,3 +261,5 @@ exports.discoverFromDrizzle = require_drizzle.discoverFromDrizzle;
|
|
|
197
261
|
exports.drizzleIntrospector = drizzleIntrospector;
|
|
198
262
|
exports.fromDrizzle = fromDrizzle;
|
|
199
263
|
exports.fromDrizzleProjection = fromDrizzleProjection;
|
|
264
|
+
exports.insertAndPush = insertAndPush;
|
|
265
|
+
exports.toColumnKeyedRow = toColumnKeyedRow;
|
package/drizzle.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { R as ProjectionMapping, z as ProjectionRef } from "./entity-config-ApnT5j3X.cjs";
|
|
2
2
|
import { n as buildUniqueConstraints, r as discoverFromDrizzle } from "./drizzle-CiK37zJm.cjs";
|
|
3
|
-
import { t as NamespaceIntrospector, v as SyncSource } from "./namespace-probe-
|
|
3
|
+
import { t as NamespaceIntrospector, v as SyncSource } from "./namespace-probe-H7yWc0JV.cjs";
|
|
4
4
|
import { Table } from "drizzle-orm";
|
|
5
5
|
//#region ../sdk/src/drizzle-projection.d.ts
|
|
6
6
|
/**
|
|
@@ -82,6 +82,21 @@ interface FromDrizzleOptions {
|
|
|
82
82
|
* check and a false explanation.
|
|
83
83
|
*/
|
|
84
84
|
objectType?: string;
|
|
85
|
+
/**
|
|
86
|
+
* The label this source's pushes carry, when it differs from `entity`.
|
|
87
|
+
*
|
|
88
|
+
* `entity` is the CURSOR KEY — two sources sharing it share a cursor, so the
|
|
89
|
+
* first to run advances it and the second silently pushes nothing. The push
|
|
90
|
+
* LABEL is matched against a mapping's `sourceTable`, which is the host
|
|
91
|
+
* table name. Those two requirements conflict whenever one table feeds two
|
|
92
|
+
* concepts: an `organization` table mapped as both a company and a
|
|
93
|
+
* subscription deal needs distinct cursors but the same table name on the
|
|
94
|
+
* wire.
|
|
95
|
+
*
|
|
96
|
+
* `fromDrizzleProjection` stamps this itself for the projection case. This
|
|
97
|
+
* is the same escape hatch for a plain single-table source.
|
|
98
|
+
*/
|
|
99
|
+
pushSource?: string;
|
|
85
100
|
}
|
|
86
101
|
/**
|
|
87
102
|
* Build a `SyncSource` from a Drizzle table, generating the keyset-paginated
|
|
@@ -100,6 +115,56 @@ export declare function fromDrizzle(db: DrizzleDb, table: Table, opts: FromDrizz
|
|
|
100
115
|
objectType: string;
|
|
101
116
|
};
|
|
102
117
|
export declare function fromDrizzle(db: DrizzleDb, table: Table, opts: FromDrizzleOptions): SyncSource;
|
|
118
|
+
interface PushOneCapable {
|
|
119
|
+
pushOne(entityKey: string, row: Record<string, unknown>): Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Insert a row into a mapped Drizzle table and push it to Clivly immediately
|
|
123
|
+
* — the "one call does both" instant-push API (see
|
|
124
|
+
* docs/reviews/2026-09-19-near-real-time-sync-plan.md, question 1). Returns
|
|
125
|
+
* only after the write completes; the push itself is fire-and-forget (see
|
|
126
|
+
* `pushOne`), so this resolves at the same time a plain `db.insert(...)`
|
|
127
|
+
* would.
|
|
128
|
+
*
|
|
129
|
+
* Created once per mapped table, mirroring `fromDrizzle`'s own convention —
|
|
130
|
+
* no per-call table-to-entity lookup, so a table two entities share (e.g.
|
|
131
|
+
* `user` for both `user` and `organizationOwner`) is never ambiguous:
|
|
132
|
+
* ```ts
|
|
133
|
+
* const insertUser = insertAndPush(clivly, db, schema.user, { entity: "user" });
|
|
134
|
+
* // in the signup handler:
|
|
135
|
+
* const created = await insertUser(newUserValues, c.executionCtx);
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* `waitUntil`, when provided (Hono exposes it as `c.executionCtx.waitUntil`),
|
|
139
|
+
* extends the request's lifetime past the response so the push survives on
|
|
140
|
+
* Cloudflare Workers and similar runtimes, which otherwise kill background
|
|
141
|
+
* work the instant a response is sent. Omit it on a long-lived process where
|
|
142
|
+
* nothing tears the request down early.
|
|
143
|
+
*
|
|
144
|
+
* Table property keys are translated to real database column names before
|
|
145
|
+
* the push — the same translation `fromDrizzle` performs on `fetchPage` rows
|
|
146
|
+
* — because a raw `.returning()` result is keyed by Drizzle property name
|
|
147
|
+
* (`fullName`), and every consumer downstream of a push (the fieldMap, the
|
|
148
|
+
* cloud's ingest) addresses columns by their database name (`full_name`).
|
|
149
|
+
* Skipping this would silently push empty fields with no error anywhere.
|
|
150
|
+
*/
|
|
151
|
+
/**
|
|
152
|
+
* Translate a Drizzle-property-keyed row (e.g. a `.returning()` result, or a
|
|
153
|
+
* plain unprojected `select()`) to real database column names — the same
|
|
154
|
+
* translation `fromDrizzle` performs on `fetchPage` rows. Every consumer
|
|
155
|
+
* downstream of a push (the fieldMap, the cloud's ingest) addresses columns
|
|
156
|
+
* by their database name (`full_name`), not the property name (`fullName`);
|
|
157
|
+
* skipping this would silently push empty fields with no error anywhere.
|
|
158
|
+
*
|
|
159
|
+
* Exported so a host can build the same translated row from a table it read
|
|
160
|
+
* some other way — e.g. re-querying a row inside an auth library's own
|
|
161
|
+
* lifecycle hook, where there is no `insertAndPush` call site to wrap
|
|
162
|
+
* because the library performs the insert internally.
|
|
163
|
+
*/
|
|
164
|
+
export declare function toColumnKeyedRow(table: Table, row: Record<string, unknown>): Record<string, unknown>;
|
|
165
|
+
export declare function insertAndPush(clivly: PushOneCapable, db: unknown, table: Table, opts: {
|
|
166
|
+
entity: string;
|
|
167
|
+
}): (values: Record<string, unknown>, waitUntil?: (promise: Promise<unknown>) => void) => Promise<Record<string, unknown>>;
|
|
103
168
|
/**
|
|
104
169
|
* Build a `NamespaceIntrospector` from any Drizzle client that exposes
|
|
105
170
|
* `.execute()`. Reads `information_schema` in the connection's default schema
|
package/drizzle.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { R as ProjectionMapping, z as ProjectionRef } from "./entity-config-CKcj4-M_.mjs";
|
|
2
2
|
import { n as buildUniqueConstraints, r as discoverFromDrizzle } from "./drizzle-ehVWLSrN.mjs";
|
|
3
|
-
import { t as NamespaceIntrospector, v as SyncSource } from "./namespace-probe-
|
|
3
|
+
import { t as NamespaceIntrospector, v as SyncSource } from "./namespace-probe-DykR0kgh.mjs";
|
|
4
4
|
import { Table } from "drizzle-orm";
|
|
5
5
|
//#region ../sdk/src/drizzle-projection.d.ts
|
|
6
6
|
/**
|
|
@@ -82,6 +82,21 @@ interface FromDrizzleOptions {
|
|
|
82
82
|
* check and a false explanation.
|
|
83
83
|
*/
|
|
84
84
|
objectType?: string;
|
|
85
|
+
/**
|
|
86
|
+
* The label this source's pushes carry, when it differs from `entity`.
|
|
87
|
+
*
|
|
88
|
+
* `entity` is the CURSOR KEY — two sources sharing it share a cursor, so the
|
|
89
|
+
* first to run advances it and the second silently pushes nothing. The push
|
|
90
|
+
* LABEL is matched against a mapping's `sourceTable`, which is the host
|
|
91
|
+
* table name. Those two requirements conflict whenever one table feeds two
|
|
92
|
+
* concepts: an `organization` table mapped as both a company and a
|
|
93
|
+
* subscription deal needs distinct cursors but the same table name on the
|
|
94
|
+
* wire.
|
|
95
|
+
*
|
|
96
|
+
* `fromDrizzleProjection` stamps this itself for the projection case. This
|
|
97
|
+
* is the same escape hatch for a plain single-table source.
|
|
98
|
+
*/
|
|
99
|
+
pushSource?: string;
|
|
85
100
|
}
|
|
86
101
|
/**
|
|
87
102
|
* Build a `SyncSource` from a Drizzle table, generating the keyset-paginated
|
|
@@ -100,6 +115,56 @@ export declare function fromDrizzle(db: DrizzleDb, table: Table, opts: FromDrizz
|
|
|
100
115
|
objectType: string;
|
|
101
116
|
};
|
|
102
117
|
export declare function fromDrizzle(db: DrizzleDb, table: Table, opts: FromDrizzleOptions): SyncSource;
|
|
118
|
+
interface PushOneCapable {
|
|
119
|
+
pushOne(entityKey: string, row: Record<string, unknown>): Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Insert a row into a mapped Drizzle table and push it to Clivly immediately
|
|
123
|
+
* — the "one call does both" instant-push API (see
|
|
124
|
+
* docs/reviews/2026-09-19-near-real-time-sync-plan.md, question 1). Returns
|
|
125
|
+
* only after the write completes; the push itself is fire-and-forget (see
|
|
126
|
+
* `pushOne`), so this resolves at the same time a plain `db.insert(...)`
|
|
127
|
+
* would.
|
|
128
|
+
*
|
|
129
|
+
* Created once per mapped table, mirroring `fromDrizzle`'s own convention —
|
|
130
|
+
* no per-call table-to-entity lookup, so a table two entities share (e.g.
|
|
131
|
+
* `user` for both `user` and `organizationOwner`) is never ambiguous:
|
|
132
|
+
* ```ts
|
|
133
|
+
* const insertUser = insertAndPush(clivly, db, schema.user, { entity: "user" });
|
|
134
|
+
* // in the signup handler:
|
|
135
|
+
* const created = await insertUser(newUserValues, c.executionCtx);
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* `waitUntil`, when provided (Hono exposes it as `c.executionCtx.waitUntil`),
|
|
139
|
+
* extends the request's lifetime past the response so the push survives on
|
|
140
|
+
* Cloudflare Workers and similar runtimes, which otherwise kill background
|
|
141
|
+
* work the instant a response is sent. Omit it on a long-lived process where
|
|
142
|
+
* nothing tears the request down early.
|
|
143
|
+
*
|
|
144
|
+
* Table property keys are translated to real database column names before
|
|
145
|
+
* the push — the same translation `fromDrizzle` performs on `fetchPage` rows
|
|
146
|
+
* — because a raw `.returning()` result is keyed by Drizzle property name
|
|
147
|
+
* (`fullName`), and every consumer downstream of a push (the fieldMap, the
|
|
148
|
+
* cloud's ingest) addresses columns by their database name (`full_name`).
|
|
149
|
+
* Skipping this would silently push empty fields with no error anywhere.
|
|
150
|
+
*/
|
|
151
|
+
/**
|
|
152
|
+
* Translate a Drizzle-property-keyed row (e.g. a `.returning()` result, or a
|
|
153
|
+
* plain unprojected `select()`) to real database column names — the same
|
|
154
|
+
* translation `fromDrizzle` performs on `fetchPage` rows. Every consumer
|
|
155
|
+
* downstream of a push (the fieldMap, the cloud's ingest) addresses columns
|
|
156
|
+
* by their database name (`full_name`), not the property name (`fullName`);
|
|
157
|
+
* skipping this would silently push empty fields with no error anywhere.
|
|
158
|
+
*
|
|
159
|
+
* Exported so a host can build the same translated row from a table it read
|
|
160
|
+
* some other way — e.g. re-querying a row inside an auth library's own
|
|
161
|
+
* lifecycle hook, where there is no `insertAndPush` call site to wrap
|
|
162
|
+
* because the library performs the insert internally.
|
|
163
|
+
*/
|
|
164
|
+
export declare function toColumnKeyedRow(table: Table, row: Record<string, unknown>): Record<string, unknown>;
|
|
165
|
+
export declare function insertAndPush(clivly: PushOneCapable, db: unknown, table: Table, opts: {
|
|
166
|
+
entity: string;
|
|
167
|
+
}): (values: Record<string, unknown>, waitUntil?: (promise: Promise<unknown>) => void) => Promise<Record<string, unknown>>;
|
|
103
168
|
/**
|
|
104
169
|
* Build a `NamespaceIntrospector` from any Drizzle client that exposes
|
|
105
170
|
* `.execute()`. Reads `information_schema` in the connection's default schema
|
package/drizzle.mjs
CHANGED
|
@@ -141,6 +141,7 @@ function fromDrizzle(db, table, opts) {
|
|
|
141
141
|
const idColumnName = idColumn.name;
|
|
142
142
|
const source = {
|
|
143
143
|
entity: opts.entity,
|
|
144
|
+
...opts.pushSource === void 0 ? {} : { pushSource: opts.pushSource },
|
|
144
145
|
cursorField: cursorColumnName,
|
|
145
146
|
idField: idColumnName,
|
|
146
147
|
fetchPage: ({ since, limit }) => drizzleDb.select(projection).from(table).where(since ? sql`(${cursorColumn}, ${idColumn}) > (${since.time}, ${since.id})` : void 0).orderBy(asc(cursorColumn), asc(idColumn)).limit(limit),
|
|
@@ -162,6 +163,69 @@ function fromDrizzle(db, table, opts) {
|
|
|
162
163
|
return source;
|
|
163
164
|
}
|
|
164
165
|
/**
|
|
166
|
+
* Insert a row into a mapped Drizzle table and push it to Clivly immediately
|
|
167
|
+
* — the "one call does both" instant-push API (see
|
|
168
|
+
* docs/reviews/2026-09-19-near-real-time-sync-plan.md, question 1). Returns
|
|
169
|
+
* only after the write completes; the push itself is fire-and-forget (see
|
|
170
|
+
* `pushOne`), so this resolves at the same time a plain `db.insert(...)`
|
|
171
|
+
* would.
|
|
172
|
+
*
|
|
173
|
+
* Created once per mapped table, mirroring `fromDrizzle`'s own convention —
|
|
174
|
+
* no per-call table-to-entity lookup, so a table two entities share (e.g.
|
|
175
|
+
* `user` for both `user` and `organizationOwner`) is never ambiguous:
|
|
176
|
+
* ```ts
|
|
177
|
+
* const insertUser = insertAndPush(clivly, db, schema.user, { entity: "user" });
|
|
178
|
+
* // in the signup handler:
|
|
179
|
+
* const created = await insertUser(newUserValues, c.executionCtx);
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* `waitUntil`, when provided (Hono exposes it as `c.executionCtx.waitUntil`),
|
|
183
|
+
* extends the request's lifetime past the response so the push survives on
|
|
184
|
+
* Cloudflare Workers and similar runtimes, which otherwise kill background
|
|
185
|
+
* work the instant a response is sent. Omit it on a long-lived process where
|
|
186
|
+
* nothing tears the request down early.
|
|
187
|
+
*
|
|
188
|
+
* Table property keys are translated to real database column names before
|
|
189
|
+
* the push — the same translation `fromDrizzle` performs on `fetchPage` rows
|
|
190
|
+
* — because a raw `.returning()` result is keyed by Drizzle property name
|
|
191
|
+
* (`fullName`), and every consumer downstream of a push (the fieldMap, the
|
|
192
|
+
* cloud's ingest) addresses columns by their database name (`full_name`).
|
|
193
|
+
* Skipping this would silently push empty fields with no error anywhere.
|
|
194
|
+
*/
|
|
195
|
+
/**
|
|
196
|
+
* Translate a Drizzle-property-keyed row (e.g. a `.returning()` result, or a
|
|
197
|
+
* plain unprojected `select()`) to real database column names — the same
|
|
198
|
+
* translation `fromDrizzle` performs on `fetchPage` rows. Every consumer
|
|
199
|
+
* downstream of a push (the fieldMap, the cloud's ingest) addresses columns
|
|
200
|
+
* by their database name (`full_name`), not the property name (`fullName`);
|
|
201
|
+
* skipping this would silently push empty fields with no error anywhere.
|
|
202
|
+
*
|
|
203
|
+
* Exported so a host can build the same translated row from a table it read
|
|
204
|
+
* some other way — e.g. re-querying a row inside an auth library's own
|
|
205
|
+
* lifecycle hook, where there is no `insertAndPush` call site to wrap
|
|
206
|
+
* because the library performs the insert internally.
|
|
207
|
+
*/
|
|
208
|
+
function toColumnKeyedRow(table, row) {
|
|
209
|
+
const columns = getTableColumns(table);
|
|
210
|
+
const columnNameByPropertyKey = /* @__PURE__ */ new Map();
|
|
211
|
+
for (const [propertyKey, column] of Object.entries(columns)) columnNameByPropertyKey.set(propertyKey, column.name);
|
|
212
|
+
const out = {};
|
|
213
|
+
for (const [propertyKey, value] of Object.entries(row)) out[columnNameByPropertyKey.get(propertyKey) ?? propertyKey] = value;
|
|
214
|
+
return out;
|
|
215
|
+
}
|
|
216
|
+
function insertAndPush(clivly, db, table, opts) {
|
|
217
|
+
const insertableDb = db;
|
|
218
|
+
return async (values, waitUntil) => {
|
|
219
|
+
const [created] = await insertableDb.insert(table).values(values).returning();
|
|
220
|
+
if (!created) throw new Error(`insertAndPush: insert into "${getTableName(table)}" returned no row.`);
|
|
221
|
+
const row = toColumnKeyedRow(table, created);
|
|
222
|
+
const pushed = clivly.pushOne(opts.entity, row);
|
|
223
|
+
if (waitUntil) waitUntil(pushed);
|
|
224
|
+
else await pushed;
|
|
225
|
+
return created;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
165
229
|
* Build a `NamespaceIntrospector` from any Drizzle client that exposes
|
|
166
230
|
* `.execute()`. Reads `information_schema` in the connection's default schema
|
|
167
231
|
* (`current_schema()`), so it reports exactly the tables the app can reach.
|
|
@@ -191,4 +255,4 @@ function drizzleIntrospector(db) {
|
|
|
191
255
|
};
|
|
192
256
|
}
|
|
193
257
|
//#endregion
|
|
194
|
-
export { buildUniqueConstraints, discoverFromDrizzle, drizzleIntrospector, fromDrizzle, fromDrizzleProjection };
|
|
258
|
+
export { buildUniqueConstraints, discoverFromDrizzle, drizzleIntrospector, fromDrizzle, fromDrizzleProjection, insertAndPush, toColumnKeyedRow };
|