@anteros/core 0.0.2-alpha.0 → 0.0.2-alpha.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.
Files changed (2) hide show
  1. package/database/file.ts +21 -7
  2. package/package.json +1 -1
package/database/file.ts CHANGED
@@ -10,13 +10,11 @@ async function syncFileCollections() {
10
10
  const fileCollections: FileCollection[] = []
11
11
  for (let tenant of cfg.tenants ?? []) {
12
12
  const TENANT_PATH = path.join(process.cwd(), tenant.dir)
13
- const FILES_PATH = path.join(TENANT_PATH, 'files')
14
- let exist = await fs.exists(FILES_PATH)
15
- if (!exist) continue;
16
- const isDirectory = await (await fs.stat(FILES_PATH)).isDirectory()
17
13
 
18
- if (isDirectory) {
19
- // Charger les fichiers *.file.ts
14
+ // Scan files/ directory
15
+ const FILES_PATH = path.join(TENANT_PATH, 'files')
16
+ const filesExist = await fs.exists(FILES_PATH).catch(() => false)
17
+ if (filesExist && (await fs.stat(FILES_PATH)).isDirectory()) {
20
18
  const globFiles = new Glob(path.join(FILES_PATH, '**/*.file.ts'))
21
19
  for await (let file of globFiles.scan('.')) {
22
20
  let fileModule = await import(file)
@@ -28,7 +26,7 @@ async function syncFileCollections() {
28
26
  }
29
27
  }
30
28
 
31
- // Charger aussi les fichiers *.model.ts avec _isFileCollection_
29
+ // Also scan *.model.ts in files/ with _isFileCollection_
32
30
  const globModels = new Glob(path.join(FILES_PATH, '**/*.model.ts'))
33
31
  for await (let file of globModels.scan('.')) {
34
32
  let fileModule = await import(file)
@@ -40,6 +38,22 @@ async function syncFileCollections() {
40
38
  }
41
39
  }
42
40
  }
41
+
42
+ // Also scan collections/ directory for *.file.ts
43
+ const COLLECTIONS_PATH = path.join(TENANT_PATH, 'collections')
44
+ const collectionsExist = await fs.exists(COLLECTIONS_PATH).catch(() => false)
45
+ if (collectionsExist && (await fs.stat(COLLECTIONS_PATH)).isDirectory()) {
46
+ const globFiles = new Glob(path.join(COLLECTIONS_PATH, '**/*.file.ts'))
47
+ for await (let file of globFiles.scan('.')) {
48
+ let fileModule = await import(file)
49
+ if (fileModule?.default?._isFileCollection_) {
50
+ fileCollections.push({
51
+ ...fileModule?.default,
52
+ _tenant_: tenant.id
53
+ })
54
+ }
55
+ }
56
+ }
43
57
  }
44
58
 
45
59
  cfg.fileCollections = fileCollections
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@anteros/core",
3
3
  "module": "index.ts",
4
- "version": "0.0.2-alpha.0",
4
+ "version": "0.0.2-alpha.1",
5
5
  "type": "module",
6
6
  "description": "Anteros Core",
7
7
  "private": false,