Skip to content

Commit f753e0f

Browse files
committed
fix: fix after upgrade to tinybase v5
1 parent ffc3815 commit f753e0f

File tree

178 files changed

+6474
-3022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+6474
-3022
lines changed

packages/examples/todolist-ts/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@
1616
},
1717
"dependencies": {
1818
"tinybase": "^5.0.0",
19-
"vue-tinybase": "workspace:*",
2019
"todomvc-app-css": "^2.4.3",
2120
"vue": "^3.4.31",
22-
"vue-router": "^4.4.0"
21+
"vue-router": "^4.4.0",
22+
"vue-tinybase": "workspace:*"
2323
},
2424
"devDependencies": {
2525
"@local/eslint-config-vue-tinybase": "workspace:*",
2626
"@tsconfig/node20": "^20.1.4",
2727
"@types/node": "^20.14.10",
2828
"@vitejs/plugin-vue": "^5.0.5",
2929
"@vue/eslint-config-prettier": "^9.0.0",
30-
"@vue/eslint-config-typescript": "^13.0.0",
3130
"@vue/tsconfig": "^0.5.1",
3231
"eslint": "^8.57.0",
3332
"eslint-plugin-vue": "^9.27.0",

packages/examples/todolist-ts/src/store.ts

-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { createStore } from 'tinybase/with-schemas'
2-
import { createLocalPersister } from 'tinybase/with-schemas/persisters/persister-browser'
32

43
export const store = createStore()
54
.setTablesSchema({
@@ -14,14 +13,6 @@ export const store = createStore()
1413
val3: { type: 'boolean', default: false },
1514
})
1615

17-
const persister = createLocalPersister(store, 'todos')
18-
19-
// eslint-disable-next-line unicorn/prefer-top-level-await
20-
void (async () => {
21-
await persister.startAutoLoad()
22-
await persister.startAutoSave()
23-
})()
24-
2516
export type Store = typeof store
2617

2718
declare module 'vue-tinybase' {

packages/private/docs/api/store/events.md

+18-18
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

packages/public/vue-tinybase/.eslintrc.cjs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
extends: ['@local/vue-tinybase'],
33
parserOptions: {
4+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
45
tsconfigRootDir: __dirname,
56
project: ['./tsconfig.json'],
67
parser: '@typescript-eslint/parser',
@@ -10,6 +11,7 @@ module.exports = {
1011
'@typescript-eslint/no-explicit-any': 'off',
1112
'unicorn/no-null': 'off',
1213
'unicorn/prevent-abbreviations': 'off',
14+
'vue/one-component-per-file': 'off',
1315
},
1416
settings: {
1517
'import/resolver': {

packages/public/vue-tinybase/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"version": "0.3.1",
44
"type": "module",
55
"description": "TinyBase Binding for Vue 3",
6-
"module": "./dist/lib.mjs",
7-
"types": "./dist/lib.d.mts",
6+
"module": "./dist/default-store/lib.mjs",
7+
"types": "./dist/default-store/lib.d.mts",
88
"exports": {
99
".": {
10-
"types": "./dist/lib.d.mts",
11-
"import": "./dist/lib.mjs"
10+
"types": "./dist/default-store/lib.d.mts",
11+
"import": "./dist/default-store/lib.mjs"
1212
},
1313
"./custom-store": {
1414
"types": "./dist/custom-store/lib.d.mts",

packages/public/vue-tinybase/src/custom-store/types.ts packages/public/vue-tinybase/src/@types/_internal/common.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import type { Store as UntypedStore } from 'tinybase'
2-
import type { OptionalSchemas, Store as TypedStore } from 'tinybase/with-schemas'
1+
import type { Ref } from '@vue/reactivity'
2+
import type { Store as StoreWithoutSchemas, Id, IdOrNull } from 'tinybase'
3+
import type { OptionalSchemas, Store as StoreWithSchemas } from 'tinybase/with-schemas'
34

4-
export type AnyStore = UntypedStore | TypedStore<any>
5+
export type AnyStore = StoreWithoutSchemas | StoreWithSchemas<any>
56

67
export type ExtractSchemasFromStore<Store extends AnyStore> =
7-
Store extends TypedStore<infer Schema> ? Schema : OptionalSchemas
8+
Store extends StoreWithSchemas<infer Schema> ? Schema : OptionalSchemas
89

910
export type ExtractValuesSchemaFromSchema<Schema extends OptionalSchemas> = Schema[1]
1011
export type ExtractValuesSchemaFromStore<Store extends AnyStore> = ExtractValuesSchemaFromSchema<
@@ -20,5 +21,14 @@ export type AnyValue = string | number | boolean
2021
export type AnyRow = Record<string, AnyValue>
2122
export type AnyTable = Record<string, AnyRow>
2223

23-
export { type Store as UntypedStore } from 'tinybase'
24-
export { type Store as TypedStore } from 'tinybase/with-schemas'
24+
export type ListenerArgument = IdOrNull | boolean | number | undefined
25+
26+
export type UseListenerOptions = {
27+
immediate?: boolean
28+
}
29+
export type UseListenerResult = {
30+
stopListening: () => void
31+
startListening: () => void
32+
listenerId: Ref<Id>
33+
isListening: Ref<boolean>
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import type {
2+
Cell,
3+
Id,
4+
OptionalSchemas,
5+
OptionalTablesSchema,
6+
OptionalValuesSchema,
7+
Store,
8+
Value,
9+
} from 'tinybase/with-schemas'
10+
11+
export type TableIdFromSchema<Schema extends OptionalTablesSchema> = AsId<keyof Schema>
12+
13+
export type CellIdFromSchema<Schema extends OptionalTablesSchema, TableId extends TableIdFromSchema<Schema>> = AsId<
14+
keyof Schema[TableId & keyof Schema]
15+
>
16+
17+
export type DefaultCellIdFromSchema<
18+
Schema extends OptionalTablesSchema,
19+
TableId extends TableIdFromSchema<Schema>,
20+
IsDefaulted extends boolean = true,
21+
> = AsId<
22+
{
23+
[CellId in CellIdFromSchema<Schema, TableId>]: CellIsDefaultedFromSchema<
24+
Schema,
25+
TableId,
26+
CellId,
27+
IsDefaulted extends true ? CellId : never,
28+
IsDefaulted extends true ? never : CellId
29+
>
30+
}[CellIdFromSchema<Schema, TableId>]
31+
>
32+
33+
export type AllCellIdFromSchema<
34+
Schema extends OptionalTablesSchema,
35+
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
36+
> = TableId extends TableIdFromSchema<Schema> ? CellIdFromSchema<Schema, TableId> : never
37+
38+
export type CellIsDefaultedFromSchema<
39+
Schema extends OptionalTablesSchema,
40+
TableId extends TableIdFromSchema<Schema>,
41+
CellId extends CellIdFromSchema<Schema, TableId>,
42+
Then,
43+
Else,
44+
> = Schema[TableId & keyof Schema][CellId & keyof Schema[TableId & keyof Schema]] extends {
45+
default: string | number | boolean
46+
}
47+
? Then
48+
: Else
49+
50+
export type DefaultedCellFromSchema<
51+
Schema extends OptionalTablesSchema,
52+
TableId extends TableIdFromSchema<Schema>,
53+
CellId extends CellIdFromSchema<Schema, TableId>,
54+
> =
55+
| Cell<Schema, TableId & string, CellId & string>
56+
| CellIsDefaultedFromSchema<Schema, TableId, CellId, never, undefined>
57+
58+
export type ValueIdFromSchema<Schema extends OptionalValuesSchema> = AsId<keyof Schema>
59+
60+
export type DefaultValueIdFromSchema<Schema extends OptionalValuesSchema, IsDefaulted extends boolean = true> = {
61+
[ValueId in ValueIdFromSchema<Schema>]: ValueIsDefaultedFromSchema<
62+
Schema,
63+
ValueId,
64+
IsDefaulted extends true ? ValueId : never,
65+
IsDefaulted extends true ? never : ValueId
66+
>
67+
}[ValueIdFromSchema<Schema>]
68+
69+
export type ValueIsDefaultedFromSchema<
70+
Schema extends OptionalValuesSchema,
71+
ValueId extends ValueIdFromSchema<Schema>,
72+
Then,
73+
Else,
74+
> = Schema[ValueId & keyof Schema] extends {
75+
default: string | number | boolean
76+
}
77+
? Then
78+
: Else
79+
80+
export type DefaultedValueFromSchema<Schema extends OptionalValuesSchema, ValueId extends ValueIdFromSchema<Schema>> =
81+
| Value<Schema, ValueId & string>
82+
| ValueIsDefaultedFromSchema<Schema, ValueId, never, undefined>
83+
84+
export type AsId<Key> = Exclude<Key & Id, number>
85+
86+
export type Truncate<Params> = Params extends [...infer ShorterParams, any] ? [...ShorterParams] : never
87+
88+
export type NoInfer<Type> = [Type][Type extends any ? 0 : never]
89+
90+
export type StoreAlias<Schemas extends OptionalSchemas> = Store<Schemas>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import type {
2+
UseCellFunction as UseCellFunctionWithSchemas,
3+
UseCellIdsFunction as UseCellIdsFunctionWithSchemas,
4+
UseHasCellFunction as UseHasCellFunctionWithSchemas,
5+
UseHasRowFunction as UseHasRowFunctionWithSchemas,
6+
UseHasTableFunction as UseHasTableFunctionWithSchemas,
7+
UseHasTableCellFunction as UseHasTableCellFunctionWithSchemas,
8+
UseHasTablesFunction as UseHasTablesFunctionWithSchemas,
9+
UseHasValueFunction as UseHasValueFunctionWithSchemas,
10+
UseHasValuesFunction as UseHasValuesFunctionWithSchemas,
11+
UseRowFunction as UseRowFunctionWithSchemas,
12+
UseRowCountFunction as UseRowCountFunctionWithSchemas,
13+
UseRowIdsFunction as UseRowIdsFunctionWithSchemas,
14+
UseSortedRowIdsFunction as UseSortedRowIdsFunctionWithSchemas,
15+
UseTableFunction as UseTableFunctionWithSchemas,
16+
UseTableCellIdsFunction as UseTableCellIdsFunctionWithSchemas,
17+
UseTableIdsFunction as UseTableIdsFunctionWithSchemas,
18+
UseTablesFunction as UseTablesFunctionWithSchemas,
19+
UseValueFunction as UseValueFunctionWithSchemas,
20+
UseValueIdsFunction as UseValueIdsFunctionWithSchemas,
21+
UseValuesFunction as UseValuesFunctionWithSchemas,
22+
} from './with-schemas/composables.js'
23+
import type {
24+
UseCellFunction as UseCellFunctionWithoutSchemas,
25+
UseCellIdsFunction as UseCellIdsFunctionWithoutSchemas,
26+
UseHasCellFunction as UseHasCellFunctionWithoutSchemas,
27+
UseHasRowFunction as UseHasRowFunctionWithoutSchemas,
28+
UseHasTableFunction as UseHasTableFunctionWithoutSchemas,
29+
UseHasTableCellFunction as UseHasTableCellFunctionWithoutSchemas,
30+
UseHasTablesFunction as UseHasTablesFunctionWithoutSchemas,
31+
UseHasValueFunction as UseHasValueFunctionWithoutSchemas,
32+
UseHasValuesFunction as UseHasValuesFunctionWithoutSchemas,
33+
UseRowFunction as UseRowFunctionWithoutSchemas,
34+
UseRowCountFunction as UseRowCountFunctionWithoutSchemas,
35+
UseRowIdsFunction as UseRowIdsFunctionWithoutSchemas,
36+
UseSortedRowIdsFunction as UseSortedRowIdsFunctionWithoutSchemas,
37+
UseTableFunction as UseTableFunctionWithoutSchemas,
38+
UseTableCellIdsFunction as UseTableCellIdsFunctionWithoutSchemas,
39+
UseTableIdsFunction as UseTableIdsFunctionWithoutSchemas,
40+
UseTablesFunction as UseTablesFunctionWithoutSchemas,
41+
UseValueFunction as UseValueFunctionWithoutSchemas,
42+
UseValueIdsFunction as UseValueIdsFunctionWithoutSchemas,
43+
UseValuesFunction as UseValuesFunctionWithoutSchemas,
44+
} from './without-schemas/composables.js'
45+
46+
export type UseCellFunction = UseCellFunctionWithSchemas & UseCellFunctionWithoutSchemas
47+
export type UseCellIdsFunction = UseCellIdsFunctionWithSchemas & UseCellIdsFunctionWithoutSchemas
48+
export type UseHasCellFunction = UseHasCellFunctionWithSchemas & UseHasCellFunctionWithoutSchemas
49+
export type UseHasRowFunction = UseHasRowFunctionWithSchemas & UseHasRowFunctionWithoutSchemas
50+
export type UseHasTableFunction = UseHasTableFunctionWithSchemas & UseHasTableFunctionWithoutSchemas
51+
export type UseHasTableCellFunction = UseHasTableCellFunctionWithSchemas & UseHasTableCellFunctionWithoutSchemas
52+
export type UseHasTablesFunction = UseHasTablesFunctionWithSchemas & UseHasTablesFunctionWithoutSchemas
53+
export type UseHasValueFunction = UseHasValueFunctionWithSchemas & UseHasValueFunctionWithoutSchemas
54+
export type UseHasValuesFunction = UseHasValuesFunctionWithSchemas & UseHasValuesFunctionWithoutSchemas
55+
export type UseRowFunction = UseRowFunctionWithSchemas & UseRowFunctionWithoutSchemas
56+
export type UseRowCountFunction = UseRowCountFunctionWithSchemas & UseRowCountFunctionWithoutSchemas
57+
export type UseRowIdsFunction = UseRowIdsFunctionWithSchemas & UseRowIdsFunctionWithoutSchemas
58+
export type UseSortedRowIdsFunction = UseSortedRowIdsFunctionWithSchemas & UseSortedRowIdsFunctionWithoutSchemas
59+
export type UseTableFunction = UseTableFunctionWithSchemas & UseTableFunctionWithoutSchemas
60+
export type UseTableCellIdsFunction = UseTableCellIdsFunctionWithSchemas & UseTableCellIdsFunctionWithoutSchemas
61+
export type UseTableIdsFunction = UseTableIdsFunctionWithSchemas & UseTableIdsFunctionWithoutSchemas
62+
export type UseTablesFunction = UseTablesFunctionWithSchemas & UseTablesFunctionWithoutSchemas
63+
export type UseValueFunction = UseValueFunctionWithSchemas & UseValueFunctionWithoutSchemas
64+
export type UseValueIdsFunction = UseValueIdsFunctionWithSchemas & UseValueIdsFunctionWithoutSchemas
65+
export type UseValuesFunction = UseValuesFunctionWithSchemas & UseValuesFunctionWithoutSchemas
66+
67+
export type {
68+
UseCellFunction as UseCellFunctionWithSchemas,
69+
UseCellIdsFunction as UseCellIdsFunctionWithSchemas,
70+
UseHasCellFunction as UseHasCellFunctionWithSchemas,
71+
UseHasRowFunction as UseHasRowFunctionWithSchemas,
72+
UseHasTableFunction as UseHasTableFunctionWithSchemas,
73+
UseHasTableCellFunction as UseHasTableCellFunctionWithSchemas,
74+
UseHasTablesFunction as UseHasTablesFunctionWithSchemas,
75+
UseHasValueFunction as UseHasValueFunctionWithSchemas,
76+
UseHasValuesFunction as UseHasValuesFunctionWithSchemas,
77+
UseRowFunction as UseRowFunctionWithSchemas,
78+
UseRowCountFunction as UseRowCountFunctionWithSchemas,
79+
UseRowIdsFunction as UseRowIdsFunctionWithSchemas,
80+
UseSortedRowIdsFunction as UseSortedRowIdsFunctionWithSchemas,
81+
UseTableFunction as UseTableFunctionWithSchemas,
82+
UseTableCellIdsFunction as UseTableCellIdsFunctionWithSchemas,
83+
UseTableIdsFunction as UseTableIdsFunctionWithSchemas,
84+
UseTablesFunction as UseTablesFunctionWithSchemas,
85+
UseValueFunction as UseValueFunctionWithSchemas,
86+
UseValueIdsFunction as UseValueIdsFunctionWithSchemas,
87+
UseValuesFunction as UseValuesFunctionWithSchemas,
88+
} from './with-schemas/composables.js'
89+
export type {
90+
UseCellFunction as UseCellFunctionWithoutSchemas,
91+
UseCellIdsFunction as UseCellIdsFunctionWithoutSchemas,
92+
UseHasCellFunction as UseHasCellFunctionWithoutSchemas,
93+
UseHasRowFunction as UseHasRowFunctionWithoutSchemas,
94+
UseHasTableFunction as UseHasTableFunctionWithoutSchemas,
95+
UseHasTableCellFunction as UseHasTableCellFunctionWithoutSchemas,
96+
UseHasTablesFunction as UseHasTablesFunctionWithoutSchemas,
97+
UseHasValueFunction as UseHasValueFunctionWithoutSchemas,
98+
UseHasValuesFunction as UseHasValuesFunctionWithoutSchemas,
99+
UseRowFunction as UseRowFunctionWithoutSchemas,
100+
UseRowCountFunction as UseRowCountFunctionWithoutSchemas,
101+
UseRowIdsFunction as UseRowIdsFunctionWithoutSchemas,
102+
UseSortedRowIdsFunction as UseSortedRowIdsFunctionWithoutSchemas,
103+
UseTableFunction as UseTableFunctionWithoutSchemas,
104+
UseTableCellIdsFunction as UseTableCellIdsFunctionWithoutSchemas,
105+
UseTableIdsFunction as UseTableIdsFunctionWithoutSchemas,
106+
UseTablesFunction as UseTablesFunctionWithoutSchemas,
107+
UseValueFunction as UseValueFunctionWithoutSchemas,
108+
UseValueIdsFunction as UseValueIdsFunctionWithoutSchemas,
109+
UseValuesFunction as UseValuesFunctionWithoutSchemas,
110+
} from './without-schemas/composables.js'

0 commit comments

Comments
 (0)