@updog/data-editor-wc 0.1.5 → 0.1.6
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/assets/chatTransform.worker-xnO1PFUC.js +1 -0
- package/index.d.ts +19 -4
- package/index.js +4478 -4401
- package/package.json +1 -1
- package/assets/chatTransform.worker-BuuMWuTX.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){function e(e){let{ops:t,rows:n,fields:r}=e,i={};for(let[t,n]of Object.entries(e.ctx.opts))i[t]=new Set(n);let a={opts:i},o=[],s=[];for(let e of t)try{let t=Function(`return `+e.fn)();s.push({action:e.action,fn:t})}catch(t){o.push(`Failed to compile ${e.action} op: ${t instanceof Error?t.message:String(t)}`)}let c=new Map,l=[];for(let[e,t]of n){let n={...t},i=!1;for(let e of s)if(e.action===`delete`)try{if(e.fn(n,a)){i=!0;break}}catch{}else try{e.fn(n,a)}catch{}if(i){l.push(e);continue}for(let i of r){let r=t[i],a=n[i];if(a!==r){let t=c.get(i);t||(t=[],c.set(i,t)),t.push([e,r,a])}}}let u=[];for(let[e,t]of c)u.push({field:e,changes:t});return{deltas:u,deleteIds:l,errors:o}}let t=self;self.addEventListener(`message`,n=>{try{let{ops:r,ctx:i,rows:a,fields:o}=n.data,s=e({ops:r,ctx:i,rows:a,fields:o});t.postMessage({type:`RESULT`,deltas:s.deltas,deleteIds:s.deleteIds,errors:s.errors})}catch(e){t.postMessage({type:`ERROR`,message:e instanceof Error?e.message:`Transform worker error`})}})})();
|
package/index.d.ts
CHANGED
|
@@ -598,13 +598,28 @@ type Filters = {
|
|
|
598
598
|
}>;
|
|
599
599
|
};
|
|
600
600
|
|
|
601
|
+
/**
|
|
602
|
+
* A single operation the LLM wants to apply to rows in the current filtered view.
|
|
603
|
+
*
|
|
604
|
+
* - `edit` — `fn` is `(r, ctx) => void`. Mutates `r` in place. Changed fields
|
|
605
|
+
* become column deltas. Rows with no changes are no-ops.
|
|
606
|
+
* - `delete` — `fn` is `(r, ctx) => boolean`. Truthy means "flag this row for
|
|
607
|
+
* deletion". Soft delete via `DeleteRowCommand`.
|
|
608
|
+
*/
|
|
609
|
+
type ChatOp = {
|
|
610
|
+
action: "edit";
|
|
611
|
+
fn: string;
|
|
612
|
+
} | {
|
|
613
|
+
action: "delete";
|
|
614
|
+
fn: string;
|
|
615
|
+
};
|
|
601
616
|
/**
|
|
602
617
|
* A single chunk in the stream returned from `DataEditorChat.onMessage`.
|
|
603
618
|
*
|
|
604
619
|
* - `status` — progress message shown while processing (e.g. "Analyzing 500 rows...").
|
|
605
620
|
* - `message` — chat reply shown to the user.
|
|
606
621
|
* - `rows` — updated rows to apply to the grid. Matched by `primaryKey`.
|
|
607
|
-
* - `
|
|
622
|
+
* - `ops` — array of per-row operations (edits and/or deletes) to apply in order.
|
|
608
623
|
*/
|
|
609
624
|
type ChatResponseChunk<TRow extends DataEditorRow = DataEditorRow> = {
|
|
610
625
|
type: "status";
|
|
@@ -616,8 +631,8 @@ type ChatResponseChunk<TRow extends DataEditorRow = DataEditorRow> = {
|
|
|
616
631
|
type: "rows";
|
|
617
632
|
content: TRow[];
|
|
618
633
|
} | {
|
|
619
|
-
type: "
|
|
620
|
-
content:
|
|
634
|
+
type: "ops";
|
|
635
|
+
content: ChatOp[];
|
|
621
636
|
};
|
|
622
637
|
/** Status of a row in the chat sample, relative to its origin snapshot. */
|
|
623
638
|
type ChatRowStatus = "new" | "edited" | "original";
|
|
@@ -693,7 +708,7 @@ type ChatContext<TRow extends DataEditorRow = DataEditorRow> = ChatDataContext<T
|
|
|
693
708
|
* }),
|
|
694
709
|
* }).then(r => r.json());
|
|
695
710
|
* yield { type: "rows", content: res.updatedRows };
|
|
696
|
-
* yield { type: "
|
|
711
|
+
* yield { type: "ops", content: res.ops };
|
|
697
712
|
* yield { type: "message", content: res.reply };
|
|
698
713
|
* },
|
|
699
714
|
* }}
|