@owlmeans/mongo-resource 0.1.18-rc.9 → 0.1.18

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 (115) hide show
  1. package/README.md +232 -71
  2. package/agent-meta/manifest.json +3 -3
  3. package/agent-meta/skills/mongo-resource/SKILL.md +89 -44
  4. package/build/consts.d.ts +8 -4
  5. package/build/consts.d.ts.map +1 -1
  6. package/build/consts.js +8 -4
  7. package/build/consts.js.map +1 -1
  8. package/build/declarations/types.d.ts +12 -0
  9. package/build/declarations/types.d.ts.map +1 -0
  10. package/build/declarations/types.js +2 -0
  11. package/build/declarations/types.js.map +1 -0
  12. package/build/declarations.d.ts +4 -9
  13. package/build/declarations.d.ts.map +1 -1
  14. package/build/declarations.js +28 -21
  15. package/build/declarations.js.map +1 -1
  16. package/build/index.d.ts +4 -0
  17. package/build/index.d.ts.map +1 -1
  18. package/build/index.js +1 -0
  19. package/build/index.js.map +1 -1
  20. package/build/resource.d.ts +2 -2
  21. package/build/resource.d.ts.map +1 -1
  22. package/build/resource.js +100 -130
  23. package/build/resource.js.map +1 -1
  24. package/build/types.d.ts +11 -5
  25. package/build/types.d.ts.map +1 -1
  26. package/build/types.local.d.ts +4 -0
  27. package/build/types.local.d.ts.map +1 -0
  28. package/build/types.local.js +2 -0
  29. package/build/types.local.js.map +1 -0
  30. package/build/utils/consts.local.d.ts +25 -0
  31. package/build/utils/consts.local.d.ts.map +1 -0
  32. package/build/utils/consts.local.js +31 -0
  33. package/build/utils/consts.local.js.map +1 -0
  34. package/build/utils/criteria/types.d.ts +27 -0
  35. package/build/utils/criteria/types.d.ts.map +1 -0
  36. package/build/utils/criteria/types.js +2 -0
  37. package/build/utils/criteria/types.js.map +1 -0
  38. package/build/utils/criteria.d.ts +9 -0
  39. package/build/utils/criteria.d.ts.map +1 -0
  40. package/build/utils/criteria.js +204 -0
  41. package/build/utils/criteria.js.map +1 -0
  42. package/build/utils/index.d.ts +1 -0
  43. package/build/utils/index.d.ts.map +1 -1
  44. package/build/utils/index.js +1 -0
  45. package/build/utils/index.js.map +1 -1
  46. package/build/utils/indexes/types.d.ts +19 -0
  47. package/build/utils/indexes/types.d.ts.map +1 -0
  48. package/build/utils/indexes/types.js +2 -0
  49. package/build/utils/indexes/types.js.map +1 -0
  50. package/build/utils/indexes.d.ts +3 -4
  51. package/build/utils/indexes.d.ts.map +1 -1
  52. package/build/utils/indexes.js +44 -28
  53. package/build/utils/indexes.js.map +1 -1
  54. package/build/utils/life-cycle/types.d.ts +36 -0
  55. package/build/utils/life-cycle/types.d.ts.map +1 -0
  56. package/build/utils/life-cycle/types.js +2 -0
  57. package/build/utils/life-cycle/types.js.map +1 -0
  58. package/build/utils/life-cycle.d.ts +3 -30
  59. package/build/utils/life-cycle.d.ts.map +1 -1
  60. package/build/utils/life-cycle.js +96 -112
  61. package/build/utils/life-cycle.js.map +1 -1
  62. package/build/utils/migrations.d.ts.map +1 -1
  63. package/build/utils/migrations.js +1 -2
  64. package/build/utils/migrations.js.map +1 -1
  65. package/build/utils/name.d.ts.map +1 -1
  66. package/build/utils/name.js +1 -5
  67. package/build/utils/name.js.map +1 -1
  68. package/build/utils/refs/types.d.ts +78 -0
  69. package/build/utils/refs/types.d.ts.map +1 -0
  70. package/build/utils/refs/types.js +2 -0
  71. package/build/utils/refs/types.js.map +1 -0
  72. package/build/utils/refs.d.ts +13 -67
  73. package/build/utils/refs.d.ts.map +1 -1
  74. package/build/utils/refs.js +115 -158
  75. package/build/utils/refs.js.map +1 -1
  76. package/build/utils/schema/types.d.ts +16 -0
  77. package/build/utils/schema/types.d.ts.map +1 -0
  78. package/build/utils/schema/types.js +2 -0
  79. package/build/utils/schema/types.js.map +1 -0
  80. package/build/utils/schema.d.ts +3 -11
  81. package/build/utils/schema.d.ts.map +1 -1
  82. package/build/utils/schema.js +86 -88
  83. package/build/utils/schema.js.map +1 -1
  84. package/build/utils/types.local.d.ts +13 -0
  85. package/build/utils/types.local.d.ts.map +1 -0
  86. package/build/utils/types.local.js +2 -0
  87. package/build/utils/types.local.js.map +1 -0
  88. package/package.json +10 -9
  89. package/src/consts.ts +8 -4
  90. package/src/declarations/types.ts +12 -0
  91. package/src/declarations.ts +32 -28
  92. package/src/index.ts +4 -0
  93. package/src/resource.ts +121 -163
  94. package/src/types.local.ts +5 -0
  95. package/src/types.ts +13 -7
  96. package/src/utils/consts.local.ts +35 -0
  97. package/src/utils/criteria/types.ts +28 -0
  98. package/src/utils/criteria.ts +235 -0
  99. package/src/utils/index.ts +1 -0
  100. package/src/utils/indexes/types.ts +20 -0
  101. package/src/utils/indexes.ts +48 -28
  102. package/src/utils/life-cycle/types.ts +39 -0
  103. package/src/utils/life-cycle.ts +120 -134
  104. package/src/utils/migrations.ts +3 -17
  105. package/src/utils/name.ts +1 -6
  106. package/src/utils/refs/types.ts +79 -0
  107. package/src/utils/refs.ts +147 -189
  108. package/src/utils/schema/types.ts +17 -0
  109. package/src/utils/schema.ts +92 -91
  110. package/src/utils/types.local.ts +13 -0
  111. package/tests/context.ts +3 -3
  112. package/tests/criteria.spec.ts +116 -0
  113. package/tests/crud.spec.ts +2 -2
  114. package/tests/indexes.spec.ts +42 -0
  115. package/tests/refs.spec.ts +5 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/life-cycle/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,gEAAgE;AAChE,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,oBAAoB,EAAE,CACpB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,KACnF,OAAO,CAAC,UAAU,CAAC,CAAA;IACxB,yEAAyE;IACzE,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAChG,wFAAwF;IACxF,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;CACjG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/life-cycle/types.ts"],"names":[],"mappings":""}
@@ -1,31 +1,4 @@
1
- import type { DbConfig, ResourceRecord } from '@owlmeans/resource';
2
- import type { BasicContext } from '@owlmeans/context';
3
- import type { MongoResource } from '../types.js';
4
- import type { Db, Collection } from 'mongodb';
5
- /**
6
- * Bring a resource's collection to the shape its schema declares.
7
- *
8
- * Order is deliberate, and matches the Postgres counterpart:
9
- *
10
- * 1. probe for the collection
11
- * 2. absent → *baseline* every registered migration; present → run the `pre` ones
12
- * (including the system `$ref:` migrations that convert declared references)
13
- * 3. create the collection, or update its validator and indexes
14
- * 4. present → run the `post` migrations
15
- * 5. reconcile declared references — the second half of their double check: the ledger
16
- * said whether the `$ref:` migration ran, this probes the collection itself and
17
- * converts whatever strings still slipped through
18
- *
19
- * Step 2 is what stops the two mechanisms colliding. A `pre` migration runs before the
20
- * validator is tightened, so it can reshape documents the new validator would reject. On a
21
- * collection this call just created there is nothing to reshape — replaying a historical
22
- * migration against a collection born in its final shape would at best scan for nothing —
23
- * so the migrations are recorded as satisfied instead of run.
24
- *
25
- * `context` is optional so the existing three-argument call keeps working; without it a
26
- * migration's `use`/`ref` can only address the owning resource.
27
- */
28
- export declare const initializeCollection: (db: Db, config: DbConfig, resource: MongoResource<ResourceRecord>, context?: BasicContext<any>) => Promise<Collection>;
29
- export declare const createCollection: (db: Db, name: string, resource: MongoResource<ResourceRecord>) => Promise<Collection>;
30
- export declare const updateCollection: (db: Db, name: string, resource: MongoResource<ResourceRecord>) => Promise<Collection>;
1
+ import type { Db } from 'mongodb';
2
+ import type { MongoLifeCycleUtils } from './life-cycle/types.js';
3
+ export declare const makeMongoLifeCycleUtils: (db: Db) => MongoLifeCycleUtils;
31
4
  //# sourceMappingURL=life-cycle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"life-cycle.d.ts","sourceRoot":"","sources":["../../src/utils/life-cycle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAmB,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,EAAE,EAAE,UAAU,EAAgC,MAAM,SAAS,CAAA;AAS3E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,oBAAoB,OAC3B,EAAE,UAAU,QAAQ,YAAY,aAAa,CAAC,cAAc,CAAC,YACvD,YAAY,CAAC,GAAG,CAAC,KAC1B,OAAO,CAAC,UAAU,CAmBpB,CAAA;AA+DD,eAAO,MAAM,gBAAgB,OAAc,EAAE,QAAQ,MAAM,YAAY,aAAa,CAAC,cAAc,CAAC,KAAG,OAAO,CAAC,UAAU,CAoBxH,CAAA;AAED,eAAO,MAAM,gBAAgB,OAAc,EAAE,QAAQ,MAAM,YAAY,aAAa,CAAC,cAAc,CAAC,KAAG,OAAO,CAAC,UAAU,CAaxH,CAAA"}
1
+ {"version":3,"file":"life-cycle.d.ts","sourceRoot":"","sources":["../../src/utils/life-cycle.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,EAA4C,MAAM,SAAS,CAAA;AAG3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAShE,eAAO,MAAM,uBAAuB,OAAQ,EAAE,KAAG,mBAsIhD,CAAA"}
@@ -1,126 +1,110 @@
1
1
  import { MigrationStage, runMigrations } from '@owlmeans/resource';
2
+ import { logger } from '@owlmeans/log';
2
3
  import { DEF_MIGRATIONS_COLLECTION } from '../consts.js';
3
- import { getDeclaration } from '../declarations.js';
4
+ import { mongoDeclarationHelper } from '../declarations.js';
4
5
  import { mongoCollectionName } from './name.js';
5
- import { applyReferenceTypes, schemaToMongoSchema } from './schema.js';
6
- import { updateIndexes } from './indexes.js';
6
+ import { mongoSchemaUtils } from './schema.js';
7
+ import { mongoIndexUtils } from './indexes.js';
7
8
  import { makeMongoMigrationStore, makeMongoTx } from './migrations.js';
8
- import { reconcileReferences } from './refs.js';
9
- /**
10
- * Bring a resource's collection to the shape its schema declares.
11
- *
12
- * Order is deliberate, and matches the Postgres counterpart:
13
- *
14
- * 1. probe for the collection
15
- * 2. absent → *baseline* every registered migration; present → run the `pre` ones
16
- * (including the system `$ref:` migrations that convert declared references)
17
- * 3. create the collection, or update its validator and indexes
18
- * 4. present → run the `post` migrations
19
- * 5. reconcile declared references — the second half of their double check: the ledger
20
- * said whether the `$ref:` migration ran, this probes the collection itself and
21
- * converts whatever strings still slipped through
22
- *
23
- * Step 2 is what stops the two mechanisms colliding. A `pre` migration runs before the
24
- * validator is tightened, so it can reshape documents the new validator would reject. On a
25
- * collection this call just created there is nothing to reshape — replaying a historical
26
- * migration against a collection born in its final shape would at best scan for nothing —
27
- * so the migrations are recorded as satisfied instead of run.
28
- *
29
- * `context` is optional so the existing three-argument call keeps working; without it a
30
- * migration's `use`/`ref` can only address the owning resource.
31
- */
32
- export const initializeCollection = async (db, config, resource, context) => {
33
- const name = mongoCollectionName(config, resource);
34
- const fresh = !await db.listCollections({ name }).hasNext();
35
- appendReferenceIndexes(resource);
36
- const migrate = prepareMigrations(db, config, resource, name, context);
37
- await migrate(fresh ? { baseline: true } : { stage: MigrationStage.Pre });
38
- const collection = fresh
39
- ? await createCollection(db, name, resource)
40
- : await updateCollection(db, name, resource);
41
- if (!fresh) {
42
- await migrate({ stage: MigrationStage.Post });
43
- await reconcileReferences(collection, referencesOf(resource), resource.alias);
44
- }
45
- return collection;
46
- };
47
- /** Tolerates hand-built resource objects that predate the reference capability. */
48
- const referencesOf = (resource) => resource.references?.() ?? [];
49
- /**
50
- * A declared reference is indexed at the mongo level — that's part of its contract. The
51
- * index is appended unless the resource already declares one with the same key pattern
52
- * (mongo refuses two indexes over identical keys, and the existing one — possibly
53
- * unique — wins).
54
- */
55
- const appendReferenceIndexes = (resource) => {
56
- for (const ref of referencesOf(resource)) {
57
- if (ref.noIndex === true) {
58
- continue;
9
+ import { mongoRefHelper } from './refs.js';
10
+ const log = logger('mongo-resource');
11
+ export const makeMongoLifeCycleUtils = (db) => {
12
+ const { applyReferenceTypes, schemaToMongoSchema } = mongoSchemaUtils;
13
+ const initializeCollection = async (config, resource, context) => {
14
+ const name = mongoCollectionName(config, resource);
15
+ const fresh = !await db.listCollections({ name }).hasNext();
16
+ appendReferenceIndexes(resource);
17
+ const migrate = prepareMigrations(config, resource, name, context);
18
+ await migrate(fresh ? { baseline: true } : { stage: MigrationStage.Pre });
19
+ const collection = fresh
20
+ ? await createCollection(name, resource)
21
+ : await updateCollection(name, resource);
22
+ if (!fresh) {
23
+ await migrate({ stage: MigrationStage.Post });
24
+ await mongoRefHelper.reconcileReferences(collection, referencesOf(resource), resource.alias);
59
25
  }
60
- resource.indexes = resource.indexes ?? [];
61
- const spec = JSON.stringify({ [ref.field]: 1 });
62
- const present = resource.indexes.some(index => JSON.stringify(index.index) === spec || index.name === `ref_${ref.field}`);
63
- if (!present) {
64
- resource.indexes.push({ name: `ref_${ref.field}`, index: { [ref.field]: 1 } });
26
+ return collection;
27
+ };
28
+ /** Tolerates hand-built resource objects that predate the reference capability. */
29
+ const referencesOf = (resource) => resource.references?.() ?? [];
30
+ /**
31
+ * A declared reference is indexed at the mongo level — that's part of its contract. The
32
+ * index is appended unless the resource already declares one with the same key pattern
33
+ * (mongo refuses two indexes over identical keys, and the existing one — possibly
34
+ * unique — wins).
35
+ */
36
+ const appendReferenceIndexes = (resource) => {
37
+ for (const ref of referencesOf(resource)) {
38
+ if (ref.noIndex === true) {
39
+ continue;
40
+ }
41
+ resource.indexes = resource.indexes ?? [];
42
+ const spec = JSON.stringify({ [ref.field]: 1 });
43
+ const present = resource.indexes.some(index => JSON.stringify(index.index) === spec || index.name === `ref_${ref.field}`);
44
+ if (!present) {
45
+ resource.indexes.push({ name: `ref_${ref.field}`, index: { [ref.field]: 1 } });
46
+ }
65
47
  }
66
- }
67
- };
68
- /**
69
- * Bind the migration runner to this resource's database, or hand back a no-op when nothing
70
- * is registered — the overwhelmingly common case, and one that shouldn't pay for a ledger.
71
- */
72
- const prepareMigrations = (db, config, resource, name, context) => {
73
- const registry = getDeclaration(resource.alias).migrations;
74
- if (registry.list().length < 1) {
75
- return async () => null;
76
- }
77
- const ledgerName = config.meta?.migrationsCollection
78
- ?? DEF_MIGRATIONS_COLLECTION;
48
+ };
79
49
  /**
80
- * `db.collection()` never round-trips, so taking the handle before the collection exists
81
- * is safe — and on the fresh path the transaction is only ever baselined, never used.
50
+ * Bind the migration runner to this resource's database, or hand back a no-op when nothing
51
+ * is registered — the overwhelmingly common case, and one that shouldn't pay for a ledger.
82
52
  */
83
- const tx = makeMongoTx(db, db.collection(name), config, context, resource.alias);
84
- const store = makeMongoMigrationStore(db, tx, ledgerName);
85
- return async (opts) => {
86
- const report = await runMigrations(resource.alias, registry, store, opts);
87
- if (report.applied.length > 0) {
88
- console.log(`@owlmeans/mongo-resource: ${name} applied ${report.stage} migrations —`
89
- + ` ${report.applied.join(', ')}`);
53
+ const prepareMigrations = (config, resource, name, context) => {
54
+ const registry = mongoDeclarationHelper.getDeclaration(resource.alias).migrations;
55
+ if (registry.list().length < 1) {
56
+ return async () => null;
90
57
  }
91
- return report;
58
+ const ledgerName = config.meta?.migrationsCollection
59
+ ?? DEF_MIGRATIONS_COLLECTION;
60
+ /**
61
+ * `db.collection()` never round-trips, so taking the handle before the collection exists
62
+ * is safe — and on the fresh path the transaction is only ever baselined, never used.
63
+ */
64
+ const tx = makeMongoTx(db, db.collection(name), config, context, resource.alias);
65
+ const store = makeMongoMigrationStore(db, tx, ledgerName);
66
+ return async (opts) => {
67
+ const report = await runMigrations(resource.alias, registry, store, opts);
68
+ if (report.applied.length > 0) {
69
+ log.info('Migrations applied', {
70
+ resource: resource.alias, collection: name, stage: report.stage, applied: report.applied,
71
+ }, { event: 'migration.applied' });
72
+ }
73
+ return report;
74
+ };
92
75
  };
93
- };
94
- export const createCollection = async (db, name, resource) => {
95
- const collection = await db.createCollection(name, {
96
- ...(resource.schema != null ? {
97
- validator: {
98
- $jsonSchema: patchJsonSchema(applyReferenceTypes(schemaToMongoSchema(resource.schema), resource.schema, resource.references()))
76
+ const createCollection = async (name, resource) => {
77
+ const collection = await db.createCollection(name, {
78
+ ...(resource.schema != null ? {
79
+ validator: {
80
+ $jsonSchema: patchJsonSchema(applyReferenceTypes(schemaToMongoSchema(resource.schema), resource.schema, resource.references()))
81
+ }
82
+ } : {})
83
+ });
84
+ if (resource.indexes != null) {
85
+ await Promise.all(resource.indexes.map(async (index) => await collection.createIndex(index.index, {
86
+ name: index.name, ...((index.options != null) ? index.options : {})
87
+ })));
88
+ }
89
+ return collection;
90
+ };
91
+ const updateCollection = async (name, resource) => {
92
+ if (resource.schema != null) {
93
+ const $jsonSchema = patchJsonSchema(applyReferenceTypes(schemaToMongoSchema(resource.schema), resource.schema, resource.references()));
94
+ await db.command({ collMod: name, validator: { $jsonSchema } });
95
+ }
96
+ const collection = db.collection(name);
97
+ await mongoIndexUtils.updateIndexes(collection, resource);
98
+ return collection;
99
+ };
100
+ const patchJsonSchema = (schema) => {
101
+ if (schema.properties != null) {
102
+ if (schema.properties._id == null) {
103
+ schema.properties._id = { bsonType: 'objectId' };
99
104
  }
100
- } : {})
101
- });
102
- if (resource.indexes != null) {
103
- await Promise.all(resource.indexes.map(async (index) => await collection.createIndex(index.index, {
104
- name: index.name, ...((index.options != null) ? index.options : {})
105
- })));
106
- }
107
- return collection;
108
- };
109
- export const updateCollection = async (db, name, resource) => {
110
- if (resource.schema != null) {
111
- const $jsonSchema = patchJsonSchema(applyReferenceTypes(schemaToMongoSchema(resource.schema), resource.schema, resource.references()));
112
- await db.command({ collMod: name, validator: { $jsonSchema } });
113
- }
114
- const collection = db.collection(name);
115
- await updateIndexes(collection, resource);
116
- return collection;
117
- };
118
- const patchJsonSchema = (schema) => {
119
- if (schema.properties != null) {
120
- if (schema.properties._id == null) {
121
- schema.properties._id = { bsonType: 'objectId' };
122
105
  }
123
- }
124
- return schema;
106
+ return schema;
107
+ };
108
+ return { initializeCollection, createCollection, updateCollection };
125
109
  };
126
110
  //# sourceMappingURL=life-cycle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"life-cycle.js","sourceRoot":"","sources":["../../src/utils/life-cycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKlE,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,M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K,EAAiC,OAAO,EAAE,MAAM,aAAa,CAAA;AAmBzE;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,OAClB,EAAE,cAAc,UAAU,UAAU,QAAQ,WAAW,YAAY,CAAC,GAAG,CAAC,QAAQ,MAAM,KACzF,OA6BF,CAAA;AAqBD;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,OAC9B,EAAE,MAAM,OAAO,SAAQ,MAAM,KAChC,cAAc,CAAC,OAAO,CAwFxB,CAAA"}
1
+ {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/utils/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAa,cAAc,EAAkB,MAAM,oBAAoB,CAAA;AAC7F,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAG7C,OAAO,KAAK,EAAiC,OAAO,EAAE,MAAM,aAAa,CAAA;AAOzE;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,OAClB,EAAE,cAAc,UAAU,UAAU,QAAQ,WAAW,YAAY,CAAC,GAAG,CAAC,QAAQ,MAAM,KACzF,OA6BF,CAAA;AAqBD;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,OAC9B,EAAE,MAAM,OAAO,SAAQ,MAAM,KAChC,cAAc,CAAC,OAAO,CAwFxB,CAAA"}
@@ -1,5 +1,4 @@
1
- import { DEF_MIGRATION_POLL, DEF_MIGRATION_WAIT, DEF_MIGRATIONS_COLLECTION, MONGO_DUPLICATE_KEY } from '../consts.js';
2
- import { DEFAULT_DB_ALIAS } from '../consts.js';
1
+ import { DEF_MIGRATION_POLL, DEF_MIGRATION_WAIT, DEF_MIGRATIONS_COLLECTION, MONGO_DUPLICATE_KEY, DEFAULT_DB_ALIAS } from '../consts.js';
3
2
  import { mongoCollectionName } from './name.js';
4
3
  const isDuplicateKey = (error) => error?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ED,MAAM,MAAM,EAAE,CAAC,SAAS,CACtB,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,EAC/B,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,IAAI,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,EAAE,CACxE,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../src/utils/name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAQhD,eAAO,MAAM,mBAAmB,WAAY,QAAQ,YAAY,aAAa,CAAC,cAAc,CAAC,KAAG,MAQ/F,CAAA"}
1
+ {"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../src/utils/name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD,eAAO,MAAM,mBAAmB,WAAY,QAAQ,YAAY,aAAa,CAAC,cAAc,CAAC,KAAG,MAQ/F,CAAA"}
@@ -1,8 +1,4 @@
1
- // Collection names must use only alphanumeric characters, underscore, and hyphen — no
2
- // colons or other delimiters. This guard enforces the rule for every collection created
3
- // through makeMongoResource across all projects (common/internal/app), failing fast at
4
- // initialization rather than silently creating a badly-named collection.
5
- const VALID_COLLECTION_NAME = /^[a-zA-Z0-9_-]+$/;
1
+ import { VALID_COLLECTION_NAME } from './consts.local.js';
6
2
  export const mongoCollectionName = (config, resource) => {
7
3
  const name = `${config.resourcePrefix ?? ''}${resource.name ?? resource.alias}`;
8
4
  if (!VALID_COLLECTION_NAME.test(name)) {
@@ -1 +1 @@
1
- {"version":3,"file":"name.js","sourceRoot":"","sources":["../../src/utils/name.ts"],"names":[],"mappings":"AAGA,sFAAsF;AACtF,wFAAwF;AACxF,uFAAuF;AACvF,yEAAyE;AACzE,MAAM,qBAAqB,GAAG,kBAAkB,CAAA;AAEhD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAgB,EAAE,QAAuC,EAAU,EAAE;IACvG,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,cAAc,IAAI,EAAE,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAA;IAC/E,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,WAAW,CACnB,kCAAkC,IAAI,cAAc,QAAQ,CAAC,KAAK,oCAAoC,CACvG,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
1
+ {"version":3,"file":"name.js","sourceRoot":"","sources":["../../src/utils/name.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAgB,EAAE,QAAuC,EAAU,EAAE;IACvG,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,cAAc,IAAI,EAAE,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAA;IAC/E,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,WAAW,CACnB,kCAAkC,IAAI,cAAc,QAAQ,CAAC,KAAK,oCAAoC,CACvG,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
@@ -0,0 +1,78 @@
1
+ import type { Collection, Document } from 'mongodb';
2
+ import type { MongoReference } from '../../types.js';
3
+ /** Declared ObjectId references: converting their values, their criteria and their stored data. */
4
+ export interface MongoRefHelper {
5
+ /** A 24 hex string — the only shape a stored reference is converted from. */
6
+ isObjectIdHex: (value: unknown) => value is string;
7
+ /**
8
+ * Write side of a declared reference: the string id a record carries becomes the
9
+ * `ObjectId` the collection stores. Arrays convert elementwise.
10
+ *
11
+ * Strict on purpose — a declared reference holding something that is not a mongo id is
12
+ * either a mis-declared field (should never have been a reference) or a bug at the call
13
+ * site, and storing it as a string would silently reintroduce the mixed type state this
14
+ * mechanism exists to remove.
15
+ *
16
+ * @throws {MisshapedRecord}
17
+ */
18
+ marshalReference: (field: string, value: unknown) => unknown;
19
+ /** Read side: `ObjectId` back to the string records carry. Tolerates not yet migrated strings. */
20
+ demarshalReference: (value: unknown) => unknown;
21
+ /** Convert every declared reference of a fetched document back to string ids, in place. */
22
+ demarshalRefs: <T extends {}>(record: T, refs: Map<string, MongoReference>) => T;
23
+ /**
24
+ * Convert a mongo filter the way records are converted: values addressed at `_id` or at a
25
+ * declared reference become `ObjectId`s, and the `id` alias records actually carry is
26
+ * mapped onto `_id` — documents never store `id`, so before this mapping such criteria
27
+ * silently matched nothing.
28
+ *
29
+ * Tolerant by design: a value that is not 24 hex passes through unconverted. Criteria are
30
+ * matched against the collection, and against an `ObjectId` typed field a stray string
31
+ * matches nothing — which is exactly what it matched before the field was converted.
32
+ *
33
+ * Operators arrive already in mongo's own vocabulary — `criteriaToFilter` translates
34
+ * the portable one first, so this pass only has to convert values.
35
+ */
36
+ marshalCriteria: (criteria: Document | undefined, refs: Map<string, MongoReference>) => Document | undefined;
37
+ /**
38
+ * Criteria for addressing a single record by a field — `get`/`load`/`update`/`delete`.
39
+ *
40
+ * `_id` keeps its historical strictness (an invalid id throws through the driver). The
41
+ * `id` alias and declared references convert tolerantly, so a caller probing a reference
42
+ * with a value that is not a mongo id gets "not found" rather than a throw.
43
+ */
44
+ identityCriteria: (field: string, id: string, refs: Map<string, MongoReference>) => Document;
45
+ /**
46
+ * Name of the system migration that converts a reference field's stored strings.
47
+ *
48
+ * The `@1` is the body's version: the shared body (`makeRefMigration`) fingerprints identically
49
+ * for every field, so an edit to it would raise `MigrationConflict` against every ledger on
50
+ * the next boot. Any semantic change to {@link MongoRefHelper.convertReferenceField} must bump
51
+ * this suffix instead — the old name stays applied, the new one runs (idempotently) once.
52
+ */
53
+ refMigrationName: (field: string) => string;
54
+ /**
55
+ * Convert one reference field's stored string ids to `ObjectId`s — the body of the
56
+ * system migration and of the boot time reconciliation probe alike.
57
+ *
58
+ * Idempotent and interrupt safe: it matches only documents where the field (or one of
59
+ * its elements) is still a string, converts only values that are actually 24 hex, and
60
+ * leaves everything else exactly as it was. Safe to run concurrently from several
61
+ * replicas — a document converts once, the loser's filter no longer matches it.
62
+ *
63
+ * Validation is bypassed deliberately: at `Pre` stage the collection still carries the
64
+ * validator that declares the field a *string*, and after the switch a legacy document
65
+ * may violate the schema in unrelated ways — either would wedge the boot on a write
66
+ * that only makes the data more correct. (Bypassing requires the connection's user to
67
+ * hold the `bypassDocumentValidation` privilege — `dbOwner`/`root` do.)
68
+ */
69
+ convertReferenceField: (collection: Collection, field: string) => Promise<number>;
70
+ /**
71
+ * The second half of the double check the reference migration promises: the ledger says
72
+ * whether the migration ran; this probes whether the collection actually holds no
73
+ * convertible strings — and repairs it when the two disagree (a restored backup, a
74
+ * write from a legacy process, a ledger created by hand).
75
+ */
76
+ reconcileReferences: (collection: Collection, refs: MongoReference[], alias: string) => Promise<void>;
77
+ }
78
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/refs/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,mGAAmG;AACnG,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK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- import type { ListCriteria } from '@owlmeans/resource';
2
- import type { Collection, Document } from 'mongodb';
3
1
  import type { MongoReference, MongoTx } from '../types.js';
4
- export declare const isObjectIdHex: (value: unknown) => value is string;
2
+ import type { MongoRefHelper } from './refs/types.js';
5
3
  /**
6
- * Write side of a declared reference: the string id a record carries becomes the
7
- * `ObjectId` the collection stores. Arrays convert elementwise.
8
- *
9
- * Strict on purpose — a declared reference holding something that is not a mongo id is
10
- * either a mis-declared field (should never have been a reference) or a bug at the call
11
- * site, and storing it as a string would silently reintroduce the mixed type state this
12
- * mechanism exists to remove.
4
+ * Ledger registered body of the system reference migration.
13
5
  *
14
- * @throws {MisshapedRecord}
6
+ * Stays a module level factory, textually unchanged: the ledger fingerprints a migration by the
7
+ * source text of the function it registers (`apply.toString()`), so moving the returned closure —
8
+ * or renaming what it calls — changes the checksum and raises `MigrationConflict` against every
9
+ * ledger that already applied it.
15
10
  */
11
+ export declare const makeRefMigration: (field: string) => (tx: MongoTx) => Promise<void>;
12
+ export declare const createMongoRefHelper: () => MongoRefHelper;
13
+ export declare const mongoRefHelper: MongoRefHelper;
14
+ /** @deprecated compat:factory-refactor — use `mongoRefHelper.isObjectIdHex(…)` */
15
+ export declare const isObjectIdHex: (value: unknown) => value is string;
16
+ /** @deprecated compat:factory-refactor — use `mongoRefHelper.marshalReference(…)` */
16
17
  export declare const marshalReference: (field: string, value: unknown) => unknown;
17
- /** Read side: `ObjectId` back to the string records carry. Tolerates not yet migrated strings. */
18
- export declare const demarshalReference: (value: unknown) => unknown;
19
- /** Convert every declared reference of a fetched document back to string ids, in place. */
18
+ /** @deprecated compat:factory-refactor — use `mongoRefHelper.demarshalRefs(…)` */
20
19
  export declare const demarshalRefs: <T extends {}>(record: T, refs: Map<string, MongoReference>) => T;
21
- /**
22
- * Convert list criteria the way records are converted: values addressed at `_id` or at a
23
- * declared reference become `ObjectId`s, and the `id` alias records actually carry is
24
- * mapped onto `_id` — documents never store `id`, so before this mapping such criteria
25
- * silently matched nothing.
26
- *
27
- * Tolerant by design: a value that is not 24 hex passes through unconverted. Criteria are
28
- * matched against the collection, and against an `ObjectId` typed field a stray string
29
- * matches nothing — which is exactly what it matched before the field was converted.
30
- */
31
- export declare const marshalCriteria: (criteria: ListCriteria | undefined, refs: Map<string, MongoReference>) => ListCriteria | undefined;
32
- /**
33
- * Criteria for addressing a single record by a field — `get`/`load`/`update`/`delete`.
34
- *
35
- * `_id` keeps its historical strictness (an invalid id throws through the driver). The
36
- * `id` alias and declared references convert tolerantly, so a caller probing a reference
37
- * with a value that is not a mongo id gets "not found" rather than a throw.
38
- */
39
- export declare const identityCriteria: (field: string, id: string, refs: Map<string, MongoReference>) => Document;
40
- /**
41
- * Name of the system migration that converts a reference field's stored strings.
42
- *
43
- * The `@1` is the body's version: the shared body below fingerprints identically for
44
- * every field, so an edit to it would raise `MigrationConflict` against every ledger on
45
- * the next boot. Any semantic change to {@link convertReferenceField} must bump this
46
- * suffix instead — the old name stays applied, the new one runs (idempotently) once.
47
- */
48
- export declare const refMigrationName: (field: string) => string;
49
- /** Ledger registered body of the system reference migration. */
50
- export declare const makeRefMigration: (field: string) => (tx: MongoTx) => Promise<void>;
51
- /**
52
- * Convert one reference field's stored string ids to `ObjectId`s — the body of the
53
- * system migration and of the boot time reconciliation probe alike.
54
- *
55
- * Idempotent and interrupt safe: it matches only documents where the field (or one of
56
- * its elements) is still a string, converts only values that are actually 24 hex, and
57
- * leaves everything else exactly as it was. Safe to run concurrently from several
58
- * replicas — a document converts once, the loser's filter no longer matches it.
59
- *
60
- * Validation is bypassed deliberately: at `Pre` stage the collection still carries the
61
- * validator that declares the field a *string*, and after the switch a legacy document
62
- * may violate the schema in unrelated ways — either would wedge the boot on a write
63
- * that only makes the data more correct. (Bypassing requires the connection's user to
64
- * hold the `bypassDocumentValidation` privilege — `dbOwner`/`root` do.)
65
- */
66
- export declare const convertReferenceField: (collection: Collection, field: string) => Promise<number>;
67
- /**
68
- * The second half of the double check the reference migration promises: the ledger says
69
- * whether the migration ran; this probes whether the collection actually holds no
70
- * convertible strings — and repairs it when the two disagree (a restored backup, a
71
- * write from a legacy process, a ledger created by hand).
72
- */
73
- export declare const reconcileReferences: (collection: Collection, refs: MongoReference[], alias: string) => Promise<void>;
74
20
  //# sourceMappingURL=refs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/utils/refs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAS1D,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,KAAK,IAAI,MACR,CAAA;AAEhD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,SAAS,OAAO,KAAG,OAehE,CAAA;AAED,kGAAkG;AAClG,eAAO,MAAM,kBAAkB,UAAW,OAAO,KAAG,OASnD,CAAA;AAED,2FAA2F;AAC3F,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,EAAE,UAAU,CAAC,QAAQ,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,KAAG,CAY1F,CAAA;AA4BD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,aAChB,YAAY,GAAG,SAAS,QAAQ,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,KACpE,YAAY,GAAG,SAkBjB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,UACpB,MAAM,MAAM,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,KAC3D,QAYF,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,MAA2B,CAAA;AAE5E,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,UAAW,MAAM,UAAgB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