@payloadcms/db-mongodb 3.0.0-canary.f6e77b8 → 3.0.0-canary.fb04843
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/connect.d.ts +1 -1
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +18 -4
- package/dist/connect.js.map +1 -1
- package/dist/count.d.ts +1 -1
- package/dist/count.d.ts.map +1 -1
- package/dist/count.js +10 -3
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.d.ts +3 -0
- package/dist/countGlobalVersions.d.ts.map +1 -0
- package/dist/countGlobalVersions.js +40 -0
- package/dist/countGlobalVersions.js.map +1 -0
- package/dist/countVersions.d.ts +3 -0
- package/dist/countVersions.d.ts.map +1 -0
- package/dist/countVersions.js +40 -0
- package/dist/countVersions.js.map +1 -0
- package/dist/create.d.ts +1 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +17 -4
- package/dist/create.js.map +1 -1
- package/dist/createGlobal.d.ts +1 -1
- package/dist/createGlobal.d.ts.map +1 -1
- package/dist/createGlobal.js +11 -6
- package/dist/createGlobal.js.map +1 -1
- package/dist/createGlobalVersion.d.ts +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +14 -5
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createMigration.d.ts +1 -1
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +20 -32
- package/dist/createMigration.js.map +1 -1
- package/dist/createVersion.d.ts +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +32 -10
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.d.ts +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +1 -1
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +12 -4
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +1 -1
- package/dist/deleteVersions.js.map +1 -1
- package/dist/destroy.d.ts +1 -1
- package/dist/destroy.d.ts.map +1 -1
- package/dist/destroy.js.map +1 -1
- package/dist/exports/migration-utils.d.ts +3 -0
- package/dist/exports/migration-utils.d.ts.map +1 -0
- package/dist/exports/migration-utils.js +4 -0
- package/dist/exports/migration-utils.js.map +1 -0
- package/dist/find.d.ts +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +36 -7
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +11 -5
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +19 -9
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +28 -4
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +17 -6
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts +59 -35
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -7
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +19 -17
- package/dist/init.js.map +1 -1
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +1 -1
- package/dist/migrateFresh.js.map +1 -1
- package/dist/models/buildCollectionSchema.d.ts +2 -29
- package/dist/models/buildCollectionSchema.d.ts.map +1 -1
- package/dist/models/buildCollectionSchema.js +16 -4
- package/dist/models/buildCollectionSchema.js.map +1 -1
- package/dist/models/buildGlobalModel.d.ts +1 -1
- package/dist/models/buildGlobalModel.d.ts.map +1 -1
- package/dist/models/buildGlobalModel.js +2 -2
- package/dist/models/buildGlobalModel.js.map +1 -1
- package/dist/models/buildSchema.d.ts +2 -29
- package/dist/models/buildSchema.d.ts.map +1 -1
- package/dist/models/buildSchema.js +116 -23
- package/dist/models/buildSchema.js.map +1 -1
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts +6 -0
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts.map +1 -0
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js +141 -0
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js.map +1 -0
- package/dist/predefinedMigrations/migrateVersionsV1_V2.d.ts +5 -0
- package/dist/predefinedMigrations/migrateVersionsV1_V2.d.ts.map +1 -0
- package/dist/predefinedMigrations/migrateVersionsV1_V2.js +107 -0
- package/dist/predefinedMigrations/migrateVersionsV1_V2.js.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.js +9 -0
- package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
- package/dist/predefinedMigrations/versions-v1-v2.d.ts +4 -0
- package/dist/predefinedMigrations/versions-v1-v2.d.ts.map +1 -0
- package/dist/predefinedMigrations/versions-v1-v2.js +8 -0
- package/dist/predefinedMigrations/versions-v1-v2.js.map +1 -0
- package/dist/queries/buildAndOrConditions.d.ts +1 -2
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +0 -2
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +3 -4
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +2 -3
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/buildSearchParams.d.ts +1 -2
- package/dist/queries/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +34 -22
- package/dist/queries/buildSearchParams.js.map +1 -1
- package/dist/queries/buildSortParam.d.ts +3 -29
- package/dist/queries/buildSortParam.d.ts.map +1 -1
- package/dist/queries/buildSortParam.js +26 -17
- package/dist/queries/buildSortParam.js.map +1 -1
- package/dist/queries/getLocalizedSortProperty.d.ts +1 -2
- package/dist/queries/getLocalizedSortProperty.d.ts.map +1 -1
- package/dist/queries/getLocalizedSortProperty.js +2 -2
- package/dist/queries/getLocalizedSortProperty.js.map +1 -1
- package/dist/queries/getLocalizedSortProperty.spec.js +44 -44
- package/dist/queries/getLocalizedSortProperty.spec.js.map +1 -1
- package/dist/queries/mock.js.map +1 -1
- package/dist/queries/operatorMap.js.map +1 -1
- package/dist/queries/parseParams.d.ts +1 -3
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +8 -6
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +145 -28
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +37 -10
- package/dist/queryDrafts.js.map +1 -1
- package/dist/testCredentials.js.map +1 -1
- package/dist/transactions/beginTransaction.d.ts +1 -1
- package/dist/transactions/beginTransaction.d.ts.map +1 -1
- package/dist/transactions/beginTransaction.js +3 -1
- package/dist/transactions/beginTransaction.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +3 -0
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/transactions/rollbackTransaction.d.ts +1 -1
- package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
- package/dist/transactions/rollbackTransaction.js +13 -7
- package/dist/transactions/rollbackTransaction.js.map +1 -1
- package/dist/types.d.ts +7 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/updateGlobal.d.ts +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +18 -5
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts +2 -3
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +19 -5
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateOne.d.ts +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +25 -7
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +18 -4
- package/dist/updateVersion.js.map +1 -1
- package/dist/upsert.d.ts +3 -0
- package/dist/upsert.d.ts.map +1 -0
- package/dist/upsert.js +15 -0
- package/dist/upsert.js.map +1 -0
- package/dist/utilities/buildJoinAggregation.d.ts +18 -0
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -0
- package/dist/utilities/buildJoinAggregation.js +159 -0
- package/dist/utilities/buildJoinAggregation.js.map +1 -0
- package/dist/utilities/buildProjectionFromSelect.d.ts +8 -0
- package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -0
- package/dist/utilities/buildProjectionFromSelect.js +171 -0
- package/dist/utilities/buildProjectionFromSelect.js.map +1 -0
- package/dist/utilities/getDBName.d.ts +1 -1
- package/dist/utilities/getDBName.d.ts.map +1 -1
- package/dist/utilities/getDBName.js +3 -1
- package/dist/utilities/getDBName.js.map +1 -1
- package/dist/utilities/handleError.d.ts +6 -2
- package/dist/utilities/handleError.d.ts.map +1 -1
- package/dist/utilities/handleError.js +12 -9
- package/dist/utilities/handleError.js.map +1 -1
- package/dist/utilities/sanitizeInternalFields.d.ts +1 -2
- package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
- package/dist/utilities/sanitizeInternalFields.js +1 -2
- package/dist/utilities/sanitizeInternalFields.js.map +1 -1
- package/dist/utilities/sanitizeRelationshipIDs.d.ts +9 -0
- package/dist/utilities/sanitizeRelationshipIDs.d.ts.map +1 -0
- package/dist/utilities/sanitizeRelationshipIDs.js +115 -0
- package/dist/utilities/sanitizeRelationshipIDs.js.map +1 -0
- package/dist/utilities/sanitizeRelationshipIDs.spec.js +383 -0
- package/dist/utilities/sanitizeRelationshipIDs.spec.js.map +1 -0
- package/dist/withSession.d.ts +3 -27
- package/dist/withSession.d.ts.map +1 -1
- package/dist/withSession.js +10 -4
- package/dist/withSession.js.map +1 -1
- package/license.md +22 -0
- package/package.json +29 -17
- package/predefinedMigrations/versions-v1-v2.js +0 -96
@@ -0,0 +1,383 @@
|
|
1
|
+
import { Types } from 'mongoose';
|
2
|
+
import { sanitizeRelationshipIDs } from './sanitizeRelationshipIDs.js';
|
3
|
+
const flattenRelationshipValues = (obj, prefix = '')=>{
|
4
|
+
return Object.keys(obj).reduce((acc, key)=>{
|
5
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
6
|
+
const value = obj[key];
|
7
|
+
if (value && typeof value === 'object' && !(value instanceof Types.ObjectId)) {
|
8
|
+
Object.assign(acc, flattenRelationshipValues(value, fullKey));
|
9
|
+
// skip relationTo and blockType
|
10
|
+
} else if (!fullKey.endsWith('relationTo') && !fullKey.endsWith('blockType')) {
|
11
|
+
acc[fullKey] = value;
|
12
|
+
}
|
13
|
+
return acc;
|
14
|
+
}, {});
|
15
|
+
};
|
16
|
+
const relsFields = [
|
17
|
+
{
|
18
|
+
name: 'rel_1',
|
19
|
+
type: 'relationship',
|
20
|
+
relationTo: 'rels'
|
21
|
+
},
|
22
|
+
{
|
23
|
+
name: 'rel_1_l',
|
24
|
+
type: 'relationship',
|
25
|
+
localized: true,
|
26
|
+
relationTo: 'rels'
|
27
|
+
},
|
28
|
+
{
|
29
|
+
name: 'rel_2',
|
30
|
+
type: 'relationship',
|
31
|
+
hasMany: true,
|
32
|
+
relationTo: 'rels'
|
33
|
+
},
|
34
|
+
{
|
35
|
+
name: 'rel_2_l',
|
36
|
+
type: 'relationship',
|
37
|
+
hasMany: true,
|
38
|
+
localized: true,
|
39
|
+
relationTo: 'rels'
|
40
|
+
},
|
41
|
+
{
|
42
|
+
name: 'rel_3',
|
43
|
+
type: 'relationship',
|
44
|
+
relationTo: [
|
45
|
+
'rels'
|
46
|
+
]
|
47
|
+
},
|
48
|
+
{
|
49
|
+
name: 'rel_3_l',
|
50
|
+
type: 'relationship',
|
51
|
+
localized: true,
|
52
|
+
relationTo: [
|
53
|
+
'rels'
|
54
|
+
]
|
55
|
+
},
|
56
|
+
{
|
57
|
+
name: 'rel_4',
|
58
|
+
type: 'relationship',
|
59
|
+
hasMany: true,
|
60
|
+
relationTo: [
|
61
|
+
'rels'
|
62
|
+
]
|
63
|
+
},
|
64
|
+
{
|
65
|
+
name: 'rel_4_l',
|
66
|
+
type: 'relationship',
|
67
|
+
hasMany: true,
|
68
|
+
localized: true,
|
69
|
+
relationTo: [
|
70
|
+
'rels'
|
71
|
+
]
|
72
|
+
}
|
73
|
+
];
|
74
|
+
const config = {
|
75
|
+
collections: [
|
76
|
+
{
|
77
|
+
slug: 'docs',
|
78
|
+
fields: [
|
79
|
+
...relsFields,
|
80
|
+
{
|
81
|
+
name: 'array',
|
82
|
+
type: 'array',
|
83
|
+
fields: [
|
84
|
+
{
|
85
|
+
name: 'array',
|
86
|
+
type: 'array',
|
87
|
+
fields: relsFields
|
88
|
+
},
|
89
|
+
{
|
90
|
+
name: 'blocks',
|
91
|
+
type: 'blocks',
|
92
|
+
blocks: [
|
93
|
+
{
|
94
|
+
slug: 'block',
|
95
|
+
fields: relsFields
|
96
|
+
}
|
97
|
+
]
|
98
|
+
},
|
99
|
+
...relsFields
|
100
|
+
]
|
101
|
+
},
|
102
|
+
{
|
103
|
+
name: 'arrayLocalized',
|
104
|
+
type: 'array',
|
105
|
+
fields: [
|
106
|
+
{
|
107
|
+
name: 'array',
|
108
|
+
type: 'array',
|
109
|
+
fields: relsFields
|
110
|
+
},
|
111
|
+
{
|
112
|
+
name: 'blocks',
|
113
|
+
type: 'blocks',
|
114
|
+
blocks: [
|
115
|
+
{
|
116
|
+
slug: 'block',
|
117
|
+
fields: relsFields
|
118
|
+
}
|
119
|
+
]
|
120
|
+
},
|
121
|
+
...relsFields
|
122
|
+
],
|
123
|
+
localized: true
|
124
|
+
},
|
125
|
+
{
|
126
|
+
name: 'blocks',
|
127
|
+
type: 'blocks',
|
128
|
+
blocks: [
|
129
|
+
{
|
130
|
+
slug: 'block',
|
131
|
+
fields: [
|
132
|
+
...relsFields,
|
133
|
+
{
|
134
|
+
name: 'group',
|
135
|
+
type: 'group',
|
136
|
+
fields: relsFields
|
137
|
+
},
|
138
|
+
{
|
139
|
+
name: 'array',
|
140
|
+
type: 'array',
|
141
|
+
fields: relsFields
|
142
|
+
}
|
143
|
+
]
|
144
|
+
}
|
145
|
+
]
|
146
|
+
},
|
147
|
+
{
|
148
|
+
name: 'group',
|
149
|
+
type: 'group',
|
150
|
+
fields: [
|
151
|
+
...relsFields,
|
152
|
+
{
|
153
|
+
name: 'array',
|
154
|
+
type: 'array',
|
155
|
+
fields: relsFields
|
156
|
+
}
|
157
|
+
]
|
158
|
+
},
|
159
|
+
{
|
160
|
+
name: 'groupLocalized',
|
161
|
+
type: 'group',
|
162
|
+
fields: [
|
163
|
+
...relsFields,
|
164
|
+
{
|
165
|
+
name: 'array',
|
166
|
+
type: 'array',
|
167
|
+
fields: relsFields
|
168
|
+
}
|
169
|
+
],
|
170
|
+
localized: true
|
171
|
+
},
|
172
|
+
{
|
173
|
+
type: 'tabs',
|
174
|
+
tabs: [
|
175
|
+
{
|
176
|
+
name: 'tab',
|
177
|
+
fields: relsFields
|
178
|
+
},
|
179
|
+
{
|
180
|
+
name: 'tabLocalized',
|
181
|
+
fields: relsFields,
|
182
|
+
localized: true
|
183
|
+
}
|
184
|
+
]
|
185
|
+
}
|
186
|
+
]
|
187
|
+
},
|
188
|
+
{
|
189
|
+
slug: 'rels',
|
190
|
+
fields: []
|
191
|
+
}
|
192
|
+
],
|
193
|
+
localization: {
|
194
|
+
defaultLocale: 'en',
|
195
|
+
localeCodes: [
|
196
|
+
'en',
|
197
|
+
'es'
|
198
|
+
],
|
199
|
+
locales: [
|
200
|
+
{
|
201
|
+
code: 'en',
|
202
|
+
label: 'EN'
|
203
|
+
},
|
204
|
+
{
|
205
|
+
code: 'es',
|
206
|
+
label: 'ES'
|
207
|
+
}
|
208
|
+
]
|
209
|
+
}
|
210
|
+
};
|
211
|
+
const relsData = {
|
212
|
+
rel_1: new Types.ObjectId().toHexString(),
|
213
|
+
rel_1_l: {
|
214
|
+
en: new Types.ObjectId().toHexString(),
|
215
|
+
es: new Types.ObjectId().toHexString()
|
216
|
+
},
|
217
|
+
rel_2: [
|
218
|
+
new Types.ObjectId().toHexString()
|
219
|
+
],
|
220
|
+
rel_2_l: {
|
221
|
+
en: [
|
222
|
+
new Types.ObjectId().toHexString()
|
223
|
+
],
|
224
|
+
es: [
|
225
|
+
new Types.ObjectId().toHexString()
|
226
|
+
]
|
227
|
+
},
|
228
|
+
rel_3: {
|
229
|
+
relationTo: 'rels',
|
230
|
+
value: new Types.ObjectId().toHexString()
|
231
|
+
},
|
232
|
+
rel_3_l: {
|
233
|
+
en: {
|
234
|
+
relationTo: 'rels',
|
235
|
+
value: new Types.ObjectId().toHexString()
|
236
|
+
},
|
237
|
+
es: {
|
238
|
+
relationTo: 'rels',
|
239
|
+
value: new Types.ObjectId().toHexString()
|
240
|
+
}
|
241
|
+
},
|
242
|
+
rel_4: [
|
243
|
+
{
|
244
|
+
relationTo: 'rels',
|
245
|
+
value: new Types.ObjectId().toHexString()
|
246
|
+
}
|
247
|
+
],
|
248
|
+
rel_4_l: {
|
249
|
+
en: [
|
250
|
+
{
|
251
|
+
relationTo: 'rels',
|
252
|
+
value: new Types.ObjectId().toHexString()
|
253
|
+
}
|
254
|
+
],
|
255
|
+
es: [
|
256
|
+
{
|
257
|
+
relationTo: 'rels',
|
258
|
+
value: new Types.ObjectId().toHexString()
|
259
|
+
}
|
260
|
+
]
|
261
|
+
}
|
262
|
+
};
|
263
|
+
describe('sanitizeRelationshipIDs', ()=>{
|
264
|
+
it('should sanitize relationships', ()=>{
|
265
|
+
const data = {
|
266
|
+
...relsData,
|
267
|
+
array: [
|
268
|
+
{
|
269
|
+
...relsData,
|
270
|
+
array: [
|
271
|
+
{
|
272
|
+
...relsData
|
273
|
+
}
|
274
|
+
],
|
275
|
+
blocks: [
|
276
|
+
{
|
277
|
+
blockType: 'block',
|
278
|
+
...relsData
|
279
|
+
}
|
280
|
+
]
|
281
|
+
}
|
282
|
+
],
|
283
|
+
arrayLocalized: {
|
284
|
+
en: [
|
285
|
+
{
|
286
|
+
...relsData,
|
287
|
+
array: [
|
288
|
+
{
|
289
|
+
...relsData
|
290
|
+
}
|
291
|
+
],
|
292
|
+
blocks: [
|
293
|
+
{
|
294
|
+
blockType: 'block',
|
295
|
+
...relsData
|
296
|
+
}
|
297
|
+
]
|
298
|
+
}
|
299
|
+
],
|
300
|
+
es: [
|
301
|
+
{
|
302
|
+
...relsData,
|
303
|
+
array: [
|
304
|
+
{
|
305
|
+
...relsData
|
306
|
+
}
|
307
|
+
],
|
308
|
+
blocks: [
|
309
|
+
{
|
310
|
+
blockType: 'block',
|
311
|
+
...relsData
|
312
|
+
}
|
313
|
+
]
|
314
|
+
}
|
315
|
+
]
|
316
|
+
},
|
317
|
+
blocks: [
|
318
|
+
{
|
319
|
+
blockType: 'block',
|
320
|
+
...relsData,
|
321
|
+
array: [
|
322
|
+
{
|
323
|
+
...relsData
|
324
|
+
}
|
325
|
+
],
|
326
|
+
group: {
|
327
|
+
...relsData
|
328
|
+
}
|
329
|
+
}
|
330
|
+
],
|
331
|
+
group: {
|
332
|
+
...relsData,
|
333
|
+
array: [
|
334
|
+
{
|
335
|
+
...relsData
|
336
|
+
}
|
337
|
+
]
|
338
|
+
},
|
339
|
+
groupLocalized: {
|
340
|
+
en: {
|
341
|
+
...relsData,
|
342
|
+
array: [
|
343
|
+
{
|
344
|
+
...relsData
|
345
|
+
}
|
346
|
+
]
|
347
|
+
},
|
348
|
+
es: {
|
349
|
+
...relsData,
|
350
|
+
array: [
|
351
|
+
{
|
352
|
+
...relsData
|
353
|
+
}
|
354
|
+
]
|
355
|
+
}
|
356
|
+
},
|
357
|
+
tab: {
|
358
|
+
...relsData
|
359
|
+
},
|
360
|
+
tabLocalized: {
|
361
|
+
en: {
|
362
|
+
...relsData
|
363
|
+
},
|
364
|
+
es: {
|
365
|
+
...relsData
|
366
|
+
}
|
367
|
+
}
|
368
|
+
};
|
369
|
+
const flattenValuesBefore = Object.values(flattenRelationshipValues(data));
|
370
|
+
sanitizeRelationshipIDs({
|
371
|
+
config,
|
372
|
+
data,
|
373
|
+
fields: config.collections[0].fields
|
374
|
+
});
|
375
|
+
const flattenValuesAfter = Object.values(flattenRelationshipValues(data));
|
376
|
+
flattenValuesAfter.forEach((value, i)=>{
|
377
|
+
expect(value).toBeInstanceOf(Types.ObjectId);
|
378
|
+
expect(flattenValuesBefore[i]).toBe(value.toHexString());
|
379
|
+
});
|
380
|
+
});
|
381
|
+
});
|
382
|
+
|
383
|
+
//# sourceMappingURL=sanitizeRelationshipIDs.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/sanitizeRelationshipIDs.spec.ts"],"sourcesContent":["import type { Field, SanitizedConfig } from 'payload'\n\nimport { Types } from 'mongoose'\n\nimport { sanitizeRelationshipIDs } from './sanitizeRelationshipIDs.js'\n\nconst flattenRelationshipValues = (obj: Record<string, any>, prefix = ''): Record<string, any> => {\n return Object.keys(obj).reduce(\n (acc, key) => {\n const fullKey = prefix ? `${prefix}.${key}` : key\n const value = obj[key]\n\n if (value && typeof value === 'object' && !(value instanceof Types.ObjectId)) {\n Object.assign(acc, flattenRelationshipValues(value, fullKey))\n // skip relationTo and blockType\n } else if (!fullKey.endsWith('relationTo') && !fullKey.endsWith('blockType')) {\n acc[fullKey] = value\n }\n\n return acc\n },\n {} as Record<string, any>,\n )\n}\n\nconst relsFields: Field[] = [\n {\n name: 'rel_1',\n type: 'relationship',\n relationTo: 'rels',\n },\n {\n name: 'rel_1_l',\n type: 'relationship',\n localized: true,\n relationTo: 'rels',\n },\n {\n name: 'rel_2',\n type: 'relationship',\n hasMany: true,\n relationTo: 'rels',\n },\n {\n name: 'rel_2_l',\n type: 'relationship',\n hasMany: true,\n localized: true,\n relationTo: 'rels',\n },\n {\n name: 'rel_3',\n type: 'relationship',\n relationTo: ['rels'],\n },\n {\n name: 'rel_3_l',\n type: 'relationship',\n localized: true,\n relationTo: ['rels'],\n },\n {\n name: 'rel_4',\n type: 'relationship',\n hasMany: true,\n relationTo: ['rels'],\n },\n {\n name: 'rel_4_l',\n type: 'relationship',\n hasMany: true,\n localized: true,\n relationTo: ['rels'],\n },\n]\n\nconst config = {\n collections: [\n {\n slug: 'docs',\n fields: [\n ...relsFields,\n {\n name: 'array',\n type: 'array',\n fields: [\n {\n name: 'array',\n type: 'array',\n fields: relsFields,\n },\n {\n name: 'blocks',\n type: 'blocks',\n blocks: [{ slug: 'block', fields: relsFields }],\n },\n ...relsFields,\n ],\n },\n {\n name: 'arrayLocalized',\n type: 'array',\n fields: [\n {\n name: 'array',\n type: 'array',\n fields: relsFields,\n },\n {\n name: 'blocks',\n type: 'blocks',\n blocks: [{ slug: 'block', fields: relsFields }],\n },\n ...relsFields,\n ],\n localized: true,\n },\n {\n name: 'blocks',\n type: 'blocks',\n blocks: [\n {\n slug: 'block',\n fields: [\n ...relsFields,\n {\n name: 'group',\n type: 'group',\n fields: relsFields,\n },\n {\n name: 'array',\n type: 'array',\n fields: relsFields,\n },\n ],\n },\n ],\n },\n {\n name: 'group',\n type: 'group',\n fields: [\n ...relsFields,\n {\n name: 'array',\n type: 'array',\n fields: relsFields,\n },\n ],\n },\n {\n name: 'groupLocalized',\n type: 'group',\n fields: [\n ...relsFields,\n {\n name: 'array',\n type: 'array',\n fields: relsFields,\n },\n ],\n localized: true,\n },\n {\n type: 'tabs',\n tabs: [\n {\n name: 'tab',\n fields: relsFields,\n },\n {\n name: 'tabLocalized',\n fields: relsFields,\n localized: true,\n },\n ],\n },\n ],\n },\n {\n slug: 'rels',\n fields: [],\n },\n ],\n localization: {\n defaultLocale: 'en',\n localeCodes: ['en', 'es'],\n locales: [\n { code: 'en', label: 'EN' },\n { code: 'es', label: 'ES' },\n ],\n },\n} as SanitizedConfig\n\nconst relsData = {\n rel_1: new Types.ObjectId().toHexString(),\n rel_1_l: {\n en: new Types.ObjectId().toHexString(),\n es: new Types.ObjectId().toHexString(),\n },\n rel_2: [new Types.ObjectId().toHexString()],\n rel_2_l: {\n en: [new Types.ObjectId().toHexString()],\n es: [new Types.ObjectId().toHexString()],\n },\n rel_3: {\n relationTo: 'rels',\n value: new Types.ObjectId().toHexString(),\n },\n rel_3_l: {\n en: {\n relationTo: 'rels',\n value: new Types.ObjectId().toHexString(),\n },\n es: {\n relationTo: 'rels',\n value: new Types.ObjectId().toHexString(),\n },\n },\n rel_4: [\n {\n relationTo: 'rels',\n value: new Types.ObjectId().toHexString(),\n },\n ],\n rel_4_l: {\n en: [\n {\n relationTo: 'rels',\n value: new Types.ObjectId().toHexString(),\n },\n ],\n es: [\n {\n relationTo: 'rels',\n value: new Types.ObjectId().toHexString(),\n },\n ],\n },\n}\n\ndescribe('sanitizeRelationshipIDs', () => {\n it('should sanitize relationships', () => {\n const data = {\n ...relsData,\n array: [\n {\n ...relsData,\n array: [{ ...relsData }],\n blocks: [\n {\n blockType: 'block',\n ...relsData,\n },\n ],\n },\n ],\n arrayLocalized: {\n en: [\n {\n ...relsData,\n array: [{ ...relsData }],\n blocks: [\n {\n blockType: 'block',\n ...relsData,\n },\n ],\n },\n ],\n es: [\n {\n ...relsData,\n array: [{ ...relsData }],\n blocks: [\n {\n blockType: 'block',\n ...relsData,\n },\n ],\n },\n ],\n },\n blocks: [\n {\n blockType: 'block',\n ...relsData,\n array: [{ ...relsData }],\n group: { ...relsData },\n },\n ],\n group: {\n ...relsData,\n array: [{ ...relsData }],\n },\n groupLocalized: {\n en: {\n ...relsData,\n array: [{ ...relsData }],\n },\n es: {\n ...relsData,\n array: [{ ...relsData }],\n },\n },\n tab: { ...relsData },\n tabLocalized: {\n en: { ...relsData },\n es: { ...relsData },\n },\n }\n const flattenValuesBefore = Object.values(flattenRelationshipValues(data))\n\n sanitizeRelationshipIDs({ config, data, fields: config.collections[0].fields })\n const flattenValuesAfter = Object.values(flattenRelationshipValues(data))\n\n flattenValuesAfter.forEach((value, i) => {\n expect(value).toBeInstanceOf(Types.ObjectId)\n expect(flattenValuesBefore[i]).toBe(value.toHexString())\n })\n })\n})\n"],"names":["Types","sanitizeRelationshipIDs","flattenRelationshipValues","obj","prefix","Object","keys","reduce","acc","key","fullKey","value","ObjectId","assign","endsWith","relsFields","name","type","relationTo","localized","hasMany","config","collections","slug","fields","blocks","tabs","localization","defaultLocale","localeCodes","locales","code","label","relsData","rel_1","toHexString","rel_1_l","en","es","rel_2","rel_2_l","rel_3","rel_3_l","rel_4","rel_4_l","describe","it","data","array","blockType","arrayLocalized","group","groupLocalized","tab","tabLocalized","flattenValuesBefore","values","flattenValuesAfter","forEach","i","expect","toBeInstanceOf","toBe"],"mappings":"AAEA,SAASA,KAAK,QAAQ,WAAU;AAEhC,SAASC,uBAAuB,QAAQ,+BAA8B;AAEtE,MAAMC,4BAA4B,CAACC,KAA0BC,SAAS,EAAE;IACtE,OAAOC,OAAOC,IAAI,CAACH,KAAKI,MAAM,CAC5B,CAACC,KAAKC;QACJ,MAAMC,UAAUN,SAAS,CAAC,EAAEA,OAAO,CAAC,EAAEK,IAAI,CAAC,GAAGA;QAC9C,MAAME,QAAQR,GAAG,CAACM,IAAI;QAEtB,IAAIE,SAAS,OAAOA,UAAU,YAAY,CAAEA,CAAAA,iBAAiBX,MAAMY,QAAQ,AAAD,GAAI;YAC5EP,OAAOQ,MAAM,CAACL,KAAKN,0BAA0BS,OAAOD;QACpD,gCAAgC;QA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;oBACXe,OAAO;wBAAC;4BAAE,GAAGf,QAAQ;wBAAC;qBAAE;oBACxBkB,OAAO;wBAAE,GAAGlB,QAAQ;oBAAC;gBACvB;aACD;YACDkB,OAAO;gBACL,GAAGlB,QAAQ;gBACXe,OAAO;oBAAC;wBAAE,GAAGf,QAAQ;oBAAC;iBAAE;YAC1B;YACAmB,gBAAgB;gBACdf,IAAI;oBACF,GAAGJ,QAAQ;oBACXe,OAAO;wBAAC;4BAAE,GAAGf,QAAQ;wBAAC;qBAAE;gBAC1B;gBACAK,IAAI;oBACF,GAAGL,QAAQ;oBACXe,OAAO;wBAAC;4BAAE,GAAGf,QAAQ;wBAAC;qBAAE;gBAC1B;YACF;YACAoB,KAAK;gBAAE,GAAGpB,QAAQ;YAAC;YACnBqB,cAAc;gBACZjB,IAAI;oBAAE,GAAGJ,QAAQ;gBAAC;gBAClBK,IAAI;oBAAE,GAAGL,QAAQ;gBAAC;YACpB;QACF;QACA,MAAMsB,sBAAsBlD,OAAOmD,MAAM,CAACtD,0BAA0B6C;QAEpE9C,wBAAwB;YAAEoB;YAAQ0B;YAAMvB,QAAQH,OAAOC,WAAW,CAAC,EAAE,CAACE,MAAM;QAAC;QAC7E,MAAMiC,qBAAqBpD,OAAOmD,MAAM,CAACtD,0BAA0B6C;QAEnEU,mBAAmBC,OAAO,CAAC,CAAC/C,OAAOgD;YACjCC,OAAOjD,OAAOkD,cAAc,CAAC7D,MAAMY,QAAQ;YAC3CgD,OAAOL,mBAAmB,CAACI,EAAE,EAAEG,IAAI,CAACnD,MAAMwB,WAAW;QACvD;IACF;AACF"}
|
package/dist/withSession.d.ts
CHANGED
@@ -1,35 +1,11 @@
|
|
1
|
-
/// <reference types="mongoose/types/aggregate.js" />
|
2
|
-
/// <reference types="mongoose/types/callback.js" />
|
3
|
-
/// <reference types="mongoose/types/collection.js" />
|
4
|
-
/// <reference types="mongoose/types/connection.js" />
|
5
|
-
/// <reference types="mongoose/types/cursor.js" />
|
6
|
-
/// <reference types="mongoose/types/document.js" />
|
7
|
-
/// <reference types="mongoose/types/error.js" />
|
8
|
-
/// <reference types="mongoose/types/expressions.js" />
|
9
|
-
/// <reference types="mongoose/types/helpers.js" />
|
10
|
-
/// <reference types="mongoose/types/middlewares.js" />
|
11
|
-
/// <reference types="mongoose/types/indexes.js" />
|
12
|
-
/// <reference types="mongoose/types/models.js" />
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions.js" />
|
14
|
-
/// <reference types="mongoose/types/pipelinestage.js" />
|
15
|
-
/// <reference types="mongoose/types/populate.js" />
|
16
|
-
/// <reference types="mongoose/types/query.js" />
|
17
|
-
/// <reference types="mongoose/types/schemaoptions.js" />
|
18
|
-
/// <reference types="mongoose/types/schematypes.js" />
|
19
|
-
/// <reference types="mongoose/types/session.js" />
|
20
|
-
/// <reference types="mongoose/types/types.js" />
|
21
|
-
/// <reference types="mongoose/types/utility.js" />
|
22
|
-
/// <reference types="mongoose/types/validation.js" />
|
23
|
-
/// <reference types="mongoose/types/virtuals.js" />
|
24
|
-
/// <reference types="mongoose/types/inferschematype.js" />
|
25
|
-
/// <reference types="mongoose-paginate-v2" />
|
26
1
|
import type { ClientSession } from 'mongoose';
|
2
|
+
import type { PayloadRequest } from 'payload';
|
27
3
|
import type { MongooseAdapter } from './index.js';
|
28
4
|
/**
|
29
5
|
* returns the session belonging to the transaction of the req.session if exists
|
30
6
|
* @returns ClientSession
|
31
7
|
*/
|
32
|
-
export declare function withSession(db: MongooseAdapter,
|
8
|
+
export declare function withSession(db: MongooseAdapter, req: PayloadRequest): Promise<{
|
33
9
|
session: ClientSession;
|
34
|
-
} |
|
10
|
+
} | Record<string, never>>;
|
35
11
|
//# sourceMappingURL=withSession.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withSession.d.ts","sourceRoot":"","sources":["../src/withSession.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"withSession.d.ts","sourceRoot":"","sources":["../src/withSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,EAAE,EAAE,eAAe,EACnB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAU7D"}
|
package/dist/withSession.js
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
/**
|
2
2
|
* returns the session belonging to the transaction of the req.session if exists
|
3
3
|
* @returns ClientSession
|
4
|
-
*/ export function withSession(db,
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
*/ export async function withSession(db, req) {
|
5
|
+
let transactionID = req.transactionID;
|
6
|
+
if (transactionID instanceof Promise) {
|
7
|
+
transactionID = await req.transactionID;
|
8
|
+
}
|
9
|
+
if (req) {
|
10
|
+
return db.sessions[transactionID] ? {
|
11
|
+
session: db.sessions[transactionID]
|
12
|
+
} : {};
|
13
|
+
}
|
8
14
|
}
|
9
15
|
|
10
16
|
//# sourceMappingURL=withSession.js.map
|
package/dist/withSession.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/withSession.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\n\nimport type { MongooseAdapter } from './index.js'\n\n/**\n * returns the session belonging to the transaction of the req.session if exists\n * @returns ClientSession\n */\nexport function withSession(\n db: MongooseAdapter,\n
|
1
|
+
{"version":3,"sources":["../src/withSession.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\nimport type { PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\n/**\n * returns the session belonging to the transaction of the req.session if exists\n * @returns ClientSession\n */\nexport async function withSession(\n db: MongooseAdapter,\n req: PayloadRequest,\n): Promise<{ session: ClientSession } | Record<string, never>> {\n let transactionID = req.transactionID\n\n if (transactionID instanceof Promise) {\n transactionID = await req.transactionID\n }\n\n if (req) {\n return db.sessions[transactionID] ? { session: db.sessions[transactionID] } : {}\n }\n}\n"],"names":["withSession","db","req","transactionID","Promise","sessions","session"],"mappings":"AAKA;;;CAGC,GACD,OAAO,eAAeA,YACpBC,EAAmB,EACnBC,GAAmB;IAEnB,IAAIC,gBAAgBD,IAAIC,aAAa;IAErC,IAAIA,yBAAyBC,SAAS;QACpCD,gBAAgB,MAAMD,IAAIC,aAAa;IACzC;IAEA,IAAID,KAAK;QACP,OAAOD,GAAGI,QAAQ,CAACF,cAAc,GAAG;YAAEG,SAASL,GAAGI,QAAQ,CAACF,cAAc;QAAC,IAAI,CAAC;IACjF;AACF"}
|
package/license.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018-2024 Payload CMS, Inc. <info@payloadcms.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
3
|
-
"version": "3.0.0-canary.
|
3
|
+
"version": "3.0.0-canary.fb04843",
|
4
4
|
"description": "The officially supported MongoDB database adapter for Payload",
|
5
5
|
"homepage": "https://payloadcms.com",
|
6
6
|
"repository": {
|
@@ -10,12 +10,24 @@
|
|
10
10
|
},
|
11
11
|
"license": "MIT",
|
12
12
|
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
13
|
+
"maintainers": [
|
14
|
+
{
|
15
|
+
"name": "Payload",
|
16
|
+
"email": "info@payloadcms.com",
|
17
|
+
"url": "https://payloadcms.com"
|
18
|
+
}
|
19
|
+
],
|
13
20
|
"type": "module",
|
14
21
|
"exports": {
|
15
22
|
".": {
|
16
23
|
"import": "./dist/index.js",
|
17
|
-
"
|
18
|
-
"
|
24
|
+
"types": "./dist/index.d.ts",
|
25
|
+
"default": "./dist/index.js"
|
26
|
+
},
|
27
|
+
"./migration-utils": {
|
28
|
+
"import": "./dist/exports/migration-utils.js",
|
29
|
+
"types": "./dist/exports/migration-utils.d.ts",
|
30
|
+
"default": "./dist/exports/migration-utils.js"
|
19
31
|
}
|
20
32
|
},
|
21
33
|
"main": "./dist/index.js",
|
@@ -26,29 +38,29 @@
|
|
26
38
|
"predefinedMigrations"
|
27
39
|
],
|
28
40
|
"dependencies": {
|
29
|
-
"bson-objectid": "2.0.4",
|
30
|
-
"deepmerge": "4.3.1",
|
31
|
-
"get-port": "5.1.1",
|
32
41
|
"http-status": "1.6.2",
|
33
|
-
"mongoose": "
|
34
|
-
"mongoose-paginate-v2": "1.
|
42
|
+
"mongoose": "8.8.1",
|
43
|
+
"mongoose-aggregate-paginate-v2": "1.1.2",
|
44
|
+
"mongoose-paginate-v2": "1.8.5",
|
35
45
|
"prompts": "2.4.2",
|
36
|
-
"uuid": "
|
46
|
+
"uuid": "10.0.0"
|
37
47
|
},
|
38
48
|
"devDependencies": {
|
39
|
-
"@types/mongoose-aggregate-paginate-v2": "1.0.
|
40
|
-
"mongodb": "
|
49
|
+
"@types/mongoose-aggregate-paginate-v2": "1.0.12",
|
50
|
+
"mongodb": "6.10.0",
|
41
51
|
"mongodb-memory-server": "^9",
|
42
|
-
"@payloadcms/eslint-config": "
|
43
|
-
"payload": "3.0.0-canary.
|
52
|
+
"@payloadcms/eslint-config": "3.0.0-beta.112",
|
53
|
+
"payload": "3.0.0-canary.fb04843"
|
44
54
|
},
|
45
55
|
"peerDependencies": {
|
46
|
-
"payload": "3.0.0-canary.
|
56
|
+
"payload": "3.0.0-canary.fb04843"
|
47
57
|
},
|
48
58
|
"scripts": {
|
49
|
-
"build": "pnpm build:
|
50
|
-
"build:swc": "swc ./src -d ./dist --config-file .swcrc-build",
|
59
|
+
"build": "pnpm build:types && pnpm build:swc",
|
60
|
+
"build:swc": "swc ./src -d ./dist --config-file .swcrc-build --strip-leading-paths",
|
51
61
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
52
|
-
"clean": "rimraf {dist,*.tsbuildinfo}"
|
62
|
+
"clean": "rimraf {dist,*.tsbuildinfo}",
|
63
|
+
"lint": "eslint .",
|
64
|
+
"lint:fix": "eslint . --fix"
|
53
65
|
}
|
54
66
|
}
|