@xyo-network/module-model 5.3.20 → 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/dist/neutral/Payload/Address.d.ts +1 -1
- package/dist/neutral/Payload/Address.d.ts.map +1 -1
- package/dist/neutral/Payload/ModuleState.d.ts +1 -1
- package/dist/neutral/Payload/ModuleState.d.ts.map +1 -1
- package/package.json +24 -14
- package/src/Config/Archiving.ts +0 -10
- package/src/Config/Config.ts +0 -29
- package/src/Config/Fields.ts +0 -47
- package/src/Config/Reentrancy.ts +0 -6
- package/src/Config/Security.ts +0 -15
- package/src/Config/index.ts +0 -5
- package/src/CreatableModule/CreatableModule.ts +0 -42
- package/src/CreatableModule/CreatableModuleRegistry.ts +0 -102
- package/src/CreatableModule/LabeledCreatableModule.ts +0 -20
- package/src/CreatableModule/LabeledCreatableModuleFactory.ts +0 -21
- package/src/CreatableModule/ModuleFactory.ts +0 -60
- package/src/CreatableModule/index.ts +0 -5
- package/src/DetailsError.ts +0 -13
- package/src/EventsModels/ModuleBusy.ts +0 -14
- package/src/EventsModels/ModuleError.ts +0 -14
- package/src/EventsModels/ModuleEventArgs.ts +0 -9
- package/src/EventsModels/ModuleEventData.ts +0 -8
- package/src/EventsModels/ModuleQueried.ts +0 -19
- package/src/EventsModels/index.ts +0 -5
- package/src/Labels/Labels.ts +0 -33
- package/src/Labels/index.ts +0 -2
- package/src/Labels/standard/View.ts +0 -4
- package/src/Labels/standard/index.ts +0 -1
- package/src/ModuleDescription.ts +0 -9
- package/src/ModuleFactoryLocatorInstance.ts +0 -47
- package/src/ModuleIdentifier.ts +0 -69
- package/src/ModuleIdentifierTransformer.ts +0 -9
- package/src/ModuleQueryHandlerResult.ts +0 -3
- package/src/ModuleQueryResult.ts +0 -8
- package/src/ModuleStatusReporter.ts +0 -3
- package/src/Payload/Address.ts +0 -37
- package/src/Payload/AddressPreviousHash.ts +0 -13
- package/src/Payload/Description.ts +0 -8
- package/src/Payload/ModuleState.ts +0 -29
- package/src/Payload/index.ts +0 -4
- package/src/Queries/Manifest.ts +0 -9
- package/src/Queries/ModuleAddress/Query.ts +0 -8
- package/src/Queries/ModuleAddress/index.ts +0 -1
- package/src/Queries/State.ts +0 -6
- package/src/Queries/Subscribe.ts +0 -21
- package/src/Queries/index.ts +0 -11
- package/src/QueryableModule/IsQueryableModuleFactory.ts +0 -34
- package/src/QueryableModule/QueryableModule.ts +0 -14
- package/src/QueryableModule/QueryableModuleFields.ts +0 -37
- package/src/QueryableModule/QueryableModuleFunctions.ts +0 -18
- package/src/QueryableModule/QueryableModuleParams.ts +0 -20
- package/src/QueryableModule/asQueryableModule.ts +0 -8
- package/src/QueryableModule/asQueryableModuleObject.ts +0 -8
- package/src/QueryableModule/index.ts +0 -9
- package/src/QueryableModule/isQueryableModule.ts +0 -20
- package/src/QueryableModule/isQueryableModuleObject.ts +0 -20
- package/src/ResolveHelper/ResolveHelper.ts +0 -213
- package/src/ResolveHelper/ResolveHelperStatic.ts +0 -9
- package/src/ResolveHelper/index.ts +0 -9
- package/src/ResolveHelper/model.ts +0 -1
- package/src/ResolveHelper/resolveAddressToInstance.ts +0 -94
- package/src/ResolveHelper/resolveAll.ts +0 -53
- package/src/ResolveHelper/resolveLocalNameToAddress.ts +0 -40
- package/src/ResolveHelper/resolveLocalNameToInstance.ts +0 -47
- package/src/ResolveHelper/resolvePathToAddress.ts +0 -15
- package/src/ResolveHelper/resolvePathToInstance.ts +0 -36
- package/src/ResolveHelper/traceModuleIdentifier.ts +0 -19
- package/src/ResolveHelper/transformModuleIdentifier.ts +0 -13
- package/src/cache.ts +0 -5
- package/src/index.ts +0 -20
- package/src/instance/Instance.ts +0 -68
- package/src/instance/ModuleFilter.ts +0 -33
- package/src/instance/ModuleInstanceParams.ts +0 -11
- package/src/instance/ModuleRepository.ts +0 -12
- package/src/instance/ModuleResolver.ts +0 -21
- package/src/instance/ObjectFilter.ts +0 -48
- package/src/instance/ObjectResolver.ts +0 -40
- package/src/instance/asModuleInstance.ts +0 -5
- package/src/instance/attachable/AttachableInstance.ts +0 -25
- package/src/instance/attachable/asAttachableInstance.ts +0 -5
- package/src/instance/attachable/index.ts +0 -3
- package/src/instance/attachable/isAttachableInstance.ts +0 -17
- package/src/instance/index.ts +0 -10
- package/src/instance/isModuleInstance.ts +0 -15
- package/src/lib/duplicateModules.ts +0 -14
- package/src/lib/index.ts +0 -2
- package/src/lib/serializable.ts +0 -30
- package/src/withModule.ts +0 -15
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { Schema } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
CreatableModuleFactory, CreatableModuleRegistry, LabeledCreatableModuleFactory,
|
|
5
|
-
} from './CreatableModule/index.ts'
|
|
6
|
-
import type { Labels } from './Labels/index.ts'
|
|
7
|
-
|
|
8
|
-
export interface ModuleFactoryLocatorInstance {
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The current registry for the module factory
|
|
12
|
-
*/
|
|
13
|
-
registry: Readonly<CreatableModuleRegistry>
|
|
14
|
-
|
|
15
|
-
freeze(): void
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Locates a module factory that matches the supplied schema and labels
|
|
19
|
-
* @param schema The config schema for the module
|
|
20
|
-
* @param labels The labels for the module factory
|
|
21
|
-
* @returns A module factory that matches the supplied schema and labels or throws if one is not found
|
|
22
|
-
*/
|
|
23
|
-
locate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory
|
|
24
|
-
|
|
25
|
-
merge(locator: ModuleFactoryLocatorInstance): ModuleFactoryLocatorInstance
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Registers a single module factory (with optional tags) with the locator
|
|
29
|
-
* @param factory The factory to register
|
|
30
|
-
* @param labels The labels for the module factory
|
|
31
|
-
*/
|
|
32
|
-
register(factory: CreatableModuleFactory, labels?: Labels, primary?: boolean | Schema | Schema[]): ModuleFactoryLocatorInstance
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Registers multiple module factories with the locator
|
|
36
|
-
* @param factories The factories to register
|
|
37
|
-
*/
|
|
38
|
-
registerMany(factories: CreatableModuleFactory[]): ModuleFactoryLocatorInstance
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Tries to locate a module factory that matches the supplied schema and labels
|
|
42
|
-
* @param schema The config schema for the module
|
|
43
|
-
* @param labels The labels for the module factory
|
|
44
|
-
* @returns A module factory that matches the supplied schema and labels or undefined
|
|
45
|
-
*/
|
|
46
|
-
tryLocate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined
|
|
47
|
-
}
|
package/src/ModuleIdentifier.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { Address } from '@xylabs/sdk-js'
|
|
2
|
-
import { isAddress } from '@xylabs/sdk-js'
|
|
3
|
-
|
|
4
|
-
export const MODULE_PATH_SEPARATOR = ':' as const
|
|
5
|
-
|
|
6
|
-
export const DisallowedModuleIdentifierCharacters = {
|
|
7
|
-
' ': true,
|
|
8
|
-
'!': true,
|
|
9
|
-
'"': true,
|
|
10
|
-
'#': true,
|
|
11
|
-
'$': true,
|
|
12
|
-
'%': true,
|
|
13
|
-
'&': true,
|
|
14
|
-
"'": true,
|
|
15
|
-
'(': true,
|
|
16
|
-
')': true,
|
|
17
|
-
'*': true,
|
|
18
|
-
',': true,
|
|
19
|
-
'.': true,
|
|
20
|
-
'/': true,
|
|
21
|
-
':': true,
|
|
22
|
-
';': true,
|
|
23
|
-
'<': true,
|
|
24
|
-
'=': true,
|
|
25
|
-
'>': true,
|
|
26
|
-
'?': true,
|
|
27
|
-
'@': true,
|
|
28
|
-
'[': true,
|
|
29
|
-
']': true,
|
|
30
|
-
'^': true,
|
|
31
|
-
'_': true,
|
|
32
|
-
'{': true,
|
|
33
|
-
'|': true,
|
|
34
|
-
'}': true,
|
|
35
|
-
'~': true,
|
|
36
|
-
}
|
|
37
|
-
export type ReservedModuleIdentifierCharacter = keyof typeof DisallowedModuleIdentifierCharacters
|
|
38
|
-
export const ReservedModuleIdentifierCharacters = new Set<ReservedModuleIdentifierCharacter>(
|
|
39
|
-
Object.keys(DisallowedModuleIdentifierCharacters) as ReservedModuleIdentifierCharacter[],
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
// TODO: Use Brand, but avoid too complex error
|
|
43
|
-
// export type ModuleName = Brand<string, { __moduleName: true }>
|
|
44
|
-
export type ModuleName = string
|
|
45
|
-
|
|
46
|
-
export type ModuleIdentifier
|
|
47
|
-
= | ColonPair<ModuleIdentifierPart>
|
|
48
|
-
| ColonPair<ColonPair<ModuleIdentifierPart>>
|
|
49
|
-
| ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>
|
|
50
|
-
| ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>
|
|
51
|
-
| ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>>
|
|
52
|
-
| ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>>>
|
|
53
|
-
| ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>>>>
|
|
54
|
-
|
|
55
|
-
export type ColonPair<T extends string> = `${T}:${T}` | T
|
|
56
|
-
|
|
57
|
-
export type ModuleIdentifierPart = Exclude<Address | ModuleName, '*'>
|
|
58
|
-
|
|
59
|
-
export const isModuleName = (value: unknown): value is ModuleName => {
|
|
60
|
-
return typeof value === 'string' && !isAddress(value) && !includesReservedModuleIdentifierCharacter(value)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const includesReservedModuleIdentifierCharacter = (value: unknown): boolean => {
|
|
64
|
-
return typeof value === 'string' && [...value].some(char => ReservedModuleIdentifierCharacters.has(char as ReservedModuleIdentifierCharacter))
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export const isModuleIdentifierPart = (value: unknown): value is ModuleIdentifierPart => {
|
|
68
|
-
return isModuleName(value) || isAddress(value)
|
|
69
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
import type { ModuleIdentifier } from './ModuleIdentifier.ts'
|
|
4
|
-
|
|
5
|
-
export type ModuleIdentifierTransformerFunc = (id: ModuleIdentifier) => Promisable<ModuleIdentifier | undefined>
|
|
6
|
-
|
|
7
|
-
export interface ModuleIdentifierTransformer {
|
|
8
|
-
transform: ModuleIdentifierTransformerFunc
|
|
9
|
-
}
|
package/src/ModuleQueryResult.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
2
|
-
import type { ModuleError, Payload } from '@xyo-network/payload-model'
|
|
3
|
-
|
|
4
|
-
export type ModuleQueryResult<P extends Payload = Payload, E extends ModuleError = ModuleError, B extends BoundWitness = BoundWitness> = [
|
|
5
|
-
B,
|
|
6
|
-
P[],
|
|
7
|
-
E[],
|
|
8
|
-
]
|
package/src/Payload/Address.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Address } from '@xylabs/sdk-js'
|
|
2
|
-
import { AsObjectFactory } from '@xylabs/sdk-js'
|
|
3
|
-
import {
|
|
4
|
-
asSchema, isPayloadOfSchemaType, type Payload,
|
|
5
|
-
} from '@xyo-network/payload-model'
|
|
6
|
-
|
|
7
|
-
export const AddressSchema = asSchema('network.xyo.address', true)
|
|
8
|
-
export type AddressSchema = typeof AddressSchema
|
|
9
|
-
|
|
10
|
-
export const AddressChildSchema = asSchema('network.xyo.address.child', true)
|
|
11
|
-
export type AddressChildSchema = typeof AddressChildSchema
|
|
12
|
-
|
|
13
|
-
export interface AddressFields {
|
|
14
|
-
address: Address
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type AddressPayload = Payload<AddressFields, AddressSchema>
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Identity function for determining if an object is an Address
|
|
21
|
-
*/
|
|
22
|
-
export const isAddressPayload = isPayloadOfSchemaType<AddressPayload>(AddressSchema)
|
|
23
|
-
export const asAddressPayload = AsObjectFactory.create(isAddressPayload)
|
|
24
|
-
export const asOptionalAddressPayload = AsObjectFactory.createOptional(isAddressPayload)
|
|
25
|
-
|
|
26
|
-
export interface AddressChildFields extends AddressFields {
|
|
27
|
-
/**
|
|
28
|
-
* The derivation path of the child address
|
|
29
|
-
*/
|
|
30
|
-
path?: string
|
|
31
|
-
/**
|
|
32
|
-
* The public address of the root of the hierarchy
|
|
33
|
-
*/
|
|
34
|
-
root?: Address
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type AddressChildPayload = Payload<AddressChildFields, AddressChildSchema>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Address } from '@xylabs/sdk-js'
|
|
2
|
-
import { asSchema, type Payload } from '@xyo-network/payload-model'
|
|
3
|
-
|
|
4
|
-
export const AddressPreviousHashSchema = asSchema('network.xyo.address.hash.previous', true)
|
|
5
|
-
export type AddressPreviousHashSchema = typeof AddressPreviousHashSchema
|
|
6
|
-
|
|
7
|
-
export type AddressPreviousHashPayload = Payload<
|
|
8
|
-
{
|
|
9
|
-
address: Address
|
|
10
|
-
previousHash?: string
|
|
11
|
-
},
|
|
12
|
-
AddressPreviousHashSchema
|
|
13
|
-
>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Payload } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
import type { ModuleDescription } from '../ModuleDescription.ts'
|
|
4
|
-
|
|
5
|
-
export const ModuleDescriptionSchema = asSchema('network.xyo.module.description', true)
|
|
6
|
-
export type ModuleDescriptionSchema = typeof ModuleDescriptionSchema
|
|
7
|
-
|
|
8
|
-
export type ModuleDescriptionPayload = Payload<ModuleDescription, ModuleDescriptionSchema>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AsObjectFactory } from '@xylabs/sdk-js'
|
|
2
|
-
import type { Payload, WithSources } from '@xyo-network/payload-model'
|
|
3
|
-
import {
|
|
4
|
-
asSchema, isPayloadOfSchemaType, isPayloadOfSchemaTypeWithSources,
|
|
5
|
-
} from '@xyo-network/payload-model'
|
|
6
|
-
|
|
7
|
-
export interface StateDictionary {
|
|
8
|
-
[key: string]: string | number
|
|
9
|
-
}
|
|
10
|
-
export interface State<T extends StateDictionary = StateDictionary> {
|
|
11
|
-
state: T
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const ModuleStateSchema = asSchema('network.xyo.module.state', true)
|
|
15
|
-
export type ModuleStateSchema = typeof ModuleStateSchema
|
|
16
|
-
|
|
17
|
-
export type ModuleState<T extends StateDictionary = StateDictionary> = Payload<State<T>, ModuleStateSchema>
|
|
18
|
-
|
|
19
|
-
export const isModuleState = <T extends StateDictionary = StateDictionary, TInput = unknown>(payload?: TInput): payload is ModuleState<T> & TInput => {
|
|
20
|
-
return isPayloadOfSchemaType<ModuleState<T>>(ModuleStateSchema)(payload)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const isModuleStateWithSources = <T extends StateDictionary = StateDictionary,
|
|
24
|
-
TInput = unknown>(payload?: TInput): payload is WithSources<ModuleState<T>> & TInput => {
|
|
25
|
-
return isPayloadOfSchemaTypeWithSources<ModuleState<T>>(ModuleStateSchema)(payload)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const asModuleState = AsObjectFactory.create<ModuleState<StateDictionary>>(isModuleState)
|
|
29
|
-
export const asOptionalModuleState = AsObjectFactory.createOptional<ModuleState<StateDictionary>>(isModuleState)
|
package/src/Payload/index.ts
DELETED
package/src/Queries/Manifest.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const ModuleManifestQuerySchema = asSchema('network.xyo.query.module.manifest', true)
|
|
4
|
-
export type ModuleManifestQuerySchema = typeof ModuleManifestQuerySchema
|
|
5
|
-
|
|
6
|
-
export type ModuleManifestQuery = Query<{
|
|
7
|
-
maxDepth?: number
|
|
8
|
-
schema: ModuleManifestQuerySchema
|
|
9
|
-
}>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const ModuleAddressQuerySchema = asSchema('network.xyo.query.module.address', true)
|
|
4
|
-
export type ModuleAddressQuerySchema = typeof ModuleAddressQuerySchema
|
|
5
|
-
|
|
6
|
-
export type ModuleAddressQuery = Query<{
|
|
7
|
-
schema: ModuleAddressQuerySchema
|
|
8
|
-
}>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Query.ts'
|
package/src/Queries/State.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const ModuleStateQuerySchema = asSchema('network.xyo.query.module.state', true)
|
|
4
|
-
export type ModuleStateQuerySchema = typeof ModuleStateQuerySchema
|
|
5
|
-
|
|
6
|
-
export type ModuleStateQuery = Query<void, ModuleStateQuerySchema>
|
package/src/Queries/Subscribe.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Address } from '@xylabs/sdk-js'
|
|
2
|
-
import { asSchema, type Query } from '@xyo-network/payload-model'
|
|
3
|
-
|
|
4
|
-
export const ModuleSubscribeQuerySchema = asSchema('network.xyo.query.module.subscribe', true)
|
|
5
|
-
export type ModuleSubscribeQuerySchema = typeof ModuleSubscribeQuerySchema
|
|
6
|
-
|
|
7
|
-
export interface ModuleSubscribeFilter {
|
|
8
|
-
/** @field if specified, at least one of the schemas must be present in the boundwtness to generate a notification */
|
|
9
|
-
schema?: string[]
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// requests notification when a boundwitness is added to the modules chain that meets the filter criteria
|
|
13
|
-
export type ModuleSubscribeQuery = Query<{
|
|
14
|
-
/** @field The address that will receive notifications */
|
|
15
|
-
address: Address
|
|
16
|
-
/** @field A subscribe with a null for filter is an unsubscribe */
|
|
17
|
-
filter?: ModuleSubscribeFilter | null
|
|
18
|
-
/** @field The maximum events queued per send [may increase frequency] */
|
|
19
|
-
maxQueue?: number
|
|
20
|
-
schema: ModuleSubscribeQuerySchema
|
|
21
|
-
}>
|
package/src/Queries/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ModuleManifestQuery } from './Manifest.ts'
|
|
2
|
-
import type { ModuleAddressQuery } from './ModuleAddress/index.ts'
|
|
3
|
-
import type { ModuleStateQuery } from './State.ts'
|
|
4
|
-
import type { ModuleSubscribeQuery } from './Subscribe.ts'
|
|
5
|
-
|
|
6
|
-
export * from './Manifest.ts'
|
|
7
|
-
export * from './ModuleAddress/index.ts'
|
|
8
|
-
export * from './State.ts'
|
|
9
|
-
export * from './Subscribe.ts'
|
|
10
|
-
|
|
11
|
-
export type ModuleQueries = ModuleAddressQuery | ModuleSubscribeQuery | ModuleManifestQuery | ModuleStateQuery
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnyNonPromise,
|
|
3
|
-
AnyObject, EmptyObject, TypeCheck,
|
|
4
|
-
TypeCheckConfig,
|
|
5
|
-
} from '@xylabs/sdk-js'
|
|
6
|
-
|
|
7
|
-
import { asQueryableModuleObject } from './asQueryableModuleObject.ts'
|
|
8
|
-
import { isQueryableModuleObject } from './isQueryableModuleObject.ts'
|
|
9
|
-
import type { QueryableModule } from './QueryableModule.ts'
|
|
10
|
-
|
|
11
|
-
export type QueryableModuleTypeCheck<T extends QueryableModule = QueryableModule> = TypeCheck<T>
|
|
12
|
-
|
|
13
|
-
/** @deprecated use QueryableModuleTypeCheck instead */
|
|
14
|
-
export type ModuleTypeCheck<T extends QueryableModule = QueryableModule> = TypeCheck<T>
|
|
15
|
-
|
|
16
|
-
export class IsQueryableModuleFactory<T extends QueryableModule = QueryableModule> {
|
|
17
|
-
create(expectedQueries?: string[], additionalChecks?: TypeCheck<AnyObject | EmptyObject>[]): QueryableModuleTypeCheck<T> {
|
|
18
|
-
const result = (obj: AnyNonPromise, config?: TypeCheckConfig | number): obj is T => {
|
|
19
|
-
const mod = asQueryableModuleObject(obj)
|
|
20
|
-
return (
|
|
21
|
-
isQueryableModuleObject(mod, config)
|
|
22
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
23
|
-
&& (expectedQueries?.reduce((prev, query) => prev && mod.queries.includes(query), true) ?? true)
|
|
24
|
-
// perform additional checks
|
|
25
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
26
|
-
&& (additionalChecks?.reduce((prev, check) => prev && check(obj, config), true) ?? true)
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
return result
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** @deprecated use IsQueryableModuleFactory instead */
|
|
34
|
-
export class IsModuleFactory<T extends QueryableModule = QueryableModule> extends IsQueryableModuleFactory<T> {}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CreatableInstance } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
import type { ModuleEventData } from '../EventsModels/index.ts'
|
|
4
|
-
import type { QueryableModuleFields } from './QueryableModuleFields.ts'
|
|
5
|
-
import type { QueryableModuleParams } from './QueryableModuleParams.ts'
|
|
6
|
-
|
|
7
|
-
export interface QueryableModule<TParams extends QueryableModuleParams = QueryableModuleParams,
|
|
8
|
-
TEventData extends ModuleEventData<object> = ModuleEventData<object>>
|
|
9
|
-
extends QueryableModuleFields<TParams>, CreatableInstance<TParams, TEventData> {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** @deprecated use QueryableModule instead */
|
|
13
|
-
export interface Module<TParams extends QueryableModuleParams = QueryableModuleParams, TEventData extends ModuleEventData<object> = ModuleEventData<object>>
|
|
14
|
-
extends QueryableModule<TParams, TEventData> {}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Address, Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
import type { QueryBoundWitness } from '@xyo-network/boundwitness-model'
|
|
3
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
-
|
|
5
|
-
import type { ModuleConfig } from '../Config/index.ts'
|
|
6
|
-
import type { ModuleName } from '../ModuleIdentifier.ts'
|
|
7
|
-
import type { ModuleQueryResult } from '../ModuleQueryResult.ts'
|
|
8
|
-
import type { QueryableModuleParams } from './QueryableModuleParams.ts'
|
|
9
|
-
|
|
10
|
-
export interface QueryableModuleFields<TParams extends QueryableModuleParams = QueryableModuleParams> {
|
|
11
|
-
address: Address
|
|
12
|
-
config: TParams['config']
|
|
13
|
-
|
|
14
|
-
/** The name (if specified) or address of the module */
|
|
15
|
-
id: string
|
|
16
|
-
|
|
17
|
-
modName?: ModuleName
|
|
18
|
-
|
|
19
|
-
params: TParams
|
|
20
|
-
|
|
21
|
-
previousHash: () => Promisable<string | undefined>
|
|
22
|
-
|
|
23
|
-
queries: string[]
|
|
24
|
-
query: <T extends QueryBoundWitness = QueryBoundWitness, TConf extends ModuleConfig = ModuleConfig>(
|
|
25
|
-
query: T,
|
|
26
|
-
payloads?: Payload[],
|
|
27
|
-
queryConfig?: TConf,
|
|
28
|
-
) => Promisable<ModuleQueryResult>
|
|
29
|
-
queryable: <T extends QueryBoundWitness = QueryBoundWitness, TConf extends ModuleConfig = ModuleConfig>(
|
|
30
|
-
query: T,
|
|
31
|
-
payloads?: Payload[],
|
|
32
|
-
queryConfig?: TConf,
|
|
33
|
-
) => Promisable<boolean>
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** @deprecated use QueryableModuleFields instead */
|
|
37
|
-
export interface ModuleFields<TParams extends QueryableModuleParams = QueryableModuleParams> extends QueryableModuleFields<TParams> {}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Address, Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
import type { AccountInstance } from '@xyo-network/account-model'
|
|
3
|
-
import type { ModuleManifestPayload } from '@xyo-network/manifest-model'
|
|
4
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
5
|
-
|
|
6
|
-
import type { ModuleQueryResult } from '../ModuleQueryResult.ts'
|
|
7
|
-
import type { AddressPayload, AddressPreviousHashPayload } from '../Payload/index.ts'
|
|
8
|
-
|
|
9
|
-
export interface QueryableModuleFunctions {
|
|
10
|
-
manifest: (maxDepth?: number, ignoreAddresses?: Address[]) => Promisable<ModuleManifestPayload>
|
|
11
|
-
manifestQuery: (account: AccountInstance, maxDepth?: number, ignoreAddresses?: Address[]) => Promisable<ModuleQueryResult<ModuleManifestPayload>>
|
|
12
|
-
moduleAddress: () => Promisable<(AddressPreviousHashPayload | AddressPayload)[]>
|
|
13
|
-
state: () => Promisable<Payload[]>
|
|
14
|
-
stateQuery: (account: AccountInstance) => Promisable<ModuleQueryResult>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** @deprecated use QueryableModuleFunctions instead */
|
|
18
|
-
export interface ModuleQueryFunctions extends QueryableModuleFunctions {}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { CreatableParams } from '@xylabs/sdk-js'
|
|
2
|
-
import type { AccountInstance } from '@xyo-network/account-model'
|
|
3
|
-
|
|
4
|
-
import type { AnyConfigSchema, ModuleConfig } from '../Config/index.ts'
|
|
5
|
-
import type { ModuleIdentifierTransformer } from '../ModuleIdentifierTransformer.ts'
|
|
6
|
-
import type { ModuleStatusReporter } from '../ModuleStatusReporter.ts'
|
|
7
|
-
|
|
8
|
-
export interface QueryableModuleParams<TConfig extends AnyConfigSchema<ModuleConfig> = AnyConfigSchema<ModuleConfig>> extends CreatableParams {
|
|
9
|
-
account?: AccountInstance | 'random'
|
|
10
|
-
addToResolvers?: boolean
|
|
11
|
-
additionalSigners?: AccountInstance[]
|
|
12
|
-
allowNameResolution?: boolean
|
|
13
|
-
config: Partial<TConfig>
|
|
14
|
-
ephemeralQueryAccountEnabled?: boolean
|
|
15
|
-
moduleIdentifierTransformers?: ModuleIdentifierTransformer[]
|
|
16
|
-
statusReporter?: ModuleStatusReporter
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** @deprecated use QueryableModuleParams instead */
|
|
20
|
-
export interface ModuleParams<TConfig extends AnyConfigSchema<ModuleConfig> = AnyConfigSchema<ModuleConfig>> extends QueryableModuleParams<TConfig> {}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AsObjectFactory } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
import { isQueryableModule } from './isQueryableModule.ts'
|
|
4
|
-
|
|
5
|
-
export const asQueryableModule = AsObjectFactory.create(isQueryableModule)
|
|
6
|
-
|
|
7
|
-
/** @deprecated use asQueryableModule instead */
|
|
8
|
-
export const asModule = asQueryableModule
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AsObjectFactory } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
import { isQueryableModuleObject } from './isQueryableModuleObject.ts'
|
|
4
|
-
|
|
5
|
-
export const asQueryableModuleObject = AsObjectFactory.create(isQueryableModuleObject)
|
|
6
|
-
|
|
7
|
-
/** @deprecated use asQueryableModuleObject instead */
|
|
8
|
-
export const asModuleObject = asQueryableModuleObject
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './asQueryableModule.ts'
|
|
2
|
-
export * from './asQueryableModuleObject.ts'
|
|
3
|
-
export * from './isQueryableModule.ts'
|
|
4
|
-
export * from './IsQueryableModuleFactory.ts'
|
|
5
|
-
export * from './isQueryableModuleObject.ts'
|
|
6
|
-
export * from './QueryableModule.ts'
|
|
7
|
-
export * from './QueryableModuleFields.ts'
|
|
8
|
-
export * from './QueryableModuleFunctions.ts'
|
|
9
|
-
export * from './QueryableModuleParams.ts'
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { TypeCheck } from '@xylabs/sdk-js'
|
|
2
|
-
import type { Schema } from '@xyo-network/payload-model'
|
|
3
|
-
|
|
4
|
-
import { ModuleStateQuerySchema } from '../Queries/index.ts'
|
|
5
|
-
import { IsQueryableModuleFactory } from './IsQueryableModuleFactory.ts'
|
|
6
|
-
import { isQueryableModuleObject } from './isQueryableModuleObject.ts'
|
|
7
|
-
import type { QueryableModule } from './QueryableModule.ts'
|
|
8
|
-
|
|
9
|
-
export const requiredQueryableModuleQueries: Schema[] = [ModuleStateQuerySchema]
|
|
10
|
-
|
|
11
|
-
/** @deprecated use requiredQueryableModuleQueries instead */
|
|
12
|
-
export const requiredModuleQueries: Schema[] = requiredQueryableModuleQueries
|
|
13
|
-
|
|
14
|
-
// we do not use IsInstanceFactory here to prevent a cycle
|
|
15
|
-
const factory = new IsQueryableModuleFactory<QueryableModule>()
|
|
16
|
-
|
|
17
|
-
export const isQueryableModule: TypeCheck<QueryableModule> = factory.create(requiredQueryableModuleQueries, [isQueryableModuleObject])
|
|
18
|
-
|
|
19
|
-
/** @deprecated use isQueryableModule instead */
|
|
20
|
-
export const isModule: TypeCheck<QueryableModule> = isQueryableModule
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ObjectTypeShape, TypeCheck } from '@xylabs/sdk-js'
|
|
2
|
-
import { IsObjectFactory } from '@xylabs/sdk-js'
|
|
3
|
-
|
|
4
|
-
import type { QueryableModule } from './QueryableModule.ts'
|
|
5
|
-
|
|
6
|
-
export const requiredQueryableModuleShape: ObjectTypeShape = {
|
|
7
|
-
address: 'string',
|
|
8
|
-
queries: 'array',
|
|
9
|
-
query: 'function',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** @deprecated use requiredQueryableModuleShape instead */
|
|
13
|
-
export const requiredModuleShape: ObjectTypeShape = requiredQueryableModuleShape
|
|
14
|
-
|
|
15
|
-
const factory = new IsObjectFactory<QueryableModule>()
|
|
16
|
-
|
|
17
|
-
export const isQueryableModuleObject: TypeCheck<QueryableModule> = factory.create(requiredQueryableModuleShape)
|
|
18
|
-
|
|
19
|
-
/** @deprecated use isQueryableModuleObject instead */
|
|
20
|
-
export const isModuleObject: TypeCheck<QueryableModule> = isQueryableModuleObject
|