@xyo-network/archivist-model 3.8.1 → 3.8.3

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.
@@ -1,18 +1,43 @@
1
1
  import * as _xylabs_promise from '@xylabs/promise';
2
2
  import { PromisableArray, Promisable } from '@xylabs/promise';
3
+ import { Hex, Hash } from '@xylabs/hex';
3
4
  import * as _xylabs_object from '@xylabs/object';
4
5
  import { EmptyObject, WithAdditional, TypeCheck, IsObjectFactory } from '@xylabs/object';
5
6
  import * as _xyo_network_module_model from '@xyo-network/module-model';
6
- import { Module, ModuleEventArgs, ModuleEventData, ModuleConfig, ModuleIdentifier, ModuleParams, AnyConfigSchema, ModuleQueryFunctions, ModuleQueryResult, ModuleInstance, AttachableModuleInstance, Labels, ModuleQueries } from '@xyo-network/module-model';
7
+ import { Module, ModuleEventArgs, ModuleEventData, ModuleQueryFunctions, ModuleConfig, ModuleIdentifier, ModuleParams, AnyConfigSchema, ModuleQueryResult, ModuleInstance, AttachableModuleInstance, Labels, ModuleQueries } from '@xyo-network/module-model';
7
8
  import * as _xyo_network_payload_model from '@xyo-network/payload-model';
8
9
  import { Payload, WithStorageMeta, Query } from '@xyo-network/payload-model';
9
10
  import { EventData } from '@xyo-network/module-events';
10
- import { Hash, Hex } from '@xylabs/hex';
11
11
  import * as _xyo_network_account_model from '@xyo-network/account-model';
12
12
  import { AccountInstance } from '@xyo-network/account-model';
13
13
  import * as _xylabs_logger from '@xylabs/logger';
14
14
  import { ObjectTypeShape } from '@xylabs/typeof';
15
15
 
16
+ interface NextOptions<TId = Hex> {
17
+ cursor?: TId;
18
+ limit?: number;
19
+ open?: boolean;
20
+ order?: 'asc' | 'desc';
21
+ }
22
+ interface ArchivistNextOptions extends NextOptions<Hash> {
23
+ }
24
+
25
+ interface AllArchivistFunctions<TReadResponse> {
26
+ all(): PromisableArray<TReadResponse>;
27
+ }
28
+ interface ReadArchivistFunctions<TReadResponse, TId = string> {
29
+ get(ids: TId[]): PromisableArray<TReadResponse>;
30
+ next(options?: NextOptions<TId>): PromisableArray<TReadResponse>;
31
+ }
32
+ interface WriteArchivistFunctions<TReadResponse, TWriteResponse = TReadResponse, TWrite = TReadResponse, TId = string> {
33
+ clear(): Promisable<void>;
34
+ delete(ids: TId[]): PromisableArray<TId>;
35
+ insert(item: TWrite[]): PromisableArray<TWriteResponse>;
36
+ }
37
+ interface StashArchivistFunctions<TWriteResponse> {
38
+ commit(): PromisableArray<TWriteResponse>;
39
+ }
40
+
16
41
  type ClearedEventArgs<T extends Module = Module> = ModuleEventArgs<T>;
17
42
  interface ClearedEventData<T extends Module = Module> extends EventData {
18
43
  cleared: ClearedEventArgs<T>;
@@ -35,6 +60,20 @@ interface InsertedEventData<T extends Module = Module> extends EventData {
35
60
  interface ArchivistModuleEventData extends InsertedEventData, DeletedEventData, ClearedEventData, ModuleEventData {
36
61
  }
37
62
 
63
+ interface AllArchivist<TReadResponse extends Payload = Payload> extends AllArchivistFunctions<WithStorageMeta<TReadResponse>> {
64
+ }
65
+ interface ReadArchivist<TReadResponse extends Payload = Payload, TId = Hash> extends ReadArchivistFunctions<WithStorageMeta<TReadResponse>, TId> {
66
+ }
67
+ interface WriteArchivist<TReadResponse extends Payload = Payload, TWriteResponse = TReadResponse, TWrite = TReadResponse, TId = Hash> extends WriteArchivistFunctions<WithStorageMeta<TReadResponse>, TWriteResponse, TWrite, TId> {
68
+ }
69
+ interface StashArchivist<TWriteResponse extends Payload = Payload> extends StashArchivistFunctions<WithStorageMeta<TWriteResponse>> {
70
+ }
71
+ interface Archivist<TReadResponse extends Payload = Payload, TWriteResponse extends Payload = Payload, TWrite extends Payload = TReadResponse & Payload, TId = Hash> extends ReadArchivist<WithStorageMeta<TReadResponse>, TId>, AllArchivist<WithStorageMeta<TReadResponse>>, WriteArchivist<WithStorageMeta<TReadResponse>, WithStorageMeta<TWriteResponse>, TWrite, TId>, StashArchivistFunctions<TWriteResponse> {
72
+ }
73
+
74
+ interface ArchivistModule<TReadResponse extends Payload = Payload, TWriteResponse extends Payload = Payload, TWrite extends Payload = TReadResponse & Payload, TId = Hash> extends Archivist<TReadResponse, TWriteResponse, TWrite, TId>, ModuleQueryFunctions {
75
+ }
76
+
38
77
  type IndexDirection = -1 | 1;
39
78
  type IndexDescription = {
40
79
  key: Record<string, IndexDirection>;
@@ -63,38 +102,11 @@ type ArchivistConfig<TConfig extends Payload | EmptyObject | void = void, TSchem
63
102
  storeParentReads?: boolean;
64
103
  }, TConfig>, TSchema>;
65
104
 
66
- interface ArchivistModule<TParams extends ModuleParams<AnyConfigSchema<ArchivistConfig>> = ModuleParams<AnyConfigSchema<ArchivistConfig>>, TEventData extends ArchivistModuleEventData = ArchivistModuleEventData> extends Module<TParams, TEventData> {
105
+ interface ArchivistModuleInstance<TParams extends ModuleParams<AnyConfigSchema<ArchivistConfig>> = ModuleParams<AnyConfigSchema<ArchivistConfig>>, TEventData extends ArchivistModuleEventData = ArchivistModuleEventData> extends Module<TParams, TEventData> {
67
106
  }
68
107
 
69
108
  type ArchivistParams<TConfig extends AnyConfigSchema<ArchivistConfig> = AnyConfigSchema<ArchivistConfig>, TAdditionalParams extends EmptyObject | undefined = undefined> = ModuleParams<TConfig, TAdditionalParams>;
70
109
 
71
- interface NextOptions<TId = Hex> {
72
- cursor?: TId;
73
- limit?: number;
74
- open?: boolean;
75
- order?: 'asc' | 'desc';
76
- }
77
- interface ArchivistNextOptions extends NextOptions<Hash> {
78
- }
79
-
80
- interface ReadArchivist<TReadResponse, TId = string> {
81
- all(): PromisableArray<TReadResponse>;
82
- get(ids: TId[]): PromisableArray<TReadResponse>;
83
- next(options?: NextOptions<TId>): PromisableArray<TReadResponse>;
84
- }
85
- interface WriteArchivist<TReadResponse, TWriteResponse = TReadResponse, TWrite = TReadResponse, TId = string> {
86
- clear(): Promisable<void>;
87
- delete(ids: TId[]): PromisableArray<TId>;
88
- insert(item: TWrite[]): PromisableArray<TWriteResponse>;
89
- }
90
- interface StashArchivist<TWriteResponse> {
91
- commit(): PromisableArray<TWriteResponse>;
92
- }
93
- interface Archivist<TReadResponse extends Payload = Payload, TWriteResponse extends Payload = Payload, TWrite extends Payload = TReadResponse & Payload, TId = Hash> extends ReadArchivist<WithStorageMeta<TReadResponse>, TId>, WriteArchivist<WithStorageMeta<TReadResponse>, WithStorageMeta<TWriteResponse>, TWrite, TId>, StashArchivist<TWriteResponse> {
94
- }
95
- interface ArchivistQueryFunctions<TReadResponse extends Payload = Payload, TWriteResponse extends Payload = Payload, TWrite extends Payload = TReadResponse & Payload, TId = Hash> extends Archivist<TReadResponse, TWriteResponse, TWrite, TId>, ModuleQueryFunctions {
96
- }
97
-
98
110
  interface ArchivistRawQueryFunctions {
99
111
  allQuery(account?: AccountInstance): Promisable<ModuleQueryResult>;
100
112
  clearQuery(account?: AccountInstance): Promisable<ModuleQueryResult>;
@@ -105,10 +117,10 @@ interface ArchivistRawQueryFunctions {
105
117
  nextQuery(options?: ArchivistNextOptions, account?: AccountInstance): Promisable<ModuleQueryResult>;
106
118
  }
107
119
 
108
- interface ArchivistInstance<TParams extends ArchivistParams = ArchivistParams, TEventData extends ArchivistModuleEventData = ArchivistModuleEventData, TPayload extends Payload = Payload> extends ArchivistModule<TParams, TEventData>, ArchivistQueryFunctions<TPayload, TPayload>, ModuleInstance<TParams, TEventData>, ArchivistRawQueryFunctions {
120
+ interface ArchivistInstance<TParams extends ArchivistParams = ArchivistParams, TEventData extends ArchivistModuleEventData = ArchivistModuleEventData, TPayload extends Payload = Payload> extends ArchivistModuleInstance<TParams, TEventData>, ArchivistModule<TPayload, TPayload>, ModuleInstance<TParams, TEventData>, ArchivistRawQueryFunctions {
109
121
  }
110
122
 
111
- interface AttachableArchivistInstance<TParams extends ArchivistParams = ArchivistParams, TEventData extends ArchivistModuleEventData = ArchivistModuleEventData, TPayload extends Payload = Payload> extends ArchivistModule<TParams, TEventData>, AttachableModuleInstance<TParams, TEventData>, ArchivistInstance<TParams, TEventData, TPayload> {
123
+ interface AttachableArchivistInstance<TParams extends ArchivistParams = ArchivistParams, TEventData extends ArchivistModuleEventData = ArchivistModuleEventData, TPayload extends Payload = Payload> extends ArchivistModuleInstance<TParams, TEventData>, AttachableModuleInstance<TParams, TEventData>, ArchivistInstance<TParams, TEventData, TPayload> {
112
124
  }
113
125
  type AttachableArchivistInstanceTypeCheck<T extends AttachableArchivistInstance = AttachableArchivistInstance> = TypeCheck<T>;
114
126
  declare class IsAttachableArchivistInstanceFactory<T extends AttachableArchivistInstance = AttachableArchivistInstance> extends IsObjectFactory<T> {
@@ -420,7 +432,7 @@ declare const isArchivistInstance: _xylabs_object.TypeCheck<ArchivistInstance<_x
420
432
  }, ArchivistModuleEventData, _xylabs_object.DeepRestrictToStringKeys<{
421
433
  schema: _xyo_network_payload_model.Schema;
422
434
  }>>>;
423
- declare const isArchivistModule: _xyo_network_module_model.ModuleTypeCheck<ArchivistModule<_xylabs_object.BaseParamsFields & {
435
+ declare const isArchivistModule: _xyo_network_module_model.ModuleTypeCheck<ArchivistModuleInstance<_xylabs_object.BaseParamsFields & {
424
436
  account?: _xyo_network_account_model.AccountInstance | "random";
425
437
  addToResolvers?: boolean;
426
438
  additionalSigners?: _xyo_network_account_model.AccountInstance[];
@@ -482,7 +494,7 @@ declare const isArchivistModule: _xyo_network_module_model.ModuleTypeCheck<Archi
482
494
  moduleIdentifierTransformers?: _xyo_network_module_model.ModuleIdentifierTransformer[];
483
495
  }, ArchivistModuleEventData>>;
484
496
  declare const asArchivistModule: {
485
- <TType extends ArchivistModule<_xylabs_object.BaseParamsFields & {
497
+ <TType extends ArchivistModuleInstance<_xylabs_object.BaseParamsFields & {
486
498
  account?: _xyo_network_account_model.AccountInstance | "random";
487
499
  addToResolvers?: boolean;
488
500
  additionalSigners?: _xyo_network_account_model.AccountInstance[];
@@ -543,7 +555,7 @@ declare const asArchivistModule: {
543
555
  ephemeralQueryAccountEnabled?: boolean;
544
556
  moduleIdentifierTransformers?: _xyo_network_module_model.ModuleIdentifierTransformer[];
545
557
  }, ArchivistModuleEventData>>(value: _xylabs_promise.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
546
- <TType extends ArchivistModule<_xylabs_object.BaseParamsFields & {
558
+ <TType extends ArchivistModuleInstance<_xylabs_object.BaseParamsFields & {
547
559
  account?: _xyo_network_account_model.AccountInstance | "random";
548
560
  addToResolvers?: boolean;
549
561
  additionalSigners?: _xyo_network_account_model.AccountInstance[];
@@ -603,7 +615,7 @@ declare const asArchivistModule: {
603
615
  }>;
604
616
  ephemeralQueryAccountEnabled?: boolean;
605
617
  moduleIdentifierTransformers?: _xyo_network_module_model.ModuleIdentifierTransformer[];
606
- }, ArchivistModuleEventData>>(value: _xylabs_promise.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<ArchivistModule<_xylabs_object.BaseParamsFields & {
618
+ }, ArchivistModuleEventData>>(value: _xylabs_promise.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<ArchivistModuleInstance<_xylabs_object.BaseParamsFields & {
607
619
  account?: _xyo_network_account_model.AccountInstance | "random";
608
620
  addToResolvers?: boolean;
609
621
  additionalSigners?: _xyo_network_account_model.AccountInstance[];
@@ -855,7 +867,7 @@ declare const asArchivistInstance: {
855
867
  schema: _xyo_network_payload_model.Schema;
856
868
  }>>>, config?: _xylabs_object.TypeCheckConfig): TType;
857
869
  };
858
- declare const withArchivistModule: <R>(mod: any, closure: (mod: ArchivistModule<_xylabs_object.BaseParamsFields & {
870
+ declare const withArchivistModule: <R>(mod: any, closure: (mod: ArchivistModuleInstance<_xylabs_object.BaseParamsFields & {
859
871
  account?: _xyo_network_account_model.AccountInstance | "random";
860
872
  addToResolvers?: boolean;
861
873
  additionalSigners?: _xyo_network_account_model.AccountInstance[];
@@ -980,4 +992,4 @@ declare const withArchivistInstance: <R>(mod: any, closure: (mod: ArchivistInsta
980
992
  schema: _xyo_network_payload_model.Schema;
981
993
  }>>) => R) => R | undefined;
982
994
 
983
- export { type Archivist, type ArchivistAllQuery, ArchivistAllQuerySchema, type ArchivistClearQuery, ArchivistClearQuerySchema, type ArchivistCommitQuery, ArchivistCommitQuerySchema, type ArchivistConfig, ArchivistConfigSchema, type ArchivistDeleteQuery, ArchivistDeleteQuerySchema, type ArchivistGetQuery, ArchivistGetQuerySchema, type ArchivistInsertQuery, ArchivistInsertQuerySchema, type ArchivistInstance, type ArchivistLabels, type ArchivistModule, type ArchivistModuleEventData, type ArchivistModuleQueries, type ArchivistNextOptions, type ArchivistNextQuery, ArchivistNextQuerySchema, type ArchivistParams, type ArchivistParents, type ArchivistQueries, type ArchivistQueryFunctions, type ArchivistRawQueryFunctions, type ArchivistStorage, type AttachableArchivistInstance, type AttachableArchivistInstanceTypeCheck, type IndexDescription, type IndexDirection, IndexSeparator, IsAttachableArchivistInstanceFactory, type NextOptions, type ReadArchivist, type StashArchivist, type WriteArchivist, asArchivistInstance, asArchivistModule, asAttachableArchivistInstance, buildStandardIndexName, isArchivistInstance, isArchivistModule, isAttachableArchivistInstance, requiredAttachableArchivistInstanceFunctions, withArchivistInstance, withArchivistModule };
995
+ export { type AllArchivist, type AllArchivistFunctions, type Archivist, type ArchivistAllQuery, ArchivistAllQuerySchema, type ArchivistClearQuery, ArchivistClearQuerySchema, type ArchivistCommitQuery, ArchivistCommitQuerySchema, type ArchivistConfig, ArchivistConfigSchema, type ArchivistDeleteQuery, ArchivistDeleteQuerySchema, type ArchivistGetQuery, ArchivistGetQuerySchema, type ArchivistInsertQuery, ArchivistInsertQuerySchema, type ArchivistInstance, type ArchivistLabels, type ArchivistModuleEventData, type ArchivistModuleInstance, type ArchivistModuleQueries, type ArchivistNextOptions, type ArchivistNextQuery, ArchivistNextQuerySchema, type ArchivistParams, type ArchivistParents, type ArchivistQueries, type ArchivistRawQueryFunctions, type ArchivistStorage, type AttachableArchivistInstance, type AttachableArchivistInstanceTypeCheck, type IndexDescription, type IndexDirection, IndexSeparator, IsAttachableArchivistInstanceFactory, type NextOptions, type ReadArchivist, type ReadArchivistFunctions, type StashArchivist, type StashArchivistFunctions, type WriteArchivist, type WriteArchivistFunctions, asArchivistInstance, asArchivistModule, asAttachableArchivistInstance, buildStandardIndexName, isArchivistInstance, isArchivistModule, isAttachableArchivistInstance, requiredAttachableArchivistInstanceFunctions, withArchivistInstance, withArchivistModule };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/attachable/asAttachableInstance.ts","../../src/attachable/isAttachableInstance.ts","../../src/typeChecks.ts","../../src/Queries/All.ts","../../src/Queries/Clear.ts","../../src/Queries/Commit.ts","../../src/Queries/Delete.ts","../../src/Queries/Get.ts","../../src/Queries/Insert.ts","../../src/Queries/Next.ts","../../src/attachable/AttachableInstance.ts","../../src/Config.ts","../../src/IndexDescription.ts"],"sourcesContent":["import { AsObjectFactory } from '@xylabs/object'\n\nimport { isAttachableArchivistInstance } from './isAttachableInstance.ts'\n\nexport const asAttachableArchivistInstance = AsObjectFactory.create(isAttachableArchivistInstance)\n","import type { TypeCheck } from '@xylabs/object'\nimport { IsObjectFactory } from '@xylabs/object'\nimport type { ObjectTypeShape } from '@xylabs/typeof'\nimport { isAttachableModuleInstance } from '@xyo-network/module-model'\n\nimport { isArchivistInstance } from '../typeChecks.ts'\nimport type { AttachableArchivistInstance } from './AttachableInstance.ts'\n\nexport const requiredAttachableArchivistInstanceFunctions: ObjectTypeShape = {}\n\n// we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsObjectFactory<AttachableArchivistInstance>()\n\nexport const isAttachableArchivistInstance: TypeCheck<AttachableArchivistInstance> = factory.create(requiredAttachableArchivistInstanceFunctions, [\n isArchivistInstance,\n isAttachableModuleInstance,\n])\n","import { AsObjectFactory } from '@xylabs/object'\nimport {\n IsInstanceFactory, IsModuleFactory, isModuleInstance, WithFactory,\n} from '@xyo-network/module-model'\n\nimport type { ArchivistInstance } from './Instance.ts'\nimport type { ArchivistModule } from './Module.ts'\nimport { ArchivistGetQuerySchema } from './Queries/index.ts'\n\nexport const isArchivistInstance = new IsInstanceFactory<ArchivistInstance>().create({ get: 'function' }, [isModuleInstance])\nexport const isArchivistModule = new IsModuleFactory<ArchivistModule>().create([ArchivistGetQuerySchema])\n\nexport const asArchivistModule = AsObjectFactory.create(isArchivistModule)\nexport const asArchivistInstance = AsObjectFactory.create(isArchivistInstance)\nexport const withArchivistModule = WithFactory.create(isArchivistModule)\nexport const withArchivistInstance = WithFactory.create(isArchivistInstance)\n","import type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistAllQuerySchema = 'network.xyo.query.archivist.all' as const\nexport type ArchivistAllQuerySchema = typeof ArchivistAllQuerySchema\n\nexport type ArchivistAllQuery = Query<{\n schema: ArchivistAllQuerySchema\n}>\n","import type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistClearQuerySchema = 'network.xyo.query.archivist.clear' as const\nexport type ArchivistClearQuerySchema = typeof ArchivistClearQuerySchema\n\nexport type ArchivistClearQuery = Query<{\n schema: ArchivistClearQuerySchema\n}>\n","import type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistCommitQuerySchema = 'network.xyo.query.archivist.commit' as const\nexport type ArchivistCommitQuerySchema = typeof ArchivistCommitQuerySchema\n\nexport type ArchivistCommitQuery = Query<{\n schema: ArchivistCommitQuerySchema\n}>\n","import type { Hash } from '@xylabs/hex'\nimport type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistDeleteQuerySchema = 'network.xyo.query.archivist.delete' as const\nexport type ArchivistDeleteQuerySchema = typeof ArchivistDeleteQuerySchema\n\nexport type ArchivistDeleteQuery = Query<{\n hashes: Hash[]\n schema: ArchivistDeleteQuerySchema\n}>\n","import type { Hash } from '@xylabs/hex'\nimport type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistGetQuerySchema = 'network.xyo.query.archivist.get' as const\nexport type ArchivistGetQuerySchema = typeof ArchivistGetQuerySchema\n\nexport type ArchivistGetQuery = Query<{\n hashes: Hash[]\n schema: ArchivistGetQuerySchema\n}>\n","import type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistInsertQuerySchema = 'network.xyo.query.archivist.insert' as const\nexport type ArchivistInsertQuerySchema = typeof ArchivistInsertQuerySchema\n\nexport type ArchivistInsertQuery = Query<{\n schema: ArchivistInsertQuerySchema\n}>\n","import type { Query } from '@xyo-network/payload-model'\n\nimport type { ArchivistNextOptions } from '../NextOptions.ts'\n\nexport const ArchivistNextQuerySchema = 'network.xyo.query.archivist.next' as const\nexport type ArchivistNextQuerySchema = typeof ArchivistNextQuerySchema\n\nexport type ArchivistNextQuery = Query<ArchivistNextOptions, ArchivistNextQuerySchema>\n","import type { TypeCheck } from '@xylabs/object'\nimport { IsObjectFactory } from '@xylabs/object'\nimport type { AttachableModuleInstance } from '@xyo-network/module-model'\nimport type { Payload } from '@xyo-network/payload-model'\n\nimport type { ArchivistModuleEventData } from '../EventData.ts'\nimport type { ArchivistInstance } from '../Instance.ts'\nimport type { ArchivistModule } from '../Module.ts'\nimport type { ArchivistParams } from '../Params.ts'\n\nexport interface AttachableArchivistInstance<\n TParams extends ArchivistParams = ArchivistParams,\n TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,\n TPayload extends Payload = Payload,\n> extends ArchivistModule<TParams, TEventData>,\n AttachableModuleInstance<TParams, TEventData>,\n ArchivistInstance<TParams, TEventData, TPayload> {}\n\nexport type AttachableArchivistInstanceTypeCheck<T extends AttachableArchivistInstance = AttachableArchivistInstance> = TypeCheck<T>\n\nexport class IsAttachableArchivistInstanceFactory<T extends AttachableArchivistInstance = AttachableArchivistInstance> extends IsObjectFactory<T> {}\n","import type { EmptyObject, WithAdditional } from '@xylabs/object'\nimport type { ModuleConfig, ModuleIdentifier } from '@xyo-network/module-model'\nimport type { Payload } from '@xyo-network/payload-model'\n\nimport type { IndexDescription } from './IndexDescription.ts'\n\nexport interface ArchivistParents {\n commit?: ModuleIdentifier[]\n read?: ModuleIdentifier[]\n write?: ModuleIdentifier[]\n}\n\nexport interface ArchivistStorage {\n /** The indexes to create on the object store */\n indexes?: IndexDescription[]\n}\n\nexport const ArchivistConfigSchema = 'network.xyo.archivist.config' as const\nexport type ArchivistConfigSchema = typeof ArchivistConfigSchema\n\nexport type ArchivistConfig<TConfig extends Payload | EmptyObject | void = void, TSchema extends string | void = void> = ModuleConfig<\n WithAdditional<\n {\n /** @field address of one or more parent archivists to read from */\n parents?: ArchivistParents\n /** @field fail if some parents can not be resolved (true if unspecified) */\n requireAllParents?: boolean\n schema: TConfig extends Payload ? TConfig['schema'] : ArchivistConfigSchema\n /** @field storage configuration */\n storage?: ArchivistStorage\n /** @field should child store all reads from parents? */\n storeParentReads?: boolean\n },\n TConfig\n >,\n TSchema\n>\n","/**\n * The index direction (1 for ascending, -1 for descending)\n */\nexport type IndexDirection = -1 | 1\n\n/**\n * Description of index(es) to be created on a store\n */\nexport type IndexDescription = {\n /**\n * The key(s) to index\n */\n key: Record<string, IndexDirection>\n /**\n * Is the indexed value an array\n */\n multiEntry?: boolean\n /**\n * The name of the index\n */\n name?: string\n /**\n * If true, the index must enforce uniqueness on the key\n */\n unique?: boolean\n}\n\nexport const IndexSeparator = '-'\n\n/**\n * Given an index description, this will build the index\n * name in standard form\n * @param index The index description\n * @returns The index name in standard form\n */\nexport const buildStandardIndexName = (index: IndexDescription) => {\n const { key, unique } = index\n const prefix = unique ? 'UX' : 'IX'\n const indexKeys = Object.keys(key)\n return `${prefix}_${indexKeys.join(IndexSeparator)}`\n}\n"],"mappings":";AAAA,SAAS,mBAAAA,wBAAuB;;;ACChC,SAAS,uBAAuB;AAEhC,SAAS,kCAAkC;;;ACH3C,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EAAmB;AAAA,EAAiB;AAAA,EAAkB;AAAA,OACjD;;;ACDA,IAAM,0BAA0B;;;ACAhC,IAAM,4BAA4B;;;ACAlC,IAAM,6BAA6B;;;ACCnC,IAAM,6BAA6B;;;ACAnC,IAAM,0BAA0B;;;ACDhC,IAAM,6BAA6B;;;ACEnC,IAAM,2BAA2B;;;APKjC,IAAM,sBAAsB,IAAI,kBAAqC,EAAE,OAAO,EAAE,KAAK,WAAW,GAAG,CAAC,gBAAgB,CAAC;AACrH,IAAM,oBAAoB,IAAI,gBAAiC,EAAE,OAAO,CAAC,uBAAuB,CAAC;AAEjG,IAAM,oBAAoB,gBAAgB,OAAO,iBAAiB;AAClE,IAAM,sBAAsB,gBAAgB,OAAO,mBAAmB;AACtE,IAAM,sBAAsB,YAAY,OAAO,iBAAiB;AAChE,IAAM,wBAAwB,YAAY,OAAO,mBAAmB;;;ADPpE,IAAM,+CAAgE,CAAC;AAG9E,IAAM,UAAU,IAAI,gBAA6C;AAE1D,IAAM,gCAAwE,QAAQ,OAAO,8CAA8C;AAAA,EAChJ;AAAA,EACA;AACF,CAAC;;;ADZM,IAAM,gCAAgCC,iBAAgB,OAAO,6BAA6B;;;AUHjG,SAAS,mBAAAC,wBAAuB;AAmBzB,IAAM,uCAAN,cAAwHA,iBAAmB;AAAC;;;ACH5I,IAAM,wBAAwB;;;ACU9B,IAAM,iBAAiB;AAQvB,IAAM,yBAAyB,CAAC,UAA4B;AACjE,QAAM,EAAE,KAAK,OAAO,IAAI;AACxB,QAAM,SAAS,SAAS,OAAO;AAC/B,QAAM,YAAY,OAAO,KAAK,GAAG;AACjC,SAAO,GAAG,MAAM,IAAI,UAAU,KAAK,cAAc,CAAC;AACpD;","names":["AsObjectFactory","AsObjectFactory","IsObjectFactory"]}
1
+ {"version":3,"sources":["../../src/attachable/asAttachableInstance.ts","../../src/attachable/isAttachableInstance.ts","../../src/typeChecks.ts","../../src/Queries/All.ts","../../src/Queries/Clear.ts","../../src/Queries/Commit.ts","../../src/Queries/Delete.ts","../../src/Queries/Get.ts","../../src/Queries/Insert.ts","../../src/Queries/Next.ts","../../src/attachable/AttachableInstance.ts","../../src/Config.ts","../../src/IndexDescription.ts"],"sourcesContent":["import { AsObjectFactory } from '@xylabs/object'\n\nimport { isAttachableArchivistInstance } from './isAttachableInstance.ts'\n\nexport const asAttachableArchivistInstance = AsObjectFactory.create(isAttachableArchivistInstance)\n","import type { TypeCheck } from '@xylabs/object'\nimport { IsObjectFactory } from '@xylabs/object'\nimport type { ObjectTypeShape } from '@xylabs/typeof'\nimport { isAttachableModuleInstance } from '@xyo-network/module-model'\n\nimport { isArchivistInstance } from '../typeChecks.ts'\nimport type { AttachableArchivistInstance } from './AttachableInstance.ts'\n\nexport const requiredAttachableArchivistInstanceFunctions: ObjectTypeShape = {}\n\n// we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsObjectFactory<AttachableArchivistInstance>()\n\nexport const isAttachableArchivistInstance: TypeCheck<AttachableArchivistInstance> = factory.create(requiredAttachableArchivistInstanceFunctions, [\n isArchivistInstance,\n isAttachableModuleInstance,\n])\n","import { AsObjectFactory } from '@xylabs/object'\nimport {\n IsInstanceFactory, IsModuleFactory, isModuleInstance, WithFactory,\n} from '@xyo-network/module-model'\n\nimport type { ArchivistInstance } from './Instance.ts'\nimport type { ArchivistModuleInstance } from './ModuleInstance.ts'\nimport { ArchivistGetQuerySchema } from './Queries/index.ts'\n\nexport const isArchivistInstance = new IsInstanceFactory<ArchivistInstance>().create({ get: 'function' }, [isModuleInstance])\nexport const isArchivistModule = new IsModuleFactory<ArchivistModuleInstance>().create([ArchivistGetQuerySchema])\n\nexport const asArchivistModule = AsObjectFactory.create(isArchivistModule)\nexport const asArchivistInstance = AsObjectFactory.create(isArchivistInstance)\nexport const withArchivistModule = WithFactory.create(isArchivistModule)\nexport const withArchivistInstance = WithFactory.create(isArchivistInstance)\n","import type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistAllQuerySchema = 'network.xyo.query.archivist.all' as const\nexport type ArchivistAllQuerySchema = typeof ArchivistAllQuerySchema\n\nexport type ArchivistAllQuery = Query<{\n schema: ArchivistAllQuerySchema\n}>\n","import type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistClearQuerySchema = 'network.xyo.query.archivist.clear' as const\nexport type ArchivistClearQuerySchema = typeof ArchivistClearQuerySchema\n\nexport type ArchivistClearQuery = Query<{\n schema: ArchivistClearQuerySchema\n}>\n","import type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistCommitQuerySchema = 'network.xyo.query.archivist.commit' as const\nexport type ArchivistCommitQuerySchema = typeof ArchivistCommitQuerySchema\n\nexport type ArchivistCommitQuery = Query<{\n schema: ArchivistCommitQuerySchema\n}>\n","import type { Hash } from '@xylabs/hex'\nimport type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistDeleteQuerySchema = 'network.xyo.query.archivist.delete' as const\nexport type ArchivistDeleteQuerySchema = typeof ArchivistDeleteQuerySchema\n\nexport type ArchivistDeleteQuery = Query<{\n hashes: Hash[]\n schema: ArchivistDeleteQuerySchema\n}>\n","import type { Hash } from '@xylabs/hex'\nimport type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistGetQuerySchema = 'network.xyo.query.archivist.get' as const\nexport type ArchivistGetQuerySchema = typeof ArchivistGetQuerySchema\n\nexport type ArchivistGetQuery = Query<{\n hashes: Hash[]\n schema: ArchivistGetQuerySchema\n}>\n","import type { Query } from '@xyo-network/payload-model'\n\nexport const ArchivistInsertQuerySchema = 'network.xyo.query.archivist.insert' as const\nexport type ArchivistInsertQuerySchema = typeof ArchivistInsertQuerySchema\n\nexport type ArchivistInsertQuery = Query<{\n schema: ArchivistInsertQuerySchema\n}>\n","import type { Query } from '@xyo-network/payload-model'\n\nimport type { ArchivistNextOptions } from '../NextOptions.ts'\n\nexport const ArchivistNextQuerySchema = 'network.xyo.query.archivist.next' as const\nexport type ArchivistNextQuerySchema = typeof ArchivistNextQuerySchema\n\nexport type ArchivistNextQuery = Query<ArchivistNextOptions, ArchivistNextQuerySchema>\n","import type { TypeCheck } from '@xylabs/object'\nimport { IsObjectFactory } from '@xylabs/object'\nimport type { AttachableModuleInstance } from '@xyo-network/module-model'\nimport type { Payload } from '@xyo-network/payload-model'\n\nimport type { ArchivistModuleEventData } from '../EventData.ts'\nimport type { ArchivistInstance } from '../Instance.ts'\nimport type { ArchivistModuleInstance } from '../ModuleInstance.ts'\nimport type { ArchivistParams } from '../Params.ts'\n\nexport interface AttachableArchivistInstance<\n TParams extends ArchivistParams = ArchivistParams,\n TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,\n TPayload extends Payload = Payload,\n> extends ArchivistModuleInstance<TParams, TEventData>,\n AttachableModuleInstance<TParams, TEventData>,\n ArchivistInstance<TParams, TEventData, TPayload> {}\n\nexport type AttachableArchivistInstanceTypeCheck<T extends AttachableArchivistInstance = AttachableArchivistInstance> = TypeCheck<T>\n\nexport class IsAttachableArchivistInstanceFactory<T extends AttachableArchivistInstance = AttachableArchivistInstance> extends IsObjectFactory<T> {}\n","import type { EmptyObject, WithAdditional } from '@xylabs/object'\nimport type { ModuleConfig, ModuleIdentifier } from '@xyo-network/module-model'\nimport type { Payload } from '@xyo-network/payload-model'\n\nimport type { IndexDescription } from './IndexDescription.ts'\n\nexport interface ArchivistParents {\n commit?: ModuleIdentifier[]\n read?: ModuleIdentifier[]\n write?: ModuleIdentifier[]\n}\n\nexport interface ArchivistStorage {\n /** The indexes to create on the object store */\n indexes?: IndexDescription[]\n}\n\nexport const ArchivistConfigSchema = 'network.xyo.archivist.config' as const\nexport type ArchivistConfigSchema = typeof ArchivistConfigSchema\n\nexport type ArchivistConfig<TConfig extends Payload | EmptyObject | void = void, TSchema extends string | void = void> = ModuleConfig<\n WithAdditional<\n {\n /** @field address of one or more parent archivists to read from */\n parents?: ArchivistParents\n /** @field fail if some parents can not be resolved (true if unspecified) */\n requireAllParents?: boolean\n schema: TConfig extends Payload ? TConfig['schema'] : ArchivistConfigSchema\n /** @field storage configuration */\n storage?: ArchivistStorage\n /** @field should child store all reads from parents? */\n storeParentReads?: boolean\n },\n TConfig\n >,\n TSchema\n>\n","/**\n * The index direction (1 for ascending, -1 for descending)\n */\nexport type IndexDirection = -1 | 1\n\n/**\n * Description of index(es) to be created on a store\n */\nexport type IndexDescription = {\n /**\n * The key(s) to index\n */\n key: Record<string, IndexDirection>\n /**\n * Is the indexed value an array\n */\n multiEntry?: boolean\n /**\n * The name of the index\n */\n name?: string\n /**\n * If true, the index must enforce uniqueness on the key\n */\n unique?: boolean\n}\n\nexport const IndexSeparator = '-'\n\n/**\n * Given an index description, this will build the index\n * name in standard form\n * @param index The index description\n * @returns The index name in standard form\n */\nexport const buildStandardIndexName = (index: IndexDescription) => {\n const { key, unique } = index\n const prefix = unique ? 'UX' : 'IX'\n const indexKeys = Object.keys(key)\n return `${prefix}_${indexKeys.join(IndexSeparator)}`\n}\n"],"mappings":";AAAA,SAAS,mBAAAA,wBAAuB;;;ACChC,SAAS,uBAAuB;AAEhC,SAAS,kCAAkC;;;ACH3C,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EAAmB;AAAA,EAAiB;AAAA,EAAkB;AAAA,OACjD;;;ACDA,IAAM,0BAA0B;;;ACAhC,IAAM,4BAA4B;;;ACAlC,IAAM,6BAA6B;;;ACCnC,IAAM,6BAA6B;;;ACAnC,IAAM,0BAA0B;;;ACDhC,IAAM,6BAA6B;;;ACEnC,IAAM,2BAA2B;;;APKjC,IAAM,sBAAsB,IAAI,kBAAqC,EAAE,OAAO,EAAE,KAAK,WAAW,GAAG,CAAC,gBAAgB,CAAC;AACrH,IAAM,oBAAoB,IAAI,gBAAyC,EAAE,OAAO,CAAC,uBAAuB,CAAC;AAEzG,IAAM,oBAAoB,gBAAgB,OAAO,iBAAiB;AAClE,IAAM,sBAAsB,gBAAgB,OAAO,mBAAmB;AACtE,IAAM,sBAAsB,YAAY,OAAO,iBAAiB;AAChE,IAAM,wBAAwB,YAAY,OAAO,mBAAmB;;;ADPpE,IAAM,+CAAgE,CAAC;AAG9E,IAAM,UAAU,IAAI,gBAA6C;AAE1D,IAAM,gCAAwE,QAAQ,OAAO,8CAA8C;AAAA,EAChJ;AAAA,EACA;AACF,CAAC;;;ADZM,IAAM,gCAAgCC,iBAAgB,OAAO,6BAA6B;;;AUHjG,SAAS,mBAAAC,wBAAuB;AAmBzB,IAAM,uCAAN,cAAwHA,iBAAmB;AAAC;;;ACH5I,IAAM,wBAAwB;;;ACU9B,IAAM,iBAAiB;AAQvB,IAAM,yBAAyB,CAAC,UAA4B;AACjE,QAAM,EAAE,KAAK,OAAO,IAAI;AACxB,QAAM,SAAS,SAAS,OAAO;AAC/B,QAAM,YAAY,OAAO,KAAK,GAAG;AACjC,SAAO,GAAG,MAAM,IAAI,UAAU,KAAK,cAAc,CAAC;AACpD;","names":["AsObjectFactory","AsObjectFactory","IsObjectFactory"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/archivist-model",
3
- "version": "3.8.1",
3
+ "version": "3.8.3",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -33,10 +33,10 @@
33
33
  "@xylabs/object": "^4.5.1",
34
34
  "@xylabs/promise": "^4.5.1",
35
35
  "@xylabs/typeof": "^4.5.1",
36
- "@xyo-network/account-model": "^3.8.1",
37
- "@xyo-network/module-events": "^3.8.1",
38
- "@xyo-network/module-model": "^3.8.1",
39
- "@xyo-network/payload-model": "^3.8.1"
36
+ "@xyo-network/account-model": "^3.8.3",
37
+ "@xyo-network/module-events": "^3.8.3",
38
+ "@xyo-network/module-model": "^3.8.3",
39
+ "@xyo-network/payload-model": "^3.8.3"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@xylabs/ts-scripts-yarn3": "^5.0.22",
@@ -0,0 +1,22 @@
1
+ import type { Promisable, PromisableArray } from '@xylabs/promise'
2
+
3
+ import type { NextOptions } from './NextOptions.ts'
4
+
5
+ export interface AllArchivistFunctions<TReadResponse> {
6
+ all(): PromisableArray<TReadResponse>
7
+ }
8
+
9
+ export interface ReadArchivistFunctions<TReadResponse, TId = string> {
10
+ get(ids: TId[]): PromisableArray<TReadResponse>
11
+ next(options?: NextOptions<TId>): PromisableArray<TReadResponse>
12
+ }
13
+
14
+ export interface WriteArchivistFunctions<TReadResponse, TWriteResponse = TReadResponse, TWrite = TReadResponse, TId = string> {
15
+ clear(): Promisable<void>
16
+ delete(ids: TId[]): PromisableArray<TId>
17
+ insert(item: TWrite[]): PromisableArray<TWriteResponse>
18
+ }
19
+
20
+ export interface StashArchivistFunctions<TWriteResponse> {
21
+ commit(): PromisableArray<TWriteResponse>
22
+ }
package/src/Instance.ts CHANGED
@@ -3,15 +3,15 @@ import type { Payload } from '@xyo-network/payload-model'
3
3
 
4
4
  import type { ArchivistModuleEventData } from './EventData.ts'
5
5
  import type { ArchivistModule } from './Module.ts'
6
+ import type { ArchivistModuleInstance } from './ModuleInstance.ts'
6
7
  import type { ArchivistParams } from './Params.ts'
7
- import type { ArchivistQueryFunctions } from './QueryFunctions.ts'
8
8
  import type { ArchivistRawQueryFunctions } from './RawQueryFunctions.ts'
9
9
 
10
10
  export interface ArchivistInstance<
11
11
  TParams extends ArchivistParams = ArchivistParams,
12
12
  TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,
13
13
  TPayload extends Payload = Payload,
14
- > extends ArchivistModule<TParams, TEventData>,
15
- ArchivistQueryFunctions<TPayload, TPayload>,
14
+ > extends ArchivistModuleInstance<TParams, TEventData>,
15
+ ArchivistModule<TPayload, TPayload>,
16
16
  ModuleInstance<TParams, TEventData>,
17
17
  ArchivistRawQueryFunctions {}
package/src/Module.ts CHANGED
@@ -1,11 +1,13 @@
1
- import type {
2
- AnyConfigSchema, Module, ModuleParams,
3
- } from '@xyo-network/module-model'
1
+ import type { Hash } from '@xylabs/hex'
2
+ import type { ModuleQueryFunctions } from '@xyo-network/module-model'
3
+ import type { Payload } from '@xyo-network/payload-model'
4
4
 
5
- import type { ArchivistConfig } from './Config.ts'
6
- import type { ArchivistModuleEventData } from './EventData.ts'
5
+ import type { Archivist } from './PayloadArchivist.ts'
7
6
 
8
7
  export interface ArchivistModule<
9
- TParams extends ModuleParams<AnyConfigSchema<ArchivistConfig>> = ModuleParams<AnyConfigSchema<ArchivistConfig>>,
10
- TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,
11
- > extends Module<TParams, TEventData> {}
8
+ TReadResponse extends Payload = Payload,
9
+ TWriteResponse extends Payload = Payload,
10
+ TWrite extends Payload = TReadResponse & Payload,
11
+ TId = Hash,
12
+ > extends Archivist<TReadResponse, TWriteResponse, TWrite, TId>,
13
+ ModuleQueryFunctions {}
@@ -0,0 +1,11 @@
1
+ import type {
2
+ AnyConfigSchema, Module, ModuleParams,
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 ModuleParams<AnyConfigSchema<ArchivistConfig>> = ModuleParams<AnyConfigSchema<ArchivistConfig>>,
10
+ TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,
11
+ > extends Module<TParams, TEventData> {}
@@ -0,0 +1,36 @@
1
+ import type { Hash } from '@xylabs/hex'
2
+ import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
3
+
4
+ import type {
5
+ AllArchivistFunctions, ReadArchivistFunctions, StashArchivistFunctions, WriteArchivistFunctions,
6
+ } from './ArchivistFunctions.ts'
7
+
8
+ export interface AllArchivist<
9
+ TReadResponse extends Payload = Payload,
10
+ > extends AllArchivistFunctions<WithStorageMeta<TReadResponse>> {}
11
+
12
+ export interface ReadArchivist<
13
+ TReadResponse extends Payload = Payload,
14
+ TId = Hash,
15
+ > extends ReadArchivistFunctions<WithStorageMeta<TReadResponse>, TId> {}
16
+
17
+ export interface WriteArchivist<
18
+ TReadResponse extends Payload = Payload,
19
+ TWriteResponse = TReadResponse,
20
+ TWrite = TReadResponse,
21
+ TId = Hash,
22
+ > extends WriteArchivistFunctions<WithStorageMeta<TReadResponse>, TWriteResponse, TWrite, TId> {}
23
+
24
+ export interface StashArchivist<
25
+ TWriteResponse extends Payload = Payload,
26
+ > extends StashArchivistFunctions<WithStorageMeta<TWriteResponse>> {}
27
+
28
+ export interface Archivist<
29
+ TReadResponse extends Payload = Payload,
30
+ TWriteResponse extends Payload = Payload,
31
+ TWrite extends Payload = TReadResponse & Payload,
32
+ TId = Hash,
33
+ > extends ReadArchivist<WithStorageMeta<TReadResponse>, TId>,
34
+ AllArchivist<WithStorageMeta<TReadResponse>>,
35
+ WriteArchivist<WithStorageMeta<TReadResponse>, WithStorageMeta<TWriteResponse>, TWrite, TId>,
36
+ StashArchivistFunctions<TWriteResponse> {}
@@ -5,14 +5,14 @@ import type { Payload } from '@xyo-network/payload-model'
5
5
 
6
6
  import type { ArchivistModuleEventData } from '../EventData.ts'
7
7
  import type { ArchivistInstance } from '../Instance.ts'
8
- import type { ArchivistModule } from '../Module.ts'
8
+ import type { ArchivistModuleInstance } from '../ModuleInstance.ts'
9
9
  import type { ArchivistParams } from '../Params.ts'
10
10
 
11
11
  export interface AttachableArchivistInstance<
12
12
  TParams extends ArchivistParams = ArchivistParams,
13
13
  TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,
14
14
  TPayload extends Payload = Payload,
15
- > extends ArchivistModule<TParams, TEventData>,
15
+ > extends ArchivistModuleInstance<TParams, TEventData>,
16
16
  AttachableModuleInstance<TParams, TEventData>,
17
17
  ArchivistInstance<TParams, TEventData, TPayload> {}
18
18
 
package/src/index.ts CHANGED
@@ -1,13 +1,14 @@
1
+ export * from './ArchivistFunctions.ts'
1
2
  export * from './attachable/index.ts'
2
3
  export * from './Config.ts'
3
4
  export * from './EventData.ts'
4
5
  export * from './IndexDescription.ts'
5
6
  export * from './Instance.ts'
6
7
  export * from './Labels.ts'
7
- export * from './Module.ts'
8
+ export * from './ModuleInstance.ts'
8
9
  export * from './NextOptions.ts'
9
10
  export * from './Params.ts'
11
+ export * from './PayloadArchivist.ts'
10
12
  export * from './Queries/index.ts'
11
- export * from './QueryFunctions.ts'
12
13
  export * from './RawQueryFunctions.ts'
13
14
  export * from './typeChecks.ts'
package/src/typeChecks.ts CHANGED
@@ -4,11 +4,11 @@ import {
4
4
  } from '@xyo-network/module-model'
5
5
 
6
6
  import type { ArchivistInstance } from './Instance.ts'
7
- import type { ArchivistModule } from './Module.ts'
7
+ import type { ArchivistModuleInstance } from './ModuleInstance.ts'
8
8
  import { ArchivistGetQuerySchema } from './Queries/index.ts'
9
9
 
10
10
  export const isArchivistInstance = new IsInstanceFactory<ArchivistInstance>().create({ get: 'function' }, [isModuleInstance])
11
- export const isArchivistModule = new IsModuleFactory<ArchivistModule>().create([ArchivistGetQuerySchema])
11
+ export const isArchivistModule = new IsModuleFactory<ArchivistModuleInstance>().create([ArchivistGetQuerySchema])
12
12
 
13
13
  export const asArchivistModule = AsObjectFactory.create(isArchivistModule)
14
14
  export const asArchivistInstance = AsObjectFactory.create(isArchivistInstance)
@@ -1,39 +0,0 @@
1
- import type { Hash } from '@xylabs/hex'
2
- import type { Promisable, PromisableArray } from '@xylabs/promise'
3
- import type { ModuleQueryFunctions } from '@xyo-network/module-model'
4
- import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
5
-
6
- import type { NextOptions } from './NextOptions.ts'
7
-
8
- export interface ReadArchivist<TReadResponse, TId = string> {
9
- all(): PromisableArray<TReadResponse>
10
- get(ids: TId[]): PromisableArray<TReadResponse>
11
- next(options?: NextOptions<TId>): PromisableArray<TReadResponse>
12
- }
13
-
14
- export interface WriteArchivist<TReadResponse, TWriteResponse = TReadResponse, TWrite = TReadResponse, TId = string> {
15
- clear(): Promisable<void>
16
- delete(ids: TId[]): PromisableArray<TId>
17
- insert(item: TWrite[]): PromisableArray<TWriteResponse>
18
- }
19
-
20
- export interface StashArchivist<TWriteResponse> {
21
- commit(): PromisableArray<TWriteResponse>
22
- }
23
-
24
- export interface Archivist<
25
- TReadResponse extends Payload = Payload,
26
- TWriteResponse extends Payload = Payload,
27
- TWrite extends Payload = TReadResponse & Payload,
28
- TId = Hash,
29
- > extends ReadArchivist<WithStorageMeta<TReadResponse>, TId>,
30
- WriteArchivist<WithStorageMeta<TReadResponse>, WithStorageMeta<TWriteResponse>, TWrite, TId>,
31
- StashArchivist<TWriteResponse> {}
32
-
33
- export interface ArchivistQueryFunctions<
34
- TReadResponse extends Payload = Payload,
35
- TWriteResponse extends Payload = Payload,
36
- TWrite extends Payload = TReadResponse & Payload,
37
- TId = Hash,
38
- > extends Archivist<TReadResponse, TWriteResponse, TWrite, TId>,
39
- ModuleQueryFunctions {}