Skip to content

Commit e4f8c33

Browse files
committed
feat(interpreter): expose all interpreter store options and make available in useInterpreterStore
1 parent 8365d79 commit e4f8c33

File tree

11 files changed

+42
-29
lines changed

11 files changed

+42
-29
lines changed

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"browserslist": "defaults, not ie <= 11",
1414
"dependencies": {
1515
"@algolia/autocomplete-core": "^1.9.2",
16-
"@coltorapps/builder": "^0.2.1",
17-
"@coltorapps/builder-react": "^0.2.1",
16+
"@coltorapps/builder": "^0.2.2",
17+
"@coltorapps/builder-react": "^0.2.2",
1818
"@dnd-kit/core": "^6.1.0",
1919
"@dnd-kit/modifiers": "^7.0.0",
2020
"@dnd-kit/sortable": "^8.0.0",

docs/src/app/docs/api/create-interpreter-store/page.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ In the example above, we've hardcoded the schema, but typically, you would retri
5050

5151
The `options` parameter properties:
5252

53-
| Property | Type | Description {% class="api-description" %} |
54-
| ----------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------ |
55-
| `initialData` | {% badge content="object" /%} {% badge content="optional" /%} | The optional partial initial data. |
56-
| `initialEntitiesValuesWithDefaults` | {% badge content="boolean" /%} {% badge content="optional" /%} | A flag to disable the automatic setting of default values. Defaults to `true`. |
53+
| Property | Type | Description {% class="api-description" %} |
54+
| ----------------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
55+
| `initialData` | {% badge content="object" /%} {% badge content="optional" /%} | The optional partial initial data. |
56+
| `initialEntitiesValuesWithDefaults` | {% badge content="boolean" /%} {% badge content="optional" /%} | A flag to enable or disable the automatic setting of default values. Defaults to `true`. |
5757

5858
### Returns
5959

docs/src/app/docs/api/react/use-interpreter-store/page.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ In the example above, we've hardcoded the schema, but typically, you would retri
5050

5151
The `options` parameter properties:
5252

53-
| Property | Type | Description {% class="api-description" %} |
54-
| ------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
55-
| `initialData` | {% badge content="object" /%} {% badge content="optional" /%} | The optional partial initial data of the [interpreter store](/docs/api/create-interpreter-store#data). |
56-
| `events` | {% badge content="object" /%} {% badge content="optional" /%} | An optional partial object with [events callbacks](#events-callbacks). |
53+
| Property | Type | Description {% class="api-description" %} |
54+
| ----------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
55+
| `initialData` | {% badge content="object" /%} {% badge content="optional" /%} | The optional partial initial data of the [interpreter store](/docs/api/create-interpreter-store#data). |
56+
| `initialEntitiesValuesWithDefaults` | {% badge content="boolean" /%} {% badge content="optional" /%} | A flag to enable or disable the automatic setting of default values. Defaults to `true`. |
57+
| `events` | {% badge content="object" /%} {% badge content="optional" /%} | An optional partial object with [events callbacks](#events-callbacks). |
5758

5859
### Returns
5960

packages/builder-react/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @coltorapps/builder-react
22

3+
## 0.2.2
4+
5+
### Patch Changes
6+
7+
- Expose all interpreter store options and make them available in useInterpreterStore.
8+
39
## 0.2.1
410

511
### Patch Changes

packages/builder-react/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@coltorapps/builder-react",
33
"private": false,
4-
"version": "0.2.1",
4+
"version": "0.2.2",
55
"homepage": "https://builder.coltorapps.com/",
66
"repository": {
77
"type": "git",
@@ -32,7 +32,7 @@
3232
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
3333
},
3434
"devDependencies": {
35-
"@coltorapps/builder": "^0.2.1",
35+
"@coltorapps/builder": "^0.2.2",
3636
"@coltorapps/eslint-config": "0.1.0",
3737
"@types/react": "^18.2.32",
3838
"eslint": "^8.52.0",
@@ -41,7 +41,7 @@
4141
"vitest": "^0.34.6"
4242
},
4343
"peerDependencies": {
44-
"@coltorapps/builder": "^0.2.0",
44+
"@coltorapps/builder": "^0.2.2",
4545
"react": "^18.0.0 || ^19.0.0"
4646
},
4747
"publishConfig": {

packages/builder-react/src/interpreter.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
type InterpreterStore,
1010
type InterpreterStoreData,
1111
type InterpreterStoreEvent,
12+
type InterpreterStoreOptions,
1213
type Schema,
1314
} from "@coltorapps/builder";
1415

@@ -24,15 +25,11 @@ export function useInterpreterStore<TBuilder extends Builder>(
2425
builder: TBuilder,
2526
schema: Schema<TBuilder>,
2627
options: {
27-
initialData?: Partial<InterpreterStoreData<TBuilder>>;
2828
events?: EventsListeners<InterpreterStoreEvent<TBuilder>>;
29-
} = {},
29+
} & InterpreterStoreOptions<TBuilder> = {},
3030
): InterpreterStore<TBuilder> {
3131
const interpreterStore = useMemo(
32-
() =>
33-
createInterpreterStore(builder, schema, {
34-
initialData: options.initialData,
35-
}),
32+
() => createInterpreterStore(builder, schema, options),
3633
// eslint-disable-next-line react-hooks/exhaustive-deps
3734
[builder, schema],
3835
);

packages/builder/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @coltorapps/builder
22

3+
## 0.2.2
4+
5+
### Patch Changes
6+
7+
- Expose all interpreter store options and make them available in useInterpreterStore.
8+
39
## 0.2.1
410

511
### Patch Changes

packages/builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@coltorapps/builder",
33
"private": false,
4-
"version": "0.2.1",
4+
"version": "0.2.2",
55
"homepage": "https://builder.coltorapps.com/",
66
"repository": {
77
"type": "git",

packages/builder/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export type {
2929
InterpreterStore,
3030
InterpreterStoreData,
3131
InterpreterStoreEvent,
32+
InterpreterStoreOptions,
3233
InterpreterStoreEventName,
3334
} from "./interpreter-store";
3435

packages/builder/src/interpreter-store.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,15 +488,17 @@ function ensureEntityProcessable(
488488
}
489489
}
490490

491+
export type InterpreterStoreOptions<TBuilder extends Builder> = {
492+
initialData?: Partial<
493+
Omit<InterpreterStoreData<TBuilder>, "unprocessableEntitiesIds">
494+
>;
495+
initialEntitiesValuesWithDefaults?: boolean;
496+
};
497+
491498
export function createInterpreterStore<TBuilder extends Builder>(
492499
builder: TBuilder,
493500
schema: Schema<TBuilder>,
494-
options?: {
495-
initialData?: Partial<
496-
Omit<InterpreterStoreData<TBuilder>, "unprocessableEntitiesIds">
497-
>;
498-
initialEntitiesValuesWithDefaults?: boolean;
499-
},
501+
options?: InterpreterStoreOptions<TBuilder>,
500502
): InterpreterStore<TBuilder> {
501503
const schemaValidationResult = validateSchemaShape(schema, builder);
502504

0 commit comments

Comments
 (0)