@mostajs/payment 0.4.0 → 0.4.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.
@@ -1,4 +1,4 @@
1
- import type { IDialect } from '@mostajs/orm';
1
+ import type { IDialect } from '@mostajs/data-plug';
2
2
  /**
3
3
  * Create payment CRUD handlers (Next.js App Router).
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"payments.route.d.ts","sourceRoot":"","sources":["../../src/api/payments.route.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI5C;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,QAAQ;eAG/B,OAAO,CAAC,QAAQ,CAAC;gBASd,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;EAWrD"}
1
+ {"version":3,"file":"payments.route.d.ts","sourceRoot":"","sources":["../../src/api/payments.route.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAIlD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,QAAQ;eAG/B,OAAO,CAAC,QAAQ,CAAC;gBASd,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;EAWrD"}
@@ -1,4 +1,4 @@
1
- import type { EntitySchema } from '@mostajs/orm';
1
+ import type { EntitySchema } from '@mostajs/data-plug';
2
2
  export declare function getSchemas(): EntitySchema[];
3
3
  export declare const moduleInfo: {
4
4
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"module-info.d.ts","sourceRoot":"","sources":["../../src/lib/module-info.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD,wBAAgB,UAAU,IAAI,YAAY,EAAE,CAE3C;AAED,eAAO,MAAM,UAAU;;;;;;CAMtB,CAAA"}
1
+ {"version":3,"file":"module-info.d.ts","sourceRoot":"","sources":["../../src/lib/module-info.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,wBAAgB,UAAU,IAAI,YAAY,EAAE,CAE3C;AAED,eAAO,MAAM,UAAU;;;;;;CAMtB,CAAA"}
@@ -1,12 +1,15 @@
1
- import { BaseRepository } from '@mostajs/orm';
2
- import type { IDialect } from '@mostajs/orm';
1
+ import { BaseRepository } from '@mostajs/data-plug';
2
+ import type { IDialect } from '@mostajs/data-plug';
3
3
  import type { PaymentDTO } from '../types/index.js';
4
4
  /**
5
- * Get or create the Payment repository.
5
+ * Get or create the Payment repository for a given dialect.
6
+ * Cache keyed par identité du dialect (WeakMap) — auto-reconstruction sur
7
+ * changement de dialect.
6
8
  */
7
9
  export declare function getPaymentRepo(dialect: IDialect): BaseRepository<PaymentDTO>;
8
10
  /**
9
- * Reset cache (for testing or dialect change).
11
+ * No-op préservé pour rétro-compat la WeakMap libère naturellement les
12
+ * entrées dont le dialect n'est plus référencé.
10
13
  */
11
14
  export declare function resetPaymentRepo(): void;
12
15
  //# sourceMappingURL=payment-factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment-factory.d.ts","sourceRoot":"","sources":["../../src/lib/payment-factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAKnD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAK5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
1
+ {"version":3,"file":"payment-factory.d.ts","sourceRoot":"","sources":["../../src/lib/payment-factory.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAKnD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAO5E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
@@ -1,21 +1,33 @@
1
1
  // @mostajs/payment — Payment repository factory
2
2
  // Author: Dr Hamid MADANI drmdh@msn.com
3
- import { BaseRepository } from '@mostajs/orm';
3
+ //
4
+ // Cache keyed par identité du dialect (WeakMap) — un changement de dialect
5
+ // (ex: /api/change-dialect côté serveur, ou rotation système↔métier) produit
6
+ // un cache miss et une reconstruction. Évite le bug où le repo capturait
7
+ // la référence du PREMIER dialect passé et ignorait tous les suivants — ce
8
+ // qui conduisait à "PostgreSQL not connected. Call connect() first." après
9
+ // disconnect d'une connexion qui restait quand même cached dans le repo.
10
+ import { BaseRepository } from '@mostajs/data-plug';
4
11
  import { PaymentSchema } from '../schemas/payment.schema.js';
5
- let cachedRepo = null;
12
+ const cache = new WeakMap();
6
13
  /**
7
- * Get or create the Payment repository.
14
+ * Get or create the Payment repository for a given dialect.
15
+ * Cache keyed par identité du dialect (WeakMap) — auto-reconstruction sur
16
+ * changement de dialect.
8
17
  */
9
18
  export function getPaymentRepo(dialect) {
10
- if (!cachedRepo) {
11
- cachedRepo = new BaseRepository(PaymentSchema, dialect);
19
+ let r = cache.get(dialect);
20
+ if (!r) {
21
+ r = new BaseRepository(PaymentSchema, dialect);
22
+ cache.set(dialect, r);
12
23
  }
13
- return cachedRepo;
24
+ return r;
14
25
  }
15
26
  /**
16
- * Reset cache (for testing or dialect change).
27
+ * No-op préservé pour rétro-compat la WeakMap libère naturellement les
28
+ * entrées dont le dialect n'est plus référencé.
17
29
  */
18
30
  export function resetPaymentRepo() {
19
- cachedRepo = null;
31
+ // Auto-cleanup via WeakMap : intentional no-op.
20
32
  }
21
33
  //# sourceMappingURL=payment-factory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment-factory.js","sourceRoot":"","sources":["../../src/lib/payment-factory.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,wCAAwC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE5D,IAAI,UAAU,GAAsC,IAAI,CAAA;AAExD;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAiB;IAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,UAAU,GAAG,IAAI,cAAc,CAAa,aAAa,EAAE,OAAO,CAAC,CAAA;IACrE,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,UAAU,GAAG,IAAI,CAAA;AACnB,CAAC"}
1
+ {"version":3,"file":"payment-factory.js","sourceRoot":"","sources":["../../src/lib/payment-factory.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,wCAAwC;AACxC,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,yEAAyE;AACzE,2EAA2E;AAC3E,2EAA2E;AAC3E,yEAAyE;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE5D,MAAM,KAAK,GAAG,IAAI,OAAO,EAAwC,CAAA;AAEjE;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAiB;IAC9C,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,CAAC,GAAG,IAAI,cAAc,CAAa,aAAa,EAAE,OAAO,CAAC,CAAA;QAC1D,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IACvB,CAAC;IACD,OAAO,CAAC,CAAA;AACV,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,gDAAgD;AAClD,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { EntitySchema } from '@mostajs/orm';
1
+ import type { EntitySchema } from '@mostajs/data-plug';
2
2
  /**
3
3
  * Create a Payment schema with configurable options.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"payment.schema.d.ts","sourceRoot":"","sources":["../../src/schemas/payment.schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,GAAG,YAAY,CAqDf;AAED,yDAAyD;AACzD,eAAO,MAAM,aAAa,cAAwB,CAAA"}
1
+ {"version":3,"file":"payment.schema.d.ts","sourceRoot":"","sources":["../../src/schemas/payment.schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,GAAG,YAAY,CAqDf;AAED,yDAAyD;AACzD,eAAO,MAAM,aAAa,cAAwB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostajs/payment",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Payment module for @mostajs — Multi-provider (Stripe, Satim/CIB, Chargily, PayPal), multi-method, multi-currency",
5
5
  "author": "Dr Hamid MADANI <drmdh@msn.com>",
6
6
  "license": "AGPL-3.0-or-later",
@@ -34,7 +34,7 @@
34
34
  "stripe": "^17.0.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@mostajs/orm": ">=1.8.0",
37
+ "@mostajs/data-plug": "^1.2.4",
38
38
  "next": ">=14.0.0",
39
39
  "react": ">=18.0.0"
40
40
  },
@@ -47,6 +47,7 @@
47
47
  }
48
48
  },
49
49
  "devDependencies": {
50
+ "@mostajs/data-plug": "^1.2.4",
50
51
  "@mostajs/orm": "^1.8.0",
51
52
  "@types/node": "^22.0.0",
52
53
  "@types/react": "^19.0.0",