@assistant-wi/core 0.0.4 → 0.0.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.
@@ -0,0 +1,112 @@
1
+ function a(e, o, t) {
2
+ const n = {};
3
+ return c(n, e, o), l(n, e), s(n, e, t), n;
4
+ }
5
+ function c(e, o, t) {
6
+ for (const n of t)
7
+ Object.defineProperty(e, n, {
8
+ value: (r) => (o[n] = r, e),
9
+ enumerable: !1,
10
+ writable: !1,
11
+ configurable: !1
12
+ });
13
+ }
14
+ function s(e, o, t) {
15
+ if (!t) return;
16
+ const n = t(o);
17
+ for (const r of Object.keys(n))
18
+ Object.defineProperty(e, r, {
19
+ value: (...u) => (n[r]?.(...u), e),
20
+ enumerable: !1,
21
+ writable: !1,
22
+ configurable: !1
23
+ });
24
+ }
25
+ function l(e, o) {
26
+ Object.defineProperty(e, "build", {
27
+ value: () => o,
28
+ enumerable: !1,
29
+ writable: !1,
30
+ configurable: !1
31
+ });
32
+ }
33
+ function i(e) {
34
+ return a({ type: "block", nodes: e ?? [] }, ["direction", "gap", "nodes"], (t) => ({
35
+ row() {
36
+ t.direction = "row";
37
+ },
38
+ col() {
39
+ t.direction = "col";
40
+ },
41
+ addNode(n) {
42
+ t.nodes.push(n);
43
+ }
44
+ }));
45
+ }
46
+ function d(e) {
47
+ return i(e).row();
48
+ }
49
+ function f(e) {
50
+ return i(e).col();
51
+ }
52
+ function b(e) {
53
+ return a({
54
+ type: "button",
55
+ text: e
56
+ }, ["text", "variant", "onClick"], (t) => ({
57
+ primary() {
58
+ t.variant = "primary";
59
+ },
60
+ secondary() {
61
+ t.variant = "secondary";
62
+ },
63
+ outline() {
64
+ t.variant = "outline";
65
+ },
66
+ ghost() {
67
+ t.variant = "ghost";
68
+ },
69
+ destructive() {
70
+ t.variant = "destructive";
71
+ }
72
+ }));
73
+ }
74
+ function p(e) {
75
+ return a(
76
+ {
77
+ type: "form",
78
+ nodes: e ?? [],
79
+ submitTitle: "Submit"
80
+ },
81
+ ["title", "description", "submitTitle", "onSubmit"],
82
+ (t) => ({
83
+ addNode(n) {
84
+ t.nodes.push(n);
85
+ }
86
+ })
87
+ );
88
+ }
89
+ function y(e) {
90
+ return {
91
+ type: "text",
92
+ text: e
93
+ };
94
+ }
95
+ const m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
96
+ __proto__: null,
97
+ block: i,
98
+ button: b,
99
+ col: f,
100
+ form: p,
101
+ row: d,
102
+ text: y
103
+ }, Symbol.toStringTag, { value: "Module" }));
104
+ export {
105
+ b as a,
106
+ i as b,
107
+ f as c,
108
+ p as f,
109
+ m as i,
110
+ d as r,
111
+ y as t
112
+ };
@@ -0,0 +1 @@
1
+ "use strict";function a(t,o,e){const n={};return b(n,t,o),y(n,t),p(n,t,e),n}function b(t,o,e){for(const n of e)Object.defineProperty(t,n,{value:r=>(o[n]=r,t),enumerable:!1,writable:!1,configurable:!1})}function p(t,o,e){if(!e)return;const n=e(o);for(const r of Object.keys(n))Object.defineProperty(t,r,{value:(...f)=>(n[r]?.(...f),t),enumerable:!1,writable:!1,configurable:!1})}function y(t,o){Object.defineProperty(t,"build",{value:()=>o,enumerable:!1,writable:!1,configurable:!1})}function i(t){return a({type:"block",nodes:t??[]},["direction","gap","nodes"],e=>({row(){e.direction="row"},col(){e.direction="col"},addNode(n){e.nodes.push(n)}}))}function u(t){return i(t).row()}function c(t){return i(t).col()}function l(t){return a({type:"button",text:t},["text","variant","onClick"],e=>({primary(){e.variant="primary"},secondary(){e.variant="secondary"},outline(){e.variant="outline"},ghost(){e.variant="ghost"},destructive(){e.variant="destructive"}}))}function d(t){return a({type:"form",nodes:t??[],submitTitle:"Submit"},["title","description","submitTitle","onSubmit"],e=>({addNode(n){e.nodes.push(n)}}))}function s(t){return{type:"text",text:t}}const m=Object.freeze(Object.defineProperty({__proto__:null,block:i,button:l,col:c,form:d,row:u,text:s},Symbol.toStringTag,{value:"Module"}));exports.block=i;exports.button=l;exports.col=c;exports.form=d;exports.index=m;exports.row=u;exports.text=s;
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DMcbwFzr.cjs"),i=require("./index-CHYnucAA.cjs");exports.tool=e.index;exports.ui=i.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DMcbwFzr.cjs"),i=require("./index-Oe1iY2v9.cjs");exports.tool=e.index;exports.ui=i.index;
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i } from "./index-BXj6EgSG.js";
2
- import { i as a } from "./index-Dwsbu01L.js";
2
+ import { i as a } from "./index-Dbt2oV4y.js";
3
3
  export {
4
4
  i as tool,
5
5
  a as ui
@@ -0,0 +1,11 @@
1
+ export type Setters = Record<string, (...args: any[]) => void>;
2
+ export type CustomMutators<T extends object, F extends readonly (keyof T)[], S extends Setters> = {
3
+ [K in keyof S]: S[K] extends (...args: infer Args) => void ? (...args: Args) => Builder<T, F, S> : never;
4
+ };
5
+ export type AutoMutators<T extends object, F extends readonly (keyof T)[], S extends Setters> = {
6
+ [K in F[number]]: (value: T[K]) => Builder<T, F, S>;
7
+ };
8
+ export type Builder<T extends object, F extends readonly (keyof T)[], S extends Setters> = AutoMutators<T, F, S> & CustomMutators<T, F, S> & {
9
+ build(): T;
10
+ };
11
+ export declare function builder<T extends object, F extends readonly (keyof T)[], S extends Setters & Partial<Record<F[number], never>>>(data: T, autoSetterFields: F, customSetterPatterns?: (self: T) => S): Builder<T, F, S>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../index-CHYnucAA.cjs");exports.block=t.block;exports.button=t.button;exports.form=t.form;exports.text=t.text;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index-Oe1iY2v9.cjs");exports.block=o.block;exports.button=o.button;exports.col=o.col;exports.form=o.form;exports.row=o.row;exports.text=o.text;
@@ -1,7 +1,9 @@
1
- import { b as o, a as s, f as b, t as f } from "../index-Dwsbu01L.js";
1
+ import { b as s, a as t, c as r, f as b, r as c, t as f } from "../index-Dbt2oV4y.js";
2
2
  export {
3
- o as block,
4
- s as button,
3
+ s as block,
4
+ t as button,
5
+ r as col,
5
6
  b as form,
7
+ c as row,
6
8
  f as text
7
9
  };
@@ -2,7 +2,21 @@ import { UI } from './ui';
2
2
  export interface UIBlock {
3
3
  type: 'block';
4
4
  nodes: UI[];
5
- direction?: 'row' | 'column';
6
- gap?: number;
5
+ direction?: 'row' | 'col' | undefined;
6
+ gap?: number | undefined;
7
7
  }
8
- export declare function block(props: Omit<UIBlock, 'type'>): UIBlock;
8
+ export declare function block(nodes?: UI[]): import('./builder').Builder<UIBlock, ("direction" | "gap" | "nodes")[], {
9
+ row(): void;
10
+ col(): void;
11
+ addNode(node: UI): void;
12
+ }>;
13
+ export declare function row(nodes?: UI[]): import('./builder').Builder<UIBlock, ("direction" | "gap" | "nodes")[], {
14
+ row(): void;
15
+ col(): void;
16
+ addNode(node: UI): void;
17
+ }>;
18
+ export declare function col(nodes?: UI[]): import('./builder').Builder<UIBlock, ("direction" | "gap" | "nodes")[], {
19
+ row(): void;
20
+ col(): void;
21
+ addNode(node: UI): void;
22
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,13 @@
1
1
  export interface UIButton {
2
2
  type: 'button';
3
- text?: string;
3
+ text: string;
4
4
  variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive';
5
5
  onClick?: () => void;
6
6
  }
7
- export declare function button(props: Omit<UIButton, 'type'>): UIButton;
7
+ export declare function button(text: string): import('./builder').Builder<UIButton, ("text" | "variant" | "onClick")[], {
8
+ primary(): void;
9
+ secondary(): void;
10
+ outline(): void;
11
+ ghost(): void;
12
+ destructive(): void;
13
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -3,7 +3,7 @@ export interface UIForm {
3
3
  title?: string;
4
4
  description?: string;
5
5
  nodes: UIFormNode[];
6
- submitTitle: string;
6
+ submitTitle?: string;
7
7
  onSubmit?: (values: Record<string, string>) => Promise<void>;
8
8
  }
9
9
  export interface UIFormNode {
@@ -15,4 +15,6 @@ export interface UIFormNode {
15
15
  value?: string;
16
16
  onChange?: (value: string) => void;
17
17
  }
18
- export declare function form(props: Omit<UIForm, 'type'>): UIForm;
18
+ export declare function form(nodes?: UIFormNode[]): import('./builder').Builder<UIForm, ("title" | "description" | "submitTitle" | "onSubmit")[], {
19
+ addNode(node: UIFormNode): void;
20
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -2,4 +2,4 @@ export interface UIText {
2
2
  type: 'text';
3
3
  text: string;
4
4
  }
5
- export declare function text(props: Omit<UIText, 'type'>): UIText;
5
+ export declare function text(text: string): UIText;
package/dist/ui/ui.d.ts CHANGED
@@ -2,4 +2,7 @@ import { UIBlock } from './ui-block';
2
2
  import { UIButton } from './ui-button';
3
3
  import { UIForm } from './ui-form';
4
4
  import { UIText } from './ui-text';
5
- export type UI = UIBlock | UIText | UIButton | UIForm;
5
+ export type UI = UIObject | {
6
+ build(): UIObject;
7
+ };
8
+ export type UIObject = UIBlock | UIText | UIButton | UIForm;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@assistant-wi/core",
3
3
  "private": false,
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs.js",
7
7
  "module": "./dist/index.es.js",
@@ -44,6 +44,7 @@
44
44
  "@types/node": "^24.3.0",
45
45
  "vite": "^7.1.3",
46
46
  "vite-plugin-dts": "^4.5.4",
47
+ "vitest": "^3.2.4",
47
48
  "zod": "^4.1.5"
48
49
  },
49
50
  "peerDependencies": {
@@ -1 +0,0 @@
1
- "use strict";function e(t){return{type:"block",...t}}function n(t){return{type:"button",...t}}function o(t){return{type:"form",...t}}function r(t){return{type:"text",...t}}const u=Object.freeze(Object.defineProperty({__proto__:null,block:e,button:n,form:o,text:r},Symbol.toStringTag,{value:"Module"}));exports.block=e;exports.button=n;exports.form=o;exports.index=u;exports.text=r;
@@ -1,38 +0,0 @@
1
- function e(t) {
2
- return {
3
- type: "block",
4
- ...t
5
- };
6
- }
7
- function n(t) {
8
- return {
9
- type: "button",
10
- ...t
11
- };
12
- }
13
- function o(t) {
14
- return {
15
- type: "form",
16
- ...t
17
- };
18
- }
19
- function r(t) {
20
- return {
21
- type: "text",
22
- ...t
23
- };
24
- }
25
- const u = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26
- __proto__: null,
27
- block: e,
28
- button: n,
29
- form: o,
30
- text: r
31
- }, Symbol.toStringTag, { value: "Module" }));
32
- export {
33
- n as a,
34
- e as b,
35
- o as f,
36
- u as i,
37
- r as t
38
- };