@adonis-agora/media 0.8.0 → 0.8.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.
- package/CHANGELOG.md +31 -0
- package/dist/src/stores/factory.d.ts.map +1 -1
- package/dist/src/stores/factory.js +15 -2
- package/dist/src/stores/factory.js.map +1 -1
- package/dist/src/upload_sessions/factory.d.ts.map +1 -1
- package/dist/src/upload_sessions/factory.js +6 -2
- package/dist/src/upload_sessions/factory.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @adonis-agora/media
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#14](https://github.com/DavideCarvalho/adonis-media/pull/14) [`9224651`](https://github.com/DavideCarvalho/adonis-media/commit/922465168256b7b248347639edaa322cf53cfeec) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Resolve the Lucid `Database` by its string alias `'lucid.db'` instead of importing
|
|
8
|
+
`@adonisjs/lucid/services/db`, making the library immune to the dual-package hazard.
|
|
9
|
+
|
|
10
|
+
The service module resolves the `Database` **class** and uses it as the container token, while
|
|
11
|
+
Lucid's provider registers `container.singleton(Database, ...)` keyed on that same class object. A
|
|
12
|
+
class token only matches when the consumer and the booting provider loaded the _same physical copy_
|
|
13
|
+
of `@adonisjs/lucid`. When a host app's tree contains two copies — different version pins, or even
|
|
14
|
+
the same version resolved under different peer sets, which pnpm materializes as separate directories
|
|
15
|
+
— the tokens differ, no binding is found, and the container tries to _construct_ `Database`, which
|
|
16
|
+
has no `@inject()`:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
RuntimeException: Cannot construct "[class Database]" class.
|
|
20
|
+
Container is not able to resolve its dependencies. Did you forget to use @inject() decorator?
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This took down every TUS upload in a production app while its local test suite passed, because the
|
|
24
|
+
duplication existed only in the `pnpm deploy` artifact and not in the workspace.
|
|
25
|
+
|
|
26
|
+
`'lucid.db'` is a string, so it cannot be duplicated: whichever copy boots registers the alias, and
|
|
27
|
+
any copy resolves it. The library no longer depends on the host app's dependency tree being
|
|
28
|
+
perfectly deduplicated. Both `stores.lucid()` and `uploadSessions.lucid()` are fixed, and a
|
|
29
|
+
regression test asserts on the resolved _token_ rather than the returned store — asserting on the
|
|
30
|
+
store would pass with either implementation and let the hazard back in silently.
|
|
31
|
+
|
|
32
|
+
No API change: both factories already received the application in their context.
|
|
33
|
+
|
|
3
34
|
## 0.8.0
|
|
4
35
|
|
|
5
36
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/stores/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,kBAAkB,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtE,gDAAgD;AAChD,MAAM,WAAW,gBAAgB;IAC/B,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM;IACjB,uFAAuF;cAC7E,YAAY;IAOtB,0DAA0D;mBAC5C,gBAAgB,GAAQ,YAAY;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/stores/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,kBAAkB,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtE,gDAAgD;AAChD,MAAM,WAAW,gBAAgB;IAC/B,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM;IACjB,uFAAuF;cAC7E,YAAY;IAOtB,0DAA0D;mBAC5C,gBAAgB,GAAQ,YAAY;CAuBnD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;CAAE,EACjE,GAAG,EAAE,YAAY,GAChB,OAAO,CAAC,UAAU,CAAC,CASrB"}
|
|
@@ -27,8 +27,21 @@ export const stores = {
|
|
|
27
27
|
},
|
|
28
28
|
/** Persist media records in SQL via `@adonisjs/lucid`. */
|
|
29
29
|
lucid(config = {}) {
|
|
30
|
-
return async () => {
|
|
31
|
-
|
|
30
|
+
return async (ctx) => {
|
|
31
|
+
// Resolve the Lucid `Database` by its STRING alias, never by importing
|
|
32
|
+
// `@adonisjs/lucid/services/db` (which resolves the `Database` CLASS and calls
|
|
33
|
+
// `container.make(Database)` with it). Lucid's provider keys its binding on the class object
|
|
34
|
+
// — `container.singleton(Database, ...)` — so a class token only matches when the consumer
|
|
35
|
+
// and the booting provider loaded the SAME physical copy of the package. In a workspace
|
|
36
|
+
// where two copies coexist (different version pins, or the same version resolved under
|
|
37
|
+
// different peer sets, which pnpm materializes as separate directories), the tokens differ,
|
|
38
|
+
// the binding is not found, and the container tries to CONSTRUCT `Database` — which has no
|
|
39
|
+
// `@inject()` — failing with `Cannot construct "[class Database]" class`.
|
|
40
|
+
//
|
|
41
|
+
// `'lucid.db'` is a string, so it cannot be duplicated: whichever copy boots registers the
|
|
42
|
+
// alias, and any copy resolves it. This makes the media library immune to the dual-package
|
|
43
|
+
// hazard instead of depending on the host app's dependency tree being perfectly deduplicated.
|
|
44
|
+
const db = await ctx.app.container.make('lucid.db');
|
|
32
45
|
const { LucidMediaStore } = await import('./lucid.js');
|
|
33
46
|
return new LucidMediaStore(db, {
|
|
34
47
|
...(config.connection !== undefined ? { connectionName: config.connection } : {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/stores/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AA2BvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,uFAAuF;IACvF,MAAM;QACJ,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,qCAAqC,CAAC,CAAC;YACnF,OAAO,IAAI,kBAAkB,EAAE,CAAC;QAClC,CAAC,CAAC;IACJ,CAAC;IAED,0DAA0D;IAC1D,KAAK,CAAC,SAA2B,EAAE;QACjC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/stores/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AA2BvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,uFAAuF;IACvF,MAAM;QACJ,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,EAAE,kBAAkB,EAAE,GAAG,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,CAAC,CAAC;QACtD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IACD,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,qCAAqC,CAAC,CAAC;IACnF,OAAO,IAAI,kBAAkB,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/upload_sessions/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,kBAAkB,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,GAAG,EAAE,yBAAyB,KAC3B,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEjC,4DAA4D;AAC5D,MAAM,WAAW,6BAA6B;IAC5C,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc;IACzB,+FAA+F;cACrF,yBAAyB;IASnC,+DAA+D;mBACjD,6BAA6B,GAAQ,yBAAyB;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/upload_sessions/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,kBAAkB,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,GAAG,EAAE,yBAAyB,KAC3B,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEjC,4DAA4D;AAC5D,MAAM,WAAW,6BAA6B;IAC5C,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc;IACzB,+FAA+F;cACrF,yBAAyB;IASnC,+DAA+D;mBACjD,6BAA6B,GAAQ,yBAAyB;CAe7E,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAA;CAAE,EAC9E,GAAG,EAAE,yBAAyB,GAC7B,OAAO,CAAC,kBAAkB,CAAC,CAW7B"}
|
|
@@ -29,8 +29,12 @@ export const uploadSessions = {
|
|
|
29
29
|
},
|
|
30
30
|
/** Persist resumable sessions in SQL via `@adonisjs/lucid`. */
|
|
31
31
|
lucid(config = {}) {
|
|
32
|
-
return async () => {
|
|
33
|
-
|
|
32
|
+
return async (ctx) => {
|
|
33
|
+
// Resolve by the STRING alias rather than importing `@adonisjs/lucid/services/db`, which
|
|
34
|
+
// resolves the `Database` CLASS and makes it the container token. See the equivalent comment
|
|
35
|
+
// in `../stores/factory.ts` for why a class token breaks when two copies of `@adonisjs/lucid`
|
|
36
|
+
// coexist in the host app's tree.
|
|
37
|
+
const db = await ctx.app.container.make('lucid.db');
|
|
34
38
|
const { LucidUploadSessionStore } = await import('./lucid.js');
|
|
35
39
|
return new LucidUploadSessionStore(db, {
|
|
36
40
|
...(config.connection !== undefined ? { connectionName: config.connection } : {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/upload_sessions/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oCAAoC,EAAE,MAAM,cAAc,CAAC;AA+BpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,+FAA+F;IAC/F,MAAM;QACJ,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,EAAE,0BAA0B,EAAE,GAAG,MAAM,MAAM,CACjD,8CAA8C,CAC/C,CAAC;YACF,OAAO,IAAI,0BAA0B,EAAE,CAAC;QAC1C,CAAC,CAAC;IACJ,CAAC;IAED,+DAA+D;IAC/D,KAAK,CAAC,SAAwC,EAAE;QAC9C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/upload_sessions/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oCAAoC,EAAE,MAAM,cAAc,CAAC;AA+BpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,+FAA+F;IAC/F,MAAM;QACJ,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,EAAE,0BAA0B,EAAE,GAAG,MAAM,MAAM,CACjD,8CAA8C,CAC/C,CAAC;YACF,OAAO,IAAI,0BAA0B,EAAE,CAAC;QAC1C,CAAC,CAAC;IACJ,CAAC;IAED,+DAA+D;IAC/D,KAAK,CAAC,SAAwC,EAAE;QAC9C,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE;YACnB,yFAAyF;YACzF,6FAA6F;YAC7F,8FAA8F;YAC9F,kCAAkC;YAClC,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACpD,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;YAC/D,OAAO,IAAI,uBAAuB,CAAC,EAAE,EAAE;gBACrC,GAAG,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjF,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC9D,GAAG,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9E,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAA8E,EAC9E,GAA8B;IAE9B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC;IAC1B,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,oCAAoC,CAAC,IAAI,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IACD,MAAM,EAAE,0BAA0B,EAAE,GAAG,MAAM,MAAM,CACjD,8CAA8C,CAC/C,CAAC;IACF,OAAO,IAAI,0BAA0B,EAAE,CAAC;AAC1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/media",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Media-library for AdonisJS — owner collections (MIME whitelist, single-file replace, ordering), image conversions (eager/lazy), and column attachments, all on top of @adonisjs/drive. Pluggable MediaStore (in-memory + Lucid) and ImageProcessor (sharp). Part of the Agora ecosystem.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|