@xyo-network/module-model 2.73.4 → 2.74.1

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.
Files changed (232) hide show
  1. package/dist/Config.d.mts +60 -0
  2. package/dist/Config.d.mts.map +1 -0
  3. package/dist/Config.d.ts +60 -0
  4. package/dist/Config.d.ts.map +1 -0
  5. package/dist/CreatableModule/CreatableModule.d.mts +23 -0
  6. package/dist/CreatableModule/CreatableModule.d.mts.map +1 -0
  7. package/dist/CreatableModule/CreatableModule.d.ts +23 -0
  8. package/dist/CreatableModule/CreatableModule.d.ts.map +1 -0
  9. package/dist/CreatableModule/CreatableModuleDictionary.d.mts +5 -0
  10. package/dist/CreatableModule/CreatableModuleDictionary.d.mts.map +1 -0
  11. package/dist/CreatableModule/CreatableModuleDictionary.d.ts +5 -0
  12. package/dist/CreatableModule/CreatableModuleDictionary.d.ts.map +1 -0
  13. package/dist/CreatableModule/CreatableModuleRegistry.d.mts +9 -0
  14. package/dist/CreatableModule/CreatableModuleRegistry.d.mts.map +1 -0
  15. package/dist/CreatableModule/CreatableModuleRegistry.d.ts +9 -0
  16. package/dist/CreatableModule/CreatableModuleRegistry.d.ts.map +1 -0
  17. package/dist/CreatableModule/LabeledCreatableModuleFactory.d.mts +6 -0
  18. package/dist/CreatableModule/LabeledCreatableModuleFactory.d.mts.map +1 -0
  19. package/dist/CreatableModule/LabeledCreatableModuleFactory.d.ts +6 -0
  20. package/dist/CreatableModule/LabeledCreatableModuleFactory.d.ts.map +1 -0
  21. package/dist/CreatableModule/ModuleFactory.d.mts +25 -0
  22. package/dist/CreatableModule/ModuleFactory.d.mts.map +1 -0
  23. package/dist/CreatableModule/ModuleFactory.d.ts +25 -0
  24. package/dist/CreatableModule/ModuleFactory.d.ts.map +1 -0
  25. package/dist/CreatableModule/ModuleFactoryLocator.d.mts +41 -0
  26. package/dist/CreatableModule/ModuleFactoryLocator.d.mts.map +1 -0
  27. package/dist/CreatableModule/ModuleFactoryLocator.d.ts +41 -0
  28. package/dist/CreatableModule/ModuleFactoryLocator.d.ts.map +1 -0
  29. package/dist/CreatableModule/index.d.mts +7 -0
  30. package/dist/CreatableModule/index.d.mts.map +1 -0
  31. package/dist/CreatableModule/index.d.ts +7 -0
  32. package/dist/CreatableModule/index.d.ts.map +1 -0
  33. package/dist/EventsModels/ModuleBusy.d.mts +9 -0
  34. package/dist/EventsModels/ModuleBusy.d.mts.map +1 -0
  35. package/dist/EventsModels/ModuleBusy.d.ts +9 -0
  36. package/dist/EventsModels/ModuleBusy.d.ts.map +1 -0
  37. package/dist/EventsModels/ModuleError.d.mts +9 -0
  38. package/dist/EventsModels/ModuleError.d.mts.map +1 -0
  39. package/dist/EventsModels/ModuleError.d.ts +9 -0
  40. package/dist/EventsModels/ModuleError.d.ts.map +1 -0
  41. package/dist/EventsModels/ModuleEventArgs.d.mts +7 -0
  42. package/dist/EventsModels/ModuleEventArgs.d.mts.map +1 -0
  43. package/dist/EventsModels/ModuleEventArgs.d.ts +7 -0
  44. package/dist/EventsModels/ModuleEventArgs.d.ts.map +1 -0
  45. package/dist/EventsModels/ModuleEventData.d.mts +6 -0
  46. package/dist/EventsModels/ModuleEventData.d.mts.map +1 -0
  47. package/dist/EventsModels/ModuleEventData.d.ts +6 -0
  48. package/dist/EventsModels/ModuleEventData.d.ts.map +1 -0
  49. package/dist/EventsModels/ModuleQueried.d.mts +14 -0
  50. package/dist/EventsModels/ModuleQueried.d.mts.map +1 -0
  51. package/dist/EventsModels/ModuleQueried.d.ts +14 -0
  52. package/dist/EventsModels/ModuleQueried.d.ts.map +1 -0
  53. package/dist/EventsModels/index.d.mts +6 -0
  54. package/dist/EventsModels/index.d.mts.map +1 -0
  55. package/dist/EventsModels/index.d.ts +6 -0
  56. package/dist/EventsModels/index.d.ts.map +1 -0
  57. package/dist/Labels/Labels.d.mts +26 -0
  58. package/dist/Labels/Labels.d.mts.map +1 -0
  59. package/dist/Labels/Labels.d.ts +26 -0
  60. package/dist/Labels/Labels.d.ts.map +1 -0
  61. package/dist/Labels/index.d.mts +2 -0
  62. package/dist/Labels/index.d.mts.map +1 -0
  63. package/dist/Labels/index.d.ts +2 -0
  64. package/dist/Labels/index.d.ts.map +1 -0
  65. package/dist/ModuleDescription.d.mts +7 -0
  66. package/dist/ModuleDescription.d.mts.map +1 -0
  67. package/dist/ModuleDescription.d.ts +7 -0
  68. package/dist/ModuleDescription.d.ts.map +1 -0
  69. package/dist/ModuleParams.d.mts +11 -0
  70. package/dist/ModuleParams.d.mts.map +1 -0
  71. package/dist/ModuleParams.d.ts +11 -0
  72. package/dist/ModuleParams.d.ts.map +1 -0
  73. package/dist/ModuleQueryHandlerResult.d.mts +3 -0
  74. package/dist/ModuleQueryHandlerResult.d.mts.map +1 -0
  75. package/dist/ModuleQueryHandlerResult.d.ts +3 -0
  76. package/dist/ModuleQueryHandlerResult.d.ts.map +1 -0
  77. package/dist/ModuleQueryResult.d.mts +4 -0
  78. package/dist/ModuleQueryResult.d.mts.map +1 -0
  79. package/dist/ModuleQueryResult.d.ts +4 -0
  80. package/dist/ModuleQueryResult.d.ts.map +1 -0
  81. package/dist/Queries/Describe/Payload.d.mts +6 -0
  82. package/dist/Queries/Describe/Payload.d.mts.map +1 -0
  83. package/dist/Queries/Describe/Payload.d.ts +6 -0
  84. package/dist/Queries/Describe/Payload.d.ts.map +1 -0
  85. package/dist/Queries/Describe/Query.d.mts +7 -0
  86. package/dist/Queries/Describe/Query.d.mts.map +1 -0
  87. package/dist/Queries/Describe/Query.d.ts +7 -0
  88. package/dist/Queries/Describe/Query.d.ts.map +1 -0
  89. package/dist/Queries/Describe/index.d.mts +3 -0
  90. package/dist/Queries/Describe/index.d.mts.map +1 -0
  91. package/dist/Queries/Describe/index.d.ts +3 -0
  92. package/dist/Queries/Describe/index.d.ts.map +1 -0
  93. package/dist/Queries/Discover.d.mts +7 -0
  94. package/dist/Queries/Discover.d.mts.map +1 -0
  95. package/dist/Queries/Discover.d.ts +7 -0
  96. package/dist/Queries/Discover.d.ts.map +1 -0
  97. package/dist/Queries/Manifest.d.mts +7 -0
  98. package/dist/Queries/Manifest.d.mts.map +1 -0
  99. package/dist/Queries/Manifest.d.ts +7 -0
  100. package/dist/Queries/Manifest.d.ts.map +1 -0
  101. package/dist/Queries/ModuleAddress/Payload.d.mts +9 -0
  102. package/dist/Queries/ModuleAddress/Payload.d.mts.map +1 -0
  103. package/dist/Queries/ModuleAddress/Payload.d.ts +9 -0
  104. package/dist/Queries/ModuleAddress/Payload.d.ts.map +1 -0
  105. package/dist/Queries/ModuleAddress/Query.d.mts +7 -0
  106. package/dist/Queries/ModuleAddress/Query.d.mts.map +1 -0
  107. package/dist/Queries/ModuleAddress/Query.d.ts +7 -0
  108. package/dist/Queries/ModuleAddress/Query.d.ts.map +1 -0
  109. package/dist/Queries/ModuleAddress/index.d.mts +3 -0
  110. package/dist/Queries/ModuleAddress/index.d.mts.map +1 -0
  111. package/dist/Queries/ModuleAddress/index.d.ts +3 -0
  112. package/dist/Queries/ModuleAddress/index.d.ts.map +1 -0
  113. package/dist/Queries/Subscribe.d.mts +17 -0
  114. package/dist/Queries/Subscribe.d.mts.map +1 -0
  115. package/dist/Queries/Subscribe.d.ts +17 -0
  116. package/dist/Queries/Subscribe.d.ts.map +1 -0
  117. package/dist/Queries/index.d.mts +14 -0
  118. package/dist/Queries/index.d.mts.map +1 -0
  119. package/dist/Queries/index.d.ts +14 -0
  120. package/dist/Queries/index.d.ts.map +1 -0
  121. package/dist/docs.json +20620 -19257
  122. package/dist/index.d.mts +14 -330
  123. package/dist/index.d.mts.map +1 -0
  124. package/dist/index.d.ts +14 -330
  125. package/dist/index.d.ts.map +1 -0
  126. package/dist/index.js +184 -63
  127. package/dist/index.js.map +1 -1
  128. package/dist/index.mjs +167 -51
  129. package/dist/index.mjs.map +1 -1
  130. package/dist/instance/ModuleInstance.d.mts +41 -0
  131. package/dist/instance/ModuleInstance.d.mts.map +1 -0
  132. package/dist/instance/ModuleInstance.d.ts +41 -0
  133. package/dist/instance/ModuleInstance.d.ts.map +1 -0
  134. package/dist/instance/ModuleRepository.d.mts +9 -0
  135. package/dist/instance/ModuleRepository.d.mts.map +1 -0
  136. package/dist/instance/ModuleRepository.d.ts +9 -0
  137. package/dist/instance/ModuleRepository.d.ts.map +1 -0
  138. package/dist/instance/asModuleInstance.d.mts +5 -0
  139. package/dist/instance/asModuleInstance.d.mts.map +1 -0
  140. package/dist/instance/asModuleInstance.d.ts +5 -0
  141. package/dist/instance/asModuleInstance.d.ts.map +1 -0
  142. package/dist/instance/index.d.mts +5 -0
  143. package/dist/instance/index.d.mts.map +1 -0
  144. package/dist/instance/index.d.ts +5 -0
  145. package/dist/instance/index.d.ts.map +1 -0
  146. package/dist/instance/isModuleInstance.d.mts +5 -0
  147. package/dist/instance/isModuleInstance.d.mts.map +1 -0
  148. package/dist/instance/isModuleInstance.d.ts +5 -0
  149. package/dist/instance/isModuleInstance.d.ts.map +1 -0
  150. package/dist/lib/duplicateModules.d.mts +12 -0
  151. package/dist/lib/duplicateModules.d.mts.map +1 -0
  152. package/dist/lib/duplicateModules.d.ts +12 -0
  153. package/dist/lib/duplicateModules.d.ts.map +1 -0
  154. package/dist/lib/index.d.mts +3 -0
  155. package/dist/lib/index.d.mts.map +1 -0
  156. package/dist/lib/index.d.ts +3 -0
  157. package/dist/lib/index.d.ts.map +1 -0
  158. package/dist/lib/serializable.d.mts +3 -0
  159. package/dist/lib/serializable.d.mts.map +1 -0
  160. package/dist/lib/serializable.d.ts +3 -0
  161. package/dist/lib/serializable.d.ts.map +1 -0
  162. package/dist/module/IsModuleFactory.d.mts +7 -0
  163. package/dist/module/IsModuleFactory.d.mts.map +1 -0
  164. package/dist/module/IsModuleFactory.d.ts +7 -0
  165. package/dist/module/IsModuleFactory.d.ts.map +1 -0
  166. package/dist/module/Module.d.mts +6 -0
  167. package/dist/module/Module.d.mts.map +1 -0
  168. package/dist/module/Module.d.ts +6 -0
  169. package/dist/module/Module.d.ts.map +1 -0
  170. package/dist/module/ModuleFields.d.mts +18 -0
  171. package/dist/module/ModuleFields.d.mts.map +1 -0
  172. package/dist/module/ModuleFields.d.ts +18 -0
  173. package/dist/module/ModuleFields.d.ts.map +1 -0
  174. package/dist/module/ModuleQueryFunctions.d.mts +12 -0
  175. package/dist/module/ModuleQueryFunctions.d.mts.map +1 -0
  176. package/dist/module/ModuleQueryFunctions.d.ts +12 -0
  177. package/dist/module/ModuleQueryFunctions.d.ts.map +1 -0
  178. package/dist/module/asModule.d.mts +5 -0
  179. package/dist/module/asModule.d.mts.map +1 -0
  180. package/dist/module/asModule.d.ts +5 -0
  181. package/dist/module/asModule.d.ts.map +1 -0
  182. package/dist/module/asModuleObject.d.mts +5 -0
  183. package/dist/module/asModuleObject.d.mts.map +1 -0
  184. package/dist/module/asModuleObject.d.ts +5 -0
  185. package/dist/module/asModuleObject.d.ts.map +1 -0
  186. package/dist/module/index.d.mts +9 -0
  187. package/dist/module/index.d.mts.map +1 -0
  188. package/dist/module/index.d.ts +9 -0
  189. package/dist/module/index.d.ts.map +1 -0
  190. package/dist/module/isModule.d.mts +5 -0
  191. package/dist/module/isModule.d.mts.map +1 -0
  192. package/dist/module/isModule.d.ts +5 -0
  193. package/dist/module/isModule.d.ts.map +1 -0
  194. package/dist/module/isModuleObject.d.mts +5 -0
  195. package/dist/module/isModuleObject.d.mts.map +1 -0
  196. package/dist/module/isModuleObject.d.ts +5 -0
  197. package/dist/module/isModuleObject.d.ts.map +1 -0
  198. package/dist/withModule.d.mts +7 -0
  199. package/dist/withModule.d.mts.map +1 -0
  200. package/dist/withModule.d.ts +7 -0
  201. package/dist/withModule.d.ts.map +1 -0
  202. package/package.json +17 -23
  203. package/src/Config.ts +56 -44
  204. package/src/{CreatableModule.ts → CreatableModule/CreatableModule.ts} +5 -5
  205. package/src/CreatableModule/CreatableModuleRegistry.ts +29 -0
  206. package/src/CreatableModule/LabeledCreatableModuleFactory.ts +9 -0
  207. package/src/{ModuleFactory.ts → CreatableModule/ModuleFactory.ts} +12 -3
  208. package/src/CreatableModule/ModuleFactoryLocator.ts +84 -0
  209. package/src/CreatableModule/index.ts +6 -0
  210. package/src/Labels/Labels.ts +34 -0
  211. package/src/Labels/index.ts +1 -0
  212. package/src/ModuleParams.ts +4 -9
  213. package/src/index.ts +2 -3
  214. package/src/instance/ModuleInstance.ts +2 -2
  215. package/src/instance/asModuleInstance.ts +1 -1
  216. package/src/instance/isModuleInstance.ts +1 -1
  217. package/src/module/IsModuleFactory.ts +1 -1
  218. package/src/module/Module.ts +2 -3
  219. package/src/module/ModuleFields.ts +2 -2
  220. package/src/module/asModule.ts +1 -1
  221. package/src/module/asModuleObject.ts +1 -1
  222. package/src/module/isModule.ts +1 -1
  223. package/src/module/isModuleObject.ts +1 -1
  224. package/src/withModule.ts +1 -1
  225. package/tsup.config.ts +0 -16
  226. /package/src/{CreatableModuleDictionary.ts → CreatableModule/CreatableModuleDictionary.ts} +0 -0
  227. /package/src/{Events → EventsModels}/ModuleBusy.ts +0 -0
  228. /package/src/{Events → EventsModels}/ModuleError.ts +0 -0
  229. /package/src/{Events → EventsModels}/ModuleEventArgs.ts +0 -0
  230. /package/src/{Events → EventsModels}/ModuleEventData.ts +0 -0
  231. /package/src/{Events → EventsModels}/ModuleQueried.ts +0 -0
  232. /package/src/{Events → EventsModels}/index.ts +0 -0
package/dist/index.js CHANGED
@@ -29,14 +29,18 @@ __export(src_exports, {
29
29
  ModuleDescriptionSchema: () => ModuleDescriptionSchema,
30
30
  ModuleDiscoverQuerySchema: () => ModuleDiscoverQuerySchema,
31
31
  ModuleFactory: () => ModuleFactory,
32
+ ModuleFactoryLocator: () => ModuleFactoryLocator,
32
33
  ModuleManifestQuerySchema: () => ModuleManifestQuerySchema,
33
34
  ModuleSubscribeQuerySchema: () => ModuleSubscribeQuerySchema,
34
35
  WithFactory: () => WithFactory,
35
36
  asModule: () => asModule,
36
37
  asModuleInstance: () => asModuleInstance,
37
38
  asModuleObject: () => asModuleObject,
39
+ assignCreatableModuleRegistry: () => assignCreatableModuleRegistry,
38
40
  creatableModule: () => creatableModule,
39
41
  duplicateModules: () => duplicateModules,
42
+ hasAllLabels: () => hasAllLabels,
43
+ hasLabels: () => hasLabels,
40
44
  isModule: () => isModule,
41
45
  isModuleInstance: () => isModuleInstance,
42
46
  isModuleObject: () => isModuleObject,
@@ -45,6 +49,7 @@ __export(src_exports, {
45
49
  requiredModuleQueries: () => requiredModuleQueries,
46
50
  serializable: () => serializable,
47
51
  serializableField: () => serializableField,
52
+ toCreatableModuleRegistry: () => toCreatableModuleRegistry,
48
53
  withModule: () => withModule,
49
54
  withModuleInstance: () => withModuleInstance
50
55
  });
@@ -53,21 +58,176 @@ module.exports = __toCommonJS(src_exports);
53
58
  // src/Config.ts
54
59
  var ModuleConfigSchema = "network.xyo.module.config";
55
60
 
56
- // src/CreatableModule.ts
61
+ // src/CreatableModule/CreatableModule.ts
57
62
  function creatableModule() {
58
63
  return (constructor) => {
59
64
  constructor;
60
65
  };
61
66
  }
62
67
 
68
+ // src/CreatableModule/CreatableModuleRegistry.ts
69
+ var toCreatableModuleRegistry = (dict) => {
70
+ return Object.entries(dict).reduce((registry, [schema, factory4]) => {
71
+ registry[schema] = Array.isArray(factory4) ? factory4 : [factory4];
72
+ return registry;
73
+ }, {});
74
+ };
75
+ var assignCreatableModuleRegistry = (target = {}, ...sources) => {
76
+ sources.map(
77
+ (source) => Object.entries(source).map(([schema, factories]) => {
78
+ if (factories) {
79
+ const existingFactories = target[schema];
80
+ target[schema] = existingFactories ? target[schema] = [...existingFactories, ...factories] : factories;
81
+ }
82
+ })
83
+ );
84
+ return target;
85
+ };
86
+
87
+ // src/CreatableModule/LabeledCreatableModuleFactory.ts
88
+ var hasLabels = (factory4) => {
89
+ return factory4.labels !== void 0;
90
+ };
91
+
92
+ // src/CreatableModule/ModuleFactory.ts
93
+ var import_assert = require("@xylabs/assert");
94
+ var import_lodash = require("@xylabs/lodash");
95
+ var ModuleFactory = class _ModuleFactory {
96
+ configSchemas;
97
+ creatableModule;
98
+ defaultLogger;
99
+ defaultParams;
100
+ labels;
101
+ constructor(creatableModule2, params, labels = {}) {
102
+ this.creatableModule = creatableModule2;
103
+ this.defaultParams = params;
104
+ this.configSchemas = creatableModule2.configSchemas;
105
+ this.labels = Object.assign({}, creatableModule2.labels ?? {}, labels ?? {});
106
+ }
107
+ get configSchema() {
108
+ return this.configSchemas[0];
109
+ }
110
+ static withParams(creatableModule2, params, labels = {}) {
111
+ return new _ModuleFactory(creatableModule2, params, labels);
112
+ }
113
+ _getRootFunction(funcName) {
114
+ let anyThis = this;
115
+ while (anyThis.__proto__[funcName]) {
116
+ anyThis = anyThis.__proto__;
117
+ }
118
+ return anyThis[funcName];
119
+ }
120
+ _noOverride(functionName) {
121
+ const thisFunc = this[functionName];
122
+ const rootFunc = this._getRootFunction(functionName);
123
+ (0, import_assert.assertEx)(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`);
124
+ }
125
+ create(params) {
126
+ const factory4 = this;
127
+ const schema = factory4.creatableModule.configSchema;
128
+ const mergedParams = (0, import_lodash.merge)({}, factory4.defaultParams, params, {
129
+ config: (0, import_lodash.merge)({}, factory4.defaultParams?.config, params?.config, { schema })
130
+ });
131
+ return factory4.creatableModule.create(mergedParams);
132
+ }
133
+ factory(_params) {
134
+ throw new Error("Method not implemented.");
135
+ }
136
+ };
137
+
138
+ // src/CreatableModule/ModuleFactoryLocator.ts
139
+ var import_assert2 = require("@xylabs/assert");
140
+
141
+ // src/Labels/Labels.ts
142
+ var hasAllLabels = (source, required) => {
143
+ if (!required)
144
+ return true;
145
+ return Object.entries(required).every(([key, value]) => {
146
+ return source?.hasOwnProperty(key) && source?.[key] === value;
147
+ });
148
+ };
149
+
150
+ // src/CreatableModule/ModuleFactoryLocator.ts
151
+ var ModuleFactoryLocator = class {
152
+ constructor(_registry = {}) {
153
+ this._registry = _registry;
154
+ }
155
+ /**
156
+ * The current registry for the module factory
157
+ */
158
+ get registry() {
159
+ return this._registry;
160
+ }
161
+ /**
162
+ * Locates a module factory that matches the supplied schema and labels
163
+ * @param schema The config schema for the module
164
+ * @param labels The labels for the module factory
165
+ * @returns A module factory that matches the supplied schema and labels or throws if one is not found
166
+ */
167
+ locate(schema, labels) {
168
+ return (0, import_assert2.assertEx)(this.tryLocate(schema, labels), () => {
169
+ const configString = `config schema [${schema}]`;
170
+ const labelsString = labels ? ` & labels [${JSON.stringify(labels)}]` : "";
171
+ return `No module factory for the supplied ${configString}${labelsString} registered`;
172
+ });
173
+ }
174
+ /**
175
+ * Registers a single module factory (with optional tags) with the locator
176
+ * @param additional Additional module factories to register
177
+ */
178
+ register(mod, labels) {
179
+ mod.configSchemas.map((schema) => {
180
+ const existingFactories = this._registry[schema];
181
+ const factory4 = {
182
+ // Destructure instance properties
183
+ ...mod,
184
+ // Copy static methods
185
+ create: mod.create.bind(mod),
186
+ // Merge module & supplied labels
187
+ labels: Object.assign({}, mod.labels ?? {}, labels ?? {})
188
+ };
189
+ this._registry[schema] = existingFactories ? [...existingFactories, factory4] : [factory4];
190
+ });
191
+ return this;
192
+ }
193
+ /**
194
+ * Registers multiple module factories with the locator
195
+ * @param additional Additional module factories to register
196
+ */
197
+ registerMany(additional) {
198
+ Object.entries(additional).map(([schema, factories]) => {
199
+ if (factories) {
200
+ const existingFactories = this._registry[schema];
201
+ this._registry[schema] = existingFactories ? [...existingFactories, ...factories] : factories;
202
+ }
203
+ });
204
+ return this;
205
+ }
206
+ /**
207
+ * Tries to locate a module factory that matches the supplied schema and labels
208
+ * @param schema The config schema for the module
209
+ * @param labels The labels for the module factory
210
+ * @returns A module factory that matches the supplied schema and labels or undefined
211
+ */
212
+ tryLocate(schema, labels) {
213
+ return labels ? (
214
+ // Find the first factory that has labels and has all the labels provided
215
+ this._registry[schema]?.filter(hasLabels).find((factory4) => hasAllLabels(factory4?.labels, labels))
216
+ ) : (
217
+ // Otherwise, return the first factory
218
+ this._registry[schema]?.[0]
219
+ );
220
+ }
221
+ };
222
+
63
223
  // src/instance/asModuleInstance.ts
64
- var import_object_identity5 = require("@xyo-network/object-identity");
224
+ var import_object5 = require("@xyo-network/object");
65
225
 
66
226
  // src/instance/isModuleInstance.ts
67
- var import_object_identity4 = require("@xyo-network/object-identity");
227
+ var import_object4 = require("@xyo-network/object");
68
228
 
69
229
  // src/module/asModule.ts
70
- var import_object_identity3 = require("@xyo-network/object-identity");
230
+ var import_object3 = require("@xyo-network/object");
71
231
 
72
232
  // src/Queries/Describe/Payload.ts
73
233
  var ModuleDescriptionSchema = "network.xyo.module.description";
@@ -92,10 +252,10 @@ var ModuleAddressQuerySchema = "network.xyo.query.module.address";
92
252
  var ModuleSubscribeQuerySchema = "network.xyo.query.module.subscribe";
93
253
 
94
254
  // src/module/asModuleObject.ts
95
- var import_object_identity2 = require("@xyo-network/object-identity");
255
+ var import_object2 = require("@xyo-network/object");
96
256
 
97
257
  // src/module/isModuleObject.ts
98
- var import_object_identity = require("@xyo-network/object-identity");
258
+ var import_object = require("@xyo-network/object");
99
259
  var requiredModuleFunctions = {
100
260
  address: "string",
101
261
  config: "object",
@@ -104,11 +264,11 @@ var requiredModuleFunctions = {
104
264
  query: "function",
105
265
  queryable: "function"
106
266
  };
107
- var factory = new import_object_identity.IsObjectFactory();
267
+ var factory = new import_object.IsObjectFactory();
108
268
  var isModuleObject = factory.create(requiredModuleFunctions);
109
269
 
110
270
  // src/module/asModuleObject.ts
111
- var asModuleObject = import_object_identity2.AsObjectFactory.create(isModuleObject);
271
+ var asModuleObject = import_object2.AsObjectFactory.create(isModuleObject);
112
272
 
113
273
  // src/module/IsModuleFactory.ts
114
274
  var IsModuleFactory = class {
@@ -135,7 +295,7 @@ var factory2 = new IsModuleFactory();
135
295
  var isModule = factory2.create(requiredModuleQueries, [isModuleObject]);
136
296
 
137
297
  // src/module/asModule.ts
138
- var asModule = import_object_identity3.AsObjectFactory.create(isModule);
298
+ var asModule = import_object3.AsObjectFactory.create(isModule);
139
299
 
140
300
  // src/instance/isModuleInstance.ts
141
301
  var requiredModuleInstanceFunctions = {
@@ -144,15 +304,15 @@ var requiredModuleInstanceFunctions = {
144
304
  manifest: "function",
145
305
  moduleAddress: "function"
146
306
  };
147
- var factory3 = new import_object_identity4.IsObjectFactory();
307
+ var factory3 = new import_object4.IsObjectFactory();
148
308
  var isModuleInstance = factory3.create(requiredModuleInstanceFunctions, [isModule]);
149
309
 
150
310
  // src/instance/asModuleInstance.ts
151
- var asModuleInstance = import_object_identity5.AsObjectFactory.create(isModuleInstance);
311
+ var asModuleInstance = import_object5.AsObjectFactory.create(isModuleInstance);
152
312
 
153
313
  // src/instance/ModuleInstance.ts
154
- var import_object_identity6 = require("@xyo-network/object-identity");
155
- var IsInstanceFactory = class extends import_object_identity6.IsObjectFactory {
314
+ var import_object6 = require("@xyo-network/object");
315
+ var IsInstanceFactory = class extends import_object6.IsObjectFactory {
156
316
  };
157
317
 
158
318
  // src/lib/duplicateModules.ts
@@ -161,9 +321,9 @@ var duplicateModules = (value, index, array) => {
161
321
  };
162
322
 
163
323
  // src/lib/serializable.ts
164
- var import_lodash = require("@xylabs/lodash");
165
- var JSONPrimitiveChecks = [import_lodash.isUndefined, import_lodash.isNull, import_lodash.isBoolean, import_lodash.isNumber, import_lodash.isString];
166
- var JSONComplexChecks = [import_lodash.isPlainObject, import_lodash.isArray];
324
+ var import_lodash2 = require("@xylabs/lodash");
325
+ var JSONPrimitiveChecks = [import_lodash2.isUndefined, import_lodash2.isNull, import_lodash2.isBoolean, import_lodash2.isNumber, import_lodash2.isString];
326
+ var JSONComplexChecks = [import_lodash2.isPlainObject, import_lodash2.isArray];
167
327
  var serializable = (field, depth) => {
168
328
  let depthExceeded = false;
169
329
  const decrementDepth = () => depth ? depth-- : void 0;
@@ -173,58 +333,14 @@ var serializable = (field, depth) => {
173
333
  return false;
174
334
  }
175
335
  decrementDepth();
176
- const nestedSerializable = (field3) => (0, import_lodash.overSome)(JSONComplexChecks)(field3) && (0, import_lodash.every)(field3, recursiveSerializable);
177
- return (0, import_lodash.overSome)([...JSONPrimitiveChecks, nestedSerializable])(field2);
336
+ const nestedSerializable = (field3) => (0, import_lodash2.overSome)(JSONComplexChecks)(field3) && (0, import_lodash2.every)(field3, recursiveSerializable);
337
+ return (0, import_lodash2.overSome)([...JSONPrimitiveChecks, nestedSerializable])(field2);
178
338
  };
179
339
  const valid = recursiveSerializable(field);
180
340
  return depthExceeded ? null : valid;
181
341
  };
182
342
  var serializableField = (field) => {
183
- return (0, import_lodash.overSome)([...JSONPrimitiveChecks, ...JSONComplexChecks])(field);
184
- };
185
-
186
- // src/ModuleFactory.ts
187
- var import_assert = require("@xylabs/assert");
188
- var import_lodash2 = require("@xylabs/lodash");
189
- var ModuleFactory = class _ModuleFactory {
190
- configSchemas;
191
- creatableModule;
192
- defaultLogger;
193
- defaultParams;
194
- constructor(creatableModule2, params) {
195
- this.creatableModule = creatableModule2;
196
- this.defaultParams = params;
197
- this.configSchemas = creatableModule2.configSchemas;
198
- }
199
- get configSchema() {
200
- return this.configSchemas[0];
201
- }
202
- static withParams(creatableModule2, params) {
203
- return new _ModuleFactory(creatableModule2, params);
204
- }
205
- _getRootFunction(funcName) {
206
- let anyThis = this;
207
- while (anyThis.__proto__[funcName]) {
208
- anyThis = anyThis.__proto__;
209
- }
210
- return anyThis[funcName];
211
- }
212
- _noOverride(functionName) {
213
- const thisFunc = this[functionName];
214
- const rootFunc = this._getRootFunction(functionName);
215
- (0, import_assert.assertEx)(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`);
216
- }
217
- create(params) {
218
- const factory4 = this;
219
- const schema = factory4.creatableModule.configSchema;
220
- const mergedParams = (0, import_lodash2.merge)({}, factory4.defaultParams, params, {
221
- config: (0, import_lodash2.merge)({}, factory4.defaultParams?.config, params?.config, { schema })
222
- });
223
- return factory4.creatableModule.create(mergedParams);
224
- }
225
- factory(_params) {
226
- throw new Error("Method not implemented.");
227
- }
343
+ return (0, import_lodash2.overSome)([...JSONPrimitiveChecks, ...JSONComplexChecks])(field);
228
344
  };
229
345
 
230
346
  // src/withModule.ts
@@ -248,14 +364,18 @@ var withModuleInstance = WithFactory.create(isModuleInstance);
248
364
  ModuleDescriptionSchema,
249
365
  ModuleDiscoverQuerySchema,
250
366
  ModuleFactory,
367
+ ModuleFactoryLocator,
251
368
  ModuleManifestQuerySchema,
252
369
  ModuleSubscribeQuerySchema,
253
370
  WithFactory,
254
371
  asModule,
255
372
  asModuleInstance,
256
373
  asModuleObject,
374
+ assignCreatableModuleRegistry,
257
375
  creatableModule,
258
376
  duplicateModules,
377
+ hasAllLabels,
378
+ hasLabels,
259
379
  isModule,
260
380
  isModuleInstance,
261
381
  isModuleObject,
@@ -264,6 +384,7 @@ var withModuleInstance = WithFactory.create(isModuleInstance);
264
384
  requiredModuleQueries,
265
385
  serializable,
266
386
  serializableField,
387
+ toCreatableModuleRegistry,
267
388
  withModule,
268
389
  withModuleInstance
269
390
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/Config.ts","../src/CreatableModule.ts","../src/instance/asModuleInstance.ts","../src/instance/isModuleInstance.ts","../src/module/asModule.ts","../src/Queries/Describe/Payload.ts","../src/Queries/Describe/Query.ts","../src/Queries/Discover.ts","../src/Queries/Manifest.ts","../src/Queries/ModuleAddress/Payload.ts","../src/Queries/ModuleAddress/Query.ts","../src/Queries/Subscribe.ts","../src/module/asModuleObject.ts","../src/module/isModuleObject.ts","../src/module/IsModuleFactory.ts","../src/module/isModule.ts","../src/instance/ModuleInstance.ts","../src/lib/duplicateModules.ts","../src/lib/serializable.ts","../src/ModuleFactory.ts","../src/withModule.ts"],"sourcesContent":["export * from './Config'\nexport * from './CreatableModule'\nexport * from './CreatableModuleDictionary'\nexport * from './Events'\nexport * from './instance'\nexport * from './lib'\nexport * from './module'\nexport * from './ModuleDescription'\nexport * from './ModuleFactory'\nexport * from './ModuleParams'\nexport * from './ModuleQueryHandlerResult'\nexport * from './ModuleQueryResult'\nexport * from './Queries'\nexport * from './withModule'\n","import { WithAdditional } from '@xyo-network/core'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport type ModuleConfigSchema = 'network.xyo.module.config'\nexport const ModuleConfigSchema: ModuleConfigSchema = 'network.xyo.module.config'\n\nexport type AddressString = string\nexport type CosigningAddressSet = string[]\nexport type SchemaString = string\n\nexport type NameOrAddress = string\n\nexport interface IndividualArchivistConfig {\n readonly commit?: NameOrAddress\n readonly read?: NameOrAddress\n readonly write?: NameOrAddress\n}\n\nexport type ArchivistModuleConfig = NameOrAddress | IndividualArchivistConfig\n\nexport type ModuleConfigBase<TConfig extends Payload | undefined = undefined> = Payload<\n WithAdditional<\n {\n /** @field The path to use when creating the account */\n accountDerivationPath?: string\n\n /** @field The name/address of the Archivist to use for this module */\n readonly archivist?: ArchivistModuleConfig\n\n /** @field Friendly name of module (not collision resistent). Can be used to resolve module when registered/attached to Node. */\n readonly name?: string\n\n /** @field paging settings for queries */\n readonly paging?: Record<string, { size?: number }>\n\n /** @field The config schema for the module */\n readonly schema: TConfig extends Payload ? TConfig['schema'] : ModuleConfigSchema\n\n /** @field The query schemas and allowed/disallowed addresses which are allowed to issue them against the module. If both allowed and disallowed is specified, then disallowed takes priority. */\n readonly security?: {\n /** @field Will the module process queries that have unsigned BoundWitness in query tuples */\n readonly allowAnonymous?: boolean\n\n /** @field If schema in record, then only these address sets can access query */\n readonly allowed?: Record<SchemaString, (AddressString | CosigningAddressSet)[]>\n\n /** @field If schema in record, then anyone except these addresses can access query */\n readonly disallowed?: Record<SchemaString, AddressString[]>\n }\n\n /** @field sign every query */\n readonly sign?: boolean\n\n /** @field Store the queries made to the module in an archivist if possible */\n readonly storeQueries?: boolean\n\n /** @field add a timestamp payload to every query */\n readonly timestamp?: boolean\n },\n Omit<TConfig, 'schema'>\n >\n>\n\nexport type ModuleConfig<TConfig extends Payload | undefined = undefined> = ModuleConfigBase<TConfig>\n\nexport type AnyConfigSchema<TConfig extends Omit<ModuleConfig, 'schema'> & { schema: string } = Omit<ModuleConfig, 'schema'> & { schema: string }> =\n ModuleConfig<\n WithAdditional<\n Omit<TConfig, 'schema'>,\n {\n schema: string\n }\n >\n >\n\nexport type OptionalConfigSchema<TConfig extends AnyConfigSchema<ModuleConfig> = AnyConfigSchema<ModuleConfig>> = Omit<TConfig, 'schema'> & {\n schema?: TConfig['schema']\n}\n\nexport type AnyModuleConfig = AnyConfigSchema<ModuleConfig>\n","import { AccountInstance } from '@xyo-network/account-model'\nimport { Logger } from '@xyo-network/logger'\n\nimport { ModuleInstance } from './instance'\n\nexport interface CreatableModule<T extends ModuleInstance = ModuleInstance> {\n configSchema: string\n configSchemas: string[]\n defaultLogger?: Logger\n new (privateConstructorKey: string, params: T['params'], account: AccountInstance): T\n _noOverride(functionName: string): void\n create<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): Promise<T>\n factory<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): CreatableModuleFactory<T>\n}\n\nexport type CreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = Omit<Omit<CreatableModule<T>, 'new'>, 'create'> & {\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: T['params']): Promise<T>\n}\n\n/**\n * Class annotation to be used to decorate Modules which support\n * an asynchronous creation pattern\n * @returns The decorated Module requiring it implement the members\n * of the CreatableModule as statics properties/methods\n */\nexport function creatableModule<TModule extends ModuleInstance = ModuleInstance>() {\n return <U extends CreatableModule<TModule>>(constructor: U) => {\n constructor\n }\n}\n","import { AsObjectFactory } from '@xyo-network/object-identity'\n\nimport { isModuleInstance } from './isModuleInstance'\n\nexport const asModuleInstance = AsObjectFactory.create(isModuleInstance)\n","import { IsObjectFactory, ObjectTypeCheck, ObjectTypeShape } from '@xyo-network/object-identity'\n\nimport { isModule } from '../module'\nimport { ModuleInstance } from './ModuleInstance'\n\nexport const requiredModuleInstanceFunctions: ObjectTypeShape = {\n describe: 'function',\n discover: 'function',\n manifest: 'function',\n moduleAddress: 'function',\n}\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsObjectFactory<ModuleInstance>()\n\nexport const isModuleInstance: ObjectTypeCheck<ModuleInstance> = factory.create(requiredModuleInstanceFunctions, [isModule])\n","import { AsObjectFactory } from '@xyo-network/object-identity'\n\nimport { isModule } from './isModule'\n\nexport const asModule = AsObjectFactory.create(isModule)\n","import { Payload } from '@xyo-network/payload-model'\n\nimport { ModuleDescription } from '../../ModuleDescription'\n\nexport const ModuleDescriptionSchema = 'network.xyo.module.description'\nexport type ModuleDescriptionSchema = typeof ModuleDescriptionSchema\n\nexport type ModuleDescriptionPayload = Payload<ModuleDescription, ModuleDescriptionSchema>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\nexport const ModuleDescribeQuerySchema: ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\n\nexport type ModuleDescribeQuery = Query<{\n schema: ModuleDescribeQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\nexport const ModuleDiscoverQuerySchema: ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\n\nexport type ModuleDiscoverQuery = Query<{\n schema: ModuleDiscoverQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\nexport const ModuleManifestQuerySchema: ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\n\nexport type ModuleManifestQuery = Query<{\n schema: ModuleManifestQuerySchema\n}>\n","import { AddressSchema } from '@xyo-network/address-payload-plugin'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport const AddressPreviousHashSchema = `${AddressSchema}.hash.previous`\nexport type AddressPreviousHashSchema = typeof AddressPreviousHashSchema\n\nexport type AddressPreviousHashPayload = Payload<{\n address: string\n previousHash?: string\n schema: AddressPreviousHashSchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleAddressQuerySchema = 'network.xyo.query.module.address'\nexport const ModuleAddressQuerySchema: ModuleAddressQuerySchema = 'network.xyo.query.module.address'\n\nexport type ModuleAddressQuery = Query<{\n schema: ModuleAddressQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\nexport const ModuleSubscribeQuerySchema: ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\n\nexport interface ModuleSubscribeFilter {\n /** @field if specified, at least one of the schemas must be present in the boundwtness to generate a notification */\n schema?: string[]\n}\n\n//requests notification when a boundwitness is added to the modules chain that meets the filter criteria\nexport type ModuleSubscribeQuery = Query<{\n /** @field The address that will receive notifications */\n address: string\n /** @field A subscribe with a null for filter is an unsubscribe */\n filter?: ModuleSubscribeFilter | null\n /** @field The maximum events queued per send [may increase frequency] */\n maxQueue?: number\n schema: ModuleSubscribeQuerySchema\n}>\n","import { AsObjectFactory } from '@xyo-network/object-identity'\n\nimport { isModuleObject } from './isModuleObject'\n\nexport const asModuleObject = AsObjectFactory.create(isModuleObject)\n","import { IsObjectFactory, ObjectTypeCheck, ObjectTypeShape } from '@xyo-network/object-identity'\n\nimport { Module } from './Module'\n\nexport const requiredModuleFunctions: ObjectTypeShape = {\n address: 'string',\n config: 'object',\n params: 'object',\n queries: 'array',\n query: 'function',\n queryable: 'function',\n}\n\nconst factory = new IsObjectFactory<Module>()\n\nexport const isModuleObject: ObjectTypeCheck<Module> = factory.create(requiredModuleFunctions)\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ObjectTypeCheck } from '@xyo-network/object-identity'\n\nimport { asModuleObject } from './asModuleObject'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport type ModuleTypeCheck<T extends Module = Module> = ObjectTypeCheck<T>\n\nexport class IsModuleFactory<T extends Module = Module> {\n create(expectedQueries?: string[], additionalChecks?: ObjectTypeCheck[]): ModuleTypeCheck<T> {\n return (obj: any, config): obj is T => {\n const module = asModuleObject(obj)\n const result =\n isModuleObject(module, config) &&\n (expectedQueries?.reduce((prev, query) => prev && obj.queries.includes(query), true) ?? true) &&\n //perform additional checks\n (additionalChecks?.reduce((prev, check) => prev && check(obj, config), true) ?? true)\n return result\n }\n }\n}\n","import { ObjectTypeCheck } from '@xyo-network/object-identity'\n\nimport { ModuleDiscoverQuerySchema } from '../Queries'\nimport { IsModuleFactory } from './IsModuleFactory'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport const requiredModuleQueries: string[] = [\n /* We need to update this once live module conform */\n //ModuleDescribeQuerySchema,\n //ModuleAddressQuerySchema,\n ModuleDiscoverQuerySchema,\n //ModuleManifestQuerySchema,\n //ModuleSubscribeQuerySchema,\n]\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsModuleFactory<Module>()\n\nexport const isModule: ObjectTypeCheck<Module> = factory.create(requiredModuleQueries, [isModuleObject])\n","import { IsObjectFactory, ObjectTypeCheck } from '@xyo-network/object-identity'\nimport { Promisable } from '@xyo-network/promise'\n\nimport { AnyConfigSchema, ModuleConfig } from '../Config'\nimport { ModuleEventData } from '../Events'\nimport { Module, ModuleQueryFunctions } from '../module'\nimport { ModuleParams } from '../ModuleParams'\n\nexport interface ResolveFunctions {\n resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promisable<T[]>\n resolve<T extends ModuleInstance = ModuleInstance>(nameOrAddress: string, options?: ModuleFilterOptions<T>): Promisable<T | undefined>\n resolve<T extends ModuleInstance = ModuleInstance>(\n nameOrAddressOrFilter?: ModuleFilter<T> | string,\n options?: ModuleFilterOptions<T>,\n ): Promisable<T | T[] | undefined>\n}\n\nexport interface ModuleResolver extends ResolveFunctions {\n addResolver: (resolver: ModuleResolver) => this\n isModuleResolver: boolean\n removeResolver: (resolver: ModuleResolver) => this\n}\n\nexport type ModuleInstance<\n TParams extends ModuleParams<AnyConfigSchema<ModuleConfig>> = ModuleParams<AnyConfigSchema<ModuleConfig>>,\n TEventData extends ModuleEventData = ModuleEventData,\n> = Module<TParams, TEventData> &\n ResolveFunctions &\n ModuleQueryFunctions & {\n /* The resolver is a 'down' resolver. It can resolve the module or any children (if it is a node for example), that are in the module*/\n readonly downResolver: Omit<ModuleResolver, 'resolve'>\n\n /* The resolver is a 'up' resolver. It can resolve the parent or any children of the parent*/\n /* This is set by a NodeModule when attaching to the module */\n readonly upResolver: Omit<ModuleResolver, 'resolve'>\n }\n\nexport type InstanceTypeCheck<T extends ModuleInstance = ModuleInstance> = ObjectTypeCheck<T>\n\nexport class IsInstanceFactory<T extends ModuleInstance = ModuleInstance> extends IsObjectFactory<T> {}\n\nexport interface ModuleFilterOptions<T extends ModuleInstance = ModuleInstance> {\n direction?: 'up' | 'down' | 'all'\n identity?: InstanceTypeCheck<T>\n maxDepth?: number\n visibility?: 'public' | 'private' | 'all'\n}\n\nexport interface AddressModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n address: string[]\n}\n\nexport interface NameModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n name: string[]\n}\n\nexport interface QueryModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n query: string[][]\n}\n\nexport type AnyModuleFilter<T extends ModuleInstance = ModuleInstance> = Partial<AddressModuleFilter<T>> &\n Partial<NameModuleFilter<T>> &\n Partial<QueryModuleFilter<T>>\n\nexport type ModuleFilter<T extends ModuleInstance = ModuleInstance> =\n | ModuleFilterOptions<T>\n | AddressModuleFilter<T>\n | NameModuleFilter<T>\n | QueryModuleFilter<T>\n","import { Module } from '../module'\n\n/**\n * Used to filter duplicates from an array of modules\n * @example: modulesArray.filter(duplicateModules)\n * @param value Current Module\n * @param index Current Module's index\n * @param array Module Array\n * @returns True if the Module's address is the first occurrence of\n * that address in the array, false otherwise\n */\nexport const duplicateModules = (value: Module, index: number, array: Module[]): value is Module => {\n return array.findIndex((v) => v.address === value.address) === index\n}\n","// Inspired by https://stackoverflow.com/a/49079549/2803259\n\nimport { every, isArray, isBoolean, isNull, isNumber, isPlainObject, isString, isUndefined, overSome } from '@xylabs/lodash'\n\nconst JSONPrimitiveChecks = [isUndefined, isNull, isBoolean, isNumber, isString]\nconst JSONComplexChecks = [isPlainObject, isArray]\n\nexport const serializable = (field: unknown, depth?: number): boolean | null => {\n let depthExceeded = false\n const decrementDepth = () => (depth ? depth-- : undefined)\n\n const recursiveSerializable = (field: unknown) => {\n if (depth !== undefined && depth < 1) {\n depthExceeded = true\n return false\n }\n\n // decrement during every recursion\n decrementDepth()\n\n const nestedSerializable = (field: unknown): boolean => overSome(JSONComplexChecks)(field) && every(field as object, recursiveSerializable)\n\n return overSome([...JSONPrimitiveChecks, nestedSerializable])(field)\n }\n\n const valid = recursiveSerializable(field)\n\n return depthExceeded ? null : valid\n}\n\nexport const serializableField = (field: unknown) => {\n return overSome([...JSONPrimitiveChecks, ...JSONComplexChecks])(field)\n}\n","import { assertEx } from '@xylabs/assert'\nimport { merge } from '@xylabs/lodash'\nimport { Logger } from '@xyo-network/logger'\n\nimport { CreatableModule, CreatableModuleFactory } from './CreatableModule'\nimport { ModuleInstance } from './instance'\n\nexport class ModuleFactory<TModule extends ModuleInstance> implements CreatableModuleFactory<TModule> {\n configSchemas: CreatableModuleFactory<TModule>['configSchemas']\n\n creatableModule: CreatableModule<TModule>\n\n defaultLogger?: Logger | undefined\n\n defaultParams?: Omit<TModule['params'], 'config'> & { config?: TModule['params']['config'] }\n\n constructor(creatableModule: CreatableModule<TModule>, params?: Omit<TModule['params'], 'config'> & { config?: TModule['params']['config'] }) {\n this.creatableModule = creatableModule\n this.defaultParams = params\n this.configSchemas = creatableModule.configSchemas\n }\n\n get configSchema(): string {\n return this.configSchemas[0]\n }\n\n static withParams<T extends ModuleInstance>(\n creatableModule: CreatableModule<T>,\n params?: Omit<T['params'], 'config'> & { config?: T['params']['config'] },\n ) {\n return new ModuleFactory(creatableModule, params)\n }\n\n _getRootFunction(funcName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let anyThis = this as any\n while (anyThis.__proto__[funcName]) {\n anyThis = anyThis.__proto__\n }\n return anyThis[funcName]\n }\n\n _noOverride(functionName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const thisFunc = (this as any)[functionName]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rootFunc = this._getRootFunction(functionName)\n assertEx(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`)\n }\n\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: TModule['params'] | undefined): Promise<T> {\n const factory = this as ModuleFactory<T>\n const schema = factory.creatableModule.configSchema\n const mergedParams: TModule['params'] = merge({}, factory.defaultParams, params, {\n config: merge({}, factory.defaultParams?.config, params?.config, { schema }),\n })\n return factory.creatableModule.create<T>(mergedParams)\n }\n\n factory<T extends ModuleInstance>(this: CreatableModule<T>, _params?: T['params'] | undefined): CreatableModuleFactory<T> {\n throw new Error('Method not implemented.')\n }\n}\n","import { ObjectTypeCheck } from '@xyo-network/object-identity'\n\nimport { isModuleInstance } from './instance'\nimport { isModule } from './module'\n\nexport const WithFactory = {\n create: <T extends object>(typeCheck: ObjectTypeCheck<T>) => {\n return <R>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n module: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n closure: (module: T) => R,\n ): R | undefined => {\n return typeCheck(module) ? closure(module) : undefined\n }\n },\n}\n\nexport const withModule = WithFactory.create(isModule)\nexport const withModuleInstance = WithFactory.create(isModuleInstance)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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Y,OAAO,QAAQ;AAC9C,IAAM,qBAAqB,YAAY,OAAO,gBAAgB;","names":["import_object_identity","import_object_identity","import_object_identity","import_object_identity","module","factory","factory","import_object_identity","field","import_lodash","creatableModule","factory","module"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/Config.ts","../src/CreatableModule/CreatableModule.ts","../src/CreatableModule/CreatableModuleRegistry.ts","../src/CreatableModule/LabeledCreatableModuleFactory.ts","../src/CreatableModule/ModuleFactory.ts","../src/CreatableModule/ModuleFactoryLocator.ts","../src/Labels/Labels.ts","../src/instance/asModuleInstance.ts","../src/instance/isModuleInstance.ts","../src/module/asModule.ts","../src/Queries/Describe/Payload.ts","../src/Queries/Describe/Query.ts","../src/Queries/Discover.ts","../src/Queries/Manifest.ts","../src/Queries/ModuleAddress/Payload.ts","../src/Queries/ModuleAddress/Query.ts","../src/Queries/Subscribe.ts","../src/module/asModuleObject.ts","../src/module/isModuleObject.ts","../src/module/IsModuleFactory.ts","../src/module/isModule.ts","../src/instance/ModuleInstance.ts","../src/lib/duplicateModules.ts","../src/lib/serializable.ts","../src/withModule.ts"],"sourcesContent":["export * from './Config'\nexport * from './CreatableModule'\nexport * from './EventsModels'\nexport * from './instance'\nexport * from './Labels'\nexport * from './lib'\nexport * from './module'\nexport * from './ModuleDescription'\nexport * from './ModuleParams'\nexport * from './ModuleQueryHandlerResult'\nexport * from './ModuleQueryResult'\nexport * from './Queries'\nexport * from './withModule'\n","import { AnyObject, WithAdditional } from '@xyo-network/core'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { Labels } from './Labels'\n\nexport type ModuleConfigSchema = 'network.xyo.module.config'\nexport const ModuleConfigSchema: ModuleConfigSchema = 'network.xyo.module.config'\n\nexport type AddressString = string\nexport type CosigningAddressSet = string[]\nexport type SchemaString = string\n\nexport type NameOrAddress = string\n\nexport interface IndividualArchivistConfig {\n readonly commit?: NameOrAddress\n readonly read?: NameOrAddress\n readonly write?: NameOrAddress\n}\n\nexport type ArchivistModuleConfig = NameOrAddress | IndividualArchivistConfig\n\nexport type ModuleConfig<\n TConfig extends Payload | void = void,\n TAdditionalParams extends AnyObject | void = void,\n TSchema extends Schema | void = void,\n> = Payload<\n WithAdditional<\n WithAdditional<\n {\n /** @field The path to use when creating the account */\n accountDerivationPath?: string\n\n /** @field The name/address of the Archivist to use for this module */\n readonly archivist?: ArchivistModuleConfig\n\n /**\n * @field The labels used for this module. If a label is specified, then the\n * ModuleFactoryLocator will attempt to find a ModuleFactory with the corresponding\n * labels to construct this module.\n */\n readonly labels?: Labels\n\n /** @field Friendly name of module (not collision resistent). Can be used to resolve module when registered/attached to Node. */\n readonly name?: string\n\n /** @field paging settings for queries */\n readonly paging?: Record<string, { size?: number }>\n\n /** @field The query schemas and allowed/disallowed addresses which are allowed to issue them against the module. If both allowed and disallowed is specified, then disallowed takes priority. */\n readonly security?: {\n /** @field Will the module process queries that have unsigned BoundWitness in query tuples */\n readonly allowAnonymous?: boolean\n\n /** @field If schema in record, then only these address sets can access query */\n readonly allowed?: Record<SchemaString, (AddressString | CosigningAddressSet)[]>\n\n /** @field If schema in record, then anyone except these addresses can access query */\n readonly disallowed?: Record<SchemaString, AddressString[]>\n }\n\n /** @field sign every query */\n readonly sign?: boolean\n\n /** @field Store the queries made to the module in an archivist if possible */\n readonly storeQueries?: boolean\n\n /** @field add a timestamp payload to every query */\n readonly timestamp?: boolean\n },\n TConfig\n >,\n TAdditionalParams\n >,\n TSchema extends Schema ? TSchema : TConfig extends Payload ? TConfig['schema'] : ModuleConfigSchema\n>\n\nexport type AnyConfigSchema<TConfig extends Omit<ModuleConfig, 'schema'> & { schema: string } = Omit<ModuleConfig, 'schema'> & { schema: string }> =\n ModuleConfig<\n WithAdditional<\n Omit<TConfig, 'schema'>,\n {\n schema: string\n }\n >\n >\n\nexport type OptionalConfigSchema<TConfig extends AnyConfigSchema<ModuleConfig> = AnyConfigSchema<ModuleConfig>> = Omit<TConfig, 'schema'> & {\n schema?: TConfig['schema']\n}\n\nexport type AnyModuleConfig = AnyConfigSchema<ModuleConfig>\n","import { AccountInstance } from '@xyo-network/account-model'\nimport { Logger } from '@xyo-network/logger'\n\nimport { ModuleInstance } from '../instance'\n\nexport type CreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = Omit<Omit<CreatableModule<T>, 'new'>, 'create'> & {\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: T['params']): Promise<T>\n}\n\nexport interface CreatableModule<T extends ModuleInstance = ModuleInstance> {\n configSchema: string\n configSchemas: string[]\n defaultLogger?: Logger\n new (privateConstructorKey: string, params: T['params'], account: AccountInstance): T\n _noOverride(functionName: string): void\n create<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): Promise<T>\n factory<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): CreatableModuleFactory<T>\n}\n\n/**\n * Class annotation to be used to decorate Modules which support\n * an asynchronous creation pattern\n * @returns The decorated Module requiring it implement the members\n * of the CreatableModule as statics properties/methods\n */\nexport function creatableModule<TModule extends ModuleInstance = ModuleInstance>() {\n return <U extends CreatableModule<TModule>>(constructor: U) => {\n constructor\n }\n}\n","import { CreatableModuleFactory } from './CreatableModule'\nimport { CreatableModuleDictionary } from './CreatableModuleDictionary'\nimport { LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\nexport interface CreatableModuleRegistry {\n [key: string]: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] | undefined\n}\n\nexport const toCreatableModuleRegistry = (dict: CreatableModuleDictionary | CreatableModuleRegistry): CreatableModuleRegistry => {\n return Object.entries(dict).reduce((registry, [schema, factory]) => {\n registry[schema] = Array.isArray(factory) ? factory : [factory]\n return registry\n }, {} as CreatableModuleRegistry)\n}\n\nexport const assignCreatableModuleRegistry = (\n target: CreatableModuleRegistry = {},\n ...sources: CreatableModuleRegistry[]\n): CreatableModuleRegistry => {\n sources.map((source) =>\n Object.entries(source).map(([schema, factories]) => {\n if (factories) {\n const existingFactories = target[schema]\n target[schema] = existingFactories ? (target[schema] = [...existingFactories, ...factories]) : factories\n }\n }),\n )\n return target\n}\n","import { ModuleInstance } from '../instance'\nimport { WithOptionalLabels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\n\nexport type LabeledCreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = CreatableModuleFactory<T> & WithOptionalLabels\n\nexport const hasLabels = (factory: CreatableModuleFactory | LabeledCreatableModuleFactory): factory is LabeledCreatableModuleFactory => {\n return (factory as LabeledCreatableModuleFactory).labels !== undefined\n}\n","import { assertEx } from '@xylabs/assert'\nimport { merge } from '@xylabs/lodash'\nimport { Logger } from '@xyo-network/logger'\n\nimport { ModuleInstance } from '../instance'\nimport { Labels, WithOptionalLabels } from '../Labels'\nimport { CreatableModule, CreatableModuleFactory } from './CreatableModule'\n\nexport class ModuleFactory<TModule extends ModuleInstance> implements CreatableModuleFactory<TModule> {\n configSchemas: CreatableModuleFactory<TModule>['configSchemas']\n\n creatableModule: CreatableModule<TModule>\n\n defaultLogger?: Logger | undefined\n\n defaultParams?: Omit<TModule['params'], 'config'> & { config?: TModule['params']['config'] }\n\n labels?: Labels\n\n constructor(\n creatableModule: CreatableModule<TModule>,\n params?: Omit<TModule['params'], 'config'> & { config?: TModule['params']['config'] },\n labels: Labels = {},\n ) {\n this.creatableModule = creatableModule\n this.defaultParams = params\n this.configSchemas = creatableModule.configSchemas\n this.labels = Object.assign({}, (creatableModule as WithOptionalLabels).labels ?? {}, labels ?? {})\n }\n\n get configSchema(): string {\n return this.configSchemas[0]\n }\n\n static withParams<T extends ModuleInstance>(\n creatableModule: CreatableModule<T>,\n params?: Omit<T['params'], 'config'> & { config?: T['params']['config'] },\n labels: Labels = {},\n ) {\n return new ModuleFactory(creatableModule, params, labels)\n }\n\n _getRootFunction(funcName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let anyThis = this as any\n while (anyThis.__proto__[funcName]) {\n anyThis = anyThis.__proto__\n }\n return anyThis[funcName]\n }\n\n _noOverride(functionName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const thisFunc = (this as any)[functionName]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rootFunc = this._getRootFunction(functionName)\n assertEx(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`)\n }\n\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: TModule['params'] | undefined): Promise<T> {\n const factory = this as ModuleFactory<T>\n const schema = factory.creatableModule.configSchema\n const mergedParams: TModule['params'] = merge({}, factory.defaultParams, params, {\n config: merge({}, factory.defaultParams?.config, params?.config, { schema }),\n })\n return factory.creatableModule.create<T>(mergedParams)\n }\n\n factory<T extends ModuleInstance>(this: CreatableModule<T>, _params?: T['params'] | undefined): CreatableModuleFactory<T> {\n throw new Error('Method not implemented.')\n }\n}\n","import { assertEx } from '@xylabs/assert'\n\nimport { ModuleInstance } from '../instance'\nimport { hasAllLabels, Labels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\nimport { CreatableModuleRegistry } from './CreatableModuleRegistry'\nimport { hasLabels, LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\n/**\n * A class which encapsulates the Service Locator Pattern for Module Factories\n */\nexport class ModuleFactoryLocator {\n constructor(protected readonly _registry: CreatableModuleRegistry = {}) {}\n\n /**\n * The current registry for the module factory\n */\n get registry(): Readonly<CreatableModuleRegistry> {\n return this._registry\n }\n\n /**\n * Locates a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or throws if one is not found\n */\n locate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory {\n return assertEx(this.tryLocate(schema, labels), () => {\n const configString = `config schema [${schema}]`\n const labelsString = labels ? ` & labels [${JSON.stringify(labels)}]` : ''\n return `No module factory for the supplied ${configString}${labelsString} registered`\n })\n }\n\n /**\n * Registers a single module factory (with optional tags) with the locator\n * @param additional Additional module factories to register\n */\n register<TModule extends ModuleInstance>(mod: CreatableModuleFactory<TModule>, labels?: Labels): this {\n mod.configSchemas.map((schema) => {\n const existingFactories = this._registry[schema]\n const factory: LabeledCreatableModuleFactory<TModule> = {\n // Destructure instance properties\n ...mod,\n // Copy static methods\n create: mod.create.bind(mod) as LabeledCreatableModuleFactory<TModule>['create'],\n // Merge module & supplied labels\n labels: Object.assign({}, (mod as LabeledCreatableModuleFactory).labels ?? {}, labels ?? {}),\n }\n this._registry[schema] = existingFactories ? [...existingFactories, factory] : [factory]\n })\n return this\n }\n\n /**\n * Registers multiple module factories with the locator\n * @param additional Additional module factories to register\n */\n registerMany(additional: CreatableModuleRegistry): this {\n Object.entries(additional).map(([schema, factories]) => {\n if (factories) {\n const existingFactories = this._registry[schema]\n this._registry[schema] = existingFactories ? [...existingFactories, ...factories] : factories\n }\n })\n return this\n }\n\n /**\n * Tries to locate a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or undefined\n */\n tryLocate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined {\n // If labels were provided\n return labels\n ? // Find the first factory that has labels and has all the labels provided\n this._registry[schema]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels))\n : // Otherwise, return the first factory\n this._registry[schema]?.[0]\n }\n}\n","/**\n * Object used to represent labels identifying a resource.\n */\nexport interface Labels {\n [key: string]: string | undefined\n}\n\n/**\n * Interface for objects that have labels.\n */\nexport interface WithLabels<T extends Labels = Labels> {\n labels: T\n}\n\n/**\n * Interface for objects that have labels.\n */\nexport interface WithOptionalLabels<T extends Labels = Labels> {\n labels?: T\n}\n\n/**\n * Returns true if the source object has all the labels from the required set\n * @param source Source object to check against\n * @param required Set of labels to check for in source\n * @returns True of the source object has all the labels from the required set\n */\nexport const hasAllLabels = (source?: Labels, required?: Labels): boolean => {\n if (!required) return true\n return Object.entries(required).every(([key, value]) => {\n // eslint-disable-next-line no-prototype-builtins\n return source?.hasOwnProperty(key as keyof typeof source) && source?.[key as keyof typeof source] === value\n })\n}\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModuleInstance } from './isModuleInstance'\n\nexport const asModuleInstance = AsObjectFactory.create(isModuleInstance)\n","import { IsObjectFactory, ObjectTypeCheck, ObjectTypeShape } from '@xyo-network/object'\n\nimport { isModule } from '../module'\nimport { ModuleInstance } from './ModuleInstance'\n\nexport const requiredModuleInstanceFunctions: ObjectTypeShape = {\n describe: 'function',\n discover: 'function',\n manifest: 'function',\n moduleAddress: 'function',\n}\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsObjectFactory<ModuleInstance>()\n\nexport const isModuleInstance: ObjectTypeCheck<ModuleInstance> = factory.create(requiredModuleInstanceFunctions, [isModule])\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModule } from './isModule'\n\nexport const asModule = AsObjectFactory.create(isModule)\n","import { Payload } from '@xyo-network/payload-model'\n\nimport { ModuleDescription } from '../../ModuleDescription'\n\nexport const ModuleDescriptionSchema = 'network.xyo.module.description'\nexport type ModuleDescriptionSchema = typeof ModuleDescriptionSchema\n\nexport type ModuleDescriptionPayload = Payload<ModuleDescription, ModuleDescriptionSchema>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\nexport const ModuleDescribeQuerySchema: ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\n\nexport type ModuleDescribeQuery = Query<{\n schema: ModuleDescribeQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\nexport const ModuleDiscoverQuerySchema: ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\n\nexport type ModuleDiscoverQuery = Query<{\n schema: ModuleDiscoverQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\nexport const ModuleManifestQuerySchema: ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\n\nexport type ModuleManifestQuery = Query<{\n schema: ModuleManifestQuerySchema\n}>\n","import { AddressSchema } from '@xyo-network/address-payload-plugin'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport const AddressPreviousHashSchema = `${AddressSchema}.hash.previous`\nexport type AddressPreviousHashSchema = typeof AddressPreviousHashSchema\n\nexport type AddressPreviousHashPayload = Payload<{\n address: string\n previousHash?: string\n schema: AddressPreviousHashSchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleAddressQuerySchema = 'network.xyo.query.module.address'\nexport const ModuleAddressQuerySchema: ModuleAddressQuerySchema = 'network.xyo.query.module.address'\n\nexport type ModuleAddressQuery = Query<{\n schema: ModuleAddressQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\nexport const ModuleSubscribeQuerySchema: ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\n\nexport interface ModuleSubscribeFilter {\n /** @field if specified, at least one of the schemas must be present in the boundwtness to generate a notification */\n schema?: string[]\n}\n\n//requests notification when a boundwitness is added to the modules chain that meets the filter criteria\nexport type ModuleSubscribeQuery = Query<{\n /** @field The address that will receive notifications */\n address: string\n /** @field A subscribe with a null for filter is an unsubscribe */\n filter?: ModuleSubscribeFilter | null\n /** @field The maximum events queued per send [may increase frequency] */\n maxQueue?: number\n schema: ModuleSubscribeQuerySchema\n}>\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModuleObject } from './isModuleObject'\n\nexport const asModuleObject = AsObjectFactory.create(isModuleObject)\n","import { IsObjectFactory, ObjectTypeCheck, ObjectTypeShape } from '@xyo-network/object'\n\nimport { Module } from './Module'\n\nexport const requiredModuleFunctions: ObjectTypeShape = {\n address: 'string',\n config: 'object',\n params: 'object',\n queries: 'array',\n query: 'function',\n queryable: 'function',\n}\n\nconst factory = new IsObjectFactory<Module>()\n\nexport const isModuleObject: ObjectTypeCheck<Module> = factory.create(requiredModuleFunctions)\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ObjectTypeCheck } from '@xyo-network/object'\n\nimport { asModuleObject } from './asModuleObject'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport type ModuleTypeCheck<T extends Module = Module> = ObjectTypeCheck<T>\n\nexport class IsModuleFactory<T extends Module = Module> {\n create(expectedQueries?: string[], additionalChecks?: ObjectTypeCheck[]): ModuleTypeCheck<T> {\n return (obj: any, config): obj is T => {\n const module = asModuleObject(obj)\n const result =\n isModuleObject(module, config) &&\n (expectedQueries?.reduce((prev, query) => prev && obj.queries.includes(query), true) ?? true) &&\n //perform additional checks\n (additionalChecks?.reduce((prev, check) => prev && check(obj, config), true) ?? true)\n return result\n }\n }\n}\n","import { ObjectTypeCheck } from '@xyo-network/object'\n\nimport { ModuleDiscoverQuerySchema } from '../Queries'\nimport { IsModuleFactory } from './IsModuleFactory'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport const requiredModuleQueries: string[] = [\n /* We need to update this once live module conform */\n //ModuleDescribeQuerySchema,\n //ModuleAddressQuerySchema,\n ModuleDiscoverQuerySchema,\n //ModuleManifestQuerySchema,\n //ModuleSubscribeQuerySchema,\n]\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsModuleFactory<Module>()\n\nexport const isModule: ObjectTypeCheck<Module> = factory.create(requiredModuleQueries, [isModuleObject])\n","import { IsObjectFactory, ObjectTypeCheck } from '@xyo-network/object'\nimport { Promisable } from '@xyo-network/promise'\n\nimport { AnyConfigSchema, ModuleConfig } from '../Config'\nimport { ModuleEventData } from '../EventsModels'\nimport { Module, ModuleQueryFunctions } from '../module'\nimport { ModuleParams } from '../ModuleParams'\n\nexport interface ResolveFunctions {\n resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promisable<T[]>\n resolve<T extends ModuleInstance = ModuleInstance>(nameOrAddress: string, options?: ModuleFilterOptions<T>): Promisable<T | undefined>\n resolve<T extends ModuleInstance = ModuleInstance>(\n nameOrAddressOrFilter?: ModuleFilter<T> | string,\n options?: ModuleFilterOptions<T>,\n ): Promisable<T | T[] | undefined>\n}\n\nexport interface ModuleResolver extends ResolveFunctions {\n addResolver: (resolver: ModuleResolver) => this\n isModuleResolver: boolean\n removeResolver: (resolver: ModuleResolver) => this\n}\n\nexport type ModuleInstance<\n TParams extends ModuleParams<AnyConfigSchema<ModuleConfig>> = ModuleParams<AnyConfigSchema<ModuleConfig>>,\n TEventData extends ModuleEventData = ModuleEventData,\n> = Module<TParams, TEventData> &\n ResolveFunctions &\n ModuleQueryFunctions & {\n /* The resolver is a 'down' resolver. It can resolve the module or any children (if it is a node for example), that are in the module*/\n readonly downResolver: Omit<ModuleResolver, 'resolve'>\n\n /* The resolver is a 'up' resolver. It can resolve the parent or any children of the parent*/\n /* This is set by a NodeModule when attaching to the module */\n readonly upResolver: Omit<ModuleResolver, 'resolve'>\n }\n\nexport type InstanceTypeCheck<T extends ModuleInstance = ModuleInstance> = ObjectTypeCheck<T>\n\nexport class IsInstanceFactory<T extends ModuleInstance = ModuleInstance> extends IsObjectFactory<T> {}\n\nexport interface ModuleFilterOptions<T extends ModuleInstance = ModuleInstance> {\n direction?: 'up' | 'down' | 'all'\n identity?: InstanceTypeCheck<T>\n maxDepth?: number\n visibility?: 'public' | 'private' | 'all'\n}\n\nexport interface AddressModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n address: string[]\n}\n\nexport interface NameModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n name: string[]\n}\n\nexport interface QueryModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n query: string[][]\n}\n\nexport type AnyModuleFilter<T extends ModuleInstance = ModuleInstance> = Partial<AddressModuleFilter<T>> &\n Partial<NameModuleFilter<T>> &\n Partial<QueryModuleFilter<T>>\n\nexport type ModuleFilter<T extends ModuleInstance = ModuleInstance> =\n | ModuleFilterOptions<T>\n | AddressModuleFilter<T>\n | NameModuleFilter<T>\n | QueryModuleFilter<T>\n","import { Module } from '../module'\n\n/**\n * Used to filter duplicates from an array of modules\n * @example: modulesArray.filter(duplicateModules)\n * @param value Current Module\n * @param index Current Module's index\n * @param array Module Array\n * @returns True if the Module's address is the first occurrence of\n * that address in the array, false otherwise\n */\nexport const duplicateModules = (value: Module, index: number, array: Module[]): value is Module => {\n return array.findIndex((v) => v.address === value.address) === index\n}\n","// Inspired by https://stackoverflow.com/a/49079549/2803259\n\nimport { every, isArray, isBoolean, isNull, isNumber, isPlainObject, isString, isUndefined, overSome } from '@xylabs/lodash'\n\nconst JSONPrimitiveChecks = [isUndefined, isNull, isBoolean, isNumber, isString]\nconst JSONComplexChecks = [isPlainObject, isArray]\n\nexport const serializable = (field: unknown, depth?: number): boolean | null => {\n let depthExceeded = false\n const decrementDepth = () => (depth ? depth-- : undefined)\n\n const recursiveSerializable = (field: unknown) => {\n if (depth !== undefined && depth < 1) {\n depthExceeded = true\n return false\n }\n\n // decrement during every recursion\n decrementDepth()\n\n const nestedSerializable = (field: unknown): boolean => overSome(JSONComplexChecks)(field) && every(field as object, recursiveSerializable)\n\n return overSome([...JSONPrimitiveChecks, nestedSerializable])(field)\n }\n\n const valid = recursiveSerializable(field)\n\n return depthExceeded ? null : valid\n}\n\nexport const serializableField = (field: unknown) => {\n return overSome([...JSONPrimitiveChecks, ...JSONComplexChecks])(field)\n}\n","import { ObjectTypeCheck } from '@xyo-network/object'\n\nimport { isModuleInstance } from './instance'\nimport { isModule } from './module'\n\nexport const WithFactory = {\n create: <T extends object>(typeCheck: ObjectTypeCheck<T>) => {\n return <R>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n module: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n closure: (module: T) => R,\n ): R | undefined => {\n return typeCheck(module) ? closure(module) : undefined\n }\n },\n}\n\nexport const withModule = WithFactory.create(isModule)\nexport const withModuleInstance = WithFactory.create(isModuleInstance)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAM,qBAAyC;;;ACmB/C,SAAS,kBAAmE;AACjF,SAAO,CAAqC,gBAAmB;AAC7D;AAAA,EACF;AACF;;;ACrBO,IAAM,4BAA4B,CAAC,SAAuF;AAC/H,SAAO,OAAO,QAAQ,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQA,QAAO,MAAM;AAClE,aAAS,MAAM,IAAI,MAAM,QAAQA,QAAO,IAAIA,WAAU,CAACA,QAAO;AAC9D,WAAO;AAAA,EACT,GAAG,CAAC,CAA4B;AAClC;AAEO,IAAM,gCAAgC,CAC3C,SAAkC,CAAC,MAChC,YACyB;AAC5B,UAAQ;AAAA,IAAI,CAAC,WACX,OAAO,QAAQ,MAAM,EAAE,IAAI,CAAC,CAAC,QAAQ,SAAS,MAAM;AAClD,UAAI,WAAW;AACb,cAAM,oBAAoB,OAAO,MAAM;AACvC,eAAO,MAAM,IAAI,oBAAqB,OAAO,MAAM,IAAI,CAAC,GAAG,mBAAmB,GAAG,SAAS,IAAK;AAAA,MACjG;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;;;ACtBO,IAAM,YAAY,CAACC,aAA8G;AACtI,SAAQA,SAA0C,WAAW;AAC/D;;;ACRA,oBAAyB;AACzB,oBAAsB;AAOf,IAAM,gBAAN,MAAM,eAAyF;AAAA,EACpG;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA,YACEC,kBACA,QACA,S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;AAAA,EACrE;AAEA,QAAM,QAAQ,sBAAsB,KAAK;AAEzC,SAAO,gBAAgB,OAAO;AAChC;AAEO,IAAM,oBAAoB,CAAC,UAAmB;AACnD,aAAO,yBAAS,CAAC,GAAG,qBAAqB,GAAG,iBAAiB,CAAC,EAAE,KAAK;AACvE;;;AC3BO,IAAM,cAAc;AAAA,EACzB,QAAQ,CAAmB,cAAkC;AAC3D,WAAO,CAELC,SAEA,YACkB;AAClB,aAAO,UAAUA,OAAM,IAAI,QAAQA,OAAM,IAAI;AAAA,IAC/C;AAAA,EACF;AACF;AAEO,IAAM,aAAa,YAAY,OAAO,QAAQ;AAC9C,IAAM,qBAAqB,YAAY,OAAO,gBAAgB;","names":["factory","factory","creatableModule","factory","import_assert","factory","import_object","import_object","import_object","import_object","module","factory","factory","import_object","import_lodash","field","module"]}