@luckystack/server 0.8.1 → 0.8.2

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.
@@ -22,7 +22,7 @@ Preset list resolution (in `resolvePresets`):
22
22
  3. `getParsedBundles()` from `argv.ts` when non-empty.
23
23
  4. Final fallback: `['default']`.
24
24
 
25
- Multiple presets are loaded in parallel, normalized to `{ apisObject, syncObject, functionsObject }`, then shallow-merged into a single view. Key collisions across presets throw at boot — services must own exactly one preset (see `docs/ARCHITECTURE_PACKAGING.md` §10).
25
+ Multiple presets are loaded in parallel, normalized to `{ apisObject, syncObject, functionsObject }`, then shallow-merged into a single view. API/sync key collisions throw at boot — services must own exactly one preset (see `docs/ARCHITECTURE_PACKAGING.md` §10). Because phase-1 generation intentionally repeats the complete function registry in every preset, equivalent function entries deduplicate; a repeated function key with different exports still throws.
26
26
 
27
27
  ## API Reference
28
28
 
@@ -66,14 +66,14 @@ interface RuntimeMapsProvider {
66
66
  1. Resolve presets via `resolvePresets(options)`.
67
67
  2. Concurrently `loadGenerated(preset)` for each preset; failures resolve to `null` (caught with `.catch(() => null)`).
68
68
  3. For each loaded module, run `normalizeGeneratedModule` (defends against missing or malformed export shape: anything other than an object becomes `{}`).
69
- 4. Merge `apis`, `syncs`, `functions` into the combined view with `mergeInto`, tracking origin per key in three `Map<string, string>`s.
69
+ 4. Merge `apis`, `syncs`, `functions` into the combined view with `mergeInto`, tracking origin per key in three `Map<string, string>`s. Equivalent repeated function entries are retained once.
70
70
  5. Skipped presets emit `console.warn('[luckystack:runtimeMaps] preset "<name>" failed to load — skipping. ...')`.
71
71
  6. If no presets loaded successfully, emit `console.warn('[luckystack:runtimeMaps] no presets resolved (tried: ...). Every api/sync request will return notFound until at least one generated module loads.')` and return empty maps.
72
72
  - The dev branch caches the devkit module promise so repeated calls share one resolved module.
73
73
 
74
74
  **Errors / Edge cases:**
75
75
 
76
- - Key collision across presets throws synchronously inside `loadProdRuntimeMaps`:
76
+ - API/sync collisions, and repeated function keys whose exported values differ, throw synchronously inside `loadProdRuntimeMaps`:
77
77
 
78
78
  ```
79
79
  [luckystack:runtimeMaps] <kind> key collision: "<key>" present in both preset "<previous>" and preset "<current>". Services must belong to exactly one preset (see docs/ARCHITECTURE_PACKAGING.md §10).
@@ -164,10 +164,11 @@ This matches what `scripts/generateServerRequests.ts` emits. Missing exports def
164
164
  `mergeInto(target, source, kind, fromPreset, keyOrigin)`:
165
165
 
166
166
  - Iterate every key in `source`.
167
- - If `keyOrigin` already records a different preset for that key -> throw the collision error.
167
+ - If an API or sync key already belongs to a different preset -> throw the collision error.
168
+ - If a function key already exists, compare both wrapper records: they must expose the same keys and every exported value must be identical through `Object.is`. Equivalent entries are skipped; different implementations throw.
168
169
  - Otherwise record the origin and shallow-assign `target[key] = source[key]`.
169
170
 
170
- Three independent origin maps are used so an api named `users/get` and a sync named `users/get` do not collide.
171
+ Three independent origin maps are used so an api named `users/get` and a sync named `users/get` do not collide. ADR 0042 governs the shared-function exception.
171
172
 
172
173
  ## Failure modes
173
174
 
@@ -176,7 +177,9 @@ Three independent origin maps are used so an api named `users/get` and a sync na
176
177
  | `loadGenerated(preset)` rejects | Warn (`preset "<name>" failed to load — skipping`); continue with other presets. |
177
178
  | All presets failed | Warn (`no presets resolved (tried: ...)`); return empty maps; every request returns `notFound`. |
178
179
  | Preset module has wrong shape | Normalize to `{}`. Same effect: requests for those routes return `notFound`. |
179
- | Key collision across presets | Throw at boot — services must own exactly one preset. |
180
+ | API/sync key collision across presets | Throw at boot — services must own exactly one preset. |
181
+ | Equivalent repeated function entry | Deduplicate — phase-1 scoped builds intentionally carry the complete registry. |
182
+ | Repeated function key with different exports | Throw at boot — generated artifacts disagree. |
180
183
  | Provider is never registered at all | `verifyBootstrap` hard-fails in production, loud-warns in dev. |
181
184
 
182
185
  ## Dev vs prod branch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luckystack/server",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -57,19 +57,19 @@
57
57
  "test": "vitest run"
58
58
  },
59
59
  "dependencies": {
60
- "@luckystack/api": "^0.8.1",
61
- "@luckystack/core": "^0.8.1"
60
+ "@luckystack/api": "^0.8.2",
61
+ "@luckystack/core": "^0.8.2"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@prisma/client": "^6.19.0",
65
65
  "socket.io": "^4.8.0",
66
- "@luckystack/devkit": "^0.8.1",
67
- "@luckystack/docs-ui": "^0.8.1",
68
- "@luckystack/email": "^0.8.1",
69
- "@luckystack/error-tracking": "^0.8.1",
70
- "@luckystack/login": "^0.8.1",
71
- "@luckystack/presence": "^0.8.1",
72
- "@luckystack/sync": "^0.8.1"
66
+ "@luckystack/devkit": "^0.8.2",
67
+ "@luckystack/docs-ui": "^0.8.2",
68
+ "@luckystack/email": "^0.8.2",
69
+ "@luckystack/error-tracking": "^0.8.2",
70
+ "@luckystack/login": "^0.8.2",
71
+ "@luckystack/presence": "^0.8.2",
72
+ "@luckystack/sync": "^0.8.2"
73
73
  },
74
74
  "peerDependenciesMeta": {
75
75
  "@prisma/client": {