@endora-commerce/mod-assets-library 0.0.0-stage → 0.100.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 (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -2
  3. package/dist/admin/api/assets-library-client.d.ts +29 -0
  4. package/dist/admin/api/assets-library-client.d.ts.map +1 -0
  5. package/dist/admin/api/assets-library-client.js +70 -0
  6. package/dist/admin/api/assets-library-client.js.map +1 -0
  7. package/dist/admin/components/AssetDetailDrawer.d.ts +8 -0
  8. package/dist/admin/components/AssetDetailDrawer.d.ts.map +1 -0
  9. package/dist/admin/components/AssetDetailDrawer.js +96 -0
  10. package/dist/admin/components/AssetDetailDrawer.js.map +1 -0
  11. package/dist/admin/components/FolderTree.d.ts +13 -0
  12. package/dist/admin/components/FolderTree.d.ts.map +1 -0
  13. package/dist/admin/components/FolderTree.js +71 -0
  14. package/dist/admin/components/FolderTree.js.map +1 -0
  15. package/dist/admin/index.d.ts +44 -0
  16. package/dist/admin/index.d.ts.map +1 -0
  17. package/dist/admin/index.js +46 -0
  18. package/dist/admin/index.js.map +1 -0
  19. package/dist/admin/pages/LibraryPage.d.ts +9 -0
  20. package/dist/admin/pages/LibraryPage.d.ts.map +1 -0
  21. package/dist/admin/pages/LibraryPage.js +163 -0
  22. package/dist/admin/pages/LibraryPage.js.map +1 -0
  23. package/dist/backend/entities/asset-folder.entity.d.ts +16 -0
  24. package/dist/backend/entities/asset-folder.entity.d.ts.map +1 -0
  25. package/dist/backend/entities/asset-folder.entity.js +57 -0
  26. package/dist/backend/entities/asset-folder.entity.js.map +1 -0
  27. package/dist/backend/entities/asset.entity.d.ts +38 -0
  28. package/dist/backend/entities/asset.entity.d.ts.map +1 -0
  29. package/dist/backend/entities/asset.entity.js +128 -0
  30. package/dist/backend/entities/asset.entity.js.map +1 -0
  31. package/dist/backend/index.d.ts +57 -0
  32. package/dist/backend/index.d.ts.map +1 -0
  33. package/dist/backend/index.js +150 -0
  34. package/dist/backend/index.js.map +1 -0
  35. package/dist/backend/jobs/hard-delete-asset.job.d.ts +18 -0
  36. package/dist/backend/jobs/hard-delete-asset.job.d.ts.map +1 -0
  37. package/dist/backend/jobs/hard-delete-asset.job.js +91 -0
  38. package/dist/backend/jobs/hard-delete-asset.job.js.map +1 -0
  39. package/dist/backend/plugin.d.ts +47 -0
  40. package/dist/backend/plugin.d.ts.map +1 -0
  41. package/dist/backend/plugin.js +96 -0
  42. package/dist/backend/plugin.js.map +1 -0
  43. package/dist/backend/routes.admin.d.ts +15 -0
  44. package/dist/backend/routes.admin.d.ts.map +1 -0
  45. package/dist/backend/routes.admin.js +189 -0
  46. package/dist/backend/routes.admin.js.map +1 -0
  47. package/dist/backend/routes.public.d.ts +14 -0
  48. package/dist/backend/routes.public.d.ts.map +1 -0
  49. package/dist/backend/routes.public.js +99 -0
  50. package/dist/backend/routes.public.js.map +1 -0
  51. package/dist/backend/services/asset-read-port.d.ts +103 -0
  52. package/dist/backend/services/asset-read-port.d.ts.map +1 -0
  53. package/dist/backend/services/asset-read-port.js +167 -0
  54. package/dist/backend/services/asset-read-port.js.map +1 -0
  55. package/dist/backend/services/assets-library.service.d.ts +76 -0
  56. package/dist/backend/services/assets-library.service.d.ts.map +1 -0
  57. package/dist/backend/services/assets-library.service.js +261 -0
  58. package/dist/backend/services/assets-library.service.js.map +1 -0
  59. package/dist/backend/services/cms-body-resolver.d.ts +6 -0
  60. package/dist/backend/services/cms-body-resolver.d.ts.map +1 -0
  61. package/dist/backend/services/cms-body-resolver.js +44 -0
  62. package/dist/backend/services/cms-body-resolver.js.map +1 -0
  63. package/dist/backend/services/folders.service.d.ts +29 -0
  64. package/dist/backend/services/folders.service.d.ts.map +1 -0
  65. package/dist/backend/services/folders.service.js +231 -0
  66. package/dist/backend/services/folders.service.js.map +1 -0
  67. package/dist/backend/services/hmac.d.ts +28 -0
  68. package/dist/backend/services/hmac.d.ts.map +1 -0
  69. package/dist/backend/services/hmac.js +50 -0
  70. package/dist/backend/services/hmac.js.map +1 -0
  71. package/dist/backend/services/reference-registry.d.ts +36 -0
  72. package/dist/backend/services/reference-registry.d.ts.map +1 -0
  73. package/dist/backend/services/reference-registry.js +63 -0
  74. package/dist/backend/services/reference-registry.js.map +1 -0
  75. package/dist/backend/services/storage/adapter-registry.d.ts +77 -0
  76. package/dist/backend/services/storage/adapter-registry.d.ts.map +1 -0
  77. package/dist/backend/services/storage/adapter-registry.js +95 -0
  78. package/dist/backend/services/storage/adapter-registry.js.map +1 -0
  79. package/dist/backend/services/storage/errors.d.ts +18 -0
  80. package/dist/backend/services/storage/errors.d.ts.map +1 -0
  81. package/dist/backend/services/storage/errors.js +30 -0
  82. package/dist/backend/services/storage/errors.js.map +1 -0
  83. package/dist/backend/services/storage/gcs-adapter.d.ts +42 -0
  84. package/dist/backend/services/storage/gcs-adapter.d.ts.map +1 -0
  85. package/dist/backend/services/storage/gcs-adapter.js +106 -0
  86. package/dist/backend/services/storage/gcs-adapter.js.map +1 -0
  87. package/dist/backend/services/storage/legacy-resolver.d.ts +15 -0
  88. package/dist/backend/services/storage/legacy-resolver.d.ts.map +1 -0
  89. package/dist/backend/services/storage/legacy-resolver.js +32 -0
  90. package/dist/backend/services/storage/legacy-resolver.js.map +1 -0
  91. package/dist/backend/services/storage/local-fs-adapter.d.ts +59 -0
  92. package/dist/backend/services/storage/local-fs-adapter.d.ts.map +1 -0
  93. package/dist/backend/services/storage/local-fs-adapter.js +153 -0
  94. package/dist/backend/services/storage/local-fs-adapter.js.map +1 -0
  95. package/dist/backend/services/storage/locator.d.ts +5 -0
  96. package/dist/backend/services/storage/locator.d.ts.map +1 -0
  97. package/dist/backend/services/storage/locator.js +16 -0
  98. package/dist/backend/services/storage/locator.js.map +1 -0
  99. package/dist/backend/services/storage/object-storage-port.d.ts +46 -0
  100. package/dist/backend/services/storage/object-storage-port.d.ts.map +1 -0
  101. package/dist/backend/services/storage/object-storage-port.js +78 -0
  102. package/dist/backend/services/storage/object-storage-port.js.map +1 -0
  103. package/dist/backend/services/storage/public-url-base.d.ts +50 -0
  104. package/dist/backend/services/storage/public-url-base.d.ts.map +1 -0
  105. package/dist/backend/services/storage/public-url-base.js +70 -0
  106. package/dist/backend/services/storage/public-url-base.js.map +1 -0
  107. package/dist/backend/services/storage/s3-adapter.d.ts +50 -0
  108. package/dist/backend/services/storage/s3-adapter.d.ts.map +1 -0
  109. package/dist/backend/services/storage/s3-adapter.js +110 -0
  110. package/dist/backend/services/storage/s3-adapter.js.map +1 -0
  111. package/dist/backend/services/storage/settings-view.d.ts +4 -0
  112. package/dist/backend/services/storage/settings-view.d.ts.map +1 -0
  113. package/dist/backend/services/storage/settings-view.js +73 -0
  114. package/dist/backend/services/storage/settings-view.js.map +1 -0
  115. package/dist/backend/services/storage/storage-adapter.d.ts +62 -0
  116. package/dist/backend/services/storage/storage-adapter.d.ts.map +1 -0
  117. package/dist/backend/services/storage/storage-adapter.js +10 -0
  118. package/dist/backend/services/storage/storage-adapter.js.map +1 -0
  119. package/dist/backend/services/upload-pipeline.d.ts +41 -0
  120. package/dist/backend/services/upload-pipeline.d.ts.map +1 -0
  121. package/dist/backend/services/upload-pipeline.js +231 -0
  122. package/dist/backend/services/upload-pipeline.js.map +1 -0
  123. package/dist/manifest.d.ts +185 -0
  124. package/dist/manifest.d.ts.map +1 -0
  125. package/dist/manifest.js +229 -0
  126. package/dist/manifest.js.map +1 -0
  127. package/dist/migrations/20260505T102206_assets_library_init.d.ts +35 -0
  128. package/dist/migrations/20260505T102206_assets_library_init.d.ts.map +1 -0
  129. package/dist/migrations/20260505T102206_assets_library_init.js +132 -0
  130. package/dist/migrations/20260505T102206_assets_library_init.js.map +1 -0
  131. package/dist/migrations/index.d.ts +27 -0
  132. package/dist/migrations/index.d.ts.map +1 -0
  133. package/dist/migrations/index.js +29 -0
  134. package/dist/migrations/index.js.map +1 -0
  135. package/docs/assets-library/index.md +125 -0
  136. package/i18n/en.json +54 -0
  137. package/i18n/pl.json +54 -0
  138. package/package.json +99 -3
  139. package/tailwind.css +14 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.admin.js","sourceRoot":"","sources":["../../src/backend/routes.admin.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,uCAAuC;AACvC,EAAE;AACF,0CAA0C;AAC1C,+DAA+D;AAC/D,gFAAgF;AAChF,qEAAqE;AACrE,uEAAuE;AACvE,8EAA8E;AAC9E,EAAE;AACF,uEAAuE;AACvE,mCAAmC;AAInC,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAcnD,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,GAAoB,EACpB,IAAqB;IAErB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAErE,8EAA8E;IAC9E,GAAG,CAAC,IAAI,CACN,sBAAsB,EACtB,EAAE,UAAU,EAAE,YAAY,CAAC,cAAc,CAAC,EAAE,EAC5C,KAAK,EAAE,GAAmB,EAAE,KAAmB,EAAE,EAAE;QACjD,8CAA8C;QAC9C,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,MAAM,IAAI,SAAS,CACjB,GAAG,EACH,WAAW,CAAC,oBAAoB,EAChC,yDAAyD,CAC1D,CAAC;QACJ,CAAC;QAED,kEAAkE;QAClE,IAAI,QAAQ,GAAkB,IAAI,CAAC;QACnC,IAAI,KAAK,GAAkB,IAAI,CAAC;QAChC,IAAI,UAAU,GAAyB,QAAQ,CAAC;QAChD,IAAI,KAAK,GAAsD,IAAI,CAAC;QAEpE,IAAI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CAAC,EAAE,CAAC;YAC5D,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,GAAG,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3E,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACtE,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import type { EntityManager } from '@mikro-orm/postgresql';
3
+ import type { AdapterRegistry } from './services/storage/adapter-registry.js';
4
+ import type { AssetsLibraryService } from './services/assets-library.service.js';
5
+ import type { HmacSigner } from './services/hmac.js';
6
+ export interface PublicRoutesDeps {
7
+ service: AssetsLibraryService;
8
+ adapters: AdapterRegistry;
9
+ emFactory: () => EntityManager;
10
+ /** Provider so tests that never serve files don't pay env-var cost. */
11
+ signer: () => HmacSigner;
12
+ }
13
+ export declare function registerAssetsLibraryPublicRoutes(app: FastifyInstance, deps: PublicRoutesDeps): Promise<void>;
14
+ //# sourceMappingURL=routes.public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.public.d.ts","sourceRoot":"","sources":["../../src/backend/routes.public.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAM3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,EAAE,eAAe,CAAC;IAC1B,SAAS,EAAE,MAAM,aAAa,CAAC;IAC/B,uEAAuE;IACvE,MAAM,EAAE,MAAM,UAAU,CAAC;CAC1B;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,IAAI,CAAC,CAqGf"}
@@ -0,0 +1,99 @@
1
+ // Public file-serving route for the Assets Library — feature 013 / US1.
2
+ // Used by the storefront for assets stored on the local-FS adapter.
3
+ // Cloud adapters (S3 / GCS) bypass this route entirely — their public URLs
4
+ // point at the bucket directly and their private URLs are signed by the
5
+ // vendor SDK; the storefront fetches them without touching this code path.
6
+ //
7
+ // Behaviour:
8
+ // public assets → no auth, long Cache-Control
9
+ // private assets → require valid HMAC token (?token=&exp=)
10
+ // soft-deleted → 410 ASSET_GONE (so still-live storefront caches degrade gracefully)
11
+ // missing file → 404 ASSET_FILE_MISSING
12
+ import { ERROR_CODES } from '@endora-commerce/contracts';
13
+ import { HttpError } from '@endora-commerce/platform/http';
14
+ import { Asset } from './entities/asset.entity.js';
15
+ import { LocalFsStorageAdapter } from './services/storage/local-fs-adapter.js';
16
+ export async function registerAssetsLibraryPublicRoutes(app, deps) {
17
+ app.get('/assets/file/:assetId', { config: { streamingResponse: true } }, async (req, reply) => {
18
+ const em = deps.emFactory();
19
+ const a = await em.findOne(Asset, { id: req.params.assetId });
20
+ if (!a) {
21
+ throw new HttpError(404, ERROR_CODES.ASSET_NOT_FOUND, 'Asset not found.');
22
+ }
23
+ if (a.deletedAt) {
24
+ throw new HttpError(410, ERROR_CODES.ASSET_GONE, 'Asset has been deleted.');
25
+ }
26
+ // This route only serves bytes from the local-FS adapter. Cloud
27
+ // assets are always reached via the bucket URL or signed URL — they
28
+ // never hit this endpoint.
29
+ if (a.storageBackend !== 'local') {
30
+ // Redirect to the resolved URL so a misconfigured client falls back
31
+ // to the canonical serving path.
32
+ const resolved = await deps.service.resolveUrl(a.id);
33
+ reply.redirect(resolved.url, 302);
34
+ return;
35
+ }
36
+ // Visibility / token check.
37
+ if (a.visibility === 'private') {
38
+ const signer = deps.signer();
39
+ const exp = Number(req.query.exp);
40
+ const token = String(req.query.token ?? '');
41
+ const ok = signer.verify({
42
+ assetId: a.id,
43
+ token,
44
+ exp,
45
+ nowSec: Math.floor(Date.now() / 1000),
46
+ });
47
+ if (!ok) {
48
+ throw new HttpError(403, ERROR_CODES.ASSET_ACCESS_DENIED, 'Access denied.');
49
+ }
50
+ }
51
+ const adapter = await deps.adapters.getForBackend('local');
52
+ if (!(adapter instanceof LocalFsStorageAdapter)) {
53
+ throw new HttpError(500, ERROR_CODES.INTERNAL, 'Local-FS adapter is not currently active.');
54
+ }
55
+ // ETag / 304 short-circuit.
56
+ const etag = `"${a.id}-${Math.floor(a.updatedAt.getTime() / 1000)}"`;
57
+ const ifNoneMatch = req.headers['if-none-match'];
58
+ if (typeof ifNoneMatch === 'string' && ifNoneMatch === etag) {
59
+ return reply.status(304).send();
60
+ }
61
+ // Stream open. open() throws on missing file → 404 ASSET_FILE_MISSING.
62
+ let stream;
63
+ try {
64
+ stream = await adapter.open({ locator: a.storageLocator || a.storageUrl });
65
+ }
66
+ catch {
67
+ throw new HttpError(404, ERROR_CODES.ASSET_FILE_MISSING, 'Underlying file is missing.');
68
+ }
69
+ // Standard headers.
70
+ reply.header('Content-Type', a.mimeType);
71
+ // sizeBytes is mapped as bigint at the DB layer; coerce to string for
72
+ // the Content-Length header (Node's HTTP layer rejects bigint values).
73
+ // Only set it when the recorded size is meaningful — a stale/legacy `0`
74
+ // (uploads that never captured a byte count) would otherwise tell the
75
+ // browser the body is empty and produce a broken/blank image. Omitting
76
+ // the header lets Fastify stream the file to EOF.
77
+ if (Number(a.sizeBytes) > 0) {
78
+ reply.header('Content-Length', String(a.sizeBytes));
79
+ }
80
+ reply.header('ETag', etag);
81
+ reply.header('Cache-Control', a.visibility === 'public'
82
+ ? 'public, max-age=31536000, immutable'
83
+ : 'private, no-store, max-age=0');
84
+ // Public assets are embedded by the storefront and admin, which run on a
85
+ // different origin than the backend. Helmet's default
86
+ // `Cross-Origin-Resource-Policy: same-origin` would block those
87
+ // cross-origin <img> loads, so relax it to `cross-origin` for public
88
+ // assets (private assets keep the stricter default).
89
+ if (a.visibility === 'public') {
90
+ reply.header('Cross-Origin-Resource-Policy', 'cross-origin');
91
+ }
92
+ const dispoMode = req.query.download === '1' ? 'attachment' : 'inline';
93
+ const safeName = a.filename.replace(/[\r\n";]/g, '_');
94
+ reply.header('Content-Disposition', `${dispoMode}; filename="${safeName}"`);
95
+ // Fastify will pipe a Readable through to the response.
96
+ return reply.send(stream);
97
+ });
98
+ }
99
+ //# sourceMappingURL=routes.public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.public.js","sourceRoot":"","sources":["../../src/backend/routes.public.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,oEAAoE;AACpE,2EAA2E;AAC3E,wEAAwE;AACxE,2EAA2E;AAC3E,EAAE;AACF,aAAa;AACb,iDAAiD;AACjD,6DAA6D;AAC7D,yFAAyF;AACzF,4CAA4C;AAI5C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAa/E,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,GAAoB,EACpB,IAAsB;IAEtB,GAAG,CAAC,GAAG,CAIL,uBAAuB,EACvB,EAAE,MA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2
+ import type { AssetBytes, AssetByteStream, AssetReadPort, AssetRecord, ObjectStorageBackendCode, StorageBackendCode } from '@endora-commerce/contracts';
3
+ import { Asset } from '../entities/asset.entity.js';
4
+ import type { StorageResolveUrlInput, StorageResolveUrlOutput } from './storage/storage-adapter.js';
5
+ /**
6
+ * The narrow slice of the adapter registry {@link AssetReadService} needs — the
7
+ * URL builder of whichever backend owns an object's bytes, and, for a backend
8
+ * that is a real object store, the reader that opens them.
9
+ *
10
+ * Declared here rather than taking `AdapterRegistry` so that the read model can
11
+ * be unit-tested over a stub, and so that the two capabilities it has over the
12
+ * `assets` table are visible in its constructor.
13
+ *
14
+ * **Two overloads, narrowest first**, because `AdapterRegistry` has exactly
15
+ * this shape and for the reason it has it: `legacy` is not a store — it
16
+ * resolves the URL of a pre-013 row this platform did not issue and can open
17
+ * nothing — so `open` exists only on the arm a `legacy` code cannot reach
18
+ * (`ObjectStoragePort`'s doc block, point 3). Widest-first would hand every
19
+ * call the arm without `open` and put the probe back at the call site, which is
20
+ * the thing the port removes.
21
+ */
22
+ export interface AssetStorageRegistry {
23
+ getForBackend(backend: ObjectStorageBackendCode): Promise<{
24
+ resolveUrl(input: StorageResolveUrlInput): StorageResolveUrlOutput | Promise<StorageResolveUrlOutput>;
25
+ open(input: {
26
+ locator: string;
27
+ }): Promise<AssetByteStream>;
28
+ }>;
29
+ getForBackend(backend: StorageBackendCode): Promise<{
30
+ resolveUrl(input: StorageResolveUrlInput): StorageResolveUrlOutput | Promise<StorageResolveUrlOutput>;
31
+ }>;
32
+ }
33
+ /**
34
+ * The row-level read model `assets_library` publishes (feature 075, Phase P).
35
+ *
36
+ * Five inbound sites read the `Asset` entity, and all five ask the same thing
37
+ * before attaching an id an admin supplied: does this asset exist, and is it
38
+ * the right kind? `catalog`'s gallery, attachments and product links do it
39
+ * three times over, `orders` once for invoice branding.
40
+ *
41
+ * `sizeBytes` stays a string: the column is `bigint`, and a `number` cannot
42
+ * hold one past 2^53.
43
+ */
44
+ export declare class AssetReadService implements AssetReadPort {
45
+ private readonly emFactory;
46
+ /**
47
+ * Required, and a provider rather than the registry itself: the registry is
48
+ * built from settings and rebuilt when they change, so a captured one goes
49
+ * stale after an operator switches the active backend. Not optional — an
50
+ * argument whose omission is silent is how this module once shipped a
51
+ * permission gate that defaulted to permissive.
52
+ */
53
+ private readonly adapters;
54
+ constructor(emFactory: () => EntityManager,
55
+ /**
56
+ * Required, and a provider rather than the registry itself: the registry is
57
+ * built from settings and rebuilt when they change, so a captured one goes
58
+ * stale after an operator switches the active backend. Not optional — an
59
+ * argument whose omission is silent is how this module once shipped a
60
+ * permission gate that defaulted to permissive.
61
+ */
62
+ adapters: () => AssetStorageRegistry);
63
+ findById(id: string, options?: {
64
+ liveOnly?: boolean;
65
+ }): Promise<AssetRecord | null>;
66
+ findByIds(ids: readonly string[], options?: {
67
+ liveOnly?: boolean;
68
+ }): Promise<AssetRecord[]>;
69
+ /**
70
+ * FR-043's rule, answered where the information is.
71
+ *
72
+ * Only a live, `public` asset can have a stable URL, and only this module can
73
+ * say so: a consumer holding an asset id cannot tell a signed link from a
74
+ * permanent one. So the filter is here and the absence is the answer — see
75
+ * the port's contract.
76
+ *
77
+ * One query for the rows and a URL build per row. The adapters are cached by
78
+ * the registry and a *public* resolution is a string join in all four of
79
+ * them, so this issues no I/O beyond the read.
80
+ */
81
+ resolvePublicUrls(assetIds: readonly string[]): Promise<Map<string, string>>;
82
+ /**
83
+ * The bytes of one live asset — the port's rule, answered where the storage
84
+ * layout is (`specs/110-instance-repository/` T118c).
85
+ *
86
+ * Three facts left a composition root to arrive here, and each of them is one
87
+ * line below. `legacy` is not a store, so a row on it has no bytes to open
88
+ * and answers `null` rather than being probed for an `open` method at the
89
+ * call site. The locator falls back to `storageUrl` for rows written before
90
+ * the column existed. And an adapter answers a stream, which the caller
91
+ * wanted whole.
92
+ *
93
+ * **The `catch` is the degrade, and it belongs here** (composition checklist
94
+ * item 7): a configured backend that will not stream is a document rendered
95
+ * without its decoration, and the caller — holding an asset id and nothing
96
+ * else — cannot tell that state from an asset that is not there. It is
97
+ * narrow on purpose: it covers the open and the drain, never the row read,
98
+ * which is this module's own `EntityManager` and whose failure is a real one.
99
+ */
100
+ openAssetBytes(assetId: string): Promise<AssetBytes | null>;
101
+ }
102
+ export declare function toAssetRecord(asset: Asset): AssetRecord;
103
+ //# sourceMappingURL=asset-read-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-read-port.d.ts","sourceRoot":"","sources":["../../../src/backend/services/asset-read-port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,WAAW,EACX,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEpG;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC;QACxD,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;QACtG,IAAI,CAAC,KAAK,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;KAC5D,CAAC,CAAC;IACH,aAAa,CACX,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC;QAAE,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;KAAE,CAAC,CAAC;CACvH;AAED;;;;;;;;;;GAUG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IAElD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBARR,SAAS,EAAE,MAAM,aAAa;IAC/C;;;;;;OAMG;IACc,QAAQ,EAAE,MAAM,oBAAoB;IAGjD,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAQnF,SAAS,CACb,GAAG,EAAE,SAAS,MAAM,EAAE,EACtB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAC/B,OAAO,CAAC,WAAW,EAAE,CAAC;IASzB;;;;;;;;;;;OAWG;IACG,iBAAiB,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IA+BlF;;;;;;;;;;;;;;;;;OAiBG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAqClE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAqBvD"}
@@ -0,0 +1,167 @@
1
+ import { rethrowIfModuleDisabled } from '@endora-commerce/platform/kernel';
2
+ import { Asset } from '../entities/asset.entity.js';
3
+ /**
4
+ * The row-level read model `assets_library` publishes (feature 075, Phase P).
5
+ *
6
+ * Five inbound sites read the `Asset` entity, and all five ask the same thing
7
+ * before attaching an id an admin supplied: does this asset exist, and is it
8
+ * the right kind? `catalog`'s gallery, attachments and product links do it
9
+ * three times over, `orders` once for invoice branding.
10
+ *
11
+ * `sizeBytes` stays a string: the column is `bigint`, and a `number` cannot
12
+ * hold one past 2^53.
13
+ */
14
+ export class AssetReadService {
15
+ emFactory;
16
+ adapters;
17
+ constructor(emFactory,
18
+ /**
19
+ * Required, and a provider rather than the registry itself: the registry is
20
+ * built from settings and rebuilt when they change, so a captured one goes
21
+ * stale after an operator switches the active backend. Not optional — an
22
+ * argument whose omission is silent is how this module once shipped a
23
+ * permission gate that defaulted to permissive.
24
+ */
25
+ adapters) {
26
+ this.emFactory = emFactory;
27
+ this.adapters = adapters;
28
+ }
29
+ async findById(id, options) {
30
+ const asset = await this.emFactory().findOne(Asset, {
31
+ id,
32
+ ...(options?.liveOnly ? { deletedAt: null } : {}),
33
+ });
34
+ return asset ? toAssetRecord(asset) : null;
35
+ }
36
+ async findByIds(ids, options) {
37
+ if (ids.length === 0)
38
+ return [];
39
+ const assets = await this.emFactory().find(Asset, {
40
+ id: { $in: [...ids] },
41
+ ...(options?.liveOnly ? { deletedAt: null } : {}),
42
+ });
43
+ return assets.map(toAssetRecord);
44
+ }
45
+ /**
46
+ * FR-043's rule, answered where the information is.
47
+ *
48
+ * Only a live, `public` asset can have a stable URL, and only this module can
49
+ * say so: a consumer holding an asset id cannot tell a signed link from a
50
+ * permanent one. So the filter is here and the absence is the answer — see
51
+ * the port's contract.
52
+ *
53
+ * One query for the rows and a URL build per row. The adapters are cached by
54
+ * the registry and a *public* resolution is a string join in all four of
55
+ * them, so this issues no I/O beyond the read.
56
+ */
57
+ async resolvePublicUrls(assetIds) {
58
+ const out = new Map();
59
+ if (assetIds.length === 0)
60
+ return out;
61
+ const registry = this.adapters();
62
+ const assets = await this.emFactory().find(Asset, {
63
+ id: { $in: [...assetIds] },
64
+ deletedAt: null,
65
+ visibility: 'public',
66
+ });
67
+ for (const asset of assets) {
68
+ const adapter = await registry.getForBackend(asset.storageBackend);
69
+ const resolved = await adapter.resolveUrl({
70
+ locator: asset.storageLocator || asset.storageUrl,
71
+ visibility: asset.visibility,
72
+ });
73
+ // The rule the port states, kept where the answer is rather than inferred
74
+ // from the filter above. **Measured**: with that filter in place this
75
+ // branch is unreachable — all four resolvers answer a `public` visibility
76
+ // with `expiresAt: null` as their first statement — and with it removed
77
+ // this branch is what still refuses a private asset. Two spellings of one
78
+ // rule is deliberate here and only here: a fifth backend, or a fifth
79
+ // visibility, changes which of the two is doing the work, and a feed that
80
+ // published an expiring link would not fail anywhere near this line.
81
+ if (resolved.expiresAt !== null)
82
+ continue;
83
+ out.set(asset.id, resolved.url);
84
+ }
85
+ return out;
86
+ }
87
+ /**
88
+ * The bytes of one live asset — the port's rule, answered where the storage
89
+ * layout is (`specs/110-instance-repository/` T118c).
90
+ *
91
+ * Three facts left a composition root to arrive here, and each of them is one
92
+ * line below. `legacy` is not a store, so a row on it has no bytes to open
93
+ * and answers `null` rather than being probed for an `open` method at the
94
+ * call site. The locator falls back to `storageUrl` for rows written before
95
+ * the column existed. And an adapter answers a stream, which the caller
96
+ * wanted whole.
97
+ *
98
+ * **The `catch` is the degrade, and it belongs here** (composition checklist
99
+ * item 7): a configured backend that will not stream is a document rendered
100
+ * without its decoration, and the caller — holding an asset id and nothing
101
+ * else — cannot tell that state from an asset that is not there. It is
102
+ * narrow on purpose: it covers the open and the drain, never the row read,
103
+ * which is this module's own `EntityManager` and whose failure is a real one.
104
+ */
105
+ async openAssetBytes(assetId) {
106
+ const asset = await this.emFactory().findOne(Asset, { id: assetId, deletedAt: null });
107
+ if (!asset)
108
+ return null;
109
+ // Narrowed here rather than probed at the caller: the overload's `open` arm
110
+ // is unreachable for `legacy` by construction.
111
+ if (asset.storageBackend === 'legacy')
112
+ return null;
113
+ try {
114
+ const store = await this.adapters().getForBackend(asset.storageBackend);
115
+ const stream = await store.open({ locator: asset.storageLocator || asset.storageUrl });
116
+ const chunks = [];
117
+ let length = 0;
118
+ for await (const chunk of stream) {
119
+ const bytes = typeof chunk === 'string' ? new TextEncoder().encode(chunk) : chunk;
120
+ chunks.push(bytes);
121
+ length += bytes.byteLength;
122
+ }
123
+ const bytes = new Uint8Array(length);
124
+ let offset = 0;
125
+ for (const chunk of chunks) {
126
+ bytes.set(chunk, offset);
127
+ offset += chunk.byteLength;
128
+ }
129
+ return { bytes, mimeType: asset.mimeType };
130
+ }
131
+ catch (error) {
132
+ // Narrow tolerance, and `rethrowIfModuleDisabled` is its first line by
133
+ // decision rather than by habit. The registry this reaches is this
134
+ // module's own and crosses no gate today, so the re-throw is unreachable;
135
+ // what it buys is that it stays unreachable *by construction* — a future
136
+ // adapter that resolved a port would otherwise have its "this capability
137
+ // is off" answer absorbed into "this asset has no bytes", which is the
138
+ // fail-open composition checklist item 7 refuses. A status-code test
139
+ // would not do: `ModuleDisabledError` is an `HttpError`.
140
+ rethrowIfModuleDisabled(error);
141
+ return null;
142
+ }
143
+ }
144
+ }
145
+ export function toAssetRecord(asset) {
146
+ return {
147
+ id: asset.id,
148
+ kind: asset.kind,
149
+ filename: asset.filename,
150
+ mimeType: asset.mimeType,
151
+ sizeBytes: asset.sizeBytes,
152
+ storageUrl: asset.storageUrl,
153
+ altText: asset.altText ?? null,
154
+ folderId: asset.folderId ?? null,
155
+ visibility: asset.visibility,
156
+ label: asset.label ?? null,
157
+ storageBackend: asset.storageBackend,
158
+ storageLocator: asset.storageLocator,
159
+ pendingCleanup: asset.pendingCleanup,
160
+ purgeAfterAt: asset.purgeAfterAt ?? null,
161
+ mimeTypeOverridden: asset.mimeTypeOverridden,
162
+ createdAt: asset.createdAt,
163
+ updatedAt: asset.updatedAt,
164
+ deletedAt: asset.deletedAt ?? null,
165
+ };
166
+ }
167
+ //# sourceMappingURL=asset-read-port.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-read-port.js","sourceRoot":"","sources":["../../../src/backend/services/asset-read-port.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AA8BpD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,gBAAgB;IAER;IAQA;IATnB,YACmB,SAA8B;IAC/C;;;;;;OAMG;IACc,QAAoC;QARpC,cAAS,GAAT,SAAS,CAAqB;QAQ9B,aAAQ,GAAR,QAAQ,CAA4B;IACpD,CAAC;IAE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ACxB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI;QAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;QAChC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI;QAC1B,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,IAAI;QACxC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;QAC5C,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI;KACnC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,76 @@
1
+ import type { EntityManager } from '@mikro-orm/postgresql';
2
+ import { type AssetSummary, type AssetDetail } from '@endora-commerce/contracts';
3
+ import type { AdapterRegistry } from './storage/adapter-registry.js';
4
+ import type { AssetReferenceRegistry } from './reference-registry.js';
5
+ import { type UploadInput, type UploadPolicy } from './upload-pipeline.js';
6
+ import type { AuditPort } from '@endora-commerce/platform/kernel';
7
+ export declare class NotImplementedYet extends Error {
8
+ readonly name = "NotImplementedYet";
9
+ constructor(method: string);
10
+ }
11
+ export interface AssetsLibraryServiceDeps {
12
+ emFactory: () => EntityManager;
13
+ adapters: AdapterRegistry;
14
+ referenceRegistry: AssetReferenceRegistry;
15
+ /** Upload-policy provider — reads `assets.allowed_file_types` + max-size. */
16
+ loadUploadPolicy: () => Promise<UploadPolicy>;
17
+ /** Feature 054 — audits asset writes co-transactionally when provided. */
18
+ auditLog?: AuditPort;
19
+ }
20
+ export interface ListAssetsQuery {
21
+ folderId?: string | null | undefined;
22
+ q?: string | undefined;
23
+ mime?: string | undefined;
24
+ visibility?: 'public' | 'private' | undefined;
25
+ includeDeleted?: boolean | undefined;
26
+ cursor?: string | undefined;
27
+ limit?: number | undefined;
28
+ }
29
+ export declare class AssetsLibraryService {
30
+ #private;
31
+ private readonly deps;
32
+ private readonly pipeline;
33
+ constructor(deps: AssetsLibraryServiceDeps);
34
+ /** Upload entry point — runs the atomic put + insert + compensating-delete pipeline. */
35
+ upload(input: UploadInput): Promise<AssetDetail>;
36
+ /** Resolve the serving URL for an asset by id (public or private). */
37
+ resolveUrl(assetId: string, opts?: {
38
+ ttlSec?: number;
39
+ }): Promise<{
40
+ url: string;
41
+ expiresAt: Date | null;
42
+ }>;
43
+ getAsset(assetId: string): Promise<AssetDetail>;
44
+ listAssets(query: ListAssetsQuery): Promise<{
45
+ data: AssetSummary[];
46
+ nextCursor: string | null;
47
+ }>;
48
+ patchAsset(assetId: string, patch: {
49
+ filename?: string;
50
+ label?: string | null;
51
+ mimeType?: string;
52
+ visibility?: 'public' | 'private';
53
+ folderId?: string | null;
54
+ /**
55
+ * Per-language alternate text. `AssetDetail` has always reported it and
56
+ * nothing could write it; feature 068 needs it, because an imported image
57
+ * must keep the alternate text the source supplied, per language
58
+ * (FR-047). Not on `patchAssetRequestSchema`, so the HTTP surface is
59
+ * unchanged — this is a service-level field for module callers.
60
+ */
61
+ altText?: Record<string, string> | null;
62
+ }): Promise<AssetDetail>;
63
+ setVisibility(assetId: string, visibility: 'public' | 'private'): Promise<AssetDetail>;
64
+ softDelete(assetId: string): Promise<{
65
+ deletedAt: Date;
66
+ purgeAfterAt: Date;
67
+ }>;
68
+ restore(assetId: string): Promise<AssetDetail>;
69
+ move(assetId: string, folderId: string | null): Promise<AssetDetail>;
70
+ moveMany(assetIds: string[], folderId: string | null): Promise<{
71
+ movedCount: number;
72
+ }>;
73
+ private summary;
74
+ private detail;
75
+ }
76
+ //# sourceMappingURL=assets-library.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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