@xyo-network/archivist-model 5.3.22 → 5.3.24
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/package.json +11 -15
- package/src/ArchivistDriver.ts +0 -13
- package/src/ArchivistFunctions.ts +0 -24
- package/src/ArchivistSnapshot.ts +0 -10
- package/src/ArchivistStats.ts +0 -7
- package/src/Config.ts +0 -48
- package/src/EventData.ts +0 -7
- package/src/EventModels/Cleared.ts +0 -8
- package/src/EventModels/Deleted.ts +0 -11
- package/src/EventModels/Inserted.ts +0 -15
- package/src/EventModels/index.ts +0 -3
- package/src/IndexDescription.ts +0 -41
- package/src/Instance.ts +0 -47
- package/src/Labels.ts +0 -5
- package/src/Module.ts +0 -14
- package/src/ModuleInstance.ts +0 -11
- package/src/NextOptions.ts +0 -11
- package/src/PayloadArchivist.ts +0 -55
- package/src/Queries/All.ts +0 -8
- package/src/Queries/Clear.ts +0 -8
- package/src/Queries/Commit.ts +0 -8
- package/src/Queries/Delete.ts +0 -10
- package/src/Queries/Get.ts +0 -10
- package/src/Queries/Insert.ts +0 -8
- package/src/Queries/Next.ts +0 -8
- package/src/Queries/Snapshot.ts +0 -8
- package/src/Queries/index.ts +0 -31
- package/src/RawQueryFunctions.ts +0 -16
- package/src/attachable/AttachableInstance.ts +0 -20
- package/src/attachable/asAttachableInstance.ts +0 -5
- package/src/attachable/index.ts +0 -3
- package/src/attachable/isAttachableInstance.ts +0 -16
- package/src/index.ts +0 -17
- package/src/lib/HydratedBoundWitness.ts +0 -18
- package/src/lib/getBoundWitness.ts +0 -22
- package/src/lib/hydrateBoundWitness.ts +0 -33
- package/src/lib/index.ts +0 -3
- package/src/typeChecks.ts +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/archivist-model",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.24",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,31 +30,27 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src",
|
|
34
33
|
"!**/*.bench.*",
|
|
35
34
|
"!**/*.spec.*",
|
|
36
35
|
"!**/*.test.*",
|
|
37
36
|
"README.md"
|
|
38
37
|
],
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@xyo-network/account-model": "~5.3.
|
|
41
|
-
"@xyo-network/boundwitness-model": "~5.3.
|
|
42
|
-
"@xyo-network/module-model": "~5.3.
|
|
43
|
-
"@xyo-network/payload-model": "~5.3.
|
|
39
|
+
"@xyo-network/account-model": "~5.3.24",
|
|
40
|
+
"@xyo-network/boundwitness-model": "~5.3.24",
|
|
41
|
+
"@xyo-network/module-model": "~5.3.24",
|
|
42
|
+
"@xyo-network/payload-model": "~5.3.24"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"@opentelemetry/api": "^1.9.1",
|
|
47
46
|
"@types/node": "^25.5.0",
|
|
48
|
-
"@xylabs/sdk-js": "^5.0.
|
|
49
|
-
"@xylabs/ts-scripts-common": "~7.6.
|
|
50
|
-
"@xylabs/ts-scripts-
|
|
51
|
-
"@xylabs/tsconfig": "~7.6.
|
|
47
|
+
"@xylabs/sdk-js": "^5.0.93",
|
|
48
|
+
"@xylabs/ts-scripts-common": "~7.6.16",
|
|
49
|
+
"@xylabs/ts-scripts-pnpm": "~7.6.16",
|
|
50
|
+
"@xylabs/tsconfig": "~7.6.16",
|
|
52
51
|
"acorn": "^8.16.0",
|
|
53
52
|
"axios": "^1.14.0",
|
|
54
|
-
"
|
|
55
|
-
"esbuild": "^0.27.4",
|
|
56
|
-
"eslint": "^10.1.0",
|
|
57
|
-
"rollup": "^4.60.1",
|
|
53
|
+
"esbuild": "^0.28.0",
|
|
58
54
|
"typescript": "~5.9.3",
|
|
59
55
|
"zod": "^4.3.6"
|
|
60
56
|
},
|
|
@@ -65,4 +61,4 @@
|
|
|
65
61
|
"publishConfig": {
|
|
66
62
|
"access": "public"
|
|
67
63
|
}
|
|
68
|
-
}
|
|
64
|
+
}
|
package/src/ArchivistDriver.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
import type { NextOptions } from './NextOptions.ts'
|
|
4
|
-
|
|
5
|
-
export interface ArchivistDriver<TId, TIn, TOut extends TIn> {
|
|
6
|
-
all(): Promisable<TOut[]>
|
|
7
|
-
clear(): Promisable<void>
|
|
8
|
-
count(): number
|
|
9
|
-
delete(hashes: TId[]): Promise<TOut[]>
|
|
10
|
-
get(hashes: TId[]): Promisable<TOut[]>
|
|
11
|
-
insert(payloads: TIn[]): TOut[]
|
|
12
|
-
next(options?: NextOptions): Promisable<TOut[]>
|
|
13
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Promisable, PromisableArray } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
import type { NextOptions } from './NextOptions.ts'
|
|
4
|
-
|
|
5
|
-
export interface AllArchivistFunctions<TReadResponse, TSnapshotResponse> {
|
|
6
|
-
/** @deprecated use next or snapshot instead */
|
|
7
|
-
all(): PromisableArray<TReadResponse>
|
|
8
|
-
snapshot(): PromisableArray<TSnapshotResponse>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ReadArchivistFunctions<TReadResponse, TId = string, TCursor = TId> {
|
|
12
|
-
get(ids: TId[]): PromisableArray<TReadResponse>
|
|
13
|
-
next(options?: NextOptions<TCursor>): PromisableArray<TReadResponse>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface WriteArchivistFunctions<TReadResponse, TWriteResponse = TReadResponse, TWrite = TReadResponse, TId = string> {
|
|
17
|
-
clear(): Promisable<void>
|
|
18
|
-
delete(ids: TId[]): PromisableArray<TReadResponse>
|
|
19
|
-
insert(item: TWrite[]): PromisableArray<TWriteResponse>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface StashArchivistFunctions<TWriteResponse> {
|
|
23
|
-
commit(): PromisableArray<TWriteResponse>
|
|
24
|
-
}
|
package/src/ArchivistSnapshot.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import {
|
|
3
|
-
asSchema, type Payload, type PayloadHashMap,
|
|
4
|
-
} from '@xyo-network/payload-model'
|
|
5
|
-
|
|
6
|
-
export const ArchivistSnapshotPayloadSchema = asSchema('network.xyo.archivist.snapshot', true)
|
|
7
|
-
export type ArchivistSnapshotPayloadSchema = typeof ArchivistSnapshotPayloadSchema
|
|
8
|
-
|
|
9
|
-
export type ArchivistSnapshotPayload<TPayload extends Payload = Payload, TId extends string | number | symbol = Hash>
|
|
10
|
-
= Payload<PayloadHashMap<TPayload, TId>, ArchivistSnapshotPayloadSchema>
|
package/src/ArchivistStats.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Payload } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const ArchivistStatsPayloadSchema = asSchema('network.xyo.archivist.stats', true)
|
|
4
|
-
export type ArchivistStatsPayloadSchema = typeof ArchivistStatsPayloadSchema
|
|
5
|
-
|
|
6
|
-
export type ArchivistStatsPayload
|
|
7
|
-
= Payload<{ payloadCount: number }, ArchivistStatsPayloadSchema>
|
package/src/Config.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { EmptyObject, WithAdditional } from '@xylabs/sdk-js'
|
|
2
|
-
import type { ModuleConfig, ModuleIdentifier } from '@xyo-network/module-model'
|
|
3
|
-
import type {
|
|
4
|
-
Payload,
|
|
5
|
-
Schema,
|
|
6
|
-
} from '@xyo-network/payload-model'
|
|
7
|
-
import { asSchema } from '@xyo-network/payload-model'
|
|
8
|
-
|
|
9
|
-
import type { IndexDescription } from './IndexDescription.ts'
|
|
10
|
-
|
|
11
|
-
export interface ArchivistParents {
|
|
12
|
-
commit?: ModuleIdentifier[]
|
|
13
|
-
read?: ModuleIdentifier[]
|
|
14
|
-
write?: ModuleIdentifier[]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ArchivistStorage {
|
|
18
|
-
/** The indexes to create on the object store */
|
|
19
|
-
indexes?: IndexDescription[]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ArchivistGetCache {
|
|
23
|
-
enabled?: boolean
|
|
24
|
-
maxEntries?: number
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const ArchivistConfigSchema = asSchema('network.xyo.archivist.config', true)
|
|
28
|
-
export type ArchivistConfigSchema = typeof ArchivistConfigSchema
|
|
29
|
-
|
|
30
|
-
export type ArchivistConfig<TConfig extends Payload | EmptyObject | void = void, TSchema extends Schema | void = void> = ModuleConfig<
|
|
31
|
-
WithAdditional<
|
|
32
|
-
{
|
|
33
|
-
/** @field caching configuration for get calls */
|
|
34
|
-
getCache?: ArchivistGetCache
|
|
35
|
-
/** @field address of one or more parent archivists to read from */
|
|
36
|
-
parents?: ArchivistParents
|
|
37
|
-
/** @field fail if some parents can not be resolved (true if unspecified) */
|
|
38
|
-
requireAllParents?: boolean
|
|
39
|
-
schema: TConfig extends Payload ? TConfig['schema'] : ArchivistConfigSchema
|
|
40
|
-
/** @field storage configuration */
|
|
41
|
-
storage?: ArchivistStorage
|
|
42
|
-
/** @field should child store all reads from parents? */
|
|
43
|
-
storeParentReads?: boolean
|
|
44
|
-
},
|
|
45
|
-
TConfig
|
|
46
|
-
>,
|
|
47
|
-
TSchema
|
|
48
|
-
>
|
package/src/EventData.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ModuleEventData } from '@xyo-network/module-model'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
ClearedEventData, DeletedEventData, InsertedEventData,
|
|
5
|
-
} from './EventModels/index.ts'
|
|
6
|
-
|
|
7
|
-
export interface ArchivistModuleEventData extends InsertedEventData, DeletedEventData, ClearedEventData, ModuleEventData {}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { EventData } from '@xylabs/sdk-js'
|
|
2
|
-
import type { ModuleEventArgs, QueryableModule } from '@xyo-network/module-model'
|
|
3
|
-
|
|
4
|
-
export type ClearedEventArgs<T extends QueryableModule = QueryableModule> = ModuleEventArgs<T>
|
|
5
|
-
|
|
6
|
-
export interface ClearedEventData<T extends QueryableModule = QueryableModule> extends EventData {
|
|
7
|
-
cleared: ClearedEventArgs<T>
|
|
8
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { EventData, Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import type { ModuleEventArgs, QueryableModule } from '@xyo-network/module-model'
|
|
3
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
-
|
|
5
|
-
export type DeletedEventArgs<T extends QueryableModule = QueryableModule> = ModuleEventArgs<
|
|
6
|
-
T, { hashes: Hash[]; payloads: Payload[] }
|
|
7
|
-
>
|
|
8
|
-
|
|
9
|
-
export interface DeletedEventData<T extends QueryableModule = QueryableModule> extends EventData {
|
|
10
|
-
deleted: DeletedEventArgs<T>
|
|
11
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { EventData } from '@xylabs/sdk-js'
|
|
2
|
-
import type { ModuleEventArgs, QueryableModule } from '@xyo-network/module-model'
|
|
3
|
-
import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
|
|
4
|
-
|
|
5
|
-
export type InsertedEventArgs<T extends QueryableModule = QueryableModule> = ModuleEventArgs<
|
|
6
|
-
T, {
|
|
7
|
-
inPayloads: Payload[]
|
|
8
|
-
outPayloads: WithStorageMeta<Payload>[]
|
|
9
|
-
payloads: WithStorageMeta<Payload>[]
|
|
10
|
-
}
|
|
11
|
-
>
|
|
12
|
-
|
|
13
|
-
export interface InsertedEventData<T extends QueryableModule = QueryableModule> extends EventData {
|
|
14
|
-
inserted: InsertedEventArgs<T>
|
|
15
|
-
}
|
package/src/EventModels/index.ts
DELETED
package/src/IndexDescription.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The index direction (1 for ascending, -1 for descending)
|
|
3
|
-
*/
|
|
4
|
-
export type IndexDirection = -1 | 1
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Description of index(es) to be created on a store
|
|
8
|
-
*/
|
|
9
|
-
export type IndexDescription = {
|
|
10
|
-
/**
|
|
11
|
-
* The key(s) to index
|
|
12
|
-
*/
|
|
13
|
-
key: Record<string, IndexDirection>
|
|
14
|
-
/**
|
|
15
|
-
* Is the indexed value an array
|
|
16
|
-
*/
|
|
17
|
-
multiEntry?: boolean
|
|
18
|
-
/**
|
|
19
|
-
* The name of the index
|
|
20
|
-
*/
|
|
21
|
-
name?: string
|
|
22
|
-
/**
|
|
23
|
-
* If true, the index must enforce uniqueness on the key
|
|
24
|
-
*/
|
|
25
|
-
unique?: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const IndexSeparator = '-'
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Given an index description, this will build the index
|
|
32
|
-
* name in standard form
|
|
33
|
-
* @param index The index description
|
|
34
|
-
* @returns The index name in standard form
|
|
35
|
-
*/
|
|
36
|
-
export const buildStandardIndexName = (index: IndexDescription) => {
|
|
37
|
-
const { key, unique } = index
|
|
38
|
-
const prefix = unique ? 'UX' : 'IX'
|
|
39
|
-
const indexKeys = Object.keys(key)
|
|
40
|
-
return `${prefix}_${indexKeys.join(IndexSeparator)}`
|
|
41
|
-
}
|
package/src/Instance.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
EventEmitter, Hash, Promisable,
|
|
3
|
-
} from '@xylabs/sdk-js'
|
|
4
|
-
import type {
|
|
5
|
-
AnyConfigSchema, ModuleInstance, QueryableModuleParams,
|
|
6
|
-
} from '@xyo-network/module-model'
|
|
7
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
8
|
-
|
|
9
|
-
import type { ArchivistConfig } from './Config.ts'
|
|
10
|
-
import type { ArchivistModuleEventData } from './EventData.ts'
|
|
11
|
-
import type { ArchivistModule } from './Module.ts'
|
|
12
|
-
import type { ArchivistModuleInstance } from './ModuleInstance.ts'
|
|
13
|
-
import type { ArchivistRawQueryFunctions } from './RawQueryFunctions.ts'
|
|
14
|
-
|
|
15
|
-
export interface ArchivistParentInstances {
|
|
16
|
-
commit?: ArchivistInstance[]
|
|
17
|
-
read?: ArchivistInstance[]
|
|
18
|
-
write?: ArchivistInstance[]
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ArchivistKeyParams<TKey extends string = Hash, TValue = Payload, TDataKey extends string = TKey> {
|
|
22
|
-
dataKey?: (value: TValue) => Promisable<TKey>
|
|
23
|
-
key?: (value: TValue) => Promisable<TDataKey>
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface ArchivistValueParams<TValue = Payload, TDataValue = TValue> {
|
|
27
|
-
dataValue?: (value: TValue) => Promisable<TDataValue>
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface ArchivistParamFields {
|
|
31
|
-
keys?: ArchivistKeyParams
|
|
32
|
-
parents?: ArchivistParentInstances
|
|
33
|
-
values?: ArchivistValueParams
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface ArchivistParams<
|
|
37
|
-
TConfig extends AnyConfigSchema<ArchivistConfig> = AnyConfigSchema<ArchivistConfig>,
|
|
38
|
-
> extends QueryableModuleParams<TConfig>, ArchivistParamFields {}
|
|
39
|
-
|
|
40
|
-
export interface ArchivistInstance<
|
|
41
|
-
TParams extends ArchivistParams = ArchivistParams,
|
|
42
|
-
TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,
|
|
43
|
-
TPayload extends Payload = Payload,
|
|
44
|
-
> extends ArchivistModuleInstance<TParams, TEventData>,
|
|
45
|
-
ArchivistModule<TPayload, TPayload>,
|
|
46
|
-
ModuleInstance<TParams, TEventData>,
|
|
47
|
-
ArchivistRawQueryFunctions, EventEmitter<TEventData> {}
|
package/src/Labels.ts
DELETED
package/src/Module.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import type { QueryableModuleFunctions } from '@xyo-network/module-model'
|
|
3
|
-
import type { Payload, Sequence } from '@xyo-network/payload-model'
|
|
4
|
-
|
|
5
|
-
import type { Archivist } from './PayloadArchivist.ts'
|
|
6
|
-
|
|
7
|
-
export interface ArchivistModule<
|
|
8
|
-
TReadResponse extends Payload = Payload,
|
|
9
|
-
TWriteResponse extends Payload = Payload,
|
|
10
|
-
TWrite extends Payload = TReadResponse & Payload,
|
|
11
|
-
TId extends string = Hash,
|
|
12
|
-
TCursor extends string = Sequence,
|
|
13
|
-
> extends Archivist<TReadResponse, TWriteResponse, TWrite, TId, TCursor>,
|
|
14
|
-
QueryableModuleFunctions {}
|
package/src/ModuleInstance.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnyConfigSchema, QueryableModule, QueryableModuleParams,
|
|
3
|
-
} from '@xyo-network/module-model'
|
|
4
|
-
|
|
5
|
-
import type { ArchivistConfig } from './Config.ts'
|
|
6
|
-
import type { ArchivistModuleEventData } from './EventData.ts'
|
|
7
|
-
|
|
8
|
-
export interface ArchivistModuleInstance<
|
|
9
|
-
TParams extends QueryableModuleParams<AnyConfigSchema<ArchivistConfig>> = QueryableModuleParams<AnyConfigSchema<ArchivistConfig>>,
|
|
10
|
-
TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,
|
|
11
|
-
> extends QueryableModule<TParams, TEventData> {}
|
package/src/NextOptions.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Hex } from '@xylabs/sdk-js'
|
|
2
|
-
import type { Sequence } from '@xyo-network/payload-model'
|
|
3
|
-
|
|
4
|
-
export interface NextOptions<TSequence = Hex> {
|
|
5
|
-
cursor?: TSequence
|
|
6
|
-
limit?: number
|
|
7
|
-
open?: boolean
|
|
8
|
-
order?: 'asc' | 'desc'
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ArchivistNextOptions extends NextOptions<Sequence> {}
|
package/src/PayloadArchivist.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import type {
|
|
3
|
-
Payload, PayloadHashMap, Sequence, WithStorageMeta,
|
|
4
|
-
} from '@xyo-network/payload-model'
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
AllArchivistFunctions, ReadArchivistFunctions, StashArchivistFunctions, WriteArchivistFunctions,
|
|
8
|
-
} from './ArchivistFunctions.ts'
|
|
9
|
-
|
|
10
|
-
export interface AllArchivist<
|
|
11
|
-
TReadResponse extends Payload = Payload,
|
|
12
|
-
TId extends string = Hash,
|
|
13
|
-
> extends AllArchivistFunctions<WithStorageMeta<TReadResponse>, PayloadHashMap<WithStorageMeta<TReadResponse>, TId>> {}
|
|
14
|
-
|
|
15
|
-
export interface ReadArchivist<
|
|
16
|
-
TReadResponse extends Payload = Payload,
|
|
17
|
-
TId extends string = Hash,
|
|
18
|
-
TCursor extends string = Sequence,
|
|
19
|
-
> extends ReadArchivistFunctions<WithStorageMeta<TReadResponse>, TId, TCursor> {}
|
|
20
|
-
|
|
21
|
-
export interface WriteArchivist<
|
|
22
|
-
TReadResponse extends Payload = Payload,
|
|
23
|
-
TWriteResponse extends Payload = TReadResponse,
|
|
24
|
-
TWrite extends Payload = TReadResponse,
|
|
25
|
-
TId extends string = Hash,
|
|
26
|
-
> extends WriteArchivistFunctions<WithStorageMeta<TReadResponse>, WithStorageMeta<TWriteResponse>, TWrite, TId> {}
|
|
27
|
-
|
|
28
|
-
export interface ReadWriteArchivist<
|
|
29
|
-
TReadResponse extends Payload = Payload,
|
|
30
|
-
TWriteResponse extends Payload = TReadResponse,
|
|
31
|
-
TWrite extends Payload = TReadResponse,
|
|
32
|
-
TId extends string = Hash,
|
|
33
|
-
> extends WriteArchivist<TReadResponse, TWriteResponse, TWrite, TId>, ReadArchivist<TReadResponse, TId> {}
|
|
34
|
-
|
|
35
|
-
export interface StashArchivist<
|
|
36
|
-
TWriteResponse extends Payload = Payload,
|
|
37
|
-
> extends StashArchivistFunctions<WithStorageMeta<TWriteResponse>> {}
|
|
38
|
-
|
|
39
|
-
export interface FullArchivist<
|
|
40
|
-
TReadResponse extends Payload = Payload,
|
|
41
|
-
TWriteResponse extends Payload = TReadResponse,
|
|
42
|
-
TWrite extends Payload = TReadResponse,
|
|
43
|
-
TId extends string = Hash,
|
|
44
|
-
> extends ReadWriteArchivist<TReadResponse, TWriteResponse, TWrite, TId>, StashArchivist<TWriteResponse> {}
|
|
45
|
-
|
|
46
|
-
export interface Archivist<
|
|
47
|
-
TReadResponse extends Payload = Payload,
|
|
48
|
-
TWriteResponse extends Payload = Payload,
|
|
49
|
-
TWrite extends Payload = TReadResponse & Payload,
|
|
50
|
-
TId extends string = Hash,
|
|
51
|
-
TCursor extends string = Sequence,
|
|
52
|
-
> extends ReadArchivist<WithStorageMeta<TReadResponse>, TId, TCursor>,
|
|
53
|
-
AllArchivist<WithStorageMeta<TReadResponse>, TId>,
|
|
54
|
-
WriteArchivist<WithStorageMeta<TReadResponse>, WithStorageMeta<TWriteResponse>, TWrite, TId>,
|
|
55
|
-
StashArchivistFunctions<TWriteResponse> {}
|
package/src/Queries/All.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const ArchivistAllQuerySchema = asSchema('network.xyo.query.archivist.all', true)
|
|
4
|
-
export type ArchivistAllQuerySchema = typeof ArchivistAllQuerySchema
|
|
5
|
-
|
|
6
|
-
export type ArchivistAllQuery = Query<{
|
|
7
|
-
schema: ArchivistAllQuerySchema
|
|
8
|
-
}>
|
package/src/Queries/Clear.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const ArchivistClearQuerySchema = asSchema('network.xyo.query.archivist.clear', true)
|
|
4
|
-
export type ArchivistClearQuerySchema = typeof ArchivistClearQuerySchema
|
|
5
|
-
|
|
6
|
-
export type ArchivistClearQuery = Query<{
|
|
7
|
-
schema: ArchivistClearQuerySchema
|
|
8
|
-
}>
|
package/src/Queries/Commit.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const ArchivistCommitQuerySchema = asSchema('network.xyo.query.archivist.commit', true)
|
|
4
|
-
export type ArchivistCommitQuerySchema = typeof ArchivistCommitQuerySchema
|
|
5
|
-
|
|
6
|
-
export type ArchivistCommitQuery = Query<{
|
|
7
|
-
schema: ArchivistCommitQuerySchema
|
|
8
|
-
}>
|
package/src/Queries/Delete.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
3
|
-
|
|
4
|
-
export const ArchivistDeleteQuerySchema = asSchema('network.xyo.query.archivist.delete', true)
|
|
5
|
-
export type ArchivistDeleteQuerySchema = typeof ArchivistDeleteQuerySchema
|
|
6
|
-
|
|
7
|
-
export type ArchivistDeleteQuery = Query<{
|
|
8
|
-
hashes: Hash[]
|
|
9
|
-
schema: ArchivistDeleteQuerySchema
|
|
10
|
-
}>
|
package/src/Queries/Get.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
3
|
-
|
|
4
|
-
export const ArchivistGetQuerySchema = asSchema('network.xyo.query.archivist.get', true)
|
|
5
|
-
export type ArchivistGetQuerySchema = typeof ArchivistGetQuerySchema
|
|
6
|
-
|
|
7
|
-
export type ArchivistGetQuery = Query<{
|
|
8
|
-
hashes: Hash[]
|
|
9
|
-
schema: ArchivistGetQuerySchema
|
|
10
|
-
}>
|
package/src/Queries/Insert.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const ArchivistInsertQuerySchema = asSchema('network.xyo.query.archivist.insert', true)
|
|
4
|
-
export type ArchivistInsertQuerySchema = typeof ArchivistInsertQuerySchema
|
|
5
|
-
|
|
6
|
-
export type ArchivistInsertQuery = Query<{
|
|
7
|
-
schema: ArchivistInsertQuerySchema
|
|
8
|
-
}>
|
package/src/Queries/Next.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
import type { ArchivistNextOptions } from '../NextOptions.ts'
|
|
4
|
-
|
|
5
|
-
export const ArchivistNextQuerySchema = asSchema('network.xyo.query.archivist.next', true)
|
|
6
|
-
export type ArchivistNextQuerySchema = typeof ArchivistNextQuerySchema
|
|
7
|
-
|
|
8
|
-
export type ArchivistNextQuery = Query<ArchivistNextOptions, ArchivistNextQuerySchema>
|
package/src/Queries/Snapshot.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const ArchivistSnapshotQuerySchema = asSchema('network.xyo.query.archivist.snapshot', true)
|
|
4
|
-
export type ArchivistSnapshotQuerySchema = typeof ArchivistSnapshotQuerySchema
|
|
5
|
-
|
|
6
|
-
export type ArchivistSnapshotQuery = Query<{
|
|
7
|
-
schema: ArchivistSnapshotQuerySchema
|
|
8
|
-
}>
|
package/src/Queries/index.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export * from './All.ts'
|
|
2
|
-
export * from './Clear.ts'
|
|
3
|
-
export * from './Commit.ts'
|
|
4
|
-
export * from './Delete.ts'
|
|
5
|
-
export * from './Get.ts'
|
|
6
|
-
export * from './Insert.ts'
|
|
7
|
-
export * from './Next.ts'
|
|
8
|
-
export * from './Snapshot.ts'
|
|
9
|
-
|
|
10
|
-
import type { ModuleQueries } from '@xyo-network/module-model'
|
|
11
|
-
|
|
12
|
-
import type { ArchivistAllQuery } from './All.ts'
|
|
13
|
-
import type { ArchivistClearQuery } from './Clear.ts'
|
|
14
|
-
import type { ArchivistCommitQuery } from './Commit.ts'
|
|
15
|
-
import type { ArchivistDeleteQuery } from './Delete.ts'
|
|
16
|
-
import type { ArchivistGetQuery } from './Get.ts'
|
|
17
|
-
import type { ArchivistInsertQuery } from './Insert.ts'
|
|
18
|
-
import type { ArchivistNextQuery } from './Next.ts'
|
|
19
|
-
import type { ArchivistSnapshotQuery } from './Snapshot.ts'
|
|
20
|
-
|
|
21
|
-
export type ArchivistQueries
|
|
22
|
-
= | ArchivistAllQuery
|
|
23
|
-
| ArchivistClearQuery
|
|
24
|
-
| ArchivistCommitQuery
|
|
25
|
-
| ArchivistDeleteQuery
|
|
26
|
-
| ArchivistGetQuery
|
|
27
|
-
| ArchivistInsertQuery
|
|
28
|
-
| ArchivistNextQuery
|
|
29
|
-
| ArchivistSnapshotQuery
|
|
30
|
-
|
|
31
|
-
export type ArchivistModuleQueries = ModuleQueries | ArchivistQueries
|
package/src/RawQueryFunctions.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Hash, Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
import type { AccountInstance } from '@xyo-network/account-model'
|
|
3
|
-
import type { ModuleQueryResult } from '@xyo-network/module-model'
|
|
4
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
5
|
-
|
|
6
|
-
import type { ArchivistNextOptions } from './NextOptions.ts'
|
|
7
|
-
|
|
8
|
-
export interface ArchivistRawQueryFunctions {
|
|
9
|
-
allQuery(account?: AccountInstance): Promisable<ModuleQueryResult>
|
|
10
|
-
clearQuery(account?: AccountInstance): Promisable<ModuleQueryResult>
|
|
11
|
-
commitQuery(account?: AccountInstance): Promisable<ModuleQueryResult>
|
|
12
|
-
deleteQuery(hashes: Hash[], account?: AccountInstance): Promisable<ModuleQueryResult>
|
|
13
|
-
getQuery(hashes: Hash[], account?: AccountInstance): Promisable<ModuleQueryResult>
|
|
14
|
-
insertQuery(payloads: Payload[], account?: AccountInstance): Promisable<ModuleQueryResult>
|
|
15
|
-
nextQuery(options?: ArchivistNextOptions, account?: AccountInstance): Promisable<ModuleQueryResult>
|
|
16
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { TypeCheck } from '@xylabs/sdk-js'
|
|
2
|
-
import { IsObjectFactory } from '@xylabs/sdk-js'
|
|
3
|
-
import type { AttachableModuleInstance } from '@xyo-network/module-model'
|
|
4
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
5
|
-
|
|
6
|
-
import type { ArchivistModuleEventData } from '../EventData.ts'
|
|
7
|
-
import type { ArchivistInstance, ArchivistParams } from '../Instance.ts'
|
|
8
|
-
import type { ArchivistModuleInstance } from '../ModuleInstance.ts'
|
|
9
|
-
|
|
10
|
-
export interface AttachableArchivistInstance<
|
|
11
|
-
TParams extends ArchivistParams = ArchivistParams,
|
|
12
|
-
TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,
|
|
13
|
-
TPayload extends Payload = Payload,
|
|
14
|
-
> extends ArchivistModuleInstance<TParams, TEventData>,
|
|
15
|
-
AttachableModuleInstance<TParams, TEventData>,
|
|
16
|
-
ArchivistInstance<TParams, TEventData, TPayload> {}
|
|
17
|
-
|
|
18
|
-
export type AttachableArchivistInstanceTypeCheck<T extends AttachableArchivistInstance = AttachableArchivistInstance> = TypeCheck<T>
|
|
19
|
-
|
|
20
|
-
export class IsAttachableArchivistInstanceFactory<T extends AttachableArchivistInstance = AttachableArchivistInstance> extends IsObjectFactory<T> {}
|
package/src/attachable/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ObjectTypeShape, TypeCheck } from '@xylabs/sdk-js'
|
|
2
|
-
import { IsObjectFactory } from '@xylabs/sdk-js'
|
|
3
|
-
import { isAttachableModuleInstance } from '@xyo-network/module-model'
|
|
4
|
-
|
|
5
|
-
import { isArchivistInstance } from '../typeChecks.ts'
|
|
6
|
-
import type { AttachableArchivistInstance } from './AttachableInstance.ts'
|
|
7
|
-
|
|
8
|
-
export const requiredAttachableArchivistInstanceFunctions: ObjectTypeShape = {}
|
|
9
|
-
|
|
10
|
-
// we do not use IsInstanceFactory here to prevent a cycle
|
|
11
|
-
const factory = new IsObjectFactory<AttachableArchivistInstance>()
|
|
12
|
-
|
|
13
|
-
export const isAttachableArchivistInstance: TypeCheck<AttachableArchivistInstance> = factory.create(requiredAttachableArchivistInstanceFunctions, [
|
|
14
|
-
isArchivistInstance,
|
|
15
|
-
isAttachableModuleInstance,
|
|
16
|
-
])
|
package/src/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './ArchivistDriver.ts'
|
|
2
|
-
export * from './ArchivistFunctions.ts'
|
|
3
|
-
export * from './ArchivistSnapshot.ts'
|
|
4
|
-
export * from './ArchivistStats.ts'
|
|
5
|
-
export * from './attachable/index.ts'
|
|
6
|
-
export * from './Config.ts'
|
|
7
|
-
export * from './EventData.ts'
|
|
8
|
-
export * from './IndexDescription.ts'
|
|
9
|
-
export * from './Instance.ts'
|
|
10
|
-
export * from './Labels.ts'
|
|
11
|
-
export * from './lib/index.ts'
|
|
12
|
-
export * from './ModuleInstance.ts'
|
|
13
|
-
export * from './NextOptions.ts'
|
|
14
|
-
export * from './PayloadArchivist.ts'
|
|
15
|
-
export * from './Queries/index.ts'
|
|
16
|
-
export * from './RawQueryFunctions.ts'
|
|
17
|
-
export * from './typeChecks.ts'
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { BoundWitness, Signed } from '@xyo-network/boundwitness-model'
|
|
2
|
-
import type {
|
|
3
|
-
Payload, WithHashMeta, WithStorageMeta,
|
|
4
|
-
} from '@xyo-network/payload-model'
|
|
5
|
-
|
|
6
|
-
export type HydratedBoundWitness<T extends BoundWitness = BoundWitness, P extends Payload = Payload> = [T, P[]]
|
|
7
|
-
|
|
8
|
-
export type HydratedBoundWitnessWithHashMeta<T extends BoundWitness = BoundWitness, P extends Payload = Payload> = [WithHashMeta<T>, WithHashMeta<P>[]]
|
|
9
|
-
|
|
10
|
-
export type HydratedBoundWitnessWithStorageMeta<T extends BoundWitness = BoundWitness, P extends Payload = Payload> = [WithStorageMeta<T>, WithStorageMeta<P>[]]
|
|
11
|
-
|
|
12
|
-
export type SignedHydratedBoundWitness<T extends Signed<BoundWitness> = Signed<BoundWitness>, P extends Payload = Payload> = [T, P[]]
|
|
13
|
-
|
|
14
|
-
export type SignedHydratedBoundWitnessWithHashMeta<T extends Signed<BoundWitness> = Signed<BoundWitness>,
|
|
15
|
-
P extends Payload = Payload> = [WithHashMeta<T>, WithHashMeta<P>[]]
|
|
16
|
-
|
|
17
|
-
export type SignedHydratedBoundWitnessWithStorageMeta<T extends Signed<BoundWitness> = Signed<BoundWitness>,
|
|
18
|
-
P extends Payload = Payload> = [WithStorageMeta<T>, WithStorageMeta<P>[]]
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Hash, IdentityFunction } from '@xylabs/sdk-js'
|
|
2
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
3
|
-
import { type BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
4
|
-
import { isStorageMeta, type WithStorageMeta } from '@xyo-network/payload-model'
|
|
5
|
-
|
|
6
|
-
import type { ReadArchivist } from '../PayloadArchivist.ts'
|
|
7
|
-
|
|
8
|
-
export const tryGetTypedBoundWitnessWithStorageMeta = async <T extends BoundWitness>(archivist: ReadArchivist, hash: Hash,
|
|
9
|
-
identity: IdentityFunction<WithStorageMeta<T>>): Promise<WithStorageMeta<T> | undefined> => {
|
|
10
|
-
const payload = (await archivist.get([hash])).at(0)
|
|
11
|
-
return identity(payload) ? payload : undefined
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const getTypedBoundWitnessWithStorageMeta = async <T extends BoundWitness>(archivist: ReadArchivist, hash: Hash,
|
|
15
|
-
identity: IdentityFunction<WithStorageMeta<T>>): Promise<WithStorageMeta<T>> => {
|
|
16
|
-
const payload = assertEx((await archivist.get([hash])).at(0), () => `failed to locate bound witness: ${hash}`)
|
|
17
|
-
return assertEx(identity(payload) ? payload : undefined, () => `located payload failed identity check: ${hash}`)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const getBoundWitnessWithStorageMeta = (archivist: ReadArchivist, hash: Hash): Promise<WithStorageMeta<BoundWitness>> => {
|
|
21
|
-
return getTypedBoundWitnessWithStorageMeta<BoundWitness>(archivist, hash, x => isStorageMeta(x) && isBoundWitness(x))
|
|
22
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Hash, IdentityFunction } from '@xylabs/sdk-js'
|
|
2
|
-
import { exists, isHash } from '@xylabs/sdk-js'
|
|
3
|
-
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
4
|
-
import { isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
5
|
-
import { isStorageMeta, type WithStorageMeta } from '@xyo-network/payload-model'
|
|
6
|
-
|
|
7
|
-
import type { ReadArchivist } from '../PayloadArchivist.ts'
|
|
8
|
-
import { getTypedBoundWitnessWithStorageMeta, tryGetTypedBoundWitnessWithStorageMeta } from './getBoundWitness.ts'
|
|
9
|
-
import type { HydratedBoundWitness } from './HydratedBoundWitness.ts'
|
|
10
|
-
|
|
11
|
-
export const tryHydrateTypedBoundWitness = async <T extends BoundWitness>(archivist: ReadArchivist, hashOrBw: Hash | WithStorageMeta<T>,
|
|
12
|
-
identity: IdentityFunction<WithStorageMeta<T>>): Promise<HydratedBoundWitness<T> | undefined> => {
|
|
13
|
-
const bw = isHash(hashOrBw) ? await tryGetTypedBoundWitnessWithStorageMeta(archivist, hashOrBw, identity) : hashOrBw
|
|
14
|
-
return bw ? [bw, (await archivist.get(bw?.payload_hashes as Hash[])).filter(exists)] : undefined
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const hydrateTypedBoundWitness = async <T extends BoundWitness>(archivist: ReadArchivist, hashOrBw: Hash | WithStorageMeta<T>,
|
|
18
|
-
identity: IdentityFunction<WithStorageMeta<T>>): Promise<HydratedBoundWitness<T>> => {
|
|
19
|
-
const bw = isHash(hashOrBw) ? await getTypedBoundWitnessWithStorageMeta(archivist, hashOrBw, identity) : hashOrBw
|
|
20
|
-
const payloads = (await archivist.get(bw?.payload_hashes as Hash[])).filter(exists)
|
|
21
|
-
if (payloads.length !== bw.payload_hashes.length) {
|
|
22
|
-
throw new Error(`missing payloads for ${bw._hash}`)
|
|
23
|
-
}
|
|
24
|
-
return [bw, payloads]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const hydrateBoundWitness = (
|
|
28
|
-
archivist: ReadArchivist,
|
|
29
|
-
hashOrBw: Hash | WithStorageMeta<BoundWitness>,
|
|
30
|
-
): Promise<HydratedBoundWitness<BoundWitness>> => {
|
|
31
|
-
const idFunction: IdentityFunction<WithStorageMeta<BoundWitness>> = x => isBoundWitness(x) && isStorageMeta(x)
|
|
32
|
-
return hydrateTypedBoundWitness<BoundWitness>(archivist, hashOrBw, idFunction)
|
|
33
|
-
}
|
package/src/lib/index.ts
DELETED
package/src/typeChecks.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { TypeCheck } from '@xylabs/sdk-js'
|
|
2
|
-
import { AsObjectFactory } from '@xylabs/sdk-js'
|
|
3
|
-
import {
|
|
4
|
-
// eslint-disable-next-line sonarjs/deprecation
|
|
5
|
-
IsInstanceFactory, isModuleInstance, IsQueryableModuleFactory, WithFactory,
|
|
6
|
-
} from '@xyo-network/module-model'
|
|
7
|
-
|
|
8
|
-
import type { ArchivistInstance } from './Instance.ts'
|
|
9
|
-
import type { ArchivistModuleInstance } from './ModuleInstance.ts'
|
|
10
|
-
import { ArchivistGetQuerySchema } from './Queries/index.ts'
|
|
11
|
-
|
|
12
|
-
export const isArchivistInstance: TypeCheck<ArchivistInstance> = new IsInstanceFactory<ArchivistInstance>().create({ get: 'function' }, [isModuleInstance])
|
|
13
|
-
export const isArchivistModule: TypeCheck<ArchivistModuleInstance> = new IsQueryableModuleFactory<ArchivistModuleInstance>().create([ArchivistGetQuerySchema])
|
|
14
|
-
|
|
15
|
-
export const asArchivistModule = AsObjectFactory.create(isArchivistModule)
|
|
16
|
-
export const asArchivistInstance = AsObjectFactory.create(isArchivistInstance)
|
|
17
|
-
|
|
18
|
-
/** @deprecated use narrowing instead [ if(is) ] */
|
|
19
|
-
// eslint-disable-next-line sonarjs/deprecation, @typescript-eslint/no-deprecated
|
|
20
|
-
export const withArchivistModule = WithFactory.create(isArchivistModule)
|
|
21
|
-
/** @deprecated use narrowing instead [ if(is) ] */
|
|
22
|
-
// eslint-disable-next-line sonarjs/deprecation, @typescript-eslint/no-deprecated
|
|
23
|
-
export const withArchivistInstance = WithFactory.create(isArchivistInstance)
|