@comapeo/core 1.0.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.
- package/LICENSE.md +9 -0
- package/README.md +31 -0
- package/dist/blob-api.d.ts +92 -0
- package/dist/blob-api.d.ts.map +1 -0
- package/dist/blob-store/index.d.ts +163 -0
- package/dist/blob-store/index.d.ts.map +1 -0
- package/dist/blob-store/live-download.d.ts +107 -0
- package/dist/blob-store/live-download.d.ts.map +1 -0
- package/dist/config-import.d.ts +74 -0
- package/dist/config-import.d.ts.map +1 -0
- package/dist/constants.d.ts +14 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/core-manager/bitfield-rle.d.ts +25 -0
- package/dist/core-manager/bitfield-rle.d.ts.map +1 -0
- package/dist/core-manager/core-index.d.ts +56 -0
- package/dist/core-manager/core-index.d.ts.map +1 -0
- package/dist/core-manager/index.d.ts +125 -0
- package/dist/core-manager/index.d.ts.map +1 -0
- package/dist/core-manager/random-access-file-pool.d.ts +17 -0
- package/dist/core-manager/random-access-file-pool.d.ts.map +1 -0
- package/dist/core-manager/remote-bitfield.d.ts +146 -0
- package/dist/core-manager/remote-bitfield.d.ts.map +1 -0
- package/dist/core-ownership.d.ts +112 -0
- package/dist/core-ownership.d.ts.map +1 -0
- package/dist/datastore/index.d.ts +91 -0
- package/dist/datastore/index.d.ts.map +1 -0
- package/dist/datatype/index.d.ts +108 -0
- package/dist/discovery/local-discovery.d.ts +64 -0
- package/dist/discovery/local-discovery.d.ts.map +1 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/fastify-controller.d.ts +27 -0
- package/dist/fastify-controller.d.ts.map +1 -0
- package/dist/fastify-plugins/blobs.d.ts +6 -0
- package/dist/fastify-plugins/blobs.d.ts.map +1 -0
- package/dist/fastify-plugins/constants.d.ts +3 -0
- package/dist/fastify-plugins/constants.d.ts.map +1 -0
- package/dist/fastify-plugins/icons.d.ts +6 -0
- package/dist/fastify-plugins/icons.d.ts.map +1 -0
- package/dist/fastify-plugins/maps/index.d.ts +11 -0
- package/dist/fastify-plugins/maps/index.d.ts.map +1 -0
- package/dist/fastify-plugins/maps/offline-fallback-map.d.ts +12 -0
- package/dist/fastify-plugins/maps/offline-fallback-map.d.ts.map +1 -0
- package/dist/fastify-plugins/maps/static-maps.d.ts +11 -0
- package/dist/fastify-plugins/maps/static-maps.d.ts.map +1 -0
- package/dist/fastify-plugins/utils.d.ts +23 -0
- package/dist/fastify-plugins/utils.d.ts.map +1 -0
- package/dist/generated/extensions.d.ts +44 -0
- package/dist/generated/extensions.d.ts.map +1 -0
- package/dist/generated/keys.d.ts +36 -0
- package/dist/generated/keys.d.ts.map +1 -0
- package/dist/generated/rpc.d.ts +87 -0
- package/dist/generated/rpc.d.ts.map +1 -0
- package/dist/icon-api.d.ts +109 -0
- package/dist/icon-api.d.ts.map +1 -0
- package/dist/index-writer/index.d.ts +51 -0
- package/dist/index-writer/index.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/invite-api.d.ts +70 -0
- package/dist/invite-api.d.ts.map +1 -0
- package/dist/lib/hashmap.d.ts +62 -0
- package/dist/lib/hashmap.d.ts.map +1 -0
- package/dist/lib/hypercore-helpers.d.ts +6 -0
- package/dist/lib/hypercore-helpers.d.ts.map +1 -0
- package/dist/lib/noise-secret-stream-helpers.d.ts +45 -0
- package/dist/lib/noise-secret-stream-helpers.d.ts.map +1 -0
- package/dist/lib/ponyfills.d.ts +10 -0
- package/dist/lib/ponyfills.d.ts.map +1 -0
- package/dist/lib/string.d.ts +2 -0
- package/dist/lib/string.d.ts.map +1 -0
- package/dist/lib/timing-safe-equal.d.ts +15 -0
- package/dist/lib/timing-safe-equal.d.ts.map +1 -0
- package/dist/local-peers.d.ts +151 -0
- package/dist/local-peers.d.ts.map +1 -0
- package/dist/logger.d.ts +32 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/mapeo-manager.d.ts +178 -0
- package/dist/mapeo-manager.d.ts.map +1 -0
- package/dist/mapeo-project.d.ts +3233 -0
- package/dist/mapeo-project.d.ts.map +1 -0
- package/dist/member-api.d.ts +114 -0
- package/dist/member-api.d.ts.map +1 -0
- package/dist/roles.d.ts +157 -0
- package/dist/roles.d.ts.map +1 -0
- package/dist/schema/client.d.ts +284 -0
- package/dist/schema/client.d.ts.map +1 -0
- package/dist/schema/project.d.ts +1812 -0
- package/dist/schema/project.d.ts.map +1 -0
- package/dist/schema/schema-to-drizzle.d.ts +20 -0
- package/dist/schema/schema-to-drizzle.d.ts.map +1 -0
- package/dist/schema/types.d.ts +98 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/utils.d.ts +55 -0
- package/dist/schema/utils.d.ts.map +1 -0
- package/dist/sync/core-sync-state.d.ts +252 -0
- package/dist/sync/core-sync-state.d.ts.map +1 -0
- package/dist/sync/namespace-sync-state.d.ts +47 -0
- package/dist/sync/namespace-sync-state.d.ts.map +1 -0
- package/dist/sync/peer-sync-controller.d.ts +44 -0
- package/dist/sync/peer-sync-controller.d.ts.map +1 -0
- package/dist/sync/sync-api.d.ts +158 -0
- package/dist/sync/sync-api.d.ts.map +1 -0
- package/dist/sync/sync-state.d.ts +40 -0
- package/dist/sync/sync-state.d.ts.map +1 -0
- package/dist/translation-api.d.ts +288 -0
- package/dist/translation-api.d.ts.map +1 -0
- package/dist/types.d.ts +115 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +115 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils_types.d.ts +14 -0
- package/drizzle/client/0000_bumpy_carnage.sql +33 -0
- package/drizzle/client/meta/0000_snapshot.json +199 -0
- package/drizzle/client/meta/_journal.json +13 -0
- package/drizzle/project/0000_spooky_lady_ursula.sql +192 -0
- package/drizzle/project/meta/0000_snapshot.json +1137 -0
- package/drizzle/project/meta/_journal.json +13 -0
- package/package.json +202 -0
- package/src/blob-api.js +139 -0
- package/src/blob-store/index.js +325 -0
- package/src/blob-store/live-download.js +373 -0
- package/src/config-import.js +604 -0
- package/src/constants.js +34 -0
- package/src/core-manager/bitfield-rle.js +235 -0
- package/src/core-manager/core-index.js +87 -0
- package/src/core-manager/index.js +504 -0
- package/src/core-manager/random-access-file-pool.js +30 -0
- package/src/core-manager/remote-bitfield.js +416 -0
- package/src/core-ownership.js +235 -0
- package/src/datastore/README.md +46 -0
- package/src/datastore/index.js +234 -0
- package/src/datatype/README.md +33 -0
- package/src/datatype/index.d.ts +108 -0
- package/src/datatype/index.js +358 -0
- package/src/discovery/local-discovery.js +303 -0
- package/src/errors.js +5 -0
- package/src/fastify-controller.js +84 -0
- package/src/fastify-plugins/blobs.js +139 -0
- package/src/fastify-plugins/constants.js +5 -0
- package/src/fastify-plugins/icons.js +158 -0
- package/src/fastify-plugins/maps/index.js +173 -0
- package/src/fastify-plugins/maps/offline-fallback-map.js +114 -0
- package/src/fastify-plugins/maps/static-maps.js +271 -0
- package/src/fastify-plugins/utils.js +52 -0
- package/src/generated/README.md +3 -0
- package/src/generated/extensions.d.ts +44 -0
- package/src/generated/extensions.js +196 -0
- package/src/generated/extensions.ts +237 -0
- package/src/generated/keys.d.ts +36 -0
- package/src/generated/keys.js +148 -0
- package/src/generated/keys.ts +185 -0
- package/src/generated/rpc.d.ts +87 -0
- package/src/generated/rpc.js +389 -0
- package/src/generated/rpc.ts +463 -0
- package/src/icon-api.js +282 -0
- package/src/index-writer/README.md +38 -0
- package/src/index-writer/index.js +124 -0
- package/src/index.js +16 -0
- package/src/invite-api.js +450 -0
- package/src/lib/hashmap.js +91 -0
- package/src/lib/hypercore-helpers.js +18 -0
- package/src/lib/noise-secret-stream-helpers.js +37 -0
- package/src/lib/ponyfills.js +25 -0
- package/src/lib/string.js +7 -0
- package/src/lib/timing-safe-equal.js +34 -0
- package/src/local-peers.js +737 -0
- package/src/logger.js +99 -0
- package/src/mapeo-manager.js +914 -0
- package/src/mapeo-project.js +980 -0
- package/src/member-api.js +319 -0
- package/src/roles.js +412 -0
- package/src/schema/client.js +55 -0
- package/src/schema/project.js +44 -0
- package/src/schema/schema-to-drizzle.js +118 -0
- package/src/schema/types.ts +153 -0
- package/src/schema/utils.js +51 -0
- package/src/sync/core-sync-state.js +440 -0
- package/src/sync/namespace-sync-state.js +193 -0
- package/src/sync/peer-sync-controller.js +332 -0
- package/src/sync/sync-api.js +588 -0
- package/src/sync/sync-state.js +63 -0
- package/src/translation-api.js +141 -0
- package/src/types.ts +149 -0
- package/src/utils.js +210 -0
- package/src/utils_types.d.ts +14 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/** @import { CoreOwnership as CoreOwnershipDoc } from '@comapeo/schema' */
|
|
2
|
+
/** @import { CoreOwnership } from '../core-ownership.js' */
|
|
3
|
+
/** @import { OpenedNoiseStream } from '../lib/noise-secret-stream-helpers.js' */
|
|
4
|
+
export const kHandleDiscoveryKey: unique symbol;
|
|
5
|
+
export const kSyncState: unique symbol;
|
|
6
|
+
export const kRequestFullStop: unique symbol;
|
|
7
|
+
export const kRescindFullStopRequest: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {'initial' | 'full'} SyncType
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {'none' | 'presync' | 'all'} SyncEnabledState
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
* @typedef {object} RemoteDeviceNamespaceGroupSyncState
|
|
17
|
+
* @property {boolean} isSyncEnabled do we want to sync this namespace group?
|
|
18
|
+
* @property {number} want number of blocks this device wants from us
|
|
19
|
+
* @property {number} wanted number of blocks we want from this device
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
* @typedef {object} RemoteDeviceSyncState state of sync for a remote peer
|
|
24
|
+
* @property {RemoteDeviceNamespaceGroupSyncState} initial state of initial namespaces (auth, config, and blob index)
|
|
25
|
+
* @property {RemoteDeviceNamespaceGroupSyncState} data state of data namespaces (data and blob)
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {object} State
|
|
29
|
+
* @property {{ isSyncEnabled: boolean }} initial state of initial namespace syncing (auth, config, and blob index) for local device
|
|
30
|
+
* @property {{ isSyncEnabled: boolean }} data state of data namespace syncing (data and blob) for local device
|
|
31
|
+
* @property {Record<string, RemoteDeviceSyncState>} remoteDeviceSyncState sync states for remote peers
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {object} SyncEvents
|
|
35
|
+
* @property {(syncState: State) => void} sync-state
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* @extends {TypedEmitter<SyncEvents>}
|
|
39
|
+
*/
|
|
40
|
+
export class SyncApi extends TypedEmitter<SyncEvents> {
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param {object} opts
|
|
44
|
+
* @param {import('../core-manager/index.js').CoreManager} opts.coreManager
|
|
45
|
+
* @param {CoreOwnership} opts.coreOwnership
|
|
46
|
+
* @param {import('../roles.js').Roles} opts.roles
|
|
47
|
+
* @param {number} [opts.throttleMs]
|
|
48
|
+
* @param {Logger} [opts.logger]
|
|
49
|
+
*/
|
|
50
|
+
constructor({ coreManager, throttleMs, roles, logger, coreOwnership }: {
|
|
51
|
+
coreManager: import("../core-manager/index.js").CoreManager;
|
|
52
|
+
coreOwnership: CoreOwnership;
|
|
53
|
+
roles: import("../roles.js").Roles;
|
|
54
|
+
throttleMs?: number | undefined;
|
|
55
|
+
logger?: Logger | undefined;
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Get the current sync state (initial and full). Also emitted via the 'sync-state' event
|
|
59
|
+
* @returns {State}
|
|
60
|
+
*/
|
|
61
|
+
getState(): State;
|
|
62
|
+
/**
|
|
63
|
+
* Start syncing data cores.
|
|
64
|
+
*
|
|
65
|
+
* If the app is backgrounded and sync has already completed, this will do
|
|
66
|
+
* nothing until the app is foregrounded.
|
|
67
|
+
*
|
|
68
|
+
* @param {object} [options]
|
|
69
|
+
* @param {null | number} [options.autostopDataSyncAfter] If no data sync
|
|
70
|
+
* happens after this duration in milliseconds, sync will be automatically
|
|
71
|
+
* stopped as if {@link stop} was called.
|
|
72
|
+
*/
|
|
73
|
+
start({ autostopDataSyncAfter }?: {
|
|
74
|
+
autostopDataSyncAfter?: number | null | undefined;
|
|
75
|
+
} | undefined): void;
|
|
76
|
+
/**
|
|
77
|
+
* Stop syncing data cores.
|
|
78
|
+
*
|
|
79
|
+
* Pre-sync cores will continue syncing unless the app is backgrounded.
|
|
80
|
+
*/
|
|
81
|
+
stop(): void;
|
|
82
|
+
/**
|
|
83
|
+
* @param {null | number} autostopDataSyncAfter
|
|
84
|
+
* @returns {void}
|
|
85
|
+
*/
|
|
86
|
+
setAutostopDataSyncTimeout(autostopDataSyncAfter: null | number): void;
|
|
87
|
+
/**
|
|
88
|
+
* @param {SyncType} type
|
|
89
|
+
* @returns {Promise<void>}
|
|
90
|
+
*/
|
|
91
|
+
waitForSync(type: SyncType): Promise<void>;
|
|
92
|
+
[kHandleDiscoveryKey](discoveryKey: Buffer, protomux: import("protomux")<import("@hyperswarm/secret-stream")>): void;
|
|
93
|
+
/**
|
|
94
|
+
* Request a graceful stop to all sync.
|
|
95
|
+
*/
|
|
96
|
+
[kRequestFullStop](): void;
|
|
97
|
+
/**
|
|
98
|
+
* Rescind any requests for a full stop.
|
|
99
|
+
*/
|
|
100
|
+
[kRescindFullStopRequest](): void;
|
|
101
|
+
[kSyncState]: SyncState;
|
|
102
|
+
#private;
|
|
103
|
+
}
|
|
104
|
+
export type SyncType = "initial" | "full";
|
|
105
|
+
export type SyncEnabledState = "none" | "presync" | "all";
|
|
106
|
+
export type RemoteDeviceNamespaceGroupSyncState = {
|
|
107
|
+
/**
|
|
108
|
+
* do we want to sync this namespace group?
|
|
109
|
+
*/
|
|
110
|
+
isSyncEnabled: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* number of blocks this device wants from us
|
|
113
|
+
*/
|
|
114
|
+
want: number;
|
|
115
|
+
/**
|
|
116
|
+
* number of blocks we want from this device
|
|
117
|
+
*/
|
|
118
|
+
wanted: number;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* state of sync for a remote peer
|
|
122
|
+
*/
|
|
123
|
+
export type RemoteDeviceSyncState = {
|
|
124
|
+
/**
|
|
125
|
+
* state of initial namespaces (auth, config, and blob index)
|
|
126
|
+
*/
|
|
127
|
+
initial: RemoteDeviceNamespaceGroupSyncState;
|
|
128
|
+
/**
|
|
129
|
+
* state of data namespaces (data and blob)
|
|
130
|
+
*/
|
|
131
|
+
data: RemoteDeviceNamespaceGroupSyncState;
|
|
132
|
+
};
|
|
133
|
+
export type State = {
|
|
134
|
+
/**
|
|
135
|
+
* state of initial namespace syncing (auth, config, and blob index) for local device
|
|
136
|
+
*/
|
|
137
|
+
initial: {
|
|
138
|
+
isSyncEnabled: boolean;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* state of data namespace syncing (data and blob) for local device
|
|
142
|
+
*/
|
|
143
|
+
data: {
|
|
144
|
+
isSyncEnabled: boolean;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* sync states for remote peers
|
|
148
|
+
*/
|
|
149
|
+
remoteDeviceSyncState: Record<string, RemoteDeviceSyncState>;
|
|
150
|
+
};
|
|
151
|
+
export type SyncEvents = {
|
|
152
|
+
"sync-state": (syncState: State) => void;
|
|
153
|
+
};
|
|
154
|
+
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
155
|
+
import { SyncState } from './sync-state.js';
|
|
156
|
+
import type { CoreOwnership } from '../core-ownership.js';
|
|
157
|
+
import { Logger } from '../logger.js';
|
|
158
|
+
//# sourceMappingURL=sync-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-api.d.ts","sourceRoot":"","sources":["../../src/sync/sync-api.js"],"names":[],"mappings":"AAWA,2EAA2E;AAC3E,4DAA4D;AAC5D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|
+
* import('./namespace-sync-state.js').SyncState
|
|
6
|
+
* >} State
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Emit sync state when it changes
|
|
10
|
+
* @extends {TypedEmitter<{ state: (state: State) => void}>}
|
|
11
|
+
*/
|
|
12
|
+
export class SyncState extends TypedEmitter<{
|
|
13
|
+
state: (state: State) => void;
|
|
14
|
+
}> {
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {object} opts
|
|
18
|
+
* @param {import('../core-manager/index.js').CoreManager} opts.coreManager
|
|
19
|
+
* @param {Map<string, import('./peer-sync-controller.js').PeerSyncController>} opts.peerSyncControllers
|
|
20
|
+
* @param {number} [opts.throttleMs]
|
|
21
|
+
*/
|
|
22
|
+
constructor({ coreManager, peerSyncControllers, throttleMs }: {
|
|
23
|
+
coreManager: import("../core-manager/index.js").CoreManager;
|
|
24
|
+
peerSyncControllers: Map<string, import("./peer-sync-controller.js").PeerSyncController>;
|
|
25
|
+
throttleMs?: number | undefined;
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* @param {string} peerId
|
|
29
|
+
*/
|
|
30
|
+
addPeer(peerId: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* @returns {State}
|
|
33
|
+
*/
|
|
34
|
+
getState(): State;
|
|
35
|
+
#private;
|
|
36
|
+
}
|
|
37
|
+
export type State = Record<Namespace, import("./namespace-sync-state.js").SyncState>;
|
|
38
|
+
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
39
|
+
import type { Namespace } from '../types.js';
|
|
40
|
+
//# sourceMappingURL=sync-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-state.d.ts","sourceRoot":"","sources":["../../src/sync/sync-state.js"],"names":[],"mappings":"AAKA,+CAA+C;AAE/C;;;;;GAKG;AAEH;;;GAGG;AACH;WAFmC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;;IAIvD;;;;;;OAMG;IACH,8DAJG;QAA6D,WAAW,EAAhE,OAAO,0BAA0B,EAAE,WAAW;QAC4B,mBAAmB,EAA7F,GAAG,CAAC,MAAM,EAAE,OAAO,2BAA2B,EAAE,kBAAkB,CAAC;QACrD,UAAU;KAAC,EAanC;IAED;;OAEG;IACH,gBAFW,MAAM,QAMhB;IAED;;OAEG;IACH,YAFa,KAAK,CAOjB;;CAKF;oBAtDY,MAAM,CAClB,SAAY,EACZ,OAAU,2BAA2B,EAAE,SAAS,CAC7C;6BAXyB,oBAAoB;+BAKlB,aAAa"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/** @import { Translation, TranslationValue } from '@comapeo/schema' */
|
|
2
|
+
/** @import { SetOptional } from 'type-fest' */
|
|
3
|
+
export const ktranslatedLanguageCodeToSchemaNames: unique symbol;
|
|
4
|
+
export default class TranslationApi {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Object} opts
|
|
7
|
+
* @param {import('./datatype/index.js').DataType<
|
|
8
|
+
* import('./datastore/index.js').DataStore<'config'>,
|
|
9
|
+
* typeof import('./schema/project.js').translationTable,
|
|
10
|
+
* 'translation',
|
|
11
|
+
* Translation,
|
|
12
|
+
* TranslationValue
|
|
13
|
+
* >} opts.dataType
|
|
14
|
+
* @param {typeof import('./schema/project.js').translationTable} opts.table
|
|
15
|
+
*/
|
|
16
|
+
constructor({ dataType, table }: {
|
|
17
|
+
dataType: import("./datatype/index.js").DataType<import("./datastore/index.js").DataStore<"config">, typeof import("./schema/project.js").translationTable, "translation", Translation, TranslationValue>;
|
|
18
|
+
table: typeof import("./schema/project.js").translationTable;
|
|
19
|
+
});
|
|
20
|
+
/** @returns {Promise<void>} */
|
|
21
|
+
ready(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* @param {TranslationValue} value
|
|
24
|
+
*/
|
|
25
|
+
put(value: TranslationValue): Promise<{
|
|
26
|
+
schemaName: "translation";
|
|
27
|
+
docRef: {
|
|
28
|
+
docId: string;
|
|
29
|
+
versionId: string;
|
|
30
|
+
};
|
|
31
|
+
docRefType: "type_unspecified" | "deviceInfo" | "preset" | "field" | "observation" | "projectSettings" | "role" | "track" | "UNRECOGNIZED";
|
|
32
|
+
propertyRef: string;
|
|
33
|
+
languageCode: string;
|
|
34
|
+
regionCode?: string | undefined;
|
|
35
|
+
message: string;
|
|
36
|
+
docId: string;
|
|
37
|
+
versionId: string;
|
|
38
|
+
originalVersionId: string;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
links: string[];
|
|
42
|
+
deleted: boolean;
|
|
43
|
+
} & {
|
|
44
|
+
forks: string[];
|
|
45
|
+
}>;
|
|
46
|
+
/** @typedef {SetOptional<TranslationValue['docRef'], 'versionId'>} DocRefWithOptionalVersionId */
|
|
47
|
+
/**
|
|
48
|
+
* @param {SetOptional<
|
|
49
|
+
* Omit<TranslationValue,'schemaName' | 'message' | 'docRef'>,
|
|
50
|
+
* 'propertyRef' | 'regionCode'> & {docRef: DocRefWithOptionalVersionId}} value
|
|
51
|
+
* @returns {Promise<import('@comapeo/schema').Translation[]>}
|
|
52
|
+
*/
|
|
53
|
+
get(value: SetOptional<Omit<TranslationValue, "schemaName" | "message" | "docRef">, "propertyRef" | "regionCode"> & {
|
|
54
|
+
docRef: {
|
|
55
|
+
docId: string;
|
|
56
|
+
versionId?: string | undefined;
|
|
57
|
+
};
|
|
58
|
+
}): Promise<import("@comapeo/schema").Translation[]>;
|
|
59
|
+
/**
|
|
60
|
+
* @param {TranslationValue} doc
|
|
61
|
+
*/
|
|
62
|
+
index(doc: TranslationValue): void;
|
|
63
|
+
get dataType(): import("./datatype/index.js").DataType<import("./datastore/index.js").DataStore<"config", "translation" | "preset" | "field" | "projectSettings" | "deviceInfo" | "icon">, import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
64
|
+
name: "translation";
|
|
65
|
+
schema: undefined;
|
|
66
|
+
columns: {
|
|
67
|
+
readonly docId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
68
|
+
name: "docId";
|
|
69
|
+
tableName: "translation";
|
|
70
|
+
dataType: "string";
|
|
71
|
+
columnType: "SQLiteText";
|
|
72
|
+
data: string;
|
|
73
|
+
driverParam: string;
|
|
74
|
+
notNull: true;
|
|
75
|
+
hasDefault: false;
|
|
76
|
+
enumValues: [string, ...string[]];
|
|
77
|
+
baseColumn: never;
|
|
78
|
+
}, object>;
|
|
79
|
+
readonly versionId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
80
|
+
name: "versionId";
|
|
81
|
+
tableName: "translation";
|
|
82
|
+
dataType: "string";
|
|
83
|
+
columnType: "SQLiteText";
|
|
84
|
+
data: string;
|
|
85
|
+
driverParam: string;
|
|
86
|
+
notNull: true;
|
|
87
|
+
hasDefault: false;
|
|
88
|
+
enumValues: [string, ...string[]];
|
|
89
|
+
baseColumn: never;
|
|
90
|
+
}, object>;
|
|
91
|
+
readonly originalVersionId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
92
|
+
name: "originalVersionId";
|
|
93
|
+
tableName: "translation";
|
|
94
|
+
dataType: "string";
|
|
95
|
+
columnType: "SQLiteText";
|
|
96
|
+
data: string;
|
|
97
|
+
driverParam: string;
|
|
98
|
+
notNull: true;
|
|
99
|
+
hasDefault: false;
|
|
100
|
+
enumValues: [string, ...string[]];
|
|
101
|
+
baseColumn: never;
|
|
102
|
+
}, object>;
|
|
103
|
+
readonly schemaName: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
104
|
+
name: "schemaName";
|
|
105
|
+
tableName: "translation";
|
|
106
|
+
dataType: "string";
|
|
107
|
+
columnType: "SQLiteText";
|
|
108
|
+
data: "translation";
|
|
109
|
+
driverParam: string;
|
|
110
|
+
notNull: true;
|
|
111
|
+
hasDefault: false;
|
|
112
|
+
enumValues: ["translation"];
|
|
113
|
+
baseColumn: never;
|
|
114
|
+
}, object>;
|
|
115
|
+
readonly createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
116
|
+
name: "createdAt";
|
|
117
|
+
tableName: "translation";
|
|
118
|
+
dataType: "string";
|
|
119
|
+
columnType: "SQLiteText";
|
|
120
|
+
data: string;
|
|
121
|
+
driverParam: string;
|
|
122
|
+
notNull: true;
|
|
123
|
+
hasDefault: false;
|
|
124
|
+
enumValues: [string, ...string[]];
|
|
125
|
+
baseColumn: never;
|
|
126
|
+
}, object>;
|
|
127
|
+
readonly updatedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
128
|
+
name: "updatedAt";
|
|
129
|
+
tableName: "translation";
|
|
130
|
+
dataType: "string";
|
|
131
|
+
columnType: "SQLiteText";
|
|
132
|
+
data: string;
|
|
133
|
+
driverParam: string;
|
|
134
|
+
notNull: true;
|
|
135
|
+
hasDefault: false;
|
|
136
|
+
enumValues: [string, ...string[]];
|
|
137
|
+
baseColumn: never;
|
|
138
|
+
}, object>;
|
|
139
|
+
readonly links: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
140
|
+
name: "links";
|
|
141
|
+
tableName: "translation";
|
|
142
|
+
dataType: "custom";
|
|
143
|
+
columnType: "SQLiteCustomColumn";
|
|
144
|
+
data: string[];
|
|
145
|
+
driverParam: string;
|
|
146
|
+
notNull: true;
|
|
147
|
+
hasDefault: false;
|
|
148
|
+
enumValues: undefined;
|
|
149
|
+
baseColumn: never;
|
|
150
|
+
}, object>;
|
|
151
|
+
readonly deleted: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
152
|
+
name: "deleted";
|
|
153
|
+
tableName: "translation";
|
|
154
|
+
dataType: "boolean";
|
|
155
|
+
columnType: "SQLiteBoolean";
|
|
156
|
+
data: boolean;
|
|
157
|
+
driverParam: number;
|
|
158
|
+
notNull: true;
|
|
159
|
+
hasDefault: false;
|
|
160
|
+
enumValues: undefined;
|
|
161
|
+
baseColumn: never;
|
|
162
|
+
}, object>;
|
|
163
|
+
readonly docRef: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
164
|
+
name: "docRef";
|
|
165
|
+
tableName: "translation";
|
|
166
|
+
dataType: "custom";
|
|
167
|
+
columnType: "SQLiteCustomColumn";
|
|
168
|
+
data: {
|
|
169
|
+
docId: string;
|
|
170
|
+
versionId: string;
|
|
171
|
+
};
|
|
172
|
+
driverParam: string;
|
|
173
|
+
notNull: true;
|
|
174
|
+
hasDefault: false;
|
|
175
|
+
enumValues: undefined;
|
|
176
|
+
baseColumn: never;
|
|
177
|
+
}, object>;
|
|
178
|
+
readonly docRefType: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
179
|
+
name: "docRefType";
|
|
180
|
+
tableName: "translation";
|
|
181
|
+
dataType: "string";
|
|
182
|
+
columnType: "SQLiteText";
|
|
183
|
+
data: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified";
|
|
184
|
+
driverParam: string;
|
|
185
|
+
notNull: true;
|
|
186
|
+
hasDefault: false;
|
|
187
|
+
enumValues: ["type_unspecified", "deviceInfo", "preset", "field", "observation", "projectSettings", "role", "track", "UNRECOGNIZED"];
|
|
188
|
+
baseColumn: never;
|
|
189
|
+
}, object>;
|
|
190
|
+
readonly propertyRef: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
191
|
+
name: "propertyRef";
|
|
192
|
+
tableName: "translation";
|
|
193
|
+
dataType: "string";
|
|
194
|
+
columnType: "SQLiteText";
|
|
195
|
+
data: string;
|
|
196
|
+
driverParam: string;
|
|
197
|
+
notNull: true;
|
|
198
|
+
hasDefault: false;
|
|
199
|
+
enumValues: [string, ...string[]];
|
|
200
|
+
baseColumn: never;
|
|
201
|
+
}, object>;
|
|
202
|
+
readonly languageCode: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
203
|
+
name: "languageCode";
|
|
204
|
+
tableName: "translation";
|
|
205
|
+
dataType: "string";
|
|
206
|
+
columnType: "SQLiteText";
|
|
207
|
+
data: string;
|
|
208
|
+
driverParam: string;
|
|
209
|
+
notNull: true;
|
|
210
|
+
hasDefault: false;
|
|
211
|
+
enumValues: [string, ...string[]];
|
|
212
|
+
baseColumn: never;
|
|
213
|
+
}, object>;
|
|
214
|
+
readonly regionCode: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
215
|
+
name: "regionCode";
|
|
216
|
+
tableName: "translation";
|
|
217
|
+
dataType: "string";
|
|
218
|
+
columnType: "SQLiteText";
|
|
219
|
+
data: string;
|
|
220
|
+
driverParam: string;
|
|
221
|
+
notNull: false;
|
|
222
|
+
hasDefault: false;
|
|
223
|
+
enumValues: [string, ...string[]];
|
|
224
|
+
baseColumn: never;
|
|
225
|
+
}, object>;
|
|
226
|
+
readonly message: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
227
|
+
name: "message";
|
|
228
|
+
tableName: "translation";
|
|
229
|
+
dataType: "string";
|
|
230
|
+
columnType: "SQLiteText";
|
|
231
|
+
data: string;
|
|
232
|
+
driverParam: string;
|
|
233
|
+
notNull: true;
|
|
234
|
+
hasDefault: false;
|
|
235
|
+
enumValues: [string, ...string[]];
|
|
236
|
+
baseColumn: never;
|
|
237
|
+
}, object>;
|
|
238
|
+
forks: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
239
|
+
name: "forks";
|
|
240
|
+
tableName: "translation";
|
|
241
|
+
dataType: "custom";
|
|
242
|
+
columnType: "SQLiteCustomColumn";
|
|
243
|
+
data: string[];
|
|
244
|
+
driverParam: string;
|
|
245
|
+
notNull: true;
|
|
246
|
+
hasDefault: false;
|
|
247
|
+
enumValues: undefined;
|
|
248
|
+
baseColumn: never;
|
|
249
|
+
}, object>;
|
|
250
|
+
};
|
|
251
|
+
dialect: "sqlite";
|
|
252
|
+
}>, "translation", {
|
|
253
|
+
schemaName: "translation";
|
|
254
|
+
docRef: {
|
|
255
|
+
docId: string;
|
|
256
|
+
versionId: string;
|
|
257
|
+
};
|
|
258
|
+
docRefType: "type_unspecified" | "deviceInfo" | "preset" | "field" | "observation" | "projectSettings" | "role" | "track" | "UNRECOGNIZED";
|
|
259
|
+
propertyRef: string;
|
|
260
|
+
languageCode: string;
|
|
261
|
+
regionCode?: string | undefined;
|
|
262
|
+
message: string;
|
|
263
|
+
docId: string;
|
|
264
|
+
versionId: string;
|
|
265
|
+
originalVersionId: string;
|
|
266
|
+
createdAt: string;
|
|
267
|
+
updatedAt: string;
|
|
268
|
+
links: string[];
|
|
269
|
+
deleted: boolean;
|
|
270
|
+
}, {
|
|
271
|
+
schemaName: "translation";
|
|
272
|
+
docRef: {
|
|
273
|
+
docId: string;
|
|
274
|
+
versionId: string;
|
|
275
|
+
};
|
|
276
|
+
docRefType: "type_unspecified" | "deviceInfo" | "preset" | "field" | "observation" | "projectSettings" | "role" | "track" | "UNRECOGNIZED";
|
|
277
|
+
propertyRef: string;
|
|
278
|
+
languageCode: string;
|
|
279
|
+
regionCode?: string | undefined;
|
|
280
|
+
message: string;
|
|
281
|
+
}>;
|
|
282
|
+
get [ktranslatedLanguageCodeToSchemaNames](): Map<string, Set<import("@comapeo/schema/dist/types.js").SchemaName>>;
|
|
283
|
+
#private;
|
|
284
|
+
}
|
|
285
|
+
import type { TranslationValue } from '@comapeo/schema';
|
|
286
|
+
import type { SetOptional } from 'type-fest';
|
|
287
|
+
import type { Translation } from '@comapeo/schema';
|
|
288
|
+
//# sourceMappingURL=translation-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation-api.d.ts","sourceRoot":"","sources":["../src/translation-api.js"],"names":[],"mappings":"AAIA,uEAAuE;AACvE,+CAA+C;AAE/C,iEAEC;AACD;IASE;;;;;;;;;;OAUG;IACH,iCATG;QAMS,QAAQ,EANT,OAAO,qBAAqB,EAAE,QAAQ,CAChD,OAAW,sBAAsB,EAAE,SAAS,CAAC,QAAQ,CAAC,EACtD,cAAkB,qBAAqB,EAAE,gBAAgB,EACzD,aAAiB,EACjB,WAAe,EACf,gBAAoB,CACjB;QACmE,KAAK,EAAjE,cAAc,qBAAqB,EAAE,gBAAgB;KAC/D,EAYA;IAED,+BAA+B;IAC/B,SADc,OAAO,CAAC,IAAI,CAAC,CAG1B;IAED;;OAEG;IACH,WAFW,gBAAgB;;;;;;;;;;;;;;;;;;;;OAgB1B;IAED,kGAAkG;IAElG;;;;;OAKG;IACH,WALW,YACR,IAAI,CAAC,gBAAgB,EAAC,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC,EAC5D,aAAe,GAAG,YAAY,CAAC,GAAG;QAAC,MAAM;;;UAA6B;KAAC,GAC3D,OAAO,CAAC,OAAO,iBAAiB,EAAE,WAAW,EAAE,CAAC,CAqC5D;IAED;;OAEG;IACH,WAFW,gBAAgB,QAkB1B;IAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAEC;IALD,mHAEC;;CAIF;sCAxIkD,iBAAiB;iCACnC,WAAW;iCADO,iBAAiB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Simplify, TupleToUnion, ValueOf, RequireAtLeastOne, SetOptional } from 'type-fest';
|
|
2
|
+
import { SUPPORTED_BLOB_VARIANTS } from './blob-store/index.js';
|
|
3
|
+
import { MapeoCommon, MapeoDoc, MapeoValue, decode } from '@comapeo/schema';
|
|
4
|
+
import type BigSparseArray from 'big-sparse-array';
|
|
5
|
+
import type Protomux from 'protomux';
|
|
6
|
+
import type NoiseStream from '@hyperswarm/secret-stream';
|
|
7
|
+
import { Duplex } from 'streamx';
|
|
8
|
+
import RandomAccessStorage from 'random-access-storage';
|
|
9
|
+
import { DefaultListener, ListenerSignature } from 'tiny-typed-emitter';
|
|
10
|
+
import type { NAMESPACES } from './constants.js';
|
|
11
|
+
export type Namespace = (typeof NAMESPACES)[number];
|
|
12
|
+
type SupportedBlobVariants = typeof SUPPORTED_BLOB_VARIANTS;
|
|
13
|
+
export type BlobType = keyof SupportedBlobVariants;
|
|
14
|
+
export type BlobVariant<TBlobType extends BlobType> = TupleToUnion<SupportedBlobVariants[TBlobType]>;
|
|
15
|
+
type BlobIdBase<T extends BlobType> = {
|
|
16
|
+
/** Type of blob */
|
|
17
|
+
type: T;
|
|
18
|
+
/** Blob variant (some blob types have smaller previews and thumbnails available) */
|
|
19
|
+
variant: BlobVariant<T>;
|
|
20
|
+
/** unique identifier for blob (e.g. hash of content) */
|
|
21
|
+
name: string;
|
|
22
|
+
/** discovery key as hex string of hyperdrive where blob is stored */
|
|
23
|
+
driveId: string;
|
|
24
|
+
};
|
|
25
|
+
export type BlobId = Simplify<ValueOf<{
|
|
26
|
+
[KeyType in BlobType]: BlobIdBase<KeyType>;
|
|
27
|
+
}>>;
|
|
28
|
+
type ArrayAtLeastOne<T> = [T, ...T[]];
|
|
29
|
+
export type BlobFilter = RequireAtLeastOne<{
|
|
30
|
+
[KeyType in BlobType]: ArrayAtLeastOne<BlobVariant<KeyType>>;
|
|
31
|
+
}>;
|
|
32
|
+
export type MapeoDocMap = {
|
|
33
|
+
[K in MapeoDoc['schemaName']]: Extract<MapeoDoc, {
|
|
34
|
+
schemaName: K;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
export type MapeoValueMap = {
|
|
38
|
+
[K in MapeoValue['schemaName']]: Extract<MapeoValue, {
|
|
39
|
+
schemaName: K;
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
42
|
+
export type CoreOwnershipWithSignatures = Extract<ReturnType<typeof decode>, {
|
|
43
|
+
schemaName: 'coreOwnership';
|
|
44
|
+
}>;
|
|
45
|
+
export type CoreOwnershipWithSignaturesValue = Omit<CoreOwnershipWithSignatures, Exclude<keyof MapeoCommon, 'schemaName'>>;
|
|
46
|
+
type NullToOptional<T> = SetOptional<T, NullKeys<T>>;
|
|
47
|
+
type RemoveNull<T> = {
|
|
48
|
+
[K in keyof T]: Exclude<T[K], null>;
|
|
49
|
+
};
|
|
50
|
+
type NullKeys<Base> = NonNullable<{
|
|
51
|
+
[Key in keyof Base]: null extends Base[Key] ? Key : never;
|
|
52
|
+
}[keyof Base]>;
|
|
53
|
+
/**
|
|
54
|
+
* Replace an object's `Buffer` values with `string`s. Useful for serialization.
|
|
55
|
+
*/
|
|
56
|
+
export type MapBuffers<T> = {
|
|
57
|
+
[K in keyof T]: T[K] extends Buffer ? string : T[K];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Make any properties whose value include `null` optional, and remove `null`
|
|
61
|
+
* from the type. This converts the types returned from SQLite (which have all
|
|
62
|
+
* top-level optional props set to `null`) to the original types in
|
|
63
|
+
* @comapeo/schema
|
|
64
|
+
*/
|
|
65
|
+
export type NullableToOptional<T> = Simplify<RemoveNull<NullToOptional<T>>>;
|
|
66
|
+
export type KeyPair = {
|
|
67
|
+
publicKey: PublicKey;
|
|
68
|
+
secretKey: SecretKey;
|
|
69
|
+
};
|
|
70
|
+
/** 32 byte buffer */
|
|
71
|
+
export type PublicKey = Buffer;
|
|
72
|
+
/** 32 byte buffer */
|
|
73
|
+
export type SecretKey = Buffer;
|
|
74
|
+
export type IdentityKeyPair = KeyPair;
|
|
75
|
+
type HypercoreRemoteBitfieldPage = {
|
|
76
|
+
bitfield: Uint32Array;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* A subset of Hypercore's `RemoteBitfield` class that we use.
|
|
80
|
+
*/
|
|
81
|
+
export type HypercoreRemoteBitfield = {
|
|
82
|
+
_pages: BigSparseArray<HypercoreRemoteBitfieldPage>;
|
|
83
|
+
get(index: number): boolean;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* A subset of Hypercore's `Peer` class that we use.
|
|
87
|
+
* TODO: Contribute these types upstream.
|
|
88
|
+
*/
|
|
89
|
+
export type HypercorePeer = {
|
|
90
|
+
protomux: Protomux;
|
|
91
|
+
remotePublicKey: Buffer;
|
|
92
|
+
remoteBitfield: HypercoreRemoteBitfield;
|
|
93
|
+
onbitfield: (options: {
|
|
94
|
+
start: number;
|
|
95
|
+
bitfield: Buffer;
|
|
96
|
+
}) => void;
|
|
97
|
+
onrange: (options: {
|
|
98
|
+
drop: boolean;
|
|
99
|
+
start: number;
|
|
100
|
+
length: number;
|
|
101
|
+
}) => void;
|
|
102
|
+
};
|
|
103
|
+
export { NoiseStream };
|
|
104
|
+
type ProtocolStream = Omit<NoiseStream, 'userData'> & {
|
|
105
|
+
userData: Protomux;
|
|
106
|
+
};
|
|
107
|
+
export type ReplicationStream = Duplex & {
|
|
108
|
+
noiseStream: ProtocolStream;
|
|
109
|
+
};
|
|
110
|
+
export type CoreStorage = (name: string) => RandomAccessStorage;
|
|
111
|
+
export type DefaultEmitterEvents<L extends ListenerSignature<L> = DefaultListener> = {
|
|
112
|
+
newListener: (event: keyof L, listener: L[keyof L]) => void;
|
|
113
|
+
removeListener: (event: keyof L, listener: L[keyof L]) => void;
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,WAAW,EACZ,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC3E,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AACpC,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE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