@mostajs/aop-sources 0.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.
- package/README.md +5 -0
- package/llms.txt +7 -0
- package/package.json +23 -0
- package/src/aop-sources.js +24 -0
- package/src/default-sources.js +14 -0
- package/src/index.js +4 -0
- package/src/memory-repo.js +2 -0
- package/src/schemas.js +22 -0
package/README.md
ADDED
package/llms.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @mostajs/aop-sources — fiche LLM
|
|
2
|
+
> Référentiel ORM des sources d AO + seed idempotent.
|
|
3
|
+
|
|
4
|
+
## EXPORTS
|
|
5
|
+
TenderSourceSchema · DEFAULT_SOURCES · createSources({repositories:{tenderSources}}) · createMemoryRepositories()
|
|
6
|
+
API: list/get(code)/create/update/byCountry/byType/enabled/seed(sources?). Idempotent par `code`.
|
|
7
|
+
Stack mosta-aop-stack. ORM-first.
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mostajs/aop-sources",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Référentiel ORM des sources d'appels d'offres (BOAMP, PLACE, TED, BOMOP, ANEP…) + seed idempotent. Extrait d'AgoraScope.",
|
|
5
|
+
"author": "Dr Hamid MADANI <drmdh@msn.com>",
|
|
6
|
+
"license": "AGPL-3.0-or-later",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "src/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"README.md",
|
|
15
|
+
"llms.txt"
|
|
16
|
+
],
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@mostajs/mjs-unit": "^0.3.0"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "node test-scripts/unit/aop-sources.test.mjs && node examples/run.mjs"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @mostajs/aop-sources — référentiel des sources d'AO (ORM-first). @author Dr Hamid MADANI <drmdh@msn.com>
|
|
2
|
+
import { DEFAULT_SOURCES } from './default-sources.js';
|
|
3
|
+
export function createSources({ repositories } = {}) {
|
|
4
|
+
if (!repositories?.tenderSources) throw new Error('aop-sources: repositories.tenderSources requis (seam ORM)');
|
|
5
|
+
const repo = repositories.tenderSources;
|
|
6
|
+
return {
|
|
7
|
+
list: () => repo.list(),
|
|
8
|
+
get: (code) => repo.find((s) => s.code === code).then((r) => r[0] || null),
|
|
9
|
+
create: (data) => repo.create(data),
|
|
10
|
+
update: (id, patch) => repo.update(id, patch),
|
|
11
|
+
byCountry: (country) => repo.find((s) => s.country === country),
|
|
12
|
+
byType: (type) => repo.find((s) => s.type === type),
|
|
13
|
+
enabled: () => repo.find((s) => s.isActive && s.sync?.enabled),
|
|
14
|
+
/** Seed idempotent (par code) des sources prédéfinies. */
|
|
15
|
+
async seed(sources = DEFAULT_SOURCES) {
|
|
16
|
+
const out = [];
|
|
17
|
+
for (const s of sources) {
|
|
18
|
+
const ex = (await repo.find((x) => x.code === s.code))[0];
|
|
19
|
+
out.push(ex ? await repo.update(ex.id, s) : await repo.create(s));
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Sources prédéfinies (extrait de AgoraScope src/config/tender-sources.ts). @author Dr Hamid MADANI <drmdh@msn.com>
|
|
2
|
+
export const DEFAULT_SOURCES = [
|
|
3
|
+
{ code: 'boamp', name: 'Bulletin Officiel des Annonces des Marchés Publics', displayName: { fr: 'BOAMP', en: 'BOAMP (FR)', ar: 'BOAMP' },
|
|
4
|
+
type: 'official', country: 'FR', languages: ['fr'], isVerified: true,
|
|
5
|
+
connection: { baseUrl: 'https://www.boamp.fr', apiEndpoint: 'https://api.dila.fr/opendata/api-boamp/annonces', auth: { type: 'none' } } },
|
|
6
|
+
{ code: 'place', name: "Plateforme des Achats de l'État", displayName: { fr: 'PLACE', en: 'PLACE (FR)' },
|
|
7
|
+
type: 'official', country: 'FR', languages: ['fr'], connection: { baseUrl: 'https://www.marches-publics.gouv.fr', auth: { type: 'none' } } },
|
|
8
|
+
{ code: 'ted', name: 'Tenders Electronic Daily', displayName: { fr: 'TED (UE)', en: 'TED (EU)' },
|
|
9
|
+
type: 'official', country: 'EU', languages: ['fr', 'en'], connection: { baseUrl: 'https://ted.europa.eu', apiEndpoint: 'https://api.ted.europa.eu/v3', auth: { type: 'apikey' } } },
|
|
10
|
+
{ code: 'algeria-bomop', name: "BOMOP - Bulletin Officiel des Marchés de l'Opérateur Public", displayName: { fr: 'BOMOP (DZ)', ar: 'BOMOP' },
|
|
11
|
+
type: 'official', country: 'DZ', languages: ['fr', 'ar'], connection: { baseUrl: 'https://www.bomop.dz', auth: { type: 'none' } } },
|
|
12
|
+
{ code: 'algeria-anep', name: 'ANEP - Agence Nationale d\'Édition et de Publicité', displayName: { fr: 'ANEP (DZ)', ar: 'ANEP' },
|
|
13
|
+
type: 'official', country: 'DZ', languages: ['fr', 'ar'], connection: { baseUrl: 'https://www.anep.com.dz', auth: { type: 'none' } } },
|
|
14
|
+
];
|
package/src/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function coll(){const m=new Map();let s=0;return{create:async d=>{const id=String(++s),r={id,...d};m.set(id,r);return r;},get:async id=>m.get(id)||null,list:async()=>[...m.values()],find:async p=>[...m.values()].filter(p),update:async(id,patch)=>{const r=m.get(id);if(!r)return null;const u={...r,...patch};m.set(id,u);return u;}};}
|
|
2
|
+
export function createMemoryRepositories(){return{tenderSources:coll()};}
|
package/src/schemas.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @mostajs/aop-sources — schéma ORM des sources d'AO. Objets imbriqués → 'json'. @author Dr Hamid MADANI <drmdh@msn.com>
|
|
2
|
+
export const TenderSourceSchema = {
|
|
3
|
+
name: 'TenderSource', collection: 'tender_sources', timestamps: true,
|
|
4
|
+
fields: {
|
|
5
|
+
code: { type: 'string', required: true, unique: true },
|
|
6
|
+
name: { type: 'string', required: true },
|
|
7
|
+
displayName: { type: 'json', default: {} }, // i18n { fr, en, ar }
|
|
8
|
+
type: { type: 'string', enum: ['official', 'aggregator', 'custom', 'manual'], default: 'official' },
|
|
9
|
+
region: { type: 'string', default: null },
|
|
10
|
+
country: { type: 'string', default: null },
|
|
11
|
+
languages: { type: 'array', default: ['fr'] },
|
|
12
|
+
connection: { type: 'json', default: {} }, // { baseUrl, apiEndpoint?, searchUrl?, auth:{type} }
|
|
13
|
+
fieldMapping: { type: 'json', default: {} }, // champ source -> champ Tender
|
|
14
|
+
supportedFilters: { type: 'json', default: {} },
|
|
15
|
+
sync: { type: 'json', default: { enabled: false, frequency: 'daily', stats: {} } },
|
|
16
|
+
metadata: { type: 'json', default: {} }, // { documentation?, contactEmail?, license? }
|
|
17
|
+
isActive: { type: 'boolean', default: true },
|
|
18
|
+
isVerified: { type: 'boolean', default: false },
|
|
19
|
+
isBeta: { type: 'boolean', default: false },
|
|
20
|
+
},
|
|
21
|
+
indexes: [{ fields: { code: 'asc' }, unique: true }, { fields: { country: 'asc' } }, { fields: { type: 'asc' } }],
|
|
22
|
+
};
|