clivly 0.4.1 → 0.7.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/README.md +83 -3
- package/{adapter-CXr12l4K.d.cts → adapter-C2eRbBfo.d.cts} +1 -2
- package/{adapter-CvNBD_3y.d.mts → adapter-D5LRa-NA.d.mts} +1 -2
- package/{auth-adapter-CdLODn2p.d.cts → auth-adapter-Bjgo8LhN.d.mts} +1 -2
- package/{auth-adapter-CRBW4elj.d.mts → auth-adapter-DWzgl5Yq.d.cts} +1 -2
- package/auth-better-auth.d.cts +1 -2
- package/auth-better-auth.d.mts +1 -2
- package/auth-clerk.d.cts +1 -2
- package/auth-clerk.d.mts +1 -2
- package/auth-workos.d.cts +1 -2
- package/auth-workos.d.mts +1 -2
- package/core-adapter.cjs +5 -0
- package/core-adapter.d.cts +1 -1
- package/core-adapter.d.mts +1 -1
- package/core-adapter.mjs +5 -0
- package/core-auth-adapter.cjs +6 -1
- package/core-auth-adapter.d.cts +1 -1
- package/core-auth-adapter.d.mts +1 -1
- package/core-auth-adapter.mjs +6 -1
- package/core-drizzle.cjs +6 -30
- package/core-drizzle.d.cts +1 -20
- package/core-drizzle.d.mts +1 -20
- package/core-drizzle.mjs +5 -29
- package/core-entity-config.cjs +5 -1
- package/core-entity-config.d.cts +1 -1
- package/core-entity-config.d.mts +1 -1
- package/core-entity-config.mjs +5 -1
- package/core-entity-heuristics.cjs +15 -453
- package/core-entity-heuristics.d.cts +1 -67
- package/core-entity-heuristics.d.mts +1 -67
- package/core-entity-heuristics.mjs +4 -442
- package/core-mapping-form.cjs +6 -1
- package/core-mapping-form.d.cts +1 -1
- package/core-mapping-form.d.mts +1 -1
- package/core-mapping-form.mjs +6 -1
- package/core-mapping-score.cjs +5 -1
- package/core-mapping-score.d.cts +1 -1
- package/core-mapping-score.d.mts +1 -1
- package/core-mapping-score.mjs +5 -1
- package/core-mappings-config.cjs +6 -1
- package/core-mappings-config.d.cts +1 -1
- package/core-mappings-config.d.mts +1 -1
- package/core-mappings-config.mjs +6 -1
- package/core-sync-engine.cjs +6 -1
- package/core-sync-engine.d.cts +1 -1
- package/core-sync-engine.d.mts +1 -1
- package/core-sync-engine.mjs +6 -1
- package/core-types.cjs +5 -0
- package/core-types.d.cts +1 -1
- package/core-types.d.mts +1 -1
- package/core-types.mjs +5 -0
- package/core-view-compiler.cjs +6 -1
- package/core-view-compiler.d.cts +1 -1
- package/core-view-compiler.d.mts +1 -1
- package/core-view-compiler.mjs +6 -1
- package/core.cjs +11 -6
- package/core.d.cts +9 -9
- package/core.d.mts +9 -9
- package/core.mjs +11 -6
- package/deprecate-subpath-B9ngvizt.cjs +30 -0
- package/deprecate-subpath-CmvZtCpE.mjs +25 -0
- package/drizzle-B89tLo4T.mjs +31 -0
- package/drizzle-CFOr9dU9.d.mts +20 -0
- package/drizzle-DiReZf6d.cjs +36 -0
- package/drizzle-DmeKSqeF.d.cts +20 -0
- package/drizzle.cjs +3 -1
- package/drizzle.d.cts +11 -3
- package/drizzle.d.mts +11 -3
- package/drizzle.mjs +3 -2
- package/{entity-config-DMuZpchz.cjs → entity-config-D87rV-tE.cjs} +194 -192
- package/{entity-config-D1DFyeUp.d.mts → entity-config-DoUCXtq5.d.cts} +48 -35
- package/{entity-config-GczjD3y8.d.cts → entity-config-DoUCXtq5.d.mts} +48 -35
- package/{entity-config-D3YpQB0z.mjs → entity-config-va2bkH5o.mjs} +194 -192
- package/index.cjs +896 -228
- package/index.d.cts +30 -2
- package/index.d.mts +30 -2
- package/index.mjs +886 -220
- package/internal-adapter.cjs +0 -0
- package/internal-adapter.d.cts +2 -0
- package/internal-adapter.d.mts +2 -0
- package/internal-adapter.mjs +1 -0
- package/internal-auth-adapter.cjs +3 -0
- package/internal-auth-adapter.d.cts +2 -0
- package/internal-auth-adapter.d.mts +2 -0
- package/internal-auth-adapter.mjs +2 -0
- package/internal-drizzle.cjs +3 -0
- package/internal-drizzle.d.cts +2 -0
- package/internal-drizzle.d.mts +2 -0
- package/internal-drizzle.mjs +2 -0
- package/internal-entity-config.cjs +13 -0
- package/internal-entity-config.d.cts +2 -0
- package/internal-entity-config.d.mts +2 -0
- package/internal-entity-config.mjs +2 -0
- package/internal-entity-heuristics.cjs +455 -0
- package/internal-entity-heuristics.d.cts +67 -0
- package/internal-entity-heuristics.d.mts +67 -0
- package/internal-entity-heuristics.mjs +444 -0
- package/internal-mapping-form.cjs +5 -0
- package/internal-mapping-form.d.cts +2 -0
- package/internal-mapping-form.d.mts +2 -0
- package/internal-mapping-form.mjs +2 -0
- package/internal-mapping-score.cjs +12 -0
- package/internal-mapping-score.d.cts +2 -0
- package/internal-mapping-score.d.mts +2 -0
- package/internal-mapping-score.mjs +2 -0
- package/internal-mappings-config.cjs +3 -0
- package/internal-mappings-config.d.cts +2 -0
- package/internal-mappings-config.d.mts +2 -0
- package/internal-mappings-config.mjs +2 -0
- package/internal-sync-engine.cjs +6 -0
- package/internal-sync-engine.d.cts +2 -0
- package/internal-sync-engine.d.mts +2 -0
- package/internal-sync-engine.mjs +2 -0
- package/internal-types.cjs +0 -0
- package/internal-types.d.cts +2 -0
- package/internal-types.d.mts +2 -0
- package/internal-types.mjs +1 -0
- package/internal-view-compiler.cjs +6 -0
- package/internal-view-compiler.d.cts +2 -0
- package/internal-view-compiler.d.mts +2 -0
- package/internal-view-compiler.mjs +2 -0
- package/internal.cjs +28 -0
- package/internal.d.cts +9 -0
- package/internal.d.mts +9 -0
- package/internal.mjs +7 -0
- package/{mapping-form-CUlFVfG8.d.cts → mapping-form-D93lhHEc.d.mts} +1 -2
- package/{mapping-form-kjSiJaCX.d.mts → mapping-form-lfyEE7EJ.d.cts} +1 -2
- package/{mappings-config-DYZ_uOOB.cjs → mappings-config-BsRADNRv.cjs} +1 -1
- package/{mappings-config-CNTZRD4g.mjs → mappings-config-Dbgxx3Nv.mjs} +1 -1
- package/{mappings-config-DjRLCb2Q.d.cts → mappings-config-DsUa7-1w.d.mts} +1 -2
- package/{mappings-config-GxiYsSBQ.d.mts → mappings-config-XmzB4dag.d.cts} +1 -2
- package/package.json +150 -2
- package/{sdk-DdzBxgMx.mjs → sdk-C_1sGiH8.mjs} +15 -11
- package/{sdk-D1BHQDf5.cjs → sdk-CzOf596t.cjs} +15 -11
- package/sdk.cjs +3 -1
- package/sdk.d.cts +1 -41
- package/sdk.d.mts +1 -41
- package/sdk.mjs +3 -2
- package/{sync-engine-DIVMG9EV.d.cts → sync-engine-B7QIbXro.d.cts} +6 -5
- package/{sync-engine-BtzkzKmY.cjs → sync-engine-CzEbpQGv.cjs} +1 -1
- package/{sync-engine-DLx243iw.d.mts → sync-engine-DGk_AeHJ.d.mts} +6 -5
- package/{sync-engine-D9vghQab.mjs → sync-engine-Do5ru3WF.mjs} +1 -1
- package/types-CsL0rFYh.d.cts +155 -0
- package/types-CsL0rFYh.d.mts +155 -0
- package/{view-compiler-4HsRUTWH.d.cts → view-compiler-BWz0sGdm.d.cts} +1 -2
- package/{view-compiler-BpIDExjd.d.mts → view-compiler-Bn_EJJMO.d.mts} +1 -2
- package/vite.d.cts +1 -2
- package/vite.d.mts +1 -2
- package/namespace-probe-CA4Vj40g.d.mts +0 -331
- package/namespace-probe-CkHCj9tQ.d.cts +0 -331
- /package/{auth-adapter-CBOKDhlc.cjs → auth-adapter-CiEXcweZ.cjs} +0 -0
- /package/{auth-adapter-wqnnEjo3.mjs → auth-adapter-gfVDxf3d.mjs} +0 -0
- /package/{drizzle-meta-BVR1qiyu.cjs → drizzle-meta-Bb1JWYqf.cjs} +0 -0
- /package/{drizzle-meta-DpMKataU.mjs → drizzle-meta-D-5k3n0i.mjs} +0 -0
- /package/{mapping-form-DdmDebC3.cjs → mapping-form-BpfON_ME.cjs} +0 -0
- /package/{mapping-form-BHtPexzI.mjs → mapping-form-DigkuvFc.mjs} +0 -0
- /package/{mapping-score-CPPvwoZC.mjs → mapping-score-C68uAqGB.mjs} +0 -0
- /package/{mapping-score-i3p8LWDF.cjs → mapping-score-CaB3F4Uu.cjs} +0 -0
- /package/{mapping-score-A2lRnlpk.d.mts → mapping-score-D7Gzg7Ii.d.cts} +0 -0
- /package/{mapping-score-BcjC0ZQs.d.cts → mapping-score-D7Gzg7Ii.d.mts} +0 -0
- /package/{types-BpsKVccL.d.cts → types-B1oRXdNP.d.cts} +0 -0
- /package/{types-_qbJXMt_.d.mts → types-B1oRXdNP.d.mts} +0 -0
- /package/{view-compiler-BcgJINr7.cjs → view-compiler-BIwvm-o2.cjs} +0 -0
- /package/{view-compiler-DeZzx_jn.mjs → view-compiler-ChWr_Lml.mjs} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clivly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clivly CLI — scaffold a CRM into your app (clivly init).",
|
|
@@ -11,6 +11,34 @@
|
|
|
11
11
|
"main": "./index.cjs",
|
|
12
12
|
"module": "./index.mjs",
|
|
13
13
|
"types": "./index.d.mts",
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"./index.mjs",
|
|
16
|
+
"./index.cjs",
|
|
17
|
+
"./core.mjs",
|
|
18
|
+
"./core.cjs",
|
|
19
|
+
"./core-adapter.mjs",
|
|
20
|
+
"./core-adapter.cjs",
|
|
21
|
+
"./core-auth-adapter.mjs",
|
|
22
|
+
"./core-auth-adapter.cjs",
|
|
23
|
+
"./core-drizzle.mjs",
|
|
24
|
+
"./core-drizzle.cjs",
|
|
25
|
+
"./core-entity-config.mjs",
|
|
26
|
+
"./core-entity-config.cjs",
|
|
27
|
+
"./core-entity-heuristics.mjs",
|
|
28
|
+
"./core-entity-heuristics.cjs",
|
|
29
|
+
"./core-mapping-form.mjs",
|
|
30
|
+
"./core-mapping-form.cjs",
|
|
31
|
+
"./core-mapping-score.mjs",
|
|
32
|
+
"./core-mapping-score.cjs",
|
|
33
|
+
"./core-mappings-config.mjs",
|
|
34
|
+
"./core-mappings-config.cjs",
|
|
35
|
+
"./core-sync-engine.mjs",
|
|
36
|
+
"./core-sync-engine.cjs",
|
|
37
|
+
"./core-types.mjs",
|
|
38
|
+
"./core-types.cjs",
|
|
39
|
+
"./core-view-compiler.mjs",
|
|
40
|
+
"./core-view-compiler.cjs"
|
|
41
|
+
],
|
|
14
42
|
"files": [
|
|
15
43
|
"*.cjs",
|
|
16
44
|
"*.mjs",
|
|
@@ -151,6 +179,126 @@
|
|
|
151
179
|
"default": "./core-view-compiler.cjs"
|
|
152
180
|
}
|
|
153
181
|
},
|
|
182
|
+
"./internal": {
|
|
183
|
+
"import": {
|
|
184
|
+
"types": "./internal.d.mts",
|
|
185
|
+
"default": "./internal.mjs"
|
|
186
|
+
},
|
|
187
|
+
"require": {
|
|
188
|
+
"types": "./internal.d.cts",
|
|
189
|
+
"default": "./internal.cjs"
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"./internal/adapter": {
|
|
193
|
+
"import": {
|
|
194
|
+
"types": "./internal-adapter.d.mts",
|
|
195
|
+
"default": "./internal-adapter.mjs"
|
|
196
|
+
},
|
|
197
|
+
"require": {
|
|
198
|
+
"types": "./internal-adapter.d.cts",
|
|
199
|
+
"default": "./internal-adapter.cjs"
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
"./internal/auth-adapter": {
|
|
203
|
+
"import": {
|
|
204
|
+
"types": "./internal-auth-adapter.d.mts",
|
|
205
|
+
"default": "./internal-auth-adapter.mjs"
|
|
206
|
+
},
|
|
207
|
+
"require": {
|
|
208
|
+
"types": "./internal-auth-adapter.d.cts",
|
|
209
|
+
"default": "./internal-auth-adapter.cjs"
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"./internal/drizzle": {
|
|
213
|
+
"import": {
|
|
214
|
+
"types": "./internal-drizzle.d.mts",
|
|
215
|
+
"default": "./internal-drizzle.mjs"
|
|
216
|
+
},
|
|
217
|
+
"require": {
|
|
218
|
+
"types": "./internal-drizzle.d.cts",
|
|
219
|
+
"default": "./internal-drizzle.cjs"
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"./internal/entity-config": {
|
|
223
|
+
"import": {
|
|
224
|
+
"types": "./internal-entity-config.d.mts",
|
|
225
|
+
"default": "./internal-entity-config.mjs"
|
|
226
|
+
},
|
|
227
|
+
"require": {
|
|
228
|
+
"types": "./internal-entity-config.d.cts",
|
|
229
|
+
"default": "./internal-entity-config.cjs"
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"./internal/entity-heuristics": {
|
|
233
|
+
"import": {
|
|
234
|
+
"types": "./internal-entity-heuristics.d.mts",
|
|
235
|
+
"default": "./internal-entity-heuristics.mjs"
|
|
236
|
+
},
|
|
237
|
+
"require": {
|
|
238
|
+
"types": "./internal-entity-heuristics.d.cts",
|
|
239
|
+
"default": "./internal-entity-heuristics.cjs"
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
"./internal/mapping-form": {
|
|
243
|
+
"import": {
|
|
244
|
+
"types": "./internal-mapping-form.d.mts",
|
|
245
|
+
"default": "./internal-mapping-form.mjs"
|
|
246
|
+
},
|
|
247
|
+
"require": {
|
|
248
|
+
"types": "./internal-mapping-form.d.cts",
|
|
249
|
+
"default": "./internal-mapping-form.cjs"
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
"./internal/mapping-score": {
|
|
253
|
+
"import": {
|
|
254
|
+
"types": "./internal-mapping-score.d.mts",
|
|
255
|
+
"default": "./internal-mapping-score.mjs"
|
|
256
|
+
},
|
|
257
|
+
"require": {
|
|
258
|
+
"types": "./internal-mapping-score.d.cts",
|
|
259
|
+
"default": "./internal-mapping-score.cjs"
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
"./internal/mappings-config": {
|
|
263
|
+
"import": {
|
|
264
|
+
"types": "./internal-mappings-config.d.mts",
|
|
265
|
+
"default": "./internal-mappings-config.mjs"
|
|
266
|
+
},
|
|
267
|
+
"require": {
|
|
268
|
+
"types": "./internal-mappings-config.d.cts",
|
|
269
|
+
"default": "./internal-mappings-config.cjs"
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"./internal/sync-engine": {
|
|
273
|
+
"import": {
|
|
274
|
+
"types": "./internal-sync-engine.d.mts",
|
|
275
|
+
"default": "./internal-sync-engine.mjs"
|
|
276
|
+
},
|
|
277
|
+
"require": {
|
|
278
|
+
"types": "./internal-sync-engine.d.cts",
|
|
279
|
+
"default": "./internal-sync-engine.cjs"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"./internal/types": {
|
|
283
|
+
"import": {
|
|
284
|
+
"types": "./internal-types.d.mts",
|
|
285
|
+
"default": "./internal-types.mjs"
|
|
286
|
+
},
|
|
287
|
+
"require": {
|
|
288
|
+
"types": "./internal-types.d.cts",
|
|
289
|
+
"default": "./internal-types.cjs"
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
"./internal/view-compiler": {
|
|
293
|
+
"import": {
|
|
294
|
+
"types": "./internal-view-compiler.d.mts",
|
|
295
|
+
"default": "./internal-view-compiler.mjs"
|
|
296
|
+
},
|
|
297
|
+
"require": {
|
|
298
|
+
"types": "./internal-view-compiler.d.cts",
|
|
299
|
+
"default": "./internal-view-compiler.cjs"
|
|
300
|
+
}
|
|
301
|
+
},
|
|
154
302
|
"./sdk": {
|
|
155
303
|
"import": {
|
|
156
304
|
"types": "./sdk.d.mts",
|
|
@@ -242,7 +390,7 @@
|
|
|
242
390
|
},
|
|
243
391
|
"author": "Joseph Amani",
|
|
244
392
|
"engines": {
|
|
245
|
-
"node": ">=
|
|
393
|
+
"node": ">=22"
|
|
246
394
|
},
|
|
247
395
|
"repository": {
|
|
248
396
|
"type": "git",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as DRIZZLE_META } from "./drizzle-meta-
|
|
1
|
+
import { t as DRIZZLE_META } from "./drizzle-meta-D-5k3n0i.mjs";
|
|
2
2
|
//#region ../sdk/src/custom-slug.ts
|
|
3
3
|
const NON_ALNUM = /[^a-z0-9]+/g;
|
|
4
4
|
const EDGE_HYPHENS = /(^-|-$)/g;
|
|
@@ -393,9 +393,7 @@ function observedTriggerUrl(req) {
|
|
|
393
393
|
const proto = forwardedProto || requestUrl.protocol.replace(":", "");
|
|
394
394
|
try {
|
|
395
395
|
return new URL(`${proto}://${host}${requestUrl.pathname}`).toString();
|
|
396
|
-
} catch {
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
396
|
+
} catch {}
|
|
399
397
|
}
|
|
400
398
|
/**
|
|
401
399
|
* Decide which trigger URL to report, in precedence order:
|
|
@@ -454,7 +452,7 @@ function originAllowed(origin, allowedOrigins) {
|
|
|
454
452
|
if (!origin) return false;
|
|
455
453
|
return allowedOrigins.includes(origin);
|
|
456
454
|
}
|
|
457
|
-
function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API_URL$1, fetchImpl = fetch }) {
|
|
455
|
+
function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API_URL$1, fetchImpl = fetch, resolveUser }) {
|
|
458
456
|
const sessionUrl = `${normalizeApiUrl(apiUrl)}/clivly/widget/session`;
|
|
459
457
|
return async (request) => {
|
|
460
458
|
if (request.method !== "POST") return new Response(JSON.stringify({ error: "method_not_allowed" }), {
|
|
@@ -473,6 +471,12 @@ function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API
|
|
|
473
471
|
return jsonResponse$1({ error: "invalid_json" }, 400);
|
|
474
472
|
}
|
|
475
473
|
if (!isChatSessionRequestBody(body)) return jsonResponse$1({ error: "invalid_request" }, 400);
|
|
474
|
+
let hostUser = null;
|
|
475
|
+
if (resolveUser) try {
|
|
476
|
+
hostUser = await resolveUser(request);
|
|
477
|
+
} catch {
|
|
478
|
+
console.warn("[clivly] resolveUser threw; continuing without host identity");
|
|
479
|
+
}
|
|
476
480
|
try {
|
|
477
481
|
const upstream = await fetchImpl(sessionUrl, {
|
|
478
482
|
method: "POST",
|
|
@@ -485,7 +489,8 @@ function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API
|
|
|
485
489
|
widgetId: body.widgetId,
|
|
486
490
|
visitor: body.visitor,
|
|
487
491
|
visitorToken: body.visitorToken,
|
|
488
|
-
origin
|
|
492
|
+
origin,
|
|
493
|
+
...hostUser ? { hostUser } : {}
|
|
489
494
|
})
|
|
490
495
|
});
|
|
491
496
|
const responseBody = await upstream.text();
|
|
@@ -675,9 +680,7 @@ function connectReason(status) {
|
|
|
675
680
|
async function resolveOrg(response) {
|
|
676
681
|
try {
|
|
677
682
|
return (await response.json())?.org;
|
|
678
|
-
} catch {
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
683
|
+
} catch {}
|
|
681
684
|
}
|
|
682
685
|
function retryAfterMs(res) {
|
|
683
686
|
const header = res.headers.get("retry-after");
|
|
@@ -700,7 +703,8 @@ function createFetcher(retry) {
|
|
|
700
703
|
}
|
|
701
704
|
if (!(res === null || isRetryableStatus(res.status)) || attempt >= maxAttempts) return res;
|
|
702
705
|
const backoff = baseDelayMs * 2 ** (attempt - 1) + Math.random() * baseDelayMs;
|
|
703
|
-
|
|
706
|
+
const wait = res ? retryAfterMs(res) ?? backoff : backoff;
|
|
707
|
+
await sleep(wait);
|
|
704
708
|
}
|
|
705
709
|
};
|
|
706
710
|
}
|
|
@@ -757,7 +761,7 @@ async function handlePreviewRequest(config, preview) {
|
|
|
757
761
|
if (!source) return jsonResponse({ error: `No configured source for table "${preview.sourceTable}"` }, 400);
|
|
758
762
|
const idField = source.idField ?? "id";
|
|
759
763
|
const filterColumns = preview.filter ? Object.keys(preview.filter).filter((k) => k !== "$raw") : [];
|
|
760
|
-
const needed = new Set([
|
|
764
|
+
const needed = /* @__PURE__ */ new Set([
|
|
761
765
|
idField,
|
|
762
766
|
...Object.values(preview.fieldMap),
|
|
763
767
|
...filterColumns
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_drizzle_meta = require("./drizzle-meta-
|
|
1
|
+
const require_drizzle_meta = require("./drizzle-meta-Bb1JWYqf.cjs");
|
|
2
2
|
//#region ../sdk/src/custom-slug.ts
|
|
3
3
|
const NON_ALNUM = /[^a-z0-9]+/g;
|
|
4
4
|
const EDGE_HYPHENS = /(^-|-$)/g;
|
|
@@ -393,9 +393,7 @@ function observedTriggerUrl(req) {
|
|
|
393
393
|
const proto = forwardedProto || requestUrl.protocol.replace(":", "");
|
|
394
394
|
try {
|
|
395
395
|
return new URL(`${proto}://${host}${requestUrl.pathname}`).toString();
|
|
396
|
-
} catch {
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
396
|
+
} catch {}
|
|
399
397
|
}
|
|
400
398
|
/**
|
|
401
399
|
* Decide which trigger URL to report, in precedence order:
|
|
@@ -454,7 +452,7 @@ function originAllowed(origin, allowedOrigins) {
|
|
|
454
452
|
if (!origin) return false;
|
|
455
453
|
return allowedOrigins.includes(origin);
|
|
456
454
|
}
|
|
457
|
-
function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API_URL$1, fetchImpl = fetch }) {
|
|
455
|
+
function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API_URL$1, fetchImpl = fetch, resolveUser }) {
|
|
458
456
|
const sessionUrl = `${normalizeApiUrl(apiUrl)}/clivly/widget/session`;
|
|
459
457
|
return async (request) => {
|
|
460
458
|
if (request.method !== "POST") return new Response(JSON.stringify({ error: "method_not_allowed" }), {
|
|
@@ -473,6 +471,12 @@ function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API
|
|
|
473
471
|
return jsonResponse$1({ error: "invalid_json" }, 400);
|
|
474
472
|
}
|
|
475
473
|
if (!isChatSessionRequestBody(body)) return jsonResponse$1({ error: "invalid_request" }, 400);
|
|
474
|
+
let hostUser = null;
|
|
475
|
+
if (resolveUser) try {
|
|
476
|
+
hostUser = await resolveUser(request);
|
|
477
|
+
} catch {
|
|
478
|
+
console.warn("[clivly] resolveUser threw; continuing without host identity");
|
|
479
|
+
}
|
|
476
480
|
try {
|
|
477
481
|
const upstream = await fetchImpl(sessionUrl, {
|
|
478
482
|
method: "POST",
|
|
@@ -485,7 +489,8 @@ function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API
|
|
|
485
489
|
widgetId: body.widgetId,
|
|
486
490
|
visitor: body.visitor,
|
|
487
491
|
visitorToken: body.visitorToken,
|
|
488
|
-
origin
|
|
492
|
+
origin,
|
|
493
|
+
...hostUser ? { hostUser } : {}
|
|
489
494
|
})
|
|
490
495
|
});
|
|
491
496
|
const responseBody = await upstream.text();
|
|
@@ -675,9 +680,7 @@ function connectReason(status) {
|
|
|
675
680
|
async function resolveOrg(response) {
|
|
676
681
|
try {
|
|
677
682
|
return (await response.json())?.org;
|
|
678
|
-
} catch {
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
683
|
+
} catch {}
|
|
681
684
|
}
|
|
682
685
|
function retryAfterMs(res) {
|
|
683
686
|
const header = res.headers.get("retry-after");
|
|
@@ -700,7 +703,8 @@ function createFetcher(retry) {
|
|
|
700
703
|
}
|
|
701
704
|
if (!(res === null || isRetryableStatus(res.status)) || attempt >= maxAttempts) return res;
|
|
702
705
|
const backoff = baseDelayMs * 2 ** (attempt - 1) + Math.random() * baseDelayMs;
|
|
703
|
-
|
|
706
|
+
const wait = res ? retryAfterMs(res) ?? backoff : backoff;
|
|
707
|
+
await sleep(wait);
|
|
704
708
|
}
|
|
705
709
|
};
|
|
706
710
|
}
|
|
@@ -757,7 +761,7 @@ async function handlePreviewRequest(config, preview) {
|
|
|
757
761
|
if (!source) return jsonResponse({ error: `No configured source for table "${preview.sourceTable}"` }, 400);
|
|
758
762
|
const idField = source.idField ?? "id";
|
|
759
763
|
const filterColumns = preview.filter ? Object.keys(preview.filter).filter((k) => k !== "$raw") : [];
|
|
760
|
-
const needed = new Set([
|
|
764
|
+
const needed = /* @__PURE__ */ new Set([
|
|
761
765
|
idField,
|
|
762
766
|
...Object.values(preview.fieldMap),
|
|
763
767
|
...filterColumns
|
package/sdk.cjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_entity_config = require("./entity-config-D87rV-tE.cjs");
|
|
3
|
+
const require_sdk = require("./sdk-CzOf596t.cjs");
|
|
3
4
|
exports.ClivlyAuthError = require_sdk.ClivlyAuthError;
|
|
4
5
|
exports.ClivlyError = require_sdk.ClivlyError;
|
|
5
6
|
exports.ClivlyNetworkError = require_sdk.ClivlyNetworkError;
|
|
6
7
|
exports.ClivlyRateLimitError = require_sdk.ClivlyRateLimitError;
|
|
7
8
|
exports.createChatSessionHandler = require_sdk.createChatSessionHandler;
|
|
8
9
|
exports.createClivlySDK = require_sdk.createClivlySDK;
|
|
10
|
+
exports.defineClivlyConfig = require_entity_config.defineClivlyConfig;
|
package/sdk.d.cts
CHANGED
|
@@ -1,41 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//#region ../sdk/src/chat-session.d.ts
|
|
4
|
-
declare function createChatSessionHandler({
|
|
5
|
-
allowedOrigins,
|
|
6
|
-
apiKey,
|
|
7
|
-
apiUrl,
|
|
8
|
-
fetchImpl
|
|
9
|
-
}: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region ../sdk/src/errors.d.ts
|
|
12
|
-
declare class ClivlyError extends Error {
|
|
13
|
-
/** HTTP status, or null when the request never completed (network error). */
|
|
14
|
-
readonly status: number | null;
|
|
15
|
-
readonly reason: ClivlyConnectResult["reason"];
|
|
16
|
-
/** Whether a retry could plausibly succeed (network, 429, 5xx). */
|
|
17
|
-
readonly retryable: boolean;
|
|
18
|
-
constructor(result: ClivlyConnectResult, message?: string);
|
|
19
|
-
/**
|
|
20
|
-
* Build the error subclass matching a failed result's reason, or `null` when
|
|
21
|
-
* the result is `ok`.
|
|
22
|
-
*/
|
|
23
|
-
static from(result: ClivlyConnectResult): ClivlyError | null;
|
|
24
|
-
}
|
|
25
|
-
/** The API key was rejected (401) or lacks access (403). Not retryable. */
|
|
26
|
-
declare class ClivlyAuthError extends ClivlyError {}
|
|
27
|
-
/** Rate limited (429). Retryable after backoff / `Retry-After`. */
|
|
28
|
-
declare class ClivlyRateLimitError extends ClivlyError {}
|
|
29
|
-
/** The request never reached the server (network/DNS/TLS). Retryable. */
|
|
30
|
-
declare class ClivlyNetworkError extends ClivlyError {}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region ../sdk/src/index.d.ts
|
|
33
|
-
/**
|
|
34
|
-
* Create the Clivly SDK. The implemented surface — heartbeat/discovery reporting
|
|
35
|
-
* and the auth-verify handler — connects a developer's app to a running Clivly
|
|
36
|
-
* backend today. Tunnel management and CRM write-back are scaffolded (see the
|
|
37
|
-
* clearly-marked TODOs) and land with the Cloudflare infrastructure.
|
|
38
|
-
*/
|
|
39
|
-
declare function createClivlySDK(config: ClivlySDKConfig): ClivlySDK;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { type ChatSessionRequestBody, type ChatWidgetVisitor, ClivlyAuthError, type ClivlyConnectReason, type ClivlyConnectResult, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, type ClivlySDK, type ClivlySDKConfig, type ClivlyUser, type CreateChatSessionHandlerOptions, type CursorStore, type DiscoveredTable, type DoctorCheck, type DoctorReport, createChatSessionHandler, createClivlySDK };
|
|
1
|
+
export {}
|
package/sdk.d.mts
CHANGED
|
@@ -1,41 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//#region ../sdk/src/chat-session.d.ts
|
|
4
|
-
declare function createChatSessionHandler({
|
|
5
|
-
allowedOrigins,
|
|
6
|
-
apiKey,
|
|
7
|
-
apiUrl,
|
|
8
|
-
fetchImpl
|
|
9
|
-
}: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region ../sdk/src/errors.d.ts
|
|
12
|
-
declare class ClivlyError extends Error {
|
|
13
|
-
/** HTTP status, or null when the request never completed (network error). */
|
|
14
|
-
readonly status: number | null;
|
|
15
|
-
readonly reason: ClivlyConnectResult["reason"];
|
|
16
|
-
/** Whether a retry could plausibly succeed (network, 429, 5xx). */
|
|
17
|
-
readonly retryable: boolean;
|
|
18
|
-
constructor(result: ClivlyConnectResult, message?: string);
|
|
19
|
-
/**
|
|
20
|
-
* Build the error subclass matching a failed result's reason, or `null` when
|
|
21
|
-
* the result is `ok`.
|
|
22
|
-
*/
|
|
23
|
-
static from(result: ClivlyConnectResult): ClivlyError | null;
|
|
24
|
-
}
|
|
25
|
-
/** The API key was rejected (401) or lacks access (403). Not retryable. */
|
|
26
|
-
declare class ClivlyAuthError extends ClivlyError {}
|
|
27
|
-
/** Rate limited (429). Retryable after backoff / `Retry-After`. */
|
|
28
|
-
declare class ClivlyRateLimitError extends ClivlyError {}
|
|
29
|
-
/** The request never reached the server (network/DNS/TLS). Retryable. */
|
|
30
|
-
declare class ClivlyNetworkError extends ClivlyError {}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region ../sdk/src/index.d.ts
|
|
33
|
-
/**
|
|
34
|
-
* Create the Clivly SDK. The implemented surface — heartbeat/discovery reporting
|
|
35
|
-
* and the auth-verify handler — connects a developer's app to a running Clivly
|
|
36
|
-
* backend today. Tunnel management and CRM write-back are scaffolded (see the
|
|
37
|
-
* clearly-marked TODOs) and land with the Cloudflare infrastructure.
|
|
38
|
-
*/
|
|
39
|
-
declare function createClivlySDK(config: ClivlySDKConfig): ClivlySDK;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { type ChatSessionRequestBody, type ChatWidgetVisitor, ClivlyAuthError, type ClivlyConnectReason, type ClivlyConnectResult, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, type ClivlySDK, type ClivlySDKConfig, type ClivlyUser, type CreateChatSessionHandlerOptions, type CursorStore, type DiscoveredTable, type DoctorCheck, type DoctorReport, createChatSessionHandler, createClivlySDK };
|
|
1
|
+
export {}
|
package/sdk.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { o as defineClivlyConfig } from "./entity-config-va2bkH5o.mjs";
|
|
2
|
+
import { a as ClivlyRateLimitError, i as ClivlyNetworkError, n as ClivlyAuthError, o as createChatSessionHandler, r as ClivlyError, t as createClivlySDK } from "./sdk-C_1sGiH8.mjs";
|
|
3
|
+
export { ClivlyAuthError, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, createChatSessionHandler, createClivlySDK, defineClivlyConfig };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-
|
|
2
|
-
import { n as CompiledView, t as CompileOptions } from "./view-compiler-
|
|
3
|
-
|
|
1
|
+
import { a as ClivlyEntitiesConfig } from "./entity-config-DoUCXtq5.cjs";
|
|
2
|
+
import { n as CompiledView, t as CompileOptions } from "./view-compiler-BWz0sGdm.cjs";
|
|
4
3
|
//#region ../core/src/sync-engine.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Sync engine (Phase 3) — materializes the read-only entity views into Clivly's
|
|
@@ -108,13 +107,15 @@ interface SyncStore {
|
|
|
108
107
|
/** Current mirror rows for a concept + role (including archived). */
|
|
109
108
|
listMirror(input: {
|
|
110
109
|
concept: string;
|
|
111
|
-
role: string;
|
|
110
|
+
role: string;
|
|
111
|
+
/** Target custom-object type id, for `concept: "custom"` entities. */
|
|
112
112
|
objectTypeId?: string;
|
|
113
113
|
}): Promise<MirrorRecord[]>;
|
|
114
114
|
/** Apply the resolved actions to the mirror table for this concept + role. */
|
|
115
115
|
persist(input: {
|
|
116
116
|
concept: string;
|
|
117
|
-
role: string;
|
|
117
|
+
role: string;
|
|
118
|
+
/** Target custom-object type id, for `concept: "custom"` entities. */
|
|
118
119
|
objectTypeId?: string;
|
|
119
120
|
actions: PersistAction[];
|
|
120
121
|
}): Promise<void>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-
|
|
2
|
-
import { n as CompiledView, t as CompileOptions } from "./view-compiler-
|
|
3
|
-
|
|
1
|
+
import { a as ClivlyEntitiesConfig } from "./entity-config-DoUCXtq5.mjs";
|
|
2
|
+
import { n as CompiledView, t as CompileOptions } from "./view-compiler-Bn_EJJMO.mjs";
|
|
4
3
|
//#region ../core/src/sync-engine.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Sync engine (Phase 3) — materializes the read-only entity views into Clivly's
|
|
@@ -108,13 +107,15 @@ interface SyncStore {
|
|
|
108
107
|
/** Current mirror rows for a concept + role (including archived). */
|
|
109
108
|
listMirror(input: {
|
|
110
109
|
concept: string;
|
|
111
|
-
role: string;
|
|
110
|
+
role: string;
|
|
111
|
+
/** Target custom-object type id, for `concept: "custom"` entities. */
|
|
112
112
|
objectTypeId?: string;
|
|
113
113
|
}): Promise<MirrorRecord[]>;
|
|
114
114
|
/** Apply the resolved actions to the mirror table for this concept + role. */
|
|
115
115
|
persist(input: {
|
|
116
116
|
concept: string;
|
|
117
|
-
role: string;
|
|
117
|
+
role: string;
|
|
118
|
+
/** Target custom-object type id, for `concept: "custom"` entities. */
|
|
118
119
|
objectTypeId?: string;
|
|
119
120
|
actions: PersistAction[];
|
|
120
121
|
}): Promise<void>;
|