@comapeo/core 2.3.0 → 2.3.2
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/dist/blob-store/entries-stream.d.ts.map +1 -1
- package/dist/blob-store/index.d.ts +27 -15
- package/dist/blob-store/index.d.ts.map +1 -1
- package/dist/core-manager/index.d.ts +4 -4
- package/dist/core-manager/index.d.ts.map +1 -1
- package/dist/datastore/index.d.ts +1 -1
- package/dist/datatype/index.d.ts +141 -111
- package/dist/datatype/index.d.ts.map +1 -0
- package/dist/fastify-plugins/utils.d.ts +0 -9
- package/dist/fastify-plugins/utils.d.ts.map +1 -1
- package/dist/generated/extensions.d.ts +7 -0
- package/dist/generated/extensions.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/mapeo-project.d.ts +17 -17
- package/dist/mapeo-project.d.ts.map +1 -1
- package/dist/schema/project.d.ts +1 -1
- package/dist/sync/core-sync-state.d.ts +14 -6
- package/dist/sync/core-sync-state.d.ts.map +1 -1
- package/dist/sync/namespace-sync-state.d.ts +3 -13
- package/dist/sync/namespace-sync-state.d.ts.map +1 -1
- package/dist/sync/sync-api.d.ts +17 -25
- package/dist/sync/sync-api.d.ts.map +1 -1
- package/dist/sync/sync-state.d.ts +3 -13
- package/dist/sync/sync-state.d.ts.map +1 -1
- package/dist/translation-api.d.ts +2 -2
- package/dist/translation-api.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -5
- package/src/blob-store/entries-stream.js +43 -18
- package/src/blob-store/index.js +161 -19
- package/src/core-manager/index.js +14 -9
- package/src/datatype/index.js +57 -19
- package/src/fastify-plugins/maps.js +1 -0
- package/src/fastify-plugins/utils.js +0 -13
- package/src/generated/extensions.d.ts +7 -0
- package/src/generated/extensions.js +12 -2
- package/src/generated/extensions.ts +19 -1
- package/src/mapeo-project.js +7 -76
- package/src/sync/core-sync-state.js +41 -14
- package/src/sync/namespace-sync-state.js +25 -22
- package/src/sync/sync-api.js +12 -43
- package/src/sync/sync-state.js +9 -19
- package/src/translation-api.js +2 -1
- package/src/types.ts +1 -1
- package/src/datatype/index.d.ts +0 -112
package/src/datatype/index.d.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// Typescript was incorrectly compiling declaration files for this, so the
|
|
2
|
-
// declaration for DataType is written manually below, and copied into the
|
|
3
|
-
// `dist` folder at build-time. The types are checked in `test-types/data-types.ts`
|
|
4
|
-
|
|
5
|
-
import { type MapeoDoc, type MapeoValue } from '@comapeo/schema'
|
|
6
|
-
import {
|
|
7
|
-
type MapeoDocMap,
|
|
8
|
-
type MapeoValueMap,
|
|
9
|
-
type CoreOwnershipWithSignaturesValue,
|
|
10
|
-
} from '../types.js'
|
|
11
|
-
import { type BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'
|
|
12
|
-
import { SQLiteSelectBase } from 'drizzle-orm/sqlite-core'
|
|
13
|
-
import { RunResult } from 'better-sqlite3'
|
|
14
|
-
import type Hypercore from 'hypercore'
|
|
15
|
-
import { TypedEmitter } from 'tiny-typed-emitter'
|
|
16
|
-
import TranslationApi from '../translation-api.js'
|
|
17
|
-
|
|
18
|
-
type MapeoDocTableName = `${MapeoDoc['schemaName']}Table`
|
|
19
|
-
type GetMapeoDocTables<T> = T[keyof T & MapeoDocTableName]
|
|
20
|
-
/** Union of Drizzle schema tables that correspond to MapeoDoc types (e.g. excluding backlink tables and other utility tables) */
|
|
21
|
-
type MapeoDocTables =
|
|
22
|
-
| GetMapeoDocTables<typeof import('../schema/project.js')>
|
|
23
|
-
| GetMapeoDocTables<typeof import('../schema/client.js')>
|
|
24
|
-
type MapeoDocTablesMap = {
|
|
25
|
-
[K in MapeoDocTables['_']['name']]: Extract<
|
|
26
|
-
MapeoDocTables,
|
|
27
|
-
{ _: { name: K } }
|
|
28
|
-
>
|
|
29
|
-
}
|
|
30
|
-
export interface DataTypeEvents<TDoc extends MapeoDoc> {
|
|
31
|
-
'updated-docs': (docs: TDoc[]) => void
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const kCreateWithDocId: unique symbol
|
|
35
|
-
export const kSelect: unique symbol
|
|
36
|
-
export const kTable: unique symbol
|
|
37
|
-
export const kDataStore: unique symbol
|
|
38
|
-
|
|
39
|
-
type OmitUnion<T, K extends keyof any> = T extends any ? Omit<T, K> : never
|
|
40
|
-
type ExcludeSchema<
|
|
41
|
-
T extends MapeoValue,
|
|
42
|
-
S extends MapeoValue['schemaName']
|
|
43
|
-
> = Exclude<T, { schemaName: S }>
|
|
44
|
-
|
|
45
|
-
export class DataType<
|
|
46
|
-
TDataStore extends import('../datastore/index.js').DataStore,
|
|
47
|
-
TTable extends MapeoDocTables,
|
|
48
|
-
TSchemaName extends TTable['_']['name'],
|
|
49
|
-
TDoc extends MapeoDocMap[TSchemaName],
|
|
50
|
-
TValue extends MapeoValueMap[TSchemaName]
|
|
51
|
-
> extends TypedEmitter<DataTypeEvents<TDoc>> {
|
|
52
|
-
constructor({
|
|
53
|
-
dataStore,
|
|
54
|
-
table,
|
|
55
|
-
db,
|
|
56
|
-
getTranslations,
|
|
57
|
-
}: {
|
|
58
|
-
table: TTable
|
|
59
|
-
dataStore: TDataStore
|
|
60
|
-
db: import('drizzle-orm/better-sqlite3').BetterSQLite3Database
|
|
61
|
-
getTranslations: TranslationApi['get']
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
get [kTable](): TTable
|
|
65
|
-
|
|
66
|
-
get [kDataStore](): TDataStore
|
|
67
|
-
|
|
68
|
-
get schemaName(): TSchemaName
|
|
69
|
-
|
|
70
|
-
get namespace(): TDataStore.namespace
|
|
71
|
-
|
|
72
|
-
[kCreateWithDocId](
|
|
73
|
-
docId: string,
|
|
74
|
-
value:
|
|
75
|
-
| ExcludeSchema<TValue, 'coreOwnership'>
|
|
76
|
-
| CoreOwnershipWithSignaturesValue
|
|
77
|
-
): Promise<TDoc & { forks: string[] }>
|
|
78
|
-
|
|
79
|
-
[kSelect](): Promise<SQLiteSelectBase<TTable, 'sync', RunResult>>
|
|
80
|
-
|
|
81
|
-
create<
|
|
82
|
-
T extends import('type-fest').Exact<
|
|
83
|
-
ExcludeSchema<TValue, 'coreOwnership'>,
|
|
84
|
-
T
|
|
85
|
-
>
|
|
86
|
-
>(value: T): Promise<TDoc & { forks: string[] }>
|
|
87
|
-
|
|
88
|
-
getByDocId(
|
|
89
|
-
docId: string,
|
|
90
|
-
opts?: { mustBeFound?: true; lang?: string }
|
|
91
|
-
): Promise<TDoc & { forks: string[] }>
|
|
92
|
-
getByDocId(
|
|
93
|
-
docId: string,
|
|
94
|
-
opts?: { mustBeFound?: boolean; lang?: string }
|
|
95
|
-
): Promise<null | (TDoc & { forks: string[] })>
|
|
96
|
-
|
|
97
|
-
getByVersionId(versionId: string, opts?: { lang?: string }): Promise<TDoc>
|
|
98
|
-
|
|
99
|
-
getMany(opts?: {
|
|
100
|
-
includeDeleted?: boolean
|
|
101
|
-
lang?: string
|
|
102
|
-
}): Promise<Array<TDoc & { forks: string[] }>>
|
|
103
|
-
|
|
104
|
-
update<
|
|
105
|
-
T extends import('type-fest').Exact<
|
|
106
|
-
ExcludeSchema<TValue, 'coreOwnership'>,
|
|
107
|
-
T
|
|
108
|
-
>
|
|
109
|
-
>(versionId: string | string[], value: T): Promise<TDoc & { forks: string[] }>
|
|
110
|
-
|
|
111
|
-
delete(docId: string): Promise<TDoc & { forks: string[] }>
|
|
112
|
-
}
|