@kubuild/core 0.1.0 → 0.2.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.
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Template and Expression Variable Interpolator
3
+ *
4
+ * Provides safe, deterministic resolution and interpolation of template strings
5
+ * like `{{form.email}}`, `{{variables.token}}`, and `{{response.data.id}}` into
6
+ * targets without using eval() or Function().
7
+ */
8
+ /**
9
+ * Standard structured runtime context for interpolations.
10
+ */
11
+ export interface InterpolationContext {
12
+ form?: Record<string, unknown>;
13
+ variables?: Record<string, unknown>;
14
+ response?: Record<string, unknown>;
15
+ state?: Record<string, unknown>;
16
+ [key: string]: unknown;
17
+ }
18
+ /**
19
+ * Checks if a string contains one or more `{{ ... }}` template expressions.
20
+ */
21
+ export declare function hasTemplateExpressions(text: unknown): boolean;
22
+ /**
23
+ * Extracts all unique property keys / variable paths referenced inside `{{ ... }}`.
24
+ */
25
+ export declare function extractTemplateVariables(text: string): string[];
26
+ /**
27
+ * Safely traverses a nested data source to resolve a dot/bracket path
28
+ * (e.g. `form.user.profile.name`, `response.data[0].id`, `items.0.title`).
29
+ *
30
+ * Returns `fallback` if any segment is missing, undefined, null, or points to
31
+ * a function or forbidden prototype property.
32
+ */
33
+ export declare function resolvePropertyPath(source: unknown, path: string, fallback?: unknown): unknown;
34
+ /**
35
+ * Interpolates all `{{ path }}` placeholders in a template string using values
36
+ * from the provided context object.
37
+ *
38
+ * If a variable cannot be resolved, it replaces it with `fallback` (default: `""`).
39
+ */
40
+ export declare function interpolateTemplateString(template: string, context?: Record<string, unknown>, fallback?: string): string;
41
+ /**
42
+ * Recursively interpolates any value (string, object, array, primitive).
43
+ *
44
+ * - If string is exactly `{{ path }}`, returns the raw resolved value (retaining type: number, boolean, object, array).
45
+ * - If string contains embedded templates (e.g. `Bearer {{token}}`), returns the interpolated string.
46
+ * - If array, interpolates every element.
47
+ * - If object, interpolates every property value while stripping forbidden prototype keys.
48
+ */
49
+ export declare function interpolateValue(value: unknown, context?: Record<string, unknown>): unknown;
50
+ //# sourceMappingURL=interpolator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interpolator.d.ts","sourceRoot":"","sources":["../src/interpolator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkBH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAG7D;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAgB/D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,OAAO,GACjB,OAAO,CA6CT;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,QAAQ,GAAE,MAAW,GACpB,MAAM,CAqBR;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CA8B3F"}
@@ -0,0 +1,136 @@
1
+ import type { ActionPipeline, ActionStep, ActionStepCondition, ActionStepType } from '@kubuild/schema';
2
+ /**
3
+ * Execution context shared across action steps in a pipeline.
4
+ */
5
+ export interface PipelineExecutionContext {
6
+ form?: Record<string, unknown>;
7
+ variables?: Record<string, unknown>;
8
+ state?: Record<string, unknown>;
9
+ response?: unknown;
10
+ stepResults?: Record<string, StepExecutionResult>;
11
+ error?: unknown;
12
+ lastError?: unknown;
13
+ nodeId?: string;
14
+ document?: unknown;
15
+ [key: string]: unknown;
16
+ }
17
+ /**
18
+ * Status of an individual step execution.
19
+ */
20
+ export type StepExecutionStatus = 'success' | 'error' | 'skipped' | 'cancelled';
21
+ /**
22
+ * Result of executing an individual action step.
23
+ */
24
+ export interface StepExecutionResult {
25
+ stepId: string;
26
+ stepType: ActionStepType | string;
27
+ status: StepExecutionStatus;
28
+ data?: unknown;
29
+ error?: Error | unknown;
30
+ durationMs: number;
31
+ subResults?: StepExecutionResult[];
32
+ }
33
+ /**
34
+ * Overall result of executing an action pipeline.
35
+ */
36
+ export interface PipelineExecutionResult {
37
+ pipelineId: string;
38
+ success: boolean;
39
+ status: 'completed' | 'failed' | 'cancelled';
40
+ stepResults: StepExecutionResult[];
41
+ context: PipelineExecutionContext;
42
+ error?: Error | unknown;
43
+ durationMs: number;
44
+ }
45
+ /**
46
+ * Handler function signature for an individual step type.
47
+ */
48
+ export type PipelineStepHandler<TContext = PipelineExecutionContext> = (step: ActionStep, context: TContext, signal: AbortSignal) => Promise<unknown> | unknown;
49
+ /**
50
+ * Options for configuring the execution of an action pipeline.
51
+ */
52
+ export interface ExecutePipelineOptions {
53
+ context?: PipelineExecutionContext;
54
+ signal?: AbortSignal;
55
+ timeout?: number;
56
+ throwOnError?: boolean;
57
+ handlers?: Record<string, PipelineStepHandler>;
58
+ onStepStart?: (step: ActionStep, context: PipelineExecutionContext) => void;
59
+ onStepComplete?: (step: ActionStep, result: StepExecutionResult, context: PipelineExecutionContext) => void;
60
+ }
61
+ /**
62
+ * Configuration options for creating an ActionPipelineExecutor instance.
63
+ */
64
+ export interface ActionPipelineExecutorOptions {
65
+ handlers?: Record<string, PipelineStepHandler>;
66
+ defaultTimeout?: number;
67
+ throwOnError?: boolean;
68
+ }
69
+ /**
70
+ * Custom error thrown when a step or pipeline times out.
71
+ */
72
+ export declare class ActionTimeoutError extends Error {
73
+ readonly stepId?: string;
74
+ readonly timeoutMs: number;
75
+ constructor(message: string, timeoutMs: number, stepId?: string);
76
+ }
77
+ /**
78
+ * Custom error thrown when an action execution is aborted/cancelled.
79
+ */
80
+ export declare class ActionCancellationError extends Error {
81
+ readonly stepId?: string;
82
+ constructor(message?: string, stepId?: string);
83
+ }
84
+ /**
85
+ * Evaluates an ActionStepCondition against a pipeline execution context.
86
+ */
87
+ export declare function evaluateActionCondition(condition: ActionStepCondition | undefined, context: PipelineExecutionContext): boolean;
88
+ /**
89
+ * ActionPipelineExecutor manages step handlers, sequential execution of action pipelines,
90
+ * timeouts, cancellation, conditional evaluation, and onSuccess / onError branching.
91
+ */
92
+ export declare class ActionPipelineExecutor {
93
+ private handlers;
94
+ private defaultTimeout?;
95
+ private throwOnError;
96
+ constructor(options?: ActionPipelineExecutorOptions);
97
+ /**
98
+ * Registers default built-in handlers for core step types like `set_state` and `reset_form`.
99
+ */
100
+ private registerBuiltInHandlers;
101
+ /**
102
+ * Registers a handler for a step type.
103
+ */
104
+ registerHandler(type: ActionStepType | string, handler: PipelineStepHandler): this;
105
+ /**
106
+ * Unregisters a handler for a step type.
107
+ */
108
+ unregisterHandler(type: ActionStepType | string): this;
109
+ /**
110
+ * Checks if a handler exists for a step type.
111
+ */
112
+ hasHandler(type: ActionStepType | string): boolean;
113
+ /**
114
+ * Gets the registered handler for a step type.
115
+ */
116
+ getHandler(type: ActionStepType | string): PipelineStepHandler | undefined;
117
+ /**
118
+ * Executes a full ActionPipeline sequentially with support for timeouts, cancellation,
119
+ * condition evaluation, and branching.
120
+ */
121
+ execute(pipeline: ActionPipeline, options?: ExecutePipelineOptions): Promise<PipelineExecutionResult>;
122
+ /**
123
+ * Executes an ordered list of ActionSteps sequentially.
124
+ */
125
+ private executeSteps;
126
+ /**
127
+ * Executes a single ActionStep with condition checking, payload interpolation, timeout,
128
+ * handler execution, response context passing, and branch execution.
129
+ */
130
+ executeSingleStep(step: ActionStep, context: PipelineExecutionContext, parentSignal: AbortSignal, options?: ExecutePipelineOptions): Promise<StepExecutionResult>;
131
+ }
132
+ /**
133
+ * Convenience helper to execute an action pipeline using default or custom executor settings.
134
+ */
135
+ export declare function executeActionPipeline(pipeline: ActionPipeline, options?: ExecutePipelineOptions): Promise<PipelineExecutionResult>;
136
+ //# sourceMappingURL=pipeline-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-executor.d.ts","sourceRoot":"","sources":["../src/pipeline-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,cAAc,EACf,MAAM,iBAAiB,CAAC;AAIzB;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;AAEhF;;GAEG;AACH,MAAM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,MAAM,GAAG,mBAAmB,GAAG,SAAS;IAIjF;;;OAGG;IACU,OAAO,CAClB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,uBAAuB,CAAC;IAuEnC;;OAEG;YACW,YAAY;IAuC1B;;;OAGG;IACU,iBAAiB,CAC5B,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,wBAAwB,EACjC,YAAY,EAAE,WAAW,EACzB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,mBAAmB,CAAC;CAoIhC;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CAGlC"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Standard form state structure managed inside the store.
3
+ */
4
+ export interface FormState {
5
+ values: Record<string, unknown>;
6
+ errors: Record<string, string>;
7
+ touched: Record<string, boolean>;
8
+ isSubmitting: boolean;
9
+ isValid: boolean;
10
+ dirty: boolean;
11
+ initialValues?: Record<string, unknown>;
12
+ }
13
+ /**
14
+ * Root state managed by the RuntimeStateStore.
15
+ */
16
+ export interface RuntimeStoreState {
17
+ variables: Record<string, unknown>;
18
+ forms: Record<string, FormState>;
19
+ state: Record<string, unknown>;
20
+ [key: string]: unknown;
21
+ }
22
+ export type Unsubscribe = () => void;
23
+ export type StoreListener = (state: Readonly<RuntimeStoreState>, prevState: Readonly<RuntimeStoreState>) => void;
24
+ export type KeyChangeListener<T = unknown> = (newValue: T, prevValue: T) => void;
25
+ export type PathChangeListener<T = unknown> = (newValue: T, prevValue: T) => void;
26
+ export type FormChangeListener = (newForm: FormState, prevForm?: FormState) => void;
27
+ /**
28
+ * Creates an initial clean FormState object.
29
+ */
30
+ export declare function createDefaultFormState(initialValues?: Record<string, unknown>): FormState;
31
+ /**
32
+ * Reactive State Store & Context Manager for form states and runtime variables.
33
+ */
34
+ export declare class RuntimeStateStore {
35
+ private state;
36
+ private listeners;
37
+ private pathListeners;
38
+ private formListeners;
39
+ private isBatching;
40
+ private batchOldState?;
41
+ private isNotifying;
42
+ constructor(initialState?: Partial<RuntimeStoreState>);
43
+ /**
44
+ * Retrieves a value at a specified path or the entire state snapshot.
45
+ */
46
+ get<T = unknown>(path?: string, fallback?: T): T;
47
+ /**
48
+ * Gets an immutable snapshot of the current state.
49
+ */
50
+ getSnapshot(): RuntimeStoreState;
51
+ /**
52
+ * Sets a value at a dotted path and notifies subscribers.
53
+ */
54
+ set(path: string, value: unknown): this;
55
+ /**
56
+ * Performs multiple updates atomically, triggering subscriber notifications once.
57
+ */
58
+ setBatch(updates: Record<string, unknown>): this;
59
+ /**
60
+ * Deletes a property at the specified path.
61
+ */
62
+ delete(path: string): boolean;
63
+ /**
64
+ * Resets the store state to an initial or clean state.
65
+ */
66
+ reset(initialState?: Partial<RuntimeStoreState>): this;
67
+ /**
68
+ * Subscribes a listener to any state changes.
69
+ */
70
+ subscribe(listener: StoreListener): Unsubscribe;
71
+ /**
72
+ * Subscribes a listener to changes on a top-level key.
73
+ */
74
+ subscribeKey<T = unknown>(key: string, listener: KeyChangeListener<T>): Unsubscribe;
75
+ /**
76
+ * Subscribes a listener to changes at a specific dotted path.
77
+ */
78
+ subscribePath<T = unknown>(path: string, listener: PathChangeListener<T>): Unsubscribe;
79
+ /**
80
+ * Subscribes a listener to changes of a specific form state.
81
+ */
82
+ subscribeForm(formId: string, listener: FormChangeListener): Unsubscribe;
83
+ /**
84
+ * Notifies all relevant listeners when state changes.
85
+ */
86
+ private notifyChanges;
87
+ /**
88
+ * Retrieves the FormState for a formId, initializing default form state if not present.
89
+ */
90
+ getForm(formId: string): FormState;
91
+ /**
92
+ * Updates a single field value in a form and marks dirty if changed from initial.
93
+ */
94
+ setFormFieldValue(formId: string, fieldName: string, value: unknown): this;
95
+ /**
96
+ * Sets or clears an error for a form field.
97
+ */
98
+ setFormFieldError(formId: string, fieldName: string, error: string | null): this;
99
+ /**
100
+ * Marks a form field as touched (or untouched).
101
+ */
102
+ setFormFieldTouched(formId: string, fieldName: string, touched?: boolean): this;
103
+ /**
104
+ * Updates multiple form errors simultaneously.
105
+ */
106
+ setFormErrors(formId: string, errors: Record<string, string>): this;
107
+ /**
108
+ * Sets multiple form field values simultaneously.
109
+ */
110
+ setFormValues(formId: string, values: Record<string, unknown>, replace?: boolean): this;
111
+ /**
112
+ * Sets the submitting status of a form.
113
+ */
114
+ setFormSubmitting(formId: string, isSubmitting: boolean): this;
115
+ /**
116
+ * Resets a form's values, errors, touched, and submitting state to defaults or specified values.
117
+ */
118
+ resetForm(formId: string, initialValues?: Record<string, unknown>): this;
119
+ /**
120
+ * Creates an isolated child scope store for a page or component container.
121
+ */
122
+ createScope(scopeId: string, initialValues?: Record<string, unknown>): RuntimeStateStore;
123
+ }
124
+ /**
125
+ * Factory function to create a new RuntimeStateStore instance.
126
+ */
127
+ export declare function createRuntimeStore(initialState?: Partial<RuntimeStoreState>): RuntimeStateStore;
128
+ //# sourceMappingURL=state-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-store.d.ts","sourceRoot":"","sources":["../src/state-store.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA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,EAAE,OAAO,GAAE,OAAc,GAAG,IAAI;IAQ5F;;OAEG;IACI,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAU1E;;OAEG;IACI,aAAa,CAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,GAAE,OAAe,GACvB,IAAI;IAUP;;OAEG;IACI,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,IAAI;IAQrE;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAY/E;;OAEG;IACI,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,iBAAiB;CAQhG;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAE/F"}
@@ -0,0 +1,39 @@
1
+ import type { FormFieldBinding, ValidationRule } from '@kubuild/schema';
2
+ /**
3
+ * Checks whether a field value is considered empty.
4
+ * Empty values include undefined, null, empty string, empty array, or boolean false.
5
+ */
6
+ export declare function isEmptyValue(value: unknown): boolean;
7
+ /**
8
+ * Applies a value transformation to a field value prior to validation.
9
+ */
10
+ export declare function applyFieldTransform(value: unknown, transform?: 'trim' | 'lowercase' | 'uppercase' | 'number' | string): unknown;
11
+ /**
12
+ * Evaluates a single validation rule against a field value.
13
+ * Returns the rule's error message if invalid, or null if valid.
14
+ */
15
+ export declare function evaluateRule(rule: ValidationRule, value: unknown, allFormValues?: Record<string, unknown>): string | null;
16
+ /**
17
+ * Validates a single field value against an array of ValidationRules.
18
+ * Returns the first failing error message, or null if all rules pass.
19
+ */
20
+ export declare function validateFieldValue(value: unknown, rules?: ValidationRule[] | null, allFormValues?: Record<string, unknown>): string | null;
21
+ /**
22
+ * Asynchronously validates a single field value against an array of ValidationRules.
23
+ */
24
+ export declare function validateFieldValueAsync(value: unknown, rules?: ValidationRule[] | null, allFormValues?: Record<string, unknown>): Promise<string | null>;
25
+ /**
26
+ * Validates an entire form values object against field configs.
27
+ * Returns a map of field names to error messages (Record<string, string>).
28
+ * If all fields are valid, returns an empty object {}.
29
+ */
30
+ export declare function validateForm(values: Record<string, unknown>, fieldConfigs: FormFieldBinding[] | Record<string, FormFieldBinding | ValidationRule[]>): Record<string, string>;
31
+ /**
32
+ * Asynchronously validates an entire form values object against field configs.
33
+ */
34
+ export declare function validateFormAsync(values: Record<string, unknown>, fieldConfigs: FormFieldBinding[] | Record<string, FormFieldBinding | ValidationRule[]>): Promise<Record<string, string>>;
35
+ /**
36
+ * Convenience helper to determine if a form error map is completely valid (no errors).
37
+ */
38
+ export declare function isFormValid(errors: Record<string, string>): boolean;
39
+ //# sourceMappingURL=validation-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-engine.d.ts","sourceRoot":"","sources":["../src/validation-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAExE;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAcpD;AAYD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,GACjE,OAAO,CA6BT;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACtC,MAAM,GAAG,IAAI,CAoGf;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,KAAK,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,EAC/B,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACtC,MAAM,GAAG,IAAI,CAaf;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,OAAO,EACd,KAAK,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,EAC/B,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACtC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAExB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,YAAY,EACR,gBAAgB,EAAE,GAClB,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,cAAc,EAAE,CAAC,GACtD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2DxB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,YAAY,EACR,gBAAgB,EAAE,GAClB,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,cAAc,EAAE,CAAC,GACtD,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAEjC;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAEnE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubuild/core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Framework-agnostic engine for KUBUILD: document utilities, command engine, history, migration, and validation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -40,7 +40,7 @@
40
40
  "homepage": "https://github.com/kustora/kubuild#readme",
41
41
  "dependencies": {
42
42
  "fflate": "^0.8.3",
43
- "@kubuild/schema": "0.1.0"
43
+ "@kubuild/schema": "0.2.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "tsup": "^8.3.6",