@ricsam/formula-engine 0.2.8 → 0.2.9
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 +1 -3
- package/dist/cjs/core/engine.cjs +515 -166
- package/dist/cjs/core/engine.cjs.map +3 -3
- package/dist/cjs/core/managers/dependency-manager.cjs.map +2 -2
- package/dist/cjs/core/managers/evaluation-manager.cjs.map +1 -1
- package/dist/cjs/core/mutation-invalidation.cjs +241 -0
- package/dist/cjs/core/mutation-invalidation.cjs.map +10 -0
- package/dist/cjs/lib.cjs +2 -13
- package/dist/cjs/lib.cjs.map +3 -3
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/core/engine.mjs +529 -207
- package/dist/mjs/core/engine.mjs.map +3 -3
- package/dist/mjs/core/managers/dependency-manager.mjs.map +2 -2
- package/dist/mjs/core/managers/evaluation-manager.mjs.map +1 -1
- package/dist/mjs/core/mutation-invalidation.mjs +201 -0
- package/dist/mjs/core/mutation-invalidation.mjs.map +10 -0
- package/dist/mjs/lib.mjs +2 -13
- package/dist/mjs/lib.mjs.map +3 -3
- package/dist/mjs/package.json +1 -1
- package/dist/types/core/engine.d.ts +17 -135
- package/dist/types/core/managers/dependency-manager.d.ts +1 -1
- package/dist/types/core/managers/evaluation-manager.d.ts +1 -1
- package/dist/types/core/mutation-invalidation.d.ts +46 -0
- package/dist/types/lib.d.ts +0 -8
- package/package.json +1 -1
- package/dist/cjs/core/commands/command-executor.cjs +0 -149
- package/dist/cjs/core/commands/command-executor.cjs.map +0 -10
- package/dist/cjs/core/commands/content-commands.cjs +0 -857
- package/dist/cjs/core/commands/content-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/metadata-commands.cjs +0 -160
- package/dist/cjs/core/commands/metadata-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/named-expression-commands.cjs +0 -363
- package/dist/cjs/core/commands/named-expression-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/structure-commands.cjs +0 -696
- package/dist/cjs/core/commands/structure-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/style-commands.cjs +0 -229
- package/dist/cjs/core/commands/style-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/table-commands.cjs +0 -495
- package/dist/cjs/core/commands/table-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/types.cjs +0 -99
- package/dist/cjs/core/commands/types.cjs.map +0 -10
- package/dist/cjs/core/managers/schema-manager.cjs +0 -374
- package/dist/cjs/core/managers/schema-manager.cjs.map +0 -10
- package/dist/cjs/core/schema/cell-orm.cjs +0 -76
- package/dist/cjs/core/schema/cell-orm.cjs.map +0 -10
- package/dist/cjs/core/schema/grid-orm.cjs +0 -125
- package/dist/cjs/core/schema/grid-orm.cjs.map +0 -10
- package/dist/cjs/core/schema/schema-builder.cjs +0 -74
- package/dist/cjs/core/schema/schema-builder.cjs.map +0 -10
- package/dist/cjs/core/schema/schema-helpers.cjs +0 -200
- package/dist/cjs/core/schema/schema-helpers.cjs.map +0 -10
- package/dist/cjs/core/schema/schema.cjs +0 -91
- package/dist/cjs/core/schema/schema.cjs.map +0 -10
- package/dist/cjs/core/schema/table-orm.cjs +0 -189
- package/dist/cjs/core/schema/table-orm.cjs.map +0 -10
- package/dist/mjs/core/commands/command-executor.mjs +0 -109
- package/dist/mjs/core/commands/command-executor.mjs.map +0 -10
- package/dist/mjs/core/commands/content-commands.mjs +0 -821
- package/dist/mjs/core/commands/content-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/metadata-commands.mjs +0 -120
- package/dist/mjs/core/commands/metadata-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/named-expression-commands.mjs +0 -323
- package/dist/mjs/core/commands/named-expression-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/structure-commands.mjs +0 -661
- package/dist/mjs/core/commands/structure-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/style-commands.mjs +0 -189
- package/dist/mjs/core/commands/style-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/table-commands.mjs +0 -459
- package/dist/mjs/core/commands/table-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/types.mjs +0 -59
- package/dist/mjs/core/commands/types.mjs.map +0 -10
- package/dist/mjs/core/managers/schema-manager.mjs +0 -334
- package/dist/mjs/core/managers/schema-manager.mjs.map +0 -10
- package/dist/mjs/core/schema/cell-orm.mjs +0 -35
- package/dist/mjs/core/schema/cell-orm.mjs.map +0 -10
- package/dist/mjs/core/schema/grid-orm.mjs +0 -84
- package/dist/mjs/core/schema/grid-orm.mjs.map +0 -10
- package/dist/mjs/core/schema/schema-builder.mjs +0 -34
- package/dist/mjs/core/schema/schema-builder.mjs.map +0 -10
- package/dist/mjs/core/schema/schema-helpers.mjs +0 -160
- package/dist/mjs/core/schema/schema-helpers.mjs.map +0 -10
- package/dist/mjs/core/schema/schema.mjs +0 -51
- package/dist/mjs/core/schema/schema.mjs.map +0 -10
- package/dist/mjs/core/schema/table-orm.mjs +0 -156
- package/dist/mjs/core/schema/table-orm.mjs.map +0 -10
- package/dist/types/core/commands/command-executor.d.ts +0 -81
- package/dist/types/core/commands/content-commands.d.ts +0 -172
- package/dist/types/core/commands/metadata-commands.d.ts +0 -55
- package/dist/types/core/commands/named-expression-commands.d.ts +0 -130
- package/dist/types/core/commands/structure-commands.d.ts +0 -155
- package/dist/types/core/commands/style-commands.d.ts +0 -76
- package/dist/types/core/commands/table-commands.d.ts +0 -119
- package/dist/types/core/commands/types.d.ts +0 -143
- package/dist/types/core/managers/schema-manager.d.ts +0 -142
- package/dist/types/core/schema/cell-orm.d.ts +0 -33
- package/dist/types/core/schema/grid-orm.d.ts +0 -63
- package/dist/types/core/schema/schema-builder.d.ts +0 -16
- package/dist/types/core/schema/schema-helpers.d.ts +0 -49
- package/dist/types/core/schema/schema.d.ts +0 -167
- package/dist/types/core/schema/schema.type-test.d.ts +0 -1
- package/dist/types/core/schema/table-orm.d.ts +0 -46
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import type { CellAddress, FiniteSpreadsheetRange, SerializedCellValue } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Define a schema for the FormulaEngine.
|
|
4
|
-
*
|
|
5
|
-
* The returned object contains:
|
|
6
|
-
* - `declaration`: The schema definitions for tables and cells
|
|
7
|
-
* - `schema`: A type-only placeholder (undefined at runtime) for TypeScript inference
|
|
8
|
-
*
|
|
9
|
-
* The actual working schema is only available through `engine.schema` after
|
|
10
|
-
* attaching the definition to a FormulaEngine instance.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const mySchema = defineSchema<CellMetadata>()
|
|
15
|
-
* .addTableSchema("users", { workbookName: "wb1", tableName: "users" }, headers)
|
|
16
|
-
* .addCellSchema("config", cellAddress, parse);
|
|
17
|
-
*
|
|
18
|
-
* const engine = new FormulaEngine(mySchema);
|
|
19
|
-
* engine.schema.users.findWhere({ id: 1 }); // Works!
|
|
20
|
-
* engine.schema.config.read(); // Works!
|
|
21
|
-
* mySchema.schema.users.findWhere({ id: 1 }); // Error: schema is undefined at runtime
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function defineSchema<TCellMetadata = unknown, TCurrentSchema extends Record<string, object> = Record<string, object>, TCurrentDeclaration extends Record<string, TableSchemaDefinition | CellSchemaDefinition | GridSchemaDefinition> = Record<string, TableSchemaDefinition | CellSchemaDefinition | GridSchemaDefinition>>(): CreateSchema<TCellMetadata, TCurrentSchema, TCurrentDeclaration>;
|
|
25
|
-
export interface TableSchemaDefinition {
|
|
26
|
-
type: "table";
|
|
27
|
-
headers: Headers<unknown>;
|
|
28
|
-
tableName: string;
|
|
29
|
-
workbookName: string;
|
|
30
|
-
}
|
|
31
|
-
export interface CellSchemaDefinition {
|
|
32
|
-
type: "cell";
|
|
33
|
-
cellAddress: CellAddress;
|
|
34
|
-
parse: (value: unknown, metadata: unknown) => unknown;
|
|
35
|
-
write: (value: unknown) => {
|
|
36
|
-
value: SerializedCellValue;
|
|
37
|
-
metadata?: unknown;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export interface GridSchemaDefinition {
|
|
41
|
-
type: "grid";
|
|
42
|
-
workbookName: string;
|
|
43
|
-
sheetName: string;
|
|
44
|
-
range: FiniteSpreadsheetRange;
|
|
45
|
-
parse: (value: unknown, metadata: unknown) => unknown;
|
|
46
|
-
write: (value: unknown) => {
|
|
47
|
-
value: SerializedCellValue;
|
|
48
|
-
metadata?: unknown;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
type Headers<TCellMetadata> = Record<string, {
|
|
52
|
-
parse: (value: SerializedCellValue, metadata: TCellMetadata) => unknown;
|
|
53
|
-
write: (value: any) => {
|
|
54
|
-
value: SerializedCellValue;
|
|
55
|
-
metadata?: TCellMetadata;
|
|
56
|
-
};
|
|
57
|
-
index: number;
|
|
58
|
-
}>;
|
|
59
|
-
/**
|
|
60
|
-
* Type representing the TableOrm methods exposed on the schema
|
|
61
|
-
*/
|
|
62
|
-
export type TableOrmSchema<TItem extends Record<string, unknown>> = {
|
|
63
|
-
findWhere(filter: Partial<TItem>): TItem | undefined;
|
|
64
|
-
findAllWhere(filter: Partial<TItem>): TItem[];
|
|
65
|
-
append(item: TItem): TItem;
|
|
66
|
-
updateWhere(filter: Partial<TItem>, update: Partial<TItem>): number;
|
|
67
|
-
removeWhere(filter: Partial<TItem>): number;
|
|
68
|
-
count(): number;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Type representing the CellOrm methods exposed on the schema
|
|
72
|
-
*/
|
|
73
|
-
export type CellOrmSchema<TValue> = {
|
|
74
|
-
read(): TValue;
|
|
75
|
-
write(value: TValue): void;
|
|
76
|
-
getAddress(): CellAddress;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Type representing the GridOrm methods exposed on the schema
|
|
80
|
-
*/
|
|
81
|
-
export type GridOrmSchema<TValue> = {
|
|
82
|
-
columns: readonly TValue[][];
|
|
83
|
-
rows: readonly TValue[][];
|
|
84
|
-
setValue(value: TValue, position: {
|
|
85
|
-
col: number;
|
|
86
|
-
row: number;
|
|
87
|
-
}): void;
|
|
88
|
-
getValue(position: {
|
|
89
|
-
col: number;
|
|
90
|
-
row: number;
|
|
91
|
-
}): TValue;
|
|
92
|
-
};
|
|
93
|
-
export type SchemaDeclaration = Record<string, TableSchemaDefinition | CellSchemaDefinition | GridSchemaDefinition>;
|
|
94
|
-
export type Schema = Record<string, object>;
|
|
95
|
-
/**
|
|
96
|
-
* Write function type for converting parsed values back to serializable form
|
|
97
|
-
*/
|
|
98
|
-
type WriteFunction<TValue, TCellMetadata> = (value: TValue) => {
|
|
99
|
-
value: SerializedCellValue;
|
|
100
|
-
metadata?: TCellMetadata;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Helper type to create the return type for addCellSchema/addGridSchema
|
|
104
|
-
*/
|
|
105
|
-
type AddCellSchemaResult<TCellMetadata, TCurrentSchema extends Schema, TCurrentDeclaration extends SchemaDeclaration, T extends string, TValue> = CreateSchema<TCellMetadata, TCurrentSchema & {
|
|
106
|
-
[K in T]: CellOrmSchema<TValue>;
|
|
107
|
-
}, TCurrentDeclaration & {
|
|
108
|
-
[K in T]: {
|
|
109
|
-
type: "cell";
|
|
110
|
-
cellAddress: CellAddress;
|
|
111
|
-
parse: (value: unknown, metadata: unknown) => unknown;
|
|
112
|
-
};
|
|
113
|
-
}>;
|
|
114
|
-
type AddGridSchemaResult<TCellMetadata, TCurrentSchema extends Schema, TCurrentDeclaration extends SchemaDeclaration, T extends string, TValue> = CreateSchema<TCellMetadata, TCurrentSchema & {
|
|
115
|
-
[K in T]: GridOrmSchema<TValue>;
|
|
116
|
-
}, TCurrentDeclaration & {
|
|
117
|
-
[K in T]: {
|
|
118
|
-
type: "grid";
|
|
119
|
-
workbookName: string;
|
|
120
|
-
sheetName: string;
|
|
121
|
-
range: FiniteSpreadsheetRange;
|
|
122
|
-
parse: (value: unknown, metadata: unknown) => unknown;
|
|
123
|
-
};
|
|
124
|
-
}>;
|
|
125
|
-
export type CreateSchema<TCellMetadata, TCurrentSchema extends Schema, TCurrentDeclaration extends SchemaDeclaration> = {
|
|
126
|
-
addTableSchema<T extends string, THeaders extends Headers<TCellMetadata>>(namespace: T, address: {
|
|
127
|
-
workbookName: string;
|
|
128
|
-
tableName: string;
|
|
129
|
-
}, headers: THeaders): CreateSchema<TCellMetadata, TCurrentSchema & {
|
|
130
|
-
[K in T]: TableOrmSchema<{
|
|
131
|
-
[H in keyof THeaders]: ReturnType<THeaders[H]["parse"]>;
|
|
132
|
-
}>;
|
|
133
|
-
}, TCurrentDeclaration & {
|
|
134
|
-
[K in T]: {
|
|
135
|
-
type: "table";
|
|
136
|
-
tableName: string;
|
|
137
|
-
workbookName: string;
|
|
138
|
-
headers: THeaders;
|
|
139
|
-
};
|
|
140
|
-
}>;
|
|
141
|
-
addCellSchema<T extends string, TValue>(namespace: T, cellAddress: CellAddress, parse: (value: unknown, metadata: TCellMetadata) => TValue, write: WriteFunction<TValue, TCellMetadata>): AddCellSchemaResult<TCellMetadata, TCurrentSchema, TCurrentDeclaration, T, TValue>;
|
|
142
|
-
addCellSchema<T extends string, TValue extends SerializedCellValue>(namespace: T, cellAddress: CellAddress, parse: (value: unknown, metadata: TCellMetadata) => TValue, write?: WriteFunction<TValue, TCellMetadata>): AddCellSchemaResult<TCellMetadata, TCurrentSchema, TCurrentDeclaration, T, TValue>;
|
|
143
|
-
addGridSchema<T extends string, TValue>(namespace: T, address: {
|
|
144
|
-
workbookName: string;
|
|
145
|
-
sheetName: string;
|
|
146
|
-
}, range: FiniteSpreadsheetRange, parse: (value: unknown, metadata: TCellMetadata) => TValue, write: WriteFunction<TValue, TCellMetadata>): AddGridSchemaResult<TCellMetadata, TCurrentSchema, TCurrentDeclaration, T, TValue>;
|
|
147
|
-
addGridSchema<T extends string, TValue extends SerializedCellValue>(namespace: T, address: {
|
|
148
|
-
workbookName: string;
|
|
149
|
-
sheetName: string;
|
|
150
|
-
}, range: FiniteSpreadsheetRange, parse: (value: unknown, metadata: TCellMetadata) => TValue, write?: WriteFunction<TValue, TCellMetadata>): AddGridSchemaResult<TCellMetadata, TCurrentSchema, TCurrentDeclaration, T, TValue>;
|
|
151
|
-
schema: TCurrentSchema;
|
|
152
|
-
declaration: TCurrentDeclaration;
|
|
153
|
-
};
|
|
154
|
-
export declare const defineHeader: <TValue, TMetadata>(index: number, parse: (value: SerializedCellValue, metadata: TMetadata) => TValue, write?: (value: TValue) => {
|
|
155
|
-
value: SerializedCellValue;
|
|
156
|
-
metadata?: TMetadata;
|
|
157
|
-
}) => {
|
|
158
|
-
parse: (value: SerializedCellValue, metadata: TMetadata) => TValue;
|
|
159
|
-
write: ((value: TValue) => {
|
|
160
|
-
value: SerializedCellValue;
|
|
161
|
-
metadata?: TMetadata;
|
|
162
|
-
}) | ((value: TValue) => {
|
|
163
|
-
value: TValue;
|
|
164
|
-
});
|
|
165
|
-
index: number;
|
|
166
|
-
};
|
|
167
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TableOrm - Object-Relational Mapping for table data
|
|
3
|
-
*
|
|
4
|
-
* Provides CRUD operations for table data with type-safe access.
|
|
5
|
-
* Used as the `this` context for custom table API methods.
|
|
6
|
-
*/
|
|
7
|
-
import type { FormulaEngine } from "../engine";
|
|
8
|
-
import { type TableSchemaHeaders } from "./schema-helpers";
|
|
9
|
-
export declare class TableOrm<TItem extends Record<string, unknown>> {
|
|
10
|
-
private engine;
|
|
11
|
-
private workbookName;
|
|
12
|
-
private tableName;
|
|
13
|
-
private headers;
|
|
14
|
-
private namespace;
|
|
15
|
-
constructor(engine: FormulaEngine<any, any>, workbookName: string, tableName: string, headers: TableSchemaHeaders, namespace: string);
|
|
16
|
-
/**
|
|
17
|
-
* Get the table definition from the engine
|
|
18
|
-
*/
|
|
19
|
-
private getTable;
|
|
20
|
-
/**
|
|
21
|
-
* Find the first row matching the filter
|
|
22
|
-
*/
|
|
23
|
-
findWhere(filter: Partial<TItem>): TItem | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Find all rows matching the filter
|
|
26
|
-
*/
|
|
27
|
-
findAllWhere(filter: Partial<TItem>): TItem[];
|
|
28
|
-
/**
|
|
29
|
-
* Append a new row to the table
|
|
30
|
-
*/
|
|
31
|
-
append(item: TItem): TItem;
|
|
32
|
-
/**
|
|
33
|
-
* Update all rows matching the filter
|
|
34
|
-
* Returns the number of rows updated
|
|
35
|
-
*/
|
|
36
|
-
updateWhere(filter: Partial<TItem>, update: Partial<TItem>): number;
|
|
37
|
-
/**
|
|
38
|
-
* Remove all rows matching the filter
|
|
39
|
-
* Returns the number of rows removed
|
|
40
|
-
*/
|
|
41
|
-
removeWhere(filter: Partial<TItem>): number;
|
|
42
|
-
/**
|
|
43
|
-
* Get the count of data rows in the table
|
|
44
|
-
*/
|
|
45
|
-
count(): number;
|
|
46
|
-
}
|