@gramio/composer 0.1.0 → 0.1.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/dist/index.cjs +11 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -311,15 +311,23 @@ class Composer {
|
|
|
311
311
|
if (this["~"].extended.has(key)) return this;
|
|
312
312
|
this["~"].extended.add(key);
|
|
313
313
|
}
|
|
314
|
+
const alreadyExtended = new Set(this["~"].extended);
|
|
314
315
|
for (const key of other["~"].extended) {
|
|
315
316
|
this["~"].extended.add(key);
|
|
316
317
|
}
|
|
317
318
|
Object.assign(this["~"].errorsDefinitions, other["~"].errorsDefinitions);
|
|
318
319
|
this["~"].onErrors.push(...other["~"].onErrors);
|
|
319
320
|
const pluginName = other["~"].name;
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
const isNew = (m) => {
|
|
322
|
+
if (!m.plugin) return true;
|
|
323
|
+
for (const key of alreadyExtended) {
|
|
324
|
+
if (key.startsWith(m.plugin + ":")) return false;
|
|
325
|
+
}
|
|
326
|
+
return true;
|
|
327
|
+
};
|
|
328
|
+
const localMws = other["~"].middlewares.filter((m) => m.scope === "local" && isNew(m));
|
|
329
|
+
const scopedMws = other["~"].middlewares.filter((m) => m.scope === "scoped" && isNew(m));
|
|
330
|
+
const globalMws = other["~"].middlewares.filter((m) => m.scope === "global" && isNew(m));
|
|
323
331
|
if (localMws.length > 0) {
|
|
324
332
|
const chain = compose(localMws.map((m) => m.fn));
|
|
325
333
|
const isolated = async (ctx, next) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -15,7 +15,7 @@ type DeriveHandler<T, D> = (context: T) => D | Promise<D>;
|
|
|
15
15
|
/** Lazy middleware factory — called per invocation */
|
|
16
16
|
type LazyFactory<T> = (context: T) => Middleware<T> | Promise<Middleware<T>>;
|
|
17
17
|
/** Single value or array */
|
|
18
|
-
type MaybeArray<T> = T | T[];
|
|
18
|
+
type MaybeArray<T> = T | readonly T[];
|
|
19
19
|
/** Scope level for middleware propagation */
|
|
20
20
|
type Scope = "local" | "scoped" | "global";
|
|
21
21
|
/** Which method created a middleware entry */
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ type DeriveHandler<T, D> = (context: T) => D | Promise<D>;
|
|
|
15
15
|
/** Lazy middleware factory — called per invocation */
|
|
16
16
|
type LazyFactory<T> = (context: T) => Middleware<T> | Promise<Middleware<T>>;
|
|
17
17
|
/** Single value or array */
|
|
18
|
-
type MaybeArray<T> = T | T[];
|
|
18
|
+
type MaybeArray<T> = T | readonly T[];
|
|
19
19
|
/** Scope level for middleware propagation */
|
|
20
20
|
type Scope = "local" | "scoped" | "global";
|
|
21
21
|
/** Which method created a middleware entry */
|
package/dist/index.js
CHANGED
|
@@ -308,15 +308,23 @@ class Composer {
|
|
|
308
308
|
if (this["~"].extended.has(key)) return this;
|
|
309
309
|
this["~"].extended.add(key);
|
|
310
310
|
}
|
|
311
|
+
const alreadyExtended = new Set(this["~"].extended);
|
|
311
312
|
for (const key of other["~"].extended) {
|
|
312
313
|
this["~"].extended.add(key);
|
|
313
314
|
}
|
|
314
315
|
Object.assign(this["~"].errorsDefinitions, other["~"].errorsDefinitions);
|
|
315
316
|
this["~"].onErrors.push(...other["~"].onErrors);
|
|
316
317
|
const pluginName = other["~"].name;
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
const isNew = (m) => {
|
|
319
|
+
if (!m.plugin) return true;
|
|
320
|
+
for (const key of alreadyExtended) {
|
|
321
|
+
if (key.startsWith(m.plugin + ":")) return false;
|
|
322
|
+
}
|
|
323
|
+
return true;
|
|
324
|
+
};
|
|
325
|
+
const localMws = other["~"].middlewares.filter((m) => m.scope === "local" && isNew(m));
|
|
326
|
+
const scopedMws = other["~"].middlewares.filter((m) => m.scope === "scoped" && isNew(m));
|
|
327
|
+
const globalMws = other["~"].middlewares.filter((m) => m.scope === "global" && isNew(m));
|
|
320
328
|
if (localMws.length > 0) {
|
|
321
329
|
const chain = compose(localMws.map((m) => m.fn));
|
|
322
330
|
const isolated = async (ctx, next) => {
|