@x12i/memorix-retrieval 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/README.md +124 -0
  2. package/catalox-seeds/inputs/entity-descriptors/assets.json +296 -0
  3. package/catalox-seeds/inputs/entity-descriptors/variabilities-groups.json +312 -0
  4. package/catalox-seeds/inputs/entity-descriptors/vulnerabilities.json +419 -0
  5. package/catalox-seeds/inputs/item-descriptors/asset-detail-item.json +85 -0
  6. package/catalox-seeds/inputs/item-descriptors/variabilities-group-detail-item.json +87 -0
  7. package/catalox-seeds/inputs/item-descriptors/vulnerability-detail-item.json +106 -0
  8. package/catalox-seeds/inputs/list-descriptors/assets-main-list.json +46 -0
  9. package/catalox-seeds/inputs/list-descriptors/critical-vulnerabilities-list.json +44 -0
  10. package/catalox-seeds/inputs/list-descriptors/variabilities-groups-main-list.json +43 -0
  11. package/catalox-seeds/inputs/list-descriptors/vulnerabilities-main-list.json +47 -0
  12. package/catalox-seeds/inputs/manifest.json +44 -0
  13. package/catalox-seeds/inputs/memorix-catalog-ids.json +8 -0
  14. package/catalox-seeds/inputs/memorix-descriptors.bundle.json +1502 -0
  15. package/catalox-seeds/inputs/memorix-entity-descriptors.catalog.json +1029 -0
  16. package/catalox-seeds/inputs/memorix-entity-descriptors.items.json +1026 -0
  17. package/catalox-seeds/inputs/memorix-item-descriptors.catalog.json +283 -0
  18. package/catalox-seeds/inputs/memorix-item-descriptors.items.json +280 -0
  19. package/catalox-seeds/inputs/memorix-list-descriptors.catalog.json +185 -0
  20. package/catalox-seeds/inputs/memorix-list-descriptors.items.json +182 -0
  21. package/catalox-seeds/inputs/scope.json +4 -0
  22. package/catalox-seeds/memorix-retrieval-descriptors.manifest.json +1844 -0
  23. package/dist/client/catalox-like.d.ts +16 -0
  24. package/dist/client/catalox-like.d.ts.map +1 -0
  25. package/dist/client/catalox-like.js +2 -0
  26. package/dist/client/catalox-like.js.map +1 -0
  27. package/dist/client/create-client.d.ts +3 -0
  28. package/dist/client/create-client.d.ts.map +1 -0
  29. package/dist/client/create-client.js +50 -0
  30. package/dist/client/create-client.js.map +1 -0
  31. package/dist/client/create-from-env.d.ts +3 -0
  32. package/dist/client/create-from-env.d.ts.map +1 -0
  33. package/dist/client/create-from-env.js +10 -0
  34. package/dist/client/create-from-env.js.map +1 -0
  35. package/dist/client/types.d.ts +109 -0
  36. package/dist/client/types.d.ts.map +1 -0
  37. package/dist/client/types.js +2 -0
  38. package/dist/client/types.js.map +1 -0
  39. package/dist/client/xronox-like.d.ts +18 -0
  40. package/dist/client/xronox-like.d.ts.map +1 -0
  41. package/dist/client/xronox-like.js +2 -0
  42. package/dist/client/xronox-like.js.map +1 -0
  43. package/dist/content/fetch-content-object.d.ts +16 -0
  44. package/dist/content/fetch-content-object.d.ts.map +1 -0
  45. package/dist/content/fetch-content-object.js +54 -0
  46. package/dist/content/fetch-content-object.js.map +1 -0
  47. package/dist/content/map-content-errors.d.ts +5 -0
  48. package/dist/content/map-content-errors.d.ts.map +1 -0
  49. package/dist/content/map-content-errors.js +39 -0
  50. package/dist/content/map-content-errors.js.map +1 -0
  51. package/dist/content/memorix-content-object.d.ts +21 -0
  52. package/dist/content/memorix-content-object.d.ts.map +1 -0
  53. package/dist/content/memorix-content-object.js +54 -0
  54. package/dist/content/memorix-content-object.js.map +1 -0
  55. package/dist/content/resolve-content-config.d.ts +19 -0
  56. package/dist/content/resolve-content-config.d.ts.map +1 -0
  57. package/dist/content/resolve-content-config.js +37 -0
  58. package/dist/content/resolve-content-config.js.map +1 -0
  59. package/dist/data/collection-name.d.ts +4 -0
  60. package/dist/data/collection-name.d.ts.map +1 -0
  61. package/dist/data/collection-name.js +23 -0
  62. package/dist/data/collection-name.js.map +1 -0
  63. package/dist/data/identity.d.ts +36 -0
  64. package/dist/data/identity.d.ts.map +1 -0
  65. package/dist/data/identity.js +68 -0
  66. package/dist/data/identity.js.map +1 -0
  67. package/dist/data/memorix-read.d.ts +17 -0
  68. package/dist/data/memorix-read.d.ts.map +1 -0
  69. package/dist/data/memorix-read.js +55 -0
  70. package/dist/data/memorix-read.js.map +1 -0
  71. package/dist/data/multi-match.d.ts +16 -0
  72. package/dist/data/multi-match.d.ts.map +1 -0
  73. package/dist/data/multi-match.js +65 -0
  74. package/dist/data/multi-match.js.map +1 -0
  75. package/dist/data/path.d.ts +3 -0
  76. package/dist/data/path.d.ts.map +1 -0
  77. package/dist/data/path.js +23 -0
  78. package/dist/data/path.js.map +1 -0
  79. package/dist/data/xronox-read.d.ts +13 -0
  80. package/dist/data/xronox-read.d.ts.map +1 -0
  81. package/dist/data/xronox-read.js +34 -0
  82. package/dist/data/xronox-read.js.map +1 -0
  83. package/dist/descriptors/catalog-ids.d.ts +5 -0
  84. package/dist/descriptors/catalog-ids.d.ts.map +1 -0
  85. package/dist/descriptors/catalog-ids.js +5 -0
  86. package/dist/descriptors/catalog-ids.js.map +1 -0
  87. package/dist/descriptors/descriptor-types.d.ts +187 -0
  88. package/dist/descriptors/descriptor-types.d.ts.map +1 -0
  89. package/dist/descriptors/descriptor-types.js +2 -0
  90. package/dist/descriptors/descriptor-types.js.map +1 -0
  91. package/dist/descriptors/load-entity-descriptor.d.ts +4 -0
  92. package/dist/descriptors/load-entity-descriptor.d.ts.map +1 -0
  93. package/dist/descriptors/load-entity-descriptor.js +15 -0
  94. package/dist/descriptors/load-entity-descriptor.js.map +1 -0
  95. package/dist/descriptors/load-item-descriptor.d.ts +4 -0
  96. package/dist/descriptors/load-item-descriptor.d.ts.map +1 -0
  97. package/dist/descriptors/load-item-descriptor.js +15 -0
  98. package/dist/descriptors/load-item-descriptor.js.map +1 -0
  99. package/dist/descriptors/load-list-descriptor.d.ts +4 -0
  100. package/dist/descriptors/load-list-descriptor.d.ts.map +1 -0
  101. package/dist/descriptors/load-list-descriptor.js +15 -0
  102. package/dist/descriptors/load-list-descriptor.js.map +1 -0
  103. package/dist/descriptors/validate-descriptor.d.ts +7 -0
  104. package/dist/descriptors/validate-descriptor.d.ts.map +1 -0
  105. package/dist/descriptors/validate-descriptor.js +80 -0
  106. package/dist/descriptors/validate-descriptor.js.map +1 -0
  107. package/dist/errors/errors.d.ts +6 -0
  108. package/dist/errors/errors.d.ts.map +1 -0
  109. package/dist/errors/errors.js +12 -0
  110. package/dist/errors/errors.js.map +1 -0
  111. package/dist/errors/issues.d.ts +14 -0
  112. package/dist/errors/issues.d.ts.map +1 -0
  113. package/dist/errors/issues.js +7 -0
  114. package/dist/errors/issues.js.map +1 -0
  115. package/dist/index.d.ts +22 -0
  116. package/dist/index.d.ts.map +1 -0
  117. package/dist/index.js +18 -0
  118. package/dist/index.js.map +1 -0
  119. package/dist/mongo/connection.d.ts +3 -0
  120. package/dist/mongo/connection.d.ts.map +1 -0
  121. package/dist/mongo/connection.js +8 -0
  122. package/dist/mongo/connection.js.map +1 -0
  123. package/dist/mongo/env.d.ts +6 -0
  124. package/dist/mongo/env.d.ts.map +1 -0
  125. package/dist/mongo/env.js +33 -0
  126. package/dist/mongo/env.js.map +1 -0
  127. package/dist/mongo/read-collection.d.ts +14 -0
  128. package/dist/mongo/read-collection.d.ts.map +1 -0
  129. package/dist/mongo/read-collection.js +45 -0
  130. package/dist/mongo/read-collection.js.map +1 -0
  131. package/dist/mongo/resolve-db.d.ts +6 -0
  132. package/dist/mongo/resolve-db.d.ts.map +1 -0
  133. package/dist/mongo/resolve-db.js +9 -0
  134. package/dist/mongo/resolve-db.js.map +1 -0
  135. package/dist/mongo/types.d.ts +2 -0
  136. package/dist/mongo/types.d.ts.map +1 -0
  137. package/dist/mongo/types.js +2 -0
  138. package/dist/mongo/types.js.map +1 -0
  139. package/dist/relations/fetch-relation.d.ts +5 -0
  140. package/dist/relations/fetch-relation.d.ts.map +1 -0
  141. package/dist/relations/fetch-relation.js +57 -0
  142. package/dist/relations/fetch-relation.js.map +1 -0
  143. package/dist/relations/resolve-relations.d.ts +6 -0
  144. package/dist/relations/resolve-relations.d.ts.map +1 -0
  145. package/dist/relations/resolve-relations.js +20 -0
  146. package/dist/relations/resolve-relations.js.map +1 -0
  147. package/dist/retrieval/batch-fetch.d.ts +11 -0
  148. package/dist/retrieval/batch-fetch.d.ts.map +1 -0
  149. package/dist/retrieval/batch-fetch.js +80 -0
  150. package/dist/retrieval/batch-fetch.js.map +1 -0
  151. package/dist/retrieval/compose-item.d.ts +11 -0
  152. package/dist/retrieval/compose-item.d.ts.map +1 -0
  153. package/dist/retrieval/compose-item.js +18 -0
  154. package/dist/retrieval/compose-item.js.map +1 -0
  155. package/dist/retrieval/compose-row.d.ts +4 -0
  156. package/dist/retrieval/compose-row.d.ts.map +1 -0
  157. package/dist/retrieval/compose-row.js +14 -0
  158. package/dist/retrieval/compose-row.js.map +1 -0
  159. package/dist/retrieval/fetch-item.d.ts +3 -0
  160. package/dist/retrieval/fetch-item.d.ts.map +1 -0
  161. package/dist/retrieval/fetch-item.js +107 -0
  162. package/dist/retrieval/fetch-item.js.map +1 -0
  163. package/dist/retrieval/fetch-list.d.ts +3 -0
  164. package/dist/retrieval/fetch-list.d.ts.map +1 -0
  165. package/dist/retrieval/fetch-list.js +148 -0
  166. package/dist/retrieval/fetch-list.js.map +1 -0
  167. package/dist/retrieval/resolve-fields.d.ts +10 -0
  168. package/dist/retrieval/resolve-fields.d.ts.map +1 -0
  169. package/dist/retrieval/resolve-fields.js +52 -0
  170. package/dist/retrieval/resolve-fields.js.map +1 -0
  171. package/dist/retrieval/resolve-filters.d.ts +3 -0
  172. package/dist/retrieval/resolve-filters.d.ts.map +1 -0
  173. package/dist/retrieval/resolve-filters.js +57 -0
  174. package/dist/retrieval/resolve-filters.js.map +1 -0
  175. package/dist/retrieval/resolve-pagination-driver.d.ts +6 -0
  176. package/dist/retrieval/resolve-pagination-driver.d.ts.map +1 -0
  177. package/dist/retrieval/resolve-pagination-driver.js +22 -0
  178. package/dist/retrieval/resolve-pagination-driver.js.map +1 -0
  179. package/dist/retrieval/resolve-property-source.d.ts +10 -0
  180. package/dist/retrieval/resolve-property-source.d.ts.map +1 -0
  181. package/dist/retrieval/resolve-property-source.js +48 -0
  182. package/dist/retrieval/resolve-property-source.js.map +1 -0
  183. package/dist/retrieval/resolve-sort.d.ts +14 -0
  184. package/dist/retrieval/resolve-sort.d.ts.map +1 -0
  185. package/dist/retrieval/resolve-sort.js +28 -0
  186. package/dist/retrieval/resolve-sort.js.map +1 -0
  187. package/dist/tests/collection-env.test.d.ts +2 -0
  188. package/dist/tests/collection-env.test.d.ts.map +1 -0
  189. package/dist/tests/collection-env.test.js +44 -0
  190. package/dist/tests/collection-env.test.js.map +1 -0
  191. package/dist/tests/content-object.test.d.ts +2 -0
  192. package/dist/tests/content-object.test.d.ts.map +1 -0
  193. package/dist/tests/content-object.test.js +39 -0
  194. package/dist/tests/content-object.test.js.map +1 -0
  195. package/dist/tests/descriptor-validation.test.d.ts +2 -0
  196. package/dist/tests/descriptor-validation.test.d.ts.map +1 -0
  197. package/dist/tests/descriptor-validation.test.js +25 -0
  198. package/dist/tests/descriptor-validation.test.js.map +1 -0
  199. package/dist/tests/env.test.d.ts +2 -0
  200. package/dist/tests/env.test.d.ts.map +1 -0
  201. package/dist/tests/env.test.js +17 -0
  202. package/dist/tests/env.test.js.map +1 -0
  203. package/dist/tests/fetch-item.test.d.ts +2 -0
  204. package/dist/tests/fetch-item.test.d.ts.map +1 -0
  205. package/dist/tests/fetch-item.test.js +86 -0
  206. package/dist/tests/fetch-item.test.js.map +1 -0
  207. package/dist/tests/fetch-list.test.d.ts +2 -0
  208. package/dist/tests/fetch-list.test.d.ts.map +1 -0
  209. package/dist/tests/fetch-list.test.js +85 -0
  210. package/dist/tests/fetch-list.test.js.map +1 -0
  211. package/dist/tests/fixtures.d.ts +5 -0
  212. package/dist/tests/fixtures.d.ts.map +1 -0
  213. package/dist/tests/fixtures.js +137 -0
  214. package/dist/tests/fixtures.js.map +1 -0
  215. package/dist/tests/identity.test.d.ts +2 -0
  216. package/dist/tests/identity.test.d.ts.map +1 -0
  217. package/dist/tests/identity.test.js +32 -0
  218. package/dist/tests/identity.test.js.map +1 -0
  219. package/dist/tests/multi-match.test.d.ts +2 -0
  220. package/dist/tests/multi-match.test.d.ts.map +1 -0
  221. package/dist/tests/multi-match.test.js +31 -0
  222. package/dist/tests/multi-match.test.js.map +1 -0
  223. package/dist/tests/read-collection.test.d.ts +2 -0
  224. package/dist/tests/read-collection.test.d.ts.map +1 -0
  225. package/dist/tests/read-collection.test.js +19 -0
  226. package/dist/tests/read-collection.test.js.map +1 -0
  227. package/dist/tests/relations.test.d.ts +2 -0
  228. package/dist/tests/relations.test.d.ts.map +1 -0
  229. package/dist/tests/relations.test.js +77 -0
  230. package/dist/tests/relations.test.js.map +1 -0
  231. package/docs/MEMORIX-DATABASE-CONVENTIONS.md +325 -0
  232. package/package.json +52 -0
@@ -0,0 +1,16 @@
1
+ export type CataloxCatalogItemResult = {
2
+ outcome: "found";
3
+ item: {
4
+ data: Record<string, unknown>;
5
+ };
6
+ } | {
7
+ outcome: "not_found";
8
+ } | {
9
+ outcome: "mapping_blocked";
10
+ };
11
+ export type CataloxLike = {
12
+ getCatalogItem(context: {
13
+ appId?: string;
14
+ }, catalogId: string, itemId: string): Promise<CataloxCatalogItemResult>;
15
+ };
16
+ //# sourceMappingURL=catalox-like.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalox-like.d.ts","sourceRoot":"","sources":["../../src/client/catalox-like.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAChC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAA;CAAE,GAC7D;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,GACxB;IAAE,OAAO,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAEnC,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,CACZ,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACtC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=catalox-like.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalox-like.js","sourceRoot":"","sources":["../../src/client/catalox-like.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { CreateMemorixRetrievalOptions, MemorixRetrievalClient } from "./types.js";
2
+ export declare function createMemorixRetrieval(options: CreateMemorixRetrievalOptions): MemorixRetrievalClient;
3
+ //# sourceMappingURL=create-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-client.d.ts","sourceRoot":"","sources":["../../src/client/create-client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,6BAA6B,EAC7B,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,6BAA6B,GACrC,sBAAsB,CAgDxB"}
@@ -0,0 +1,50 @@
1
+ import { MEMORIX_APP_ID } from "../descriptors/catalog-ids.js";
2
+ import { connectMemorixMongo } from "../mongo/connection.js";
3
+ const DEFAULT_MAX_PAGE_LIMIT = 500;
4
+ const DEFAULT_CONTENT_MAX_BYTES = 5 * 1024 * 1024;
5
+ export function createMemorixRetrieval(options) {
6
+ const defaults = options.defaults ?? {};
7
+ const processEnv = options.processEnv ?? process.env;
8
+ let mongoClient = options.mongo ?? null;
9
+ let mongoConnect = null;
10
+ const getMongo = async () => {
11
+ if (mongoClient)
12
+ return mongoClient;
13
+ if (!mongoConnect) {
14
+ mongoConnect = connectMemorixMongo(processEnv).then((client) => {
15
+ mongoClient = client;
16
+ return client;
17
+ });
18
+ }
19
+ return mongoConnect;
20
+ };
21
+ const close = async () => {
22
+ if (mongoClient) {
23
+ await mongoClient.close();
24
+ mongoClient = null;
25
+ mongoConnect = null;
26
+ }
27
+ };
28
+ return {
29
+ appId: options.appId ?? MEMORIX_APP_ID,
30
+ catalox: options.catalox,
31
+ xronox: options.xronox,
32
+ contentReaders: options.contentReaders,
33
+ processEnv,
34
+ memorixDb: options.memorixDb,
35
+ xronoxRoles: options.xronoxRoles,
36
+ getMongo: options.xronox ? undefined : getMongo,
37
+ close: options.xronox ? undefined : close,
38
+ defaults: {
39
+ canonicalContentType: defaults.canonicalContentType ?? "snapshots",
40
+ effectiveDatePath: defaults.effectiveDatePath ?? "modifiedAt",
41
+ fallbackEffectiveDatePaths: defaults.fallbackEffectiveDatePaths ?? [
42
+ "capturedAt",
43
+ "snapshot.capturedAt",
44
+ ],
45
+ maxPageLimit: defaults.maxPageLimit ?? DEFAULT_MAX_PAGE_LIMIT,
46
+ contentMaxBytes: defaults.contentMaxBytes ?? DEFAULT_CONTENT_MAX_BYTES,
47
+ },
48
+ };
49
+ }
50
+ //# sourceMappingURL=create-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-client.js","sourceRoot":"","sources":["../../src/client/create-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAM7D,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,yBAAyB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD,MAAM,UAAU,sBAAsB,CACpC,OAAsC;IAEtC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IACxC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;IAErD,IAAI,WAAW,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC;IACxC,IAAI,YAAY,GAAgC,IAAI,CAAC;IAErD,MAAM,QAAQ,GAAG,KAAK,IAA0B,EAAE;QAChD,IAAI,WAAW;YAAE,OAA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AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CreateMemorixRetrievalFromEnvOptions, MemorixRetrievalClient } from "./types.js";
2
+ export declare function createMemorixRetrievalFromEnv(options: CreateMemorixRetrievalFromEnvOptions): Promise<MemorixRetrievalClient>;
3
+ //# sourceMappingURL=create-from-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-from-env.d.ts","sourceRoot":"","sources":["../../src/client/create-from-env.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oCAAoC,EACpC,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAEpB,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,oCAAoC,GAC5C,OAAO,CAAC,sBAAsB,CAAC,CAMjC"}
@@ -0,0 +1,10 @@
1
+ import { connectMemorixMongo } from "../mongo/connection.js";
2
+ import { createMemorixRetrieval } from "./create-client.js";
3
+ export async function createMemorixRetrievalFromEnv(options) {
4
+ const mongo = await connectMemorixMongo(options.processEnv);
5
+ return createMemorixRetrieval({
6
+ ...options,
7
+ mongo,
8
+ });
9
+ }
10
+ //# sourceMappingURL=create-from-env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-from-env.js","sourceRoot":"","sources":["../../src/client/create-from-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAM5D,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAA6C;IAE7C,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5D,OAAO,sBAAsB,CAAC;QAC5B,GAAG,OAAO;QACV,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,109 @@
1
+ import type { MongoClient } from "mongodb";
2
+ import type { createGcsClient } from "@x12i/helpers/gcs";
3
+ import type { createS3Client } from "@x12i/helpers/s3";
4
+ import type { CataloxLike } from "./catalox-like.js";
5
+ import type { XronoxLike } from "./xronox-like.js";
6
+ import type { MemorixTarget } from "../mongo/types.js";
7
+ export type { CataloxLike } from "./catalox-like.js";
8
+ export type { XronoxLike, XronoxReadParams } from "./xronox-like.js";
9
+ export type ContentReaders = {
10
+ gcs?: ReturnType<typeof createGcsClient>;
11
+ s3?: ReturnType<typeof createS3Client>;
12
+ };
13
+ export type CreateMemorixRetrievalOptions = {
14
+ appId?: string;
15
+ catalox: CataloxLike;
16
+ /** Advanced: inject a pre-configured Xronox client instead of built-in Mongo reads. */
17
+ xronox?: XronoxLike;
18
+ /** Advanced: reuse an existing MongoClient (otherwise connects lazily from `MONGO_URI`). */
19
+ mongo?: MongoClient;
20
+ contentReaders?: ContentReaders;
21
+ processEnv?: NodeJS.ProcessEnv;
22
+ /** Advanced: per-target database overrides (default: env resolution). */
23
+ memorixDb?: Partial<Record<MemorixTarget, string>>;
24
+ /** Advanced with `xronox`: role names for entity/event databases. */
25
+ xronoxRoles?: Partial<Record<MemorixTarget, string>>;
26
+ defaults?: {
27
+ canonicalContentType?: string;
28
+ effectiveDatePath?: string;
29
+ fallbackEffectiveDatePaths?: string[];
30
+ maxPageLimit?: number;
31
+ contentMaxBytes?: number;
32
+ };
33
+ };
34
+ export type CreateMemorixRetrievalFromEnvOptions = Omit<CreateMemorixRetrievalOptions, "xronox" | "mongo">;
35
+ export type MemorixRetrievalClient = {
36
+ appId: string;
37
+ catalox: CataloxLike;
38
+ xronox?: XronoxLike;
39
+ contentReaders?: ContentReaders;
40
+ processEnv: NodeJS.ProcessEnv;
41
+ memorixDb?: Partial<Record<MemorixTarget, string>>;
42
+ xronoxRoles?: Partial<Record<MemorixTarget, string>>;
43
+ /** Internal Mongo access (simple mode). */
44
+ getMongo?: () => Promise<MongoClient>;
45
+ close?: () => Promise<void>;
46
+ defaults: {
47
+ canonicalContentType: string;
48
+ effectiveDatePath: string;
49
+ fallbackEffectiveDatePaths: string[];
50
+ maxPageLimit: number;
51
+ contentMaxBytes: number;
52
+ };
53
+ };
54
+ export type FetchMemorixListRequest = {
55
+ listId: string;
56
+ page?: {
57
+ limit?: number;
58
+ offset?: number;
59
+ };
60
+ sort?: {
61
+ property: string;
62
+ direction: "asc" | "desc";
63
+ };
64
+ filters?: Array<import("../descriptors/descriptor-types.js").MemorixFilterInput>;
65
+ includeExtensions?: string[];
66
+ includeRelations?: string[];
67
+ };
68
+ export type FetchMemorixListResponse = {
69
+ listId: string;
70
+ entity: string;
71
+ page: {
72
+ limit: number;
73
+ offset: number;
74
+ count: number;
75
+ hasMore: boolean;
76
+ };
77
+ sort?: {
78
+ property: string;
79
+ direction: "asc" | "desc";
80
+ contentType: string;
81
+ };
82
+ rows: Array<Record<string, unknown>>;
83
+ issues?: import("../errors/issues.js").MemorixRetrievalIssue[];
84
+ };
85
+ export type FetchMemorixItemRequest = {
86
+ itemDescriptorId: string;
87
+ entityId?: string;
88
+ eventId?: string;
89
+ content?: {
90
+ include: boolean;
91
+ fields?: string[];
92
+ maxBytes?: number;
93
+ };
94
+ includeRelations?: string[];
95
+ };
96
+ export type FetchMemorixItemResponse = {
97
+ itemDescriptorId: string;
98
+ entity: string;
99
+ entityId?: string;
100
+ eventId?: string;
101
+ sections: Array<{
102
+ id: string;
103
+ title: string;
104
+ fields: Record<string, unknown>;
105
+ }>;
106
+ relations?: Record<string, unknown>;
107
+ issues?: import("../errors/issues.js").MemorixRetrievalIssue[];
108
+ };
109
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mB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,qBAAqB,EAAE,qBAAqB,EAAE,CAAC;CAChE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ export type XronoxReadParams = {
2
+ dataType: "metadata";
3
+ sourceType: "database";
4
+ subSourceType: "mongo";
5
+ source: string;
6
+ /** Xronox role selecting Mongo database (default operational/logs for entity/event). */
7
+ role?: string;
8
+ query?: Record<string, unknown>;
9
+ project?: string[];
10
+ sort?: string | string[] | Record<string, 1 | -1>;
11
+ limit?: number;
12
+ skip?: number;
13
+ };
14
+ export type XronoxLike = {
15
+ read(params: XronoxReadParams): Promise<unknown[] | AsyncIterable<unknown>>;
16
+ readArray?(params: XronoxReadParams): Promise<unknown[]>;
17
+ };
18
+ //# sourceMappingURL=xronox-like.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xronox-like.d.ts","sourceRoot":"","sources":["../../src/client/xronox-like.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,UAAU,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,SAAS,CAAC,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC1D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=xronox-like.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xronox-like.js","sourceRoot":"","sources":["../../src/client/xronox-like.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import type { MemorixRetrievalClient } from "../client/types.js";
2
+ import type { MemorixContentObject } from "../descriptors/descriptor-types.js";
3
+ import type { MemorixRetrievalIssue } from "../errors/issues.js";
4
+ import type { MemorixEntityDescriptor, MemorixPropertyContentDescriptor } from "../descriptors/descriptor-types.js";
5
+ export declare function fetchMemorixContentObject(client: MemorixRetrievalClient, entity: MemorixEntityDescriptor, fieldContent: MemorixPropertyContentDescriptor, contentObject: MemorixContentObject, options?: {
6
+ maxBytes?: number;
7
+ path?: string;
8
+ }): Promise<{
9
+ ok: true;
10
+ content: string;
11
+ format: "markdown" | "text";
12
+ } | {
13
+ ok: false;
14
+ issue: MemorixRetrievalIssue;
15
+ }>;
16
+ //# sourceMappingURL=fetch-content-object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-content-object.d.ts","sourceRoot":"","sources":["../../src/content/fetch-content-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAMjE,OAAO,KAAK,EACV,uBAAuB,EACvB,gCAAgC,EACjC,MAAM,oCAAoC,CAAC;AAI5C,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,sBAAsB,EAC9B,MAAM,EAAE,uBAAuB,EAC/B,YAAY,EAAE,gCAAgC,EAC9C,aAAa,EAAE,oBAAoB,EACnC,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7C,OAAO,CACN;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAA;CAAE,GAC1D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,qBAAqB,CAAA;CAAE,CAC9C,CA4BA"}
@@ -0,0 +1,54 @@
1
+ import { buildStorageObjectKey, resolveContentConfig, } from "./resolve-content-config.js";
2
+ import { mapContentFetchError } from "./map-content-errors.js";
3
+ import { createIssue } from "../errors/issues.js";
4
+ export async function fetchMemorixContentObject(client, entity, fieldContent, contentObject, options) {
5
+ const config = resolveContentConfig(entity, fieldContent, client, {
6
+ maxBytes: options?.maxBytes,
7
+ });
8
+ if (!config) {
9
+ return {
10
+ ok: false,
11
+ issue: createIssue({
12
+ code: "CONTENT_PERMISSION_DENIED",
13
+ message: "Content storage is not configured; provide contentReaders with matching provider",
14
+ path: options?.path,
15
+ }),
16
+ };
17
+ }
18
+ const objectKey = buildStorageObjectKey(config.storage, contentObject.contentKey);
19
+ try {
20
+ const buffer = await readFromStorage(client, config, objectKey);
21
+ const text = buffer.toString(config.encoding);
22
+ return { ok: true, content: text, format: config.format };
23
+ }
24
+ catch (error) {
25
+ return {
26
+ ok: false,
27
+ issue: mapContentFetchError(error, { path: options?.path }),
28
+ };
29
+ }
30
+ }
31
+ async function readFromStorage(client, config, objectKey) {
32
+ const { provider } = config.storage;
33
+ const maxBytes = config.maxBytes;
34
+ if (provider === "gcs") {
35
+ const gcs = client.contentReaders?.gcs;
36
+ if (!gcs) {
37
+ throw Object.assign(new Error("GCS content reader not configured"), {
38
+ name: "PermissionError",
39
+ });
40
+ }
41
+ return gcs.readObjectBuffer(objectKey, { maxBytes });
42
+ }
43
+ if (provider === "s3") {
44
+ const s3 = client.contentReaders?.s3;
45
+ if (!s3) {
46
+ throw Object.assign(new Error("S3 content reader not configured"), {
47
+ name: "PermissionError",
48
+ });
49
+ }
50
+ return s3.readObjectBuffer(objectKey, { maxBytes });
51
+ }
52
+ throw new Error(`Unsupported storage provider: ${provider}`);
53
+ }
54
+ //# sourceMappingURL=fetch-content-object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-content-object.js","sourceRoot":"","sources":["../../src/content/fetch-content-object.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAA8B,EAC9B,MAA+B,EAC/B,YAA8C,EAC9C,aAAmC,EACnC,OAA8C;IAK9C,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;QAChE,QAAQ,EAAE,OAAO,EAAE,QAAQ;KAC5B,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,WAAW,CAAC;gBACjB,IAAI,EAAE,2BAA2B;gBACjC,OAAO,EACL,kFAAkF;gBACpF,IAAI,EAAE,OAAO,EAAE,IAAI;aACpB,CAAC;SACH,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,qBAAqB,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAElF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAA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AC,gBAAgB,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,iCAAiC,QAAQ,EAAE,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type MemorixRetrievalIssue } from "../errors/issues.js";
2
+ export declare function mapContentFetchError(error: unknown, context?: {
3
+ path?: string;
4
+ }): MemorixRetrievalIssue;
5
+ //# sourceMappingURL=map-content-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-content-errors.d.ts","sourceRoot":"","sources":["../../src/content/map-content-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1B,qBAAqB,CA4CvB"}
@@ -0,0 +1,39 @@
1
+ import { createIssue } from "../errors/issues.js";
2
+ export function mapContentFetchError(error, context) {
3
+ const name = error && typeof error === "object" && "name" in error
4
+ ? String(error.name)
5
+ : "";
6
+ const message = error instanceof Error ? error.message : String(error);
7
+ if (name.includes("NotFound") ||
8
+ name.includes("NoSuchKey") ||
9
+ message.toLowerCase().includes("not found")) {
10
+ return createIssue({
11
+ code: "CONTENT_NOT_FOUND",
12
+ message: message || "Content object not found",
13
+ path: context?.path,
14
+ });
15
+ }
16
+ if (name.includes("TooLarge") || message.toLowerCase().includes("too large")) {
17
+ return createIssue({
18
+ code: "CONTENT_TOO_LARGE",
19
+ message: message || "Content exceeds maxBytes",
20
+ path: context?.path,
21
+ });
22
+ }
23
+ if (name.includes("Permission") ||
24
+ name.includes("AccessDenied") ||
25
+ name.includes("Forbidden")) {
26
+ return createIssue({
27
+ code: "CONTENT_PERMISSION_DENIED",
28
+ message: message || "Content access denied",
29
+ path: context?.path,
30
+ });
31
+ }
32
+ return createIssue({
33
+ code: "CONTENT_NOT_FOUND",
34
+ message: message || "Failed to fetch content",
35
+ path: context?.path,
36
+ severity: "error",
37
+ });
38
+ }
39
+ //# sourceMappingURL=map-content-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-content-errors.js","sourceRoot":"","sources":["../../src/content/map-content-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA8B,MAAM,qBAAqB,CAAC;AAE9E,MAAM,UAAU,oBAAoB,CAClC,KAAc,EACd,OAA2B;IAE3B,MAAM,IAAI,GACR,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK;QACnD,CAAC,CAAC,MAAM,CAAE,KAA0B,CAAC,IAAI,CAAC;QAC1C,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEzD,IACE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC1B,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EAC3C,CAAC;QACD,OAAO,WAAW,CAAC;YACjB,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,OAAO,IAAI,0BAA0B;YAC9C,IAAI,EAAE,OAAO,EAAE,IAAI;SACpB,CAAC,CAAC;IACL,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7E,OAAO,WAAW,CAAC;YACjB,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,OAAO,IAAI,0BAA0B;YAC9C,IAAI,EAAE,OAAO,EAAE,IAAI;SACpB,CAAC,CAAC;IACL,CAAC;IACD,IACE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAC1B,CAAC;QACD,OAAO,WAAW,CAAC;YACjB,IAAI,EAAE,2BAA2B;YACjC,OAAO,EAAE,OAAO,IAAI,uBAAuB;YAC3C,IAAI,EAAE,OAAO,EAAE,IAAI;SACpB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,WAAW,CAAC;QACjB,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,OAAO,IAAI,yBAAyB;QAC7C,IAAI,EAAE,OAAO,EAAE,IAAI;QACnB,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { MemorixContentObject } from "../descriptors/descriptor-types.js";
2
+ import { type MemorixRetrievalIssue } from "../errors/issues.js";
3
+ export type { MemorixContentObject };
4
+ export declare function resolveMemorixContentObject(value: unknown): {
5
+ ok: true;
6
+ object: MemorixContentObject;
7
+ } | {
8
+ ok: false;
9
+ issue: MemorixRetrievalIssue;
10
+ };
11
+ export declare function shapeContentForList(object: MemorixContentObject, behavior: {
12
+ returnPreview?: boolean;
13
+ returnMetadata?: boolean;
14
+ returnContentKey?: boolean;
15
+ }): Record<string, unknown>;
16
+ export declare function shapeContentForItem(object: MemorixContentObject, behavior: {
17
+ returnPreview?: boolean;
18
+ returnMetadata?: boolean;
19
+ returnContentKey?: boolean;
20
+ }, fullContent?: string): Record<string, unknown>;
21
+ //# sourceMappingURL=memorix-content-object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memorix-content-object.d.ts","sourceRoot":"","sources":["../../src/content/memorix-content-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAe,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAErC,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,GACb;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,qBAAqB,CAAA;CAAE,CAgC1F;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,oBAAoB,EAC5B,QAAQ,EAAE;IACR,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,GACA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,oBAAoB,EAC5B,QAAQ,EAAE;IACR,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,EACD,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB"}
@@ -0,0 +1,54 @@
1
+ import { createIssue } from "../errors/issues.js";
2
+ export function resolveMemorixContentObject(value) {
3
+ if (value == null || typeof value !== "object" || Array.isArray(value)) {
4
+ return {
5
+ ok: false,
6
+ issue: createIssue({
7
+ code: "MISSING_CONTENT_OBJECT",
8
+ message: "Expected memorix-content-object",
9
+ }),
10
+ };
11
+ }
12
+ const obj = value;
13
+ const contentKey = obj.contentKey;
14
+ if (typeof contentKey !== "string" || !contentKey) {
15
+ return {
16
+ ok: false,
17
+ issue: createIssue({
18
+ code: "MISSING_CONTENT_KEY",
19
+ message: "Content object missing contentKey",
20
+ }),
21
+ };
22
+ }
23
+ return {
24
+ ok: true,
25
+ object: {
26
+ contentKey,
27
+ metadata: obj.metadata && typeof obj.metadata === "object" && !Array.isArray(obj.metadata)
28
+ ? obj.metadata
29
+ : undefined,
30
+ preview: typeof obj.preview === "string" ? obj.preview : undefined,
31
+ },
32
+ };
33
+ }
34
+ export function shapeContentForList(object, behavior) {
35
+ const out = {};
36
+ if (behavior.returnPreview !== false && object.preview != null) {
37
+ out.preview = object.preview;
38
+ }
39
+ if (behavior.returnMetadata !== false && object.metadata) {
40
+ out.metadata = object.metadata;
41
+ }
42
+ if (behavior.returnContentKey && object.contentKey) {
43
+ out.contentKey = object.contentKey;
44
+ }
45
+ return out;
46
+ }
47
+ export function shapeContentForItem(object, behavior, fullContent) {
48
+ const out = shapeContentForList(object, behavior);
49
+ if (fullContent != null) {
50
+ out.content = fullContent;
51
+ }
52
+ return out;
53
+ }
54
+ //# sourceMappingURL=memorix-content-object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memorix-content-object.js","sourceRoot":"","sources":["../../src/content/memorix-content-object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAA8B,MAAM,qBAAqB,CAAC;AAI9E,MAAM,UAAU,2BAA2B,CACzC,KAAc;IAEd,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvE,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,WAAW,CAAC;gBACjB,IAAI,EAAE,wBAAwB;gBAC9B,OAAO,EAAE,iCAAiC;aAC3C,CAAC;SACH,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAAG,KAAgC,CAAC;IAC7C,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;IAClC,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;QAClD,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,WAAW,CAAC;gBACjB,IAAI,EAAE,qBAAqB;gBAC3B,OAAO,EAAE,mCAAmC;aAC7C,CAAC;SACH,CAAC;I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AAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { MemorixRetrievalClient } from "../client/types.js";
2
+ import type { MemorixContentStorageDescriptor, MemorixEntityDescriptor, MemorixPropertyContentDescriptor } from "../descriptors/descriptor-types.js";
3
+ export type ResolvedContentConfig = {
4
+ format: "markdown" | "text";
5
+ storage: MemorixContentStorageDescriptor;
6
+ maxBytes: number;
7
+ encoding: string;
8
+ };
9
+ export declare function resolveContentMaxBytes(client: MemorixRetrievalClient, options: {
10
+ requestMaxBytes?: number;
11
+ itemDescriptorMaxBytes?: number;
12
+ fieldMaxBytes?: number;
13
+ entityMaxBytes?: number;
14
+ }): number;
15
+ export declare function resolveContentConfig(entity: MemorixEntityDescriptor, fieldContent: MemorixPropertyContentDescriptor, client: MemorixRetrievalClient, overrides?: {
16
+ maxBytes?: number;
17
+ }): ResolvedContentConfig | null;
18
+ export declare function buildStorageObjectKey(storage: MemorixContentStorageDescriptor, contentKey: string): string;
19
+ //# sourceMappingURL=resolve-content-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-content-config.d.ts","sourceRoot":"","sources":["../../src/content/resolve-content-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAEV,+BAA+B,EAC/B,uBAAuB,EACvB,gCAAgC,EACjC,MAAM,oCAAoC,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;IAC5B,OAAO,EAAE,+BAA+B,CAAC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,sBAAsB,EAC9B,OAAO,EAAE;IACP,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GACA,MAAM,CAWR;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,YAAY,EAAE,gCAAgC,EAC9C,MAAM,EAAE,sBAAsB,EAC9B,SAAS,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAChC,qBAAqB,GAAG,IAAI,CAoB9B;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,+BAA+B,EACxC,UAAU,EAAE,MAAM,GACjB,MAAM,CAKR"}
@@ -0,0 +1,37 @@
1
+ export function resolveContentMaxBytes(client, options) {
2
+ const candidates = [
3
+ options.requestMaxBytes,
4
+ options.itemDescriptorMaxBytes,
5
+ options.fieldMaxBytes,
6
+ options.entityMaxBytes,
7
+ client.defaults.contentMaxBytes,
8
+ ].filter((n) => typeof n === "number" && n > 0);
9
+ const resolved = Math.min(...candidates);
10
+ return Math.min(resolved, client.defaults.contentMaxBytes);
11
+ }
12
+ export function resolveContentConfig(entity, fieldContent, client, overrides) {
13
+ const defaults = entity.contentDefaults ?? {};
14
+ const storage = fieldContent.storage ?? defaults.storage;
15
+ if (!storage?.provider || !storage.bucket) {
16
+ return null;
17
+ }
18
+ const maxBytes = resolveContentMaxBytes(client, {
19
+ requestMaxBytes: overrides?.maxBytes,
20
+ fieldMaxBytes: storage.maxBytes,
21
+ entityMaxBytes: defaults.maxBytes,
22
+ });
23
+ return {
24
+ format: fieldContent.format ?? defaults.format ?? "markdown",
25
+ storage,
26
+ maxBytes,
27
+ encoding: storage.encoding ?? defaults.encoding ?? "utf8",
28
+ };
29
+ }
30
+ export function buildStorageObjectKey(storage, contentKey) {
31
+ const prefix = storage.prefix?.replace(/\/$/, "") ?? "";
32
+ if (!prefix)
33
+ return contentKey.replace(/^\//, "");
34
+ const key = contentKey.replace(/^\//, "");
35
+ return `${prefix}/${key}`;
36
+ }
37
+ //# sourceMappingURL=resolve-content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P,QAAQ;QACR,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,IAAI,MAAM;KAC1D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAAwC,EACxC,UAAkB;IAElB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;IACxD,IAAI,CAAC,MAAM;QAAE,OAAO,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC1C,OAAO,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { MemorixContentTypeDescriptor, MemorixEntityDescriptor } from "../descriptors/descriptor-types.js";
2
+ export declare function resolveMemorixCollectionName(entity: MemorixEntityDescriptor, contentTypeKey: string, env?: NodeJS.ProcessEnv): string;
3
+ export declare function resolveMemorixCollectionNameFromDescriptor(entity: MemorixEntityDescriptor, contentType: MemorixContentTypeDescriptor, env?: NodeJS.ProcessEnv): string;
4
+ //# sourceMappingURL=collection-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection-name.d.ts","sourceRoot":"","sources":["../../src/data/collection-name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,uBAAuB,EACxB,MAAM,oCAAoC,CAAC;AAK5C,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,uBAAuB,EAC/B,cAAc,EAAE,MAAM,EACtB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CASR;AAED,wBAAgB,0CAA0C,CACxD,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,4BAA4B,EACzC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CAaR"}
@@ -0,0 +1,23 @@
1
+ import { throwRetrievalError } from "../errors/errors.js";
2
+ import { targetCollectionEnvKey } from "../mongo/env.js";
3
+ import { resolveEntityTarget } from "../mongo/resolve-db.js";
4
+ export function resolveMemorixCollectionName(entity, contentTypeKey, env = process.env) {
5
+ const ct = entity.contentTypes[contentTypeKey];
6
+ if (!ct) {
7
+ throwRetrievalError("UNKNOWN_CONTENT_TYPE", `Unknown content type "${contentTypeKey}" on entity "${entity.id}"`);
8
+ }
9
+ return resolveMemorixCollectionNameFromDescriptor(entity, ct, env);
10
+ }
11
+ export function resolveMemorixCollectionNameFromDescriptor(entity, contentType, env = process.env) {
12
+ if (contentType.collection) {
13
+ return contentType.collection;
14
+ }
15
+ const target = resolveEntityTarget(entity);
16
+ const envKey = targetCollectionEnvKey(target, entity.entityName);
17
+ const fromEnv = env[envKey]?.trim();
18
+ if (fromEnv) {
19
+ return fromEnv;
20
+ }
21
+ return `${entity.collectionPrefix}-${contentType.postfix}`;
22
+ }
23
+ //# sourceMappingURL=collection-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection-name.js","sourceRoot":"","sources":["../../src/data/collection-name.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,UAAU,4BAA4B,CAC1C,MAA+B,EAC/B,cAAsB,EACtB,MAAyB,OAAO,CAAC,GAAG;IAEpC,MAAM,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAC/C,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,mBAAmB,CACjB,sBAAsB,EACtB,yBAAyB,cAAc,gBAAgB,MAAM,CAAC,EAAE,GAAG,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,0CAA0C,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,0CAA0C,CACxD,MAA+B,EAC/B,WAAyC,EACzC,MAAyB,OAAO,CAAC,GAAG;IAEpC,IAAI,WAAW,CAAC,UAAU,EAAE,CAAC;QAC3B,OAAO,WAAW,CAAC,UAAU,CAAC;IAChC,CAAC;IAED,MAAM,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;IACpC,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,GAAG,MAAM,CAAC,gBAAgB,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;AAC7D,CAAC"}