@prisma-next/mongo-contract 0.13.0-dev.34 → 0.13.0-dev.35

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,10 +1,12 @@
1
1
  import {
2
2
  freezeNode,
3
+ hydrateNamespaceEntities,
3
4
  NamespaceBase,
4
5
  UNBOUND_NAMESPACE_ID,
5
6
  } from '@prisma-next/framework-components/ir';
6
7
  import { blindCast } from '@prisma-next/utils/casts';
7
- import { MongoCollection, type MongoCollectionInput } from './mongo-collection';
8
+ import { composeMongoEntityKinds } from '../entity-kinds';
9
+ import type { MongoCollection } from './mongo-collection';
8
10
  import type {
9
11
  MongoNamespace,
10
12
  MongoNamespaceCollectionsInput,
@@ -34,26 +36,16 @@ class MongoBoundNamespace extends NamespaceBase {
34
36
  super();
35
37
  this.id = input.id;
36
38
 
37
- const carried: Record<string, Readonly<Record<string, unknown>>> = {};
38
- let collection: Readonly<Record<string, MongoCollection>> = Object.freeze({});
39
- for (const [kind, rawMap] of Object.entries(input.entries)) {
40
- if (kind === 'collection') {
41
- const collectionMap: Record<string, MongoCollection> = {};
42
- for (const [name, c] of Object.entries(
43
- blindCast<
44
- Record<string, MongoCollectionInput>,
45
- 'entries[collection] holds MongoCollectionInput by construction'
46
- >(rawMap),
47
- )) {
48
- collectionMap[name] = new MongoCollection(c);
49
- }
50
- collection = Object.freeze(collectionMap);
51
- } else {
52
- carried[kind] = Object.freeze(rawMap);
53
- }
54
- }
55
-
56
- this.entries = Object.freeze({ ...carried, collection });
39
+ const rawEntries: Record<string, Readonly<Record<string, unknown>>> = {
40
+ collection: {},
41
+ ...input.entries,
42
+ };
43
+ this.entries = Object.freeze(
44
+ blindCast<
45
+ MongoNamespaceEntries,
46
+ 'composeMongoEntityKinds() supplies the collection→MongoCollection descriptor, so this open-dict result holds the typed collection member MongoNamespaceEntries declares; the descriptor Map erases that per-kind Node type from the return.'
47
+ >(hydrateNamespaceEntities(rawEntries, composeMongoEntityKinds(), 'carry')),
48
+ );
57
49
  Object.defineProperty(this, 'kind', {
58
50
  value: MONGO_NAMESPACE_KIND,
59
51
  writable: false,