@sincpro/client-framework 2.7.0 → 2.8.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.
@@ -15,7 +15,13 @@
15
15
  * | components | composer, a router |
16
16
  * | common | any bounded context |
17
17
  * | any layer | another bounded context — but its `index.ts`, from `infrastructure/` |
18
- * | entrypoints/ root | a bounded context's insides — only its `index.ts` (and `common`) |
18
+ * | entrypoints/ root | a bounded context's insides — only its doors (and `common`) |
19
+ * | entrypoints/<face>| another face's door: `index.ts` or its own (`sales/admin.ts`) |
20
+ *
21
+ * A context's doors are the files in its root: `index.ts` — the bounded context itself — and one
22
+ * per face of the application (`admin.ts`, `sitio.ts`, `portal.ts`) that exports what that face
23
+ * draws of it. A face enters by its own door, so another face's screens never reach its bundle:
24
+ * the public site does not load the back office's.
19
25
  *
20
26
  * Context: the architecture says these rules are enforced, not recommended; a rule only read in a
21
27
  * page is the first to go under a deadline. Each import is resolved the way the application's
@@ -36,15 +42,16 @@ export type Place = {
36
42
  context: string;
37
43
  layer: string | null;
38
44
  index: boolean;
39
- } | {
45
+ /** A file in the context's root is one of its doors: `index`, or a face's (`admin`). */
46
+ door: string | null;
47
+ }
48
+ /** An entrypoint, and the face of the application it belongs to (`entrypoints/admin/…`). */
49
+ | {
40
50
  kind: "entrypoint";
51
+ face: string | null;
41
52
  } | {
42
53
  kind: "other";
43
54
  };
44
- /**
45
- * `domains/sales/services/close.ts` → the bounded context `sales`, the layer `services` — wherever
46
- * the `domains/` folder is (`src/domains/…`, a workspace's `domains/sales/src/services/…`).
47
- */
48
55
  export declare function placeOf(path: string): Place;
49
56
  /**
50
57
  * Why `from` may not import `specifier`, which resolves to `to` (`null`: a package), or nothing
@@ -13,11 +13,16 @@ const LAYERS = new Set([
13
13
  * `domains/sales/services/close.ts` → the bounded context `sales`, the layer `services` — wherever
14
14
  * the `domains/` folder is (`src/domains/…`, a workspace's `domains/sales/src/services/…`).
15
15
  */
16
+ /** What a source file ends in — the checker reads every one, and names a door by what is before. */
17
+ const SOURCE = /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/;
16
18
  export function placeOf(path) {
17
19
  const parts = path.split(/[\\/]/).filter((one) => one !== "");
18
20
  const start = parts[0] === "src" ? 1 : 0;
19
21
  if (parts[start] === "entrypoints")
20
- return { kind: "entrypoint" };
22
+ return {
23
+ kind: "entrypoint",
24
+ face: parts.length > start + 2 ? (parts[start + 1] ?? null) : null,
25
+ };
21
26
  const at = parts.indexOf("domains");
22
27
  const context = at === -1 ? undefined : parts[at + 1];
23
28
  if (context === undefined || parts.length < at + 3)
@@ -26,8 +31,9 @@ export function placeOf(path) {
26
31
  const rest = parts.slice(at + 2);
27
32
  const inside = rest[0] === "src" && rest.length > 1 ? rest.slice(1) : rest;
28
33
  const first = inside[0] ?? "";
29
- const index = inside.length === 1 && /^index\.(ts|tsx|js|jsx|mts)$/.test(first);
30
- return { kind: "context", context, layer: LAYERS.has(first) ? first : null, index };
34
+ const door = inside.length === 1 ? first.replace(SOURCE, "") : null;
35
+ const index = door === "index";
36
+ return { kind: "context", context, layer: LAYERS.has(first) ? first : null, index, door };
31
37
  }
32
38
  const REACT = /^(react|react-dom|react-native)(\/|$)/;
33
39
  const DRAWING = /^@sincpro\/(web-ui|web-composer)(\/|$)/;
@@ -66,11 +72,24 @@ export function violationOf(from, specifier, to) {
66
72
  : "nothing imports the application's entrypoints";
67
73
  if (to.kind !== "context")
68
74
  return undefined;
69
- // Outside the bounded contexts (the entrypoints, `main.tsx`, a `lib/`): only their index.ts.
70
- if (from.kind !== "context")
71
- return to.context === "common" || to.index
72
- ? undefined
73
- : `outside a bounded context, it is used through its index.ts, never its insides («${to.context}»)`;
75
+ // Outside the bounded contexts (the entrypoints, `main.tsx`, a `lib/`): only their doors — its
76
+ // index.ts, or the door of the face it belongs to (`sales/admin.ts` for `entrypoints/admin/`).
77
+ // Another face's door would bring that face's screens into this face's bundle.
78
+ if (from.kind !== "context") {
79
+ if (to.context === "common" || to.index)
80
+ return undefined;
81
+ if (to.door !== null) {
82
+ // A module that is neither a face nor a context (a helper, `main.tsx`) opens no face's door:
83
+ // a face that imported it would reach another face's screens through it.
84
+ if (from.kind !== "entrypoint")
85
+ return `a face's door (${to.door}) is opened only by the faces' entrypoints — a module outside them uses «${to.context}» through its index.ts`;
86
+ // The composition root (`entrypoints/app.tsx`, of no face) puts the faces together.
87
+ return from.face === null || to.door === from.face
88
+ ? undefined
89
+ : `the «${from.face}» face enters «${to.context}» by another face's door (${to.door}): by its index.ts or its ${from.face}.ts`;
90
+ }
91
+ return `outside a bounded context, it is used through its doors — its index.ts, or its face's — never its insides («${to.context}»)`;
92
+ }
74
93
  if (from.context === "common")
75
94
  return to.context === "common" ? undefined : "common never imports a bounded context";
76
95
  if (to.context === "common")
@@ -95,7 +114,7 @@ function sources(root) {
95
114
  const path = join(root, entry.name);
96
115
  if (entry.isDirectory())
97
116
  found.push(...sources(path));
98
- else if (/\.(ts|tsx|mts|cts|js|jsx)$/.test(entry.name) && !entry.name.endsWith(".d.ts"))
117
+ else if (SOURCE.test(entry.name) && !entry.name.endsWith(".d.ts"))
99
118
  found.push(path);
100
119
  }
101
120
  return found;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sincpro/client-framework",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "The client side of sincpro_framework, for every platform: Feature and ApplicationService traced and reported by default, applications made of domains, and the typed client generated from a service's contract. No React, no DOM.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",