@payloadcms/db-mongodb 3.0.0-canary.f83d96a → 3.0.0-canary.fb04843
Sign up to get free protection for your applications and to get access to all the features.
- 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.map +1 -1
- package/dist/count.js +9 -2
- 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.map +1 -1
- package/dist/create.js +11 -2
- package/dist/create.js.map +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.map +1 -1
- package/dist/createMigration.js +9 -7
- 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.map +1 -1
- package/dist/deleteMany.js +1 -1
- package/dist/deleteMany.js.map +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.map +1 -1
- package/dist/deleteVersions.js +1 -1
- package/dist/deleteVersions.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.map +1 -1
- package/dist/find.js +35 -6
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +10 -4
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +18 -7
- package/dist/findGlobalVersions.js.map +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.map +1 -1
- package/dist/findVersions.js +17 -6
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts +59 -10
- 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.map +1 -1
- package/dist/init.js +18 -16
- package/dist/init.js.map +1 -1
- package/dist/migrateFresh.js.map +1 -1
- package/dist/models/buildCollectionSchema.d.ts +1 -2
- 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.js +2 -2
- package/dist/models/buildGlobalModel.js.map +1 -1
- package/dist/models/buildSchema.d.ts +1 -2
- 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 +5 -95
- package/dist/predefinedMigrations/versions-v1-v2.js.map +1 -1
- 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 +2 -2
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +1 -2
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +28 -18
- package/dist/queries/buildSearchParams.js.map +1 -1
- package/dist/queries/buildSortParam.d.ts +2 -2
- 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.spec.js +43 -43
- package/dist/queries/getLocalizedSortProperty.spec.js.map +1 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +7 -5
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +144 -27
- package/dist/queries/sanitizeQueryValue.js.map +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/transactions/beginTransaction.d.ts.map +1 -1
- package/dist/transactions/beginTransaction.js +2 -0
- package/dist/transactions/beginTransaction.js.map +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.map +1 -1
- package/dist/transactions/rollbackTransaction.js +13 -7
- package/dist/transactions/rollbackTransaction.js.map +1 -1
- package/dist/types.d.ts +7 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +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 -2
- 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.map +1 -1
- package/dist/updateOne.js +19 -5
- 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.map +1 -1
- package/dist/utilities/getDBName.js +3 -1
- package/dist/utilities/getDBName.js.map +1 -1
- package/dist/utilities/handleError.js +2 -2
- 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 -2
- 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 +24 -11
@@ -5,20 +5,17 @@ describe('get localized sort property', ()=>{
|
|
5
5
|
beforeAll(async ()=>{
|
6
6
|
config = await sanitizeConfig({
|
7
7
|
localization: {
|
8
|
+
defaultLocale: 'en',
|
9
|
+
fallback: true,
|
8
10
|
locales: [
|
9
11
|
'en',
|
10
12
|
'es'
|
11
|
-
]
|
12
|
-
defaultLocale: 'en',
|
13
|
-
fallback: true
|
13
|
+
]
|
14
14
|
}
|
15
15
|
});
|
16
16
|
});
|
17
|
-
it('passes through a non-localized sort property',
|
17
|
+
it('passes through a non-localized sort property', ()=>{
|
18
18
|
const result = getLocalizedSortProperty({
|
19
|
-
segments: [
|
20
|
-
'title'
|
21
|
-
],
|
22
19
|
config,
|
23
20
|
fields: [
|
24
21
|
{
|
@@ -26,15 +23,15 @@ describe('get localized sort property', ()=>{
|
|
26
23
|
type: 'text'
|
27
24
|
}
|
28
25
|
],
|
29
|
-
locale: 'en'
|
26
|
+
locale: 'en',
|
27
|
+
segments: [
|
28
|
+
'title'
|
29
|
+
]
|
30
30
|
});
|
31
31
|
expect(result).toStrictEqual('title');
|
32
32
|
});
|
33
33
|
it('properly localizes an un-localized sort property', ()=>{
|
34
34
|
const result = getLocalizedSortProperty({
|
35
|
-
segments: [
|
36
|
-
'title'
|
37
|
-
],
|
38
35
|
config,
|
39
36
|
fields: [
|
40
37
|
{
|
@@ -43,16 +40,15 @@ describe('get localized sort property', ()=>{
|
|
43
40
|
localized: true
|
44
41
|
}
|
45
42
|
],
|
46
|
-
locale: 'en'
|
43
|
+
locale: 'en',
|
44
|
+
segments: [
|
45
|
+
'title'
|
46
|
+
]
|
47
47
|
});
|
48
48
|
expect(result).toStrictEqual('title.en');
|
49
49
|
});
|
50
50
|
it('keeps specifically asked-for localized sort properties', ()=>{
|
51
51
|
const result = getLocalizedSortProperty({
|
52
|
-
segments: [
|
53
|
-
'title',
|
54
|
-
'es'
|
55
|
-
],
|
56
52
|
config,
|
57
53
|
fields: [
|
58
54
|
{
|
@@ -61,16 +57,16 @@ describe('get localized sort property', ()=>{
|
|
61
57
|
localized: true
|
62
58
|
}
|
63
59
|
],
|
64
|
-
locale: 'en'
|
60
|
+
locale: 'en',
|
61
|
+
segments: [
|
62
|
+
'title',
|
63
|
+
'es'
|
64
|
+
]
|
65
65
|
});
|
66
66
|
expect(result).toStrictEqual('title.es');
|
67
67
|
});
|
68
68
|
it('properly localizes nested sort properties', ()=>{
|
69
69
|
const result = getLocalizedSortProperty({
|
70
|
-
segments: [
|
71
|
-
'group',
|
72
|
-
'title'
|
73
|
-
],
|
74
70
|
config,
|
75
71
|
fields: [
|
76
72
|
{
|
@@ -85,17 +81,16 @@ describe('get localized sort property', ()=>{
|
|
85
81
|
]
|
86
82
|
}
|
87
83
|
],
|
88
|
-
locale: 'en'
|
84
|
+
locale: 'en',
|
85
|
+
segments: [
|
86
|
+
'group',
|
87
|
+
'title'
|
88
|
+
]
|
89
89
|
});
|
90
90
|
expect(result).toStrictEqual('group.title.en');
|
91
91
|
});
|
92
92
|
it('keeps requested locale with nested sort properties', ()=>{
|
93
93
|
const result = getLocalizedSortProperty({
|
94
|
-
segments: [
|
95
|
-
'group',
|
96
|
-
'title',
|
97
|
-
'es'
|
98
|
-
],
|
99
94
|
config,
|
100
95
|
fields: [
|
101
96
|
{
|
@@ -110,15 +105,17 @@ describe('get localized sort property', ()=>{
|
|
110
105
|
]
|
111
106
|
}
|
112
107
|
],
|
113
|
-
locale: 'en'
|
108
|
+
locale: 'en',
|
109
|
+
segments: [
|
110
|
+
'group',
|
111
|
+
'title',
|
112
|
+
'es'
|
113
|
+
]
|
114
114
|
});
|
115
115
|
expect(result).toStrictEqual('group.title.es');
|
116
116
|
});
|
117
117
|
it('properly localizes field within row', ()=>{
|
118
118
|
const result = getLocalizedSortProperty({
|
119
|
-
segments: [
|
120
|
-
'title'
|
121
|
-
],
|
122
119
|
config,
|
123
120
|
fields: [
|
124
121
|
{
|
@@ -132,16 +129,15 @@ describe('get localized sort property', ()=>{
|
|
132
129
|
]
|
133
130
|
}
|
134
131
|
],
|
135
|
-
locale: 'en'
|
132
|
+
locale: 'en',
|
133
|
+
segments: [
|
134
|
+
'title'
|
135
|
+
]
|
136
136
|
});
|
137
137
|
expect(result).toStrictEqual('title.en');
|
138
138
|
});
|
139
139
|
it('properly localizes field within named tab', ()=>{
|
140
140
|
const result = getLocalizedSortProperty({
|
141
|
-
segments: [
|
142
|
-
'tab',
|
143
|
-
'title'
|
144
|
-
],
|
145
141
|
config,
|
146
142
|
fields: [
|
147
143
|
{
|
@@ -160,34 +156,38 @@ describe('get localized sort property', ()=>{
|
|
160
156
|
]
|
161
157
|
}
|
162
158
|
],
|
163
|
-
locale: 'en'
|
159
|
+
locale: 'en',
|
160
|
+
segments: [
|
161
|
+
'tab',
|
162
|
+
'title'
|
163
|
+
]
|
164
164
|
});
|
165
165
|
expect(result).toStrictEqual('tab.title.en');
|
166
166
|
});
|
167
167
|
it('properly localizes field within unnamed tab', ()=>{
|
168
168
|
const result = getLocalizedSortProperty({
|
169
|
-
segments: [
|
170
|
-
'title'
|
171
|
-
],
|
172
169
|
config,
|
173
170
|
fields: [
|
174
171
|
{
|
175
172
|
type: 'tabs',
|
176
173
|
tabs: [
|
177
174
|
{
|
178
|
-
label: 'Tab',
|
179
175
|
fields: [
|
180
176
|
{
|
181
177
|
name: 'title',
|
182
178
|
type: 'text',
|
183
179
|
localized: true
|
184
180
|
}
|
185
|
-
]
|
181
|
+
],
|
182
|
+
label: 'Tab'
|
186
183
|
}
|
187
184
|
]
|
188
185
|
}
|
189
186
|
],
|
190
|
-
locale: 'en'
|
187
|
+
locale: 'en',
|
188
|
+
segments: [
|
189
|
+
'title'
|
190
|
+
]
|
191
191
|
});
|
192
192
|
expect(result).toStrictEqual('title.en');
|
193
193
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/queries/getLocalizedSortProperty.spec.ts"],"sourcesContent":["import {
|
1
|
+
{"version":3,"sources":["../../src/queries/getLocalizedSortProperty.spec.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload'\n\nimport { sanitizeConfig } from 'payload'\n\nimport { getLocalizedSortProperty } from './getLocalizedSortProperty.js'\n\nlet config: SanitizedConfig\n\ndescribe('get localized sort property', () => {\n beforeAll(async () => {\n config = await sanitizeConfig({\n localization: {\n defaultLocale: 'en',\n fallback: true,\n locales: ['en', 'es'],\n },\n } as Config)\n })\n it('passes through a non-localized sort property', () => {\n const result = getLocalizedSortProperty({\n config,\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n ],\n locale: 'en',\n segments: ['title'],\n })\n\n expect(result).toStrictEqual('title')\n })\n\n it('properly localizes an un-localized sort property', () => {\n const result = getLocalizedSortProperty({\n config,\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n locale: 'en',\n segments: ['title'],\n })\n\n expect(result).toStrictEqual('title.en')\n })\n\n it('keeps specifically asked-for localized sort properties', () => {\n const result = getLocalizedSortProperty({\n config,\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n locale: 'en',\n segments: ['title', 'es'],\n })\n\n expect(result).toStrictEqual('title.es')\n })\n\n it('properly localizes nested sort properties', () => {\n const result = getLocalizedSortProperty({\n config,\n fields: [\n {\n name: 'group',\n type: 'group',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n locale: 'en',\n segments: ['group', 'title'],\n })\n\n expect(result).toStrictEqual('group.title.en')\n })\n\n it('keeps requested locale with nested sort properties', () => {\n const result = getLocalizedSortProperty({\n config,\n fields: [\n {\n name: 'group',\n type: 'group',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n locale: 'en',\n segments: ['group', 'title', 'es'],\n })\n\n expect(result).toStrictEqual('group.title.es')\n })\n\n it('properly localizes field within row', () => {\n const result = getLocalizedSortProperty({\n config,\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n locale: 'en',\n segments: ['title'],\n })\n\n expect(result).toStrictEqual('title.en')\n })\n\n it('properly localizes field within named tab', () => {\n const result = getLocalizedSortProperty({\n config,\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n name: 'tab',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n },\n ],\n locale: 'en',\n segments: ['tab', 'title'],\n })\n\n expect(result).toStrictEqual('tab.title.en')\n })\n\n it('properly localizes field within unnamed tab', () => {\n const result = getLocalizedSortProperty({\n config,\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n label: 'Tab',\n },\n ],\n },\n ],\n locale: 'en',\n segments: ['title'],\n })\n\n expect(result).toStrictEqual('title.en')\n })\n})\n"],"names":["sanitizeConfig","getLocalizedSortProperty","config","describe","beforeAll","localization","defaultLocale","fallback","locales","it","result","fields","name","type","locale","segments","expect","toStrictEqual","localized","tabs","label"],"mappings":"AAEA,SAASA,cAAc,QAAQ,UAAS;AAExC,SAASC,wBAAwB,QAAQ,gCAA+B;AAExE,IAAIC;AAEJC,SAAS,+BAA+B;IACtCC,UAAU;QACRF,SAAS,MAAMF,eAAe;YAC5BK,cAAc;gBACZC,eAAe;gBACfC,UAAU;gBACVC,SAAS;oBAAC;oBAAM;i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,uCAAuC;QACxC,MAAMC,SAAST,yBAAyB;YACtCC;YACAS,QAAQ;gBACN;oBACEE,MAAM;oBACNF,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNK,WAAW;wBACb;qBACD;gBACH;aACD;YACDJ,QAAQ;YACRC,UAAU;gBAAC;aAAQ;QACrB;QAEAC,OAAON,QAAQO,aAAa,CAAC;IAC/B;IAEAR,GAAG,6CAA6C;QAC9C,MAAMC,SAAST,yBAAyB;YACtCC;YACAS,QAAQ;gBACN;oBACEE,MAAM;oBACNM,MAAM;wBACJ;4BACEP,MAAM;4BACND,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNK,WAAW;gCACb;6BACD;wBACH;qBACD;gBACH;aACD;YACDJ,QAAQ;YACRC,UAAU;gBAAC;gBAAO;aAAQ;QAC5B;QAEAC,OAAON,QAAQO,aAAa,CAAC;IAC/B;IAEAR,GAAG,+CAA+C;QAChD,MAAMC,SAAST,yBAAyB;YACtCC;YACAS,QAAQ;gBACN;oBACEE,MAAM;oBACNM,MAAM;wBACJ;4BACER,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNK,WAAW;gCACb;6BACD;4BACDE,OAAO;wBACT;qBACD;gBACH;aACD;YACDN,QAAQ;YACRC,UAAU;gBAAC;aAAQ;QACrB;QAEAC,OAAON,QAAQO,aAAa,CAAC;IAC/B;AACF"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parseParams.d.ts","sourceRoot":"","sources":["../../src/queries/parseParams.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"parseParams.d.ts","sourceRoot":"","sources":["../../src/queries/parseParams.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAY,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAQ9D,wBAAsB,WAAW,CAAC,EAChC,cAAc,EACd,MAAM,EACN,UAAU,EACV,MAAM,EACN,OAAO,EACP,KAAK,GACN,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA+DnC"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { combineMerge } from 'payload';
|
1
|
+
import { deepMergeWithCombinedArrays } from 'payload';
|
3
2
|
import { validOperators } from 'payload/shared';
|
4
3
|
import { buildAndOrConditions } from './buildAndOrConditions.js';
|
5
4
|
import { buildSearchParam } from './buildSearchParams.js';
|
@@ -24,7 +23,9 @@ export async function parseParams({ collectionSlug, fields, globalSlug, locale,
|
|
24
23
|
payload,
|
25
24
|
where: condition
|
26
25
|
});
|
27
|
-
if (builtConditions.length > 0)
|
26
|
+
if (builtConditions.length > 0) {
|
27
|
+
result[conditionOperator] = builtConditions;
|
28
|
+
}
|
28
29
|
} else {
|
29
30
|
// It's a path - and there can be multiple comparisons on a single path.
|
30
31
|
// For example - title like 'test' and title not equal to 'tester'
|
@@ -49,8 +50,9 @@ export async function parseParams({ collectionSlug, fields, globalSlug, locale,
|
|
49
50
|
[searchParam.path]: searchParam.value
|
50
51
|
};
|
51
52
|
} else if (typeof searchParam?.value === 'object') {
|
52
|
-
result =
|
53
|
-
|
53
|
+
result = deepMergeWithCombinedArrays(result, searchParam.value, {
|
54
|
+
// dont clone Types.ObjectIDs
|
55
|
+
clone: false
|
54
56
|
});
|
55
57
|
}
|
56
58
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/queries/parseParams.ts"],"sourcesContent":["
|
1
|
+
{"version":3,"sources":["../../src/queries/parseParams.ts"],"sourcesContent":["import type { FilterQuery } from 'mongoose'\nimport type { Field, Operator, Payload, Where } from 'payload'\n\nimport { deepMergeWithCombinedArrays } from 'payload'\nimport { validOperators } from 'payload/shared'\n\nimport { buildAndOrConditions } from './buildAndOrConditions.js'\nimport { buildSearchParam } from './buildSearchParams.js'\n\nexport async function parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n payload,\n where,\n}: {\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n locale: string\n payload: Payload\n where: Where\n}): Promise<Record<string, unknown>> {\n let result = {} as FilterQuery<any>\n\n if (typeof where === 'object') {\n // We need to determine if the whereKey is an AND, OR, or a schema path\n for (const relationOrPath of Object.keys(where)) {\n const condition = where[relationOrPath]\n let conditionOperator: '$and' | '$or'\n if (relationOrPath.toLowerCase() === 'and') {\n conditionOperator = '$and'\n } else if (relationOrPath.toLowerCase() === 'or') {\n conditionOperator = '$or'\n }\n if (Array.isArray(condition)) {\n const builtConditions = await buildAndOrConditions({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n payload,\n where: condition,\n })\n if (builtConditions.length > 0) {\n result[conditionOperator] = builtConditions\n }\n } else {\n // It's a path - and there can be multiple comparisons on a single path.\n // For example - title like 'test' and title not equal to 'tester'\n // So we need to loop on keys again here to handle each operator independently\n const pathOperators = where[relationOrPath]\n if (typeof pathOperators === 'object') {\n for (const operator of Object.keys(pathOperators)) {\n if (validOperators.includes(operator as Operator)) {\n const searchParam = await buildSearchParam({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath: relationOrPath,\n locale,\n operator,\n payload,\n val: pathOperators[operator],\n })\n\n if (searchParam?.value && searchParam?.path) {\n result = {\n ...result,\n [searchParam.path]: searchParam.value,\n }\n } else if (typeof searchParam?.value === 'object') {\n result = deepMergeWithCombinedArrays(result, searchParam.value, {\n // dont clone Types.ObjectIDs\n clone: false,\n })\n }\n }\n }\n }\n }\n }\n }\n\n return result\n}\n"],"names":["deepMergeWithCombinedArrays","validOperators","buildAndOrConditions","buildSearchParam","parseParams","collectionSlug","fields","globalSlug","locale","payload","where","result","relationOrPath","Object","keys","condition","conditionOperator","toLowerCase","Array","isArray","builtConditions","length","pathOperators","operator","includes","searchParam","incomingPath","val","value","path","clone"],"mappings":"AAGA,SAASA,2BAA2B,QAAQ,UAAS;AACrD,SAASC,cAAc,QAAQ,iBAAgB;AAE/C,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,gBAAgB,QAAQ,yBAAwB;AAEzD,OAAO,eAAeC,YAAY,EAChCC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,KAAK,EAQN;IACC,IAAIC,SAAS,CAAC;IAEd,IAAI,OAAOD,UAAU,UAAU;QAC7B,uEAAuE;QACvE,KAAK,MAAME,kBAAkBC,OAAOC,IAAI,CAACJ,OAAQ;YAC/C,MAAMK,YAAYL,KAAK,CAACE,eAAe;YACvC,IAAII;YACJ,IAAIJ,eAAeK,WAAW,OAAO,OAAO;gBAC1CD,oBAAoB;YACtB,OAAO,IAAIJ,eAAeK,WAAW,OAAO,MAAM;gBAChDD,oBAAoB;YACtB;YACA,IAAIE,MAAMC,OAAO,CAACJ,YAAY;gBAC5B,MAAMK,kBAAkB,MAAMlB,qBAAqB;oBACjDG;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC,OAAOK;gBACT;gBACA,IAAIK,gBAAgBC,MAAM,GAAG,GAAG;oBAC9BV,MAAM,CAACK,kBAAkB,GAAGI;gBAC9B;YACF,OAAO;gBACL,wEAAwE;gBACxE,kEAAkE;gBAClE,8EAA8E;gBAC9E,MAAME,gBAAgBZ,KAAK,CAACE,eAAe;gBAC3C,IAAI,OAAOU,kBAAkB,UAAU;oBACrC,KAAK,MAAMC,YAAYV,OAAOC,IAAI,CAACQ,eAAgB;wBACjD,IAAIrB,eAAeuB,QAAQ,CAACD,WAAuB;4BACjD,MAAME,cAAc,MAAMtB,iBAAiB;gCACzCE;gCACAC;gCACAC;gCACAmB,cAAcd;gCACdJ;gCACAe;gCACAd;gCACAkB,KAAKL,aAAa,CAACC,SAAS;4BAC9B;4BAEA,IAAIE,aAAaG,SAASH,aAAaI,MAAM;gCAC3ClB,SAAS;oCACP,GAAGA,MAAM;oCACT,CAACc,YAAYI,IAAI,CAAC,EAAEJ,YAAYG,KAAK;gCACvC;4BACF,OAAO,IAAI,OAAOH,aAAaG,UAAU,UAAU;gCACjDjB,SAASX,4BAA4BW,QAAQc,YAAYG,KAAK,EAAE;oCAC9D,6BAA6B;oCAC7BE,OAAO;gCACT;4BACF;wBACF;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAOnB;AACT"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sanitizeQueryValue.d.ts","sourceRoot":"","sources":["../../src/queries/sanitizeQueryValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAKhD,KAAK,sBAAsB,GAAG;IAC5B,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;
|
1
|
+
{"version":3,"file":"sanitizeQueryValue.d.ts","sourceRoot":"","sources":["../../src/queries/sanitizeQueryValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAKhD,KAAK,sBAAsB,GAAG;IAC5B,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;AA0BD,eAAO,MAAM,kBAAkB,iDAM5B,sBAAsB,KAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;CAsOd,CAAA"}
|
@@ -1,33 +1,119 @@
|
|
1
|
-
import
|
1
|
+
import { Types } from 'mongoose';
|
2
2
|
import { createArrayFromCommaDelineated } from 'payload';
|
3
|
+
const buildExistsQuery = (formattedValue, path)=>{
|
4
|
+
if (formattedValue) {
|
5
|
+
return {
|
6
|
+
rawQuery: {
|
7
|
+
$and: [
|
8
|
+
{
|
9
|
+
[path]: {
|
10
|
+
$exists: true
|
11
|
+
}
|
12
|
+
},
|
13
|
+
{
|
14
|
+
[path]: {
|
15
|
+
$ne: null
|
16
|
+
}
|
17
|
+
},
|
18
|
+
{
|
19
|
+
[path]: {
|
20
|
+
$ne: ''
|
21
|
+
}
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}
|
25
|
+
};
|
26
|
+
} else {
|
27
|
+
return {
|
28
|
+
rawQuery: {
|
29
|
+
$or: [
|
30
|
+
{
|
31
|
+
[path]: {
|
32
|
+
$exists: false
|
33
|
+
}
|
34
|
+
},
|
35
|
+
{
|
36
|
+
[path]: {
|
37
|
+
$eq: null
|
38
|
+
}
|
39
|
+
},
|
40
|
+
{
|
41
|
+
[path]: {
|
42
|
+
$eq: ''
|
43
|
+
}
|
44
|
+
}
|
45
|
+
]
|
46
|
+
}
|
47
|
+
};
|
48
|
+
}
|
49
|
+
};
|
3
50
|
export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=>{
|
4
51
|
let formattedValue = val;
|
5
52
|
let formattedOperator = operator;
|
6
53
|
// Disregard invalid _ids
|
7
|
-
if (path === '_id'
|
8
|
-
if (
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
54
|
+
if (path === '_id') {
|
55
|
+
if (typeof val === 'string' && val.split(',').length === 1) {
|
56
|
+
if (!hasCustomID) {
|
57
|
+
const isValid = Types.ObjectId.isValid(val);
|
58
|
+
if (!isValid) {
|
59
|
+
return {
|
60
|
+
operator: formattedOperator,
|
61
|
+
val: undefined
|
62
|
+
};
|
63
|
+
} else {
|
64
|
+
if ([
|
65
|
+
'in',
|
66
|
+
'not_in'
|
67
|
+
].includes(operator)) {
|
68
|
+
formattedValue = createArrayFromCommaDelineated(formattedValue).map((id)=>new Types.ObjectId(id));
|
69
|
+
} else {
|
70
|
+
formattedValue = new Types.ObjectId(val);
|
71
|
+
}
|
72
|
+
}
|
15
73
|
}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
74
|
+
if (field.type === 'number') {
|
75
|
+
const parsedNumber = parseFloat(val);
|
76
|
+
if (Number.isNaN(parsedNumber)) {
|
77
|
+
return {
|
78
|
+
operator: formattedOperator,
|
79
|
+
val: undefined
|
80
|
+
};
|
81
|
+
}
|
24
82
|
}
|
83
|
+
} else if (Array.isArray(val) || typeof val === 'string' && val.split(',').length > 1) {
|
84
|
+
if (typeof val === 'string') {
|
85
|
+
formattedValue = createArrayFromCommaDelineated(val);
|
86
|
+
}
|
87
|
+
formattedValue = formattedValue.reduce((formattedValues, inVal)=>{
|
88
|
+
const newValues = [
|
89
|
+
inVal
|
90
|
+
];
|
91
|
+
if (!hasCustomID) {
|
92
|
+
if (Types.ObjectId.isValid(inVal)) {
|
93
|
+
newValues.push(new Types.ObjectId(inVal));
|
94
|
+
}
|
95
|
+
}
|
96
|
+
if (field.type === 'number') {
|
97
|
+
const parsedNumber = parseFloat(inVal);
|
98
|
+
if (!Number.isNaN(parsedNumber)) {
|
99
|
+
newValues.push(parsedNumber);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
return [
|
103
|
+
...formattedValues,
|
104
|
+
...newValues
|
105
|
+
];
|
106
|
+
}, []);
|
25
107
|
}
|
26
108
|
}
|
27
109
|
// Cast incoming values as proper searchable types
|
28
110
|
if (field.type === 'checkbox' && typeof val === 'string') {
|
29
|
-
if (val.toLowerCase() === 'true')
|
30
|
-
|
111
|
+
if (val.toLowerCase() === 'true') {
|
112
|
+
formattedValue = true;
|
113
|
+
}
|
114
|
+
if (val.toLowerCase() === 'false') {
|
115
|
+
formattedValue = false;
|
116
|
+
}
|
31
117
|
}
|
32
118
|
if ([
|
33
119
|
'all',
|
@@ -39,8 +125,14 @@ export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=
|
|
39
125
|
formattedValue = formattedValue.map((arrayVal)=>parseFloat(arrayVal));
|
40
126
|
}
|
41
127
|
}
|
42
|
-
if (field.type === 'number'
|
43
|
-
formattedValue
|
128
|
+
if (field.type === 'number') {
|
129
|
+
if (typeof formattedValue === 'string' && operator !== 'exists') {
|
130
|
+
formattedValue = Number(val);
|
131
|
+
}
|
132
|
+
if (operator === 'exists') {
|
133
|
+
formattedValue = val === 'true' ? true : val === 'false' ? false : Boolean(val);
|
134
|
+
return buildExistsQuery(formattedValue, path);
|
135
|
+
}
|
44
136
|
}
|
45
137
|
if (field.type === 'date' && typeof val === 'string' && operator !== 'exists') {
|
46
138
|
formattedValue = new Date(val);
|
@@ -57,6 +149,11 @@ export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=
|
|
57
149
|
}
|
58
150
|
// Object equality requires the value to be the first key in the object that is being queried.
|
59
151
|
if (operator === 'equals' && formattedValue && typeof formattedValue === 'object' && formattedValue.value && formattedValue.relationTo) {
|
152
|
+
const { value } = formattedValue;
|
153
|
+
const isValid = Types.ObjectId.isValid(value);
|
154
|
+
if (isValid) {
|
155
|
+
formattedValue.value = new Types.ObjectId(value);
|
156
|
+
}
|
60
157
|
return {
|
61
158
|
rawQuery: {
|
62
159
|
$and: [
|
@@ -74,20 +171,32 @@ export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=
|
|
74
171
|
}
|
75
172
|
};
|
76
173
|
}
|
77
|
-
if (
|
174
|
+
if ([
|
175
|
+
'in',
|
176
|
+
'not_in'
|
177
|
+
].includes(operator) && Array.isArray(formattedValue)) {
|
78
178
|
formattedValue = formattedValue.reduce((formattedValues, inVal)=>{
|
79
179
|
const newValues = [
|
80
180
|
inVal
|
81
181
|
];
|
82
|
-
if (
|
182
|
+
if (Types.ObjectId.isValid(inVal)) {
|
183
|
+
newValues.push(new Types.ObjectId(inVal));
|
184
|
+
}
|
83
185
|
const parsedNumber = parseFloat(inVal);
|
84
|
-
if (!Number.isNaN(parsedNumber))
|
186
|
+
if (!Number.isNaN(parsedNumber)) {
|
187
|
+
newValues.push(parsedNumber);
|
188
|
+
}
|
85
189
|
return [
|
86
190
|
...formattedValues,
|
87
191
|
...newValues
|
88
192
|
];
|
89
193
|
}, []);
|
90
194
|
}
|
195
|
+
if (typeof formattedValue === 'string') {
|
196
|
+
if (Types.ObjectId.isValid(formattedValue)) {
|
197
|
+
formattedValue = new Types.ObjectId(formattedValue);
|
198
|
+
}
|
199
|
+
}
|
91
200
|
}
|
92
201
|
// Set up specific formatting necessary by operators
|
93
202
|
if (operator === 'near') {
|
@@ -113,8 +222,12 @@ export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=
|
|
113
222
|
]
|
114
223
|
}
|
115
224
|
};
|
116
|
-
if (maxDistance)
|
117
|
-
|
225
|
+
if (maxDistance) {
|
226
|
+
formattedValue.$maxDistance = parseFloat(maxDistance);
|
227
|
+
}
|
228
|
+
if (minDistance) {
|
229
|
+
formattedValue.$minDistance = parseFloat(minDistance);
|
230
|
+
}
|
118
231
|
}
|
119
232
|
}
|
120
233
|
if (operator === 'within' || operator === 'intersects') {
|
@@ -123,12 +236,16 @@ export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=
|
|
123
236
|
};
|
124
237
|
}
|
125
238
|
if (path !== '_id' || path === '_id' && hasCustomID && field.type === 'text') {
|
126
|
-
if (operator === 'contains') {
|
239
|
+
if (operator === 'contains' && !Types.ObjectId.isValid(formattedValue)) {
|
127
240
|
formattedValue = {
|
128
241
|
$options: 'i',
|
129
242
|
$regex: formattedValue.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&')
|
130
243
|
};
|
131
244
|
}
|
245
|
+
if (operator === 'exists') {
|
246
|
+
formattedValue = formattedValue === 'true' || formattedValue === true;
|
247
|
+
return buildExistsQuery(formattedValue, path);
|
248
|
+
}
|
132
249
|
}
|
133
250
|
if ((path === '_id' || path === 'parent') && operator === 'like' && formattedValue.length === 24 && !hasCustomID) {
|
134
251
|
formattedOperator = 'equals';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/queries/sanitizeQueryValue.ts"],"sourcesContent":["import type { Field, TabAsField } from 'payload'\n\nimport mongoose from 'mongoose'\nimport { createArrayFromCommaDelineated } from 'payload'\n\ntype SanitizeQueryValueArgs = {\n field: Field | TabAsField\n hasCustomID: boolean\n operator: string\n path: string\n val: any\n}\n\nexport const sanitizeQueryValue = ({\n field,\n hasCustomID,\n operator,\n path,\n val,\n}: SanitizeQueryValueArgs): {\n operator?: string\n rawQuery?: unknown\n val?: unknown\n} => {\n let formattedValue = val\n let formattedOperator = operator\n\n // Disregard invalid _ids\n if (path === '_id' && typeof val === 'string' && val.split(',').length === 1) {\n if (!hasCustomID) {\n const isValid = mongoose.Types.ObjectId.isValid(val)\n\n if (!isValid) {\n return { operator: formattedOperator, val: undefined }\n }\n }\n\n if (field.type === 'number') {\n const parsedNumber = parseFloat(val)\n\n if (Number.isNaN(parsedNumber)) {\n return { operator: formattedOperator, val: undefined }\n }\n }\n }\n\n // Cast incoming values as proper searchable types\n if (field.type === 'checkbox' && typeof val === 'string') {\n if (val.toLowerCase() === 'true') formattedValue = true\n if (val.toLowerCase() === 'false') formattedValue = false\n }\n\n if (['all', 'in', 'not_in'].includes(operator) && typeof formattedValue === 'string') {\n formattedValue = createArrayFromCommaDelineated(formattedValue)\n\n if (field.type === 'number') {\n formattedValue = formattedValue.map((arrayVal) => parseFloat(arrayVal))\n }\n }\n\n if (field.type === 'number' && typeof formattedValue === 'string') {\n formattedValue = Number(val)\n }\n\n if (field.type === 'date' && typeof val === 'string' && operator !== 'exists') {\n formattedValue = new Date(val)\n if (Number.isNaN(Date.parse(formattedValue))) {\n return undefined\n }\n }\n\n if (['relationship', 'upload'].includes(field.type)) {\n if (val === 'null') {\n formattedValue = null\n }\n\n // Object equality requires the value to be the first key in the object that is being queried.\n if (\n operator === 'equals' &&\n formattedValue &&\n typeof formattedValue === 'object' &&\n formattedValue.value &&\n formattedValue.relationTo\n ) {\n return {\n rawQuery: {\n $and: [\n { [`${path}.value`]: { $eq: formattedValue.value } },\n { [`${path}.relationTo`]: { $eq: formattedValue.relationTo } },\n ],\n },\n }\n }\n\n if (operator === 'in' && Array.isArray(formattedValue)) {\n formattedValue = formattedValue.reduce((formattedValues, inVal) => {\n const newValues = [inVal]\n if (mongoose.Types.ObjectId.isValid(inVal))\n newValues.push(new mongoose.Types.ObjectId(inVal))\n\n const parsedNumber = parseFloat(inVal)\n if (!Number.isNaN(parsedNumber)) newValues.push(parsedNumber)\n\n return [...formattedValues, ...newValues]\n }, [])\n }\n }\n\n // Set up specific formatting necessary by operators\n\n if (operator === 'near') {\n let lng\n let lat\n let maxDistance\n let minDistance\n\n if (Array.isArray(formattedValue)) {\n ;[lng, lat, maxDistance, minDistance] = formattedValue\n }\n\n if (typeof formattedValue === 'string') {\n ;[lng, lat, maxDistance, minDistance] = createArrayFromCommaDelineated(formattedValue)\n }\n\n if (lng == null || lat == null || (maxDistance == null && minDistance == null)) {\n formattedValue = undefined\n } else {\n formattedValue = {\n $geometry: { type: 'Point', coordinates: [parseFloat(lng), parseFloat(lat)] },\n }\n\n if (maxDistance) formattedValue.$maxDistance = parseFloat(maxDistance)\n if (minDistance) formattedValue.$minDistance = parseFloat(minDistance)\n }\n }\n\n if (operator === 'within' || operator === 'intersects') {\n formattedValue = {\n $geometry: formattedValue,\n }\n }\n\n if (path !== '_id' || (path === '_id' && hasCustomID && field.type === 'text')) {\n if (operator === 'contains') {\n formattedValue = {\n $options: 'i',\n $regex: formattedValue.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&'),\n }\n }\n }\n\n if (\n (path === '_id' || path === 'parent') &&\n operator === 'like' &&\n formattedValue.length === 24 &&\n !hasCustomID\n ) {\n formattedOperator = 'equals'\n }\n\n if (operator === 'exists') {\n formattedValue = formattedValue === 'true' || formattedValue === true\n\n // Clearable fields\n if (['relationship', 'select', 'upload'].includes(field.type)) {\n if (formattedValue) {\n return {\n rawQuery: {\n $and: [{ [path]: { $exists: true } }, { [path]: { $ne: null } }],\n },\n }\n } else {\n return {\n rawQuery: {\n $or: [{ [path]: { $exists: false } }, { [path]: { $eq: null } }],\n },\n }\n }\n }\n }\n\n return { operator: formattedOperator, val: formattedValue }\n}\n"],"names":["mongoose","createArrayFromCommaDelineated","sanitizeQueryValue","field","hasCustomID","operator","path","val","formattedValue","formattedOperator","split","length","isValid","Types","ObjectId","undefined","type","parsedNumber","parseFloat","Number","isNaN","toLowerCase","includes","map","arrayVal","Date","parse","value","relationTo","rawQuery","$and","$eq","Array","isArray","reduce","formattedValues","inVal","newValues","push","lng","lat","maxDistance","minDistance","$geometry","coordinates","$maxDistance","$minDistance","$options","$regex","replace","$exists","$ne","$or"],"mappings":"AAEA,OAAOA,cAAc,WAAU;AAC/B,SAASC,8BAA8B,QAAQ,UAAS;AAUxD,OAAO,MAAMC,qBAAqB,CAAC,EACjCC,KAAK,EACLC,WAAW,EACXC,QAAQ,EACRC,IAAI,EACJC,GAAG,EACoB;IAKvB,IAAIC,iBAAiBD;IACrB,IAAIE,oBAAoBJ;IAExB,yBAAyB;IACzB,IAAIC,SAAS,SAAS,OAAOC,QAAQ,YAAYA,IAAIG,KAAK,CAAC,KAAKC,MAAM,KAAK,GAAG;QAC5E,IAAI,CAACP,aAAa;YAChB,MAAMQ,UAAUZ,SAASa,KAAK,CAACC,QAAQ,CAACF,OAAO,CAACL;YAEhD,IAAI,CAACK,SAAS;gBACZ,OAAO;oBAAEP,UAAUI;oBAAmBF,KAAKQ;gBAAU;YACvD;QACF;QAEA,IAAIZ,MAAMa,IAAI,KAAK,UAAU;YAC3B,MAAMC,eAAeC,WAAWX;YAEhC,IAAI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S,SAAUA,SAAS,SAASF,eAAeD,MAAMa,IAAI,KAAK,QAAS;QAC9E,IAAIX,aAAa,YAAY;YAC3BG,iBAAiB;gBACfuC,UAAU;gBACVC,QAAQxC,eAAeyC,OAAO,CAAC,uBAAuB;YACxD;QACF;IACF;IAEA,IACE,AAAC3C,CAAAA,SAAS,SAASA,SAAS,QAAO,KACnCD,aAAa,UACbG,eAAeG,MAAM,KAAK,MAC1B,CAACP,aACD;QACAK,oBAAoB;IACtB;IAEA,IAAIJ,aAAa,UAAU;QACzBG,iBAAiBA,mBAAmB,UAAUA,mBAAmB;QAEjE,mBAAmB;QACnB,IAAI;YAAC;YAAgB;YAAU;SAAS,CAACc,QAAQ,CAACnB,MAAMa,IAAI,GAAG;YAC7D,IAAIR,gBAAgB;gBAClB,OAAO;oBACLqB,UAAU;wBACRC,MAAM;4BAAC;gCAAE,CAACxB,KAAK,EAAE;oCAAE4C,SAAS;gCAAK;4BAAE;4BAAG;gCAAE,CAAC5C,KAAK,EAAE;oCAAE6C,KAAK;gCAAK;4BAAE;yBAAE;oBAClE;gBACF;YACF,OAAO;gBACL,OAAO;oBACLtB,UAAU;wBACRuB,KAAK;4BAAC;gCAAE,CAAC9C,KAAK,EAAE;oCAAE4C,SAAS;gCAAM;4BAAE;4BAAG;gCAAE,CAAC5C,KAAK,EAAE;oCAAEyB,KAAK;gCAAK;4BAAE;yBAAE;oBAClE;gBACF;YACF;QACF;IACF;IAEA,OAAO;QAAE1B,UAAUI;QAAmBF,KAAKC;IAAe;AAC5D,EAAC"}
|
1
|
+
{"version":3,"sources":["../../src/queries/sanitizeQueryValue.ts"],"sourcesContent":["import type { Field, TabAsField } from 'payload'\n\nimport { Types } from 'mongoose'\nimport { createArrayFromCommaDelineated } from 'payload'\n\ntype SanitizeQueryValueArgs = {\n field: Field | TabAsField\n hasCustomID: boolean\n operator: string\n path: string\n val: any\n}\n\nconst buildExistsQuery = (formattedValue, path) => {\n if (formattedValue) {\n return {\n rawQuery: {\n $and: [\n { [path]: { $exists: true } },\n { [path]: { $ne: null } },\n { [path]: { $ne: '' } }, // Exclude null and empty string\n ],\n },\n }\n } else {\n return {\n rawQuery: {\n $or: [\n { [path]: { $exists: false } },\n { [path]: { $eq: null } },\n { [path]: { $eq: '' } }, // Treat empty string as null / undefined\n ],\n },\n }\n }\n}\n\nexport const sanitizeQueryValue = ({\n field,\n hasCustomID,\n operator,\n path,\n val,\n}: SanitizeQueryValueArgs): {\n operator?: string\n rawQuery?: unknown\n val?: unknown\n} => {\n let formattedValue = val\n let formattedOperator = operator\n\n // Disregard invalid _ids\n if (path === '_id') {\n if (typeof val === 'string' && val.split(',').length === 1) {\n if (!hasCustomID) {\n const isValid = Types.ObjectId.isValid(val)\n\n if (!isValid) {\n return { operator: formattedOperator, val: undefined }\n } else {\n if (['in', 'not_in'].includes(operator)) {\n formattedValue = createArrayFromCommaDelineated(formattedValue).map(\n (id) => new Types.ObjectId(id),\n )\n } else {\n formattedValue = new Types.ObjectId(val)\n }\n }\n }\n\n if (field.type === 'number') {\n const parsedNumber = parseFloat(val)\n\n if (Number.isNaN(parsedNumber)) {\n return { operator: formattedOperator, val: undefined }\n }\n }\n } else if (Array.isArray(val) || (typeof val === 'string' && val.split(',').length > 1)) {\n if (typeof val === 'string') {\n formattedValue = createArrayFromCommaDelineated(val)\n }\n\n formattedValue = formattedValue.reduce((formattedValues, inVal) => {\n const newValues = [inVal]\n if (!hasCustomID) {\n if (Types.ObjectId.isValid(inVal)) {\n newValues.push(new Types.ObjectId(inVal))\n }\n }\n\n if (field.type === 'number') {\n const parsedNumber = parseFloat(inVal)\n if (!Number.isNaN(parsedNumber)) {\n newValues.push(parsedNumber)\n }\n }\n\n return [...formattedValues, ...newValues]\n }, [])\n }\n }\n\n // Cast incoming values as proper searchable types\n if (field.type === 'checkbox' && typeof val === 'string') {\n if (val.toLowerCase() === 'true') {\n formattedValue = true\n }\n if (val.toLowerCase() === 'false') {\n formattedValue = false\n }\n }\n\n if (['all', 'in', 'not_in'].includes(operator) && typeof formattedValue === 'string') {\n formattedValue = createArrayFromCommaDelineated(formattedValue)\n\n if (field.type === 'number') {\n formattedValue = formattedValue.map((arrayVal) => parseFloat(arrayVal))\n }\n }\n\n if (field.type === 'number') {\n if (typeof formattedValue === 'string' && operator !== 'exists') {\n formattedValue = Number(val)\n }\n\n if (operator === 'exists') {\n formattedValue = val === 'true' ? true : val === 'false' ? false : Boolean(val)\n\n return buildExistsQuery(formattedValue, path)\n }\n }\n\n if (field.type === 'date' && typeof val === 'string' && operator !== 'exists') {\n formattedValue = new Date(val)\n if (Number.isNaN(Date.parse(formattedValue))) {\n return undefined\n }\n }\n\n if (['relationship', 'upload'].includes(field.type)) {\n if (val === 'null') {\n formattedValue = null\n }\n\n // Object equality requires the value to be the first key in the object that is being queried.\n if (\n operator === 'equals' &&\n formattedValue &&\n typeof formattedValue === 'object' &&\n formattedValue.value &&\n formattedValue.relationTo\n ) {\n const { value } = formattedValue\n const isValid = Types.ObjectId.isValid(value)\n\n if (isValid) {\n formattedValue.value = new Types.ObjectId(value)\n }\n\n return {\n rawQuery: {\n $and: [\n { [`${path}.value`]: { $eq: formattedValue.value } },\n { [`${path}.relationTo`]: { $eq: formattedValue.relationTo } },\n ],\n },\n }\n }\n\n if (['in', 'not_in'].includes(operator) && Array.isArray(formattedValue)) {\n formattedValue = formattedValue.reduce((formattedValues, inVal) => {\n const newValues = [inVal]\n if (Types.ObjectId.isValid(inVal)) {\n newValues.push(new Types.ObjectId(inVal))\n }\n\n const parsedNumber = parseFloat(inVal)\n if (!Number.isNaN(parsedNumber)) {\n newValues.push(parsedNumber)\n }\n\n return [...formattedValues, ...newValues]\n }, [])\n }\n\n if (typeof formattedValue === 'string') {\n if (Types.ObjectId.isValid(formattedValue)) {\n formattedValue = new Types.ObjectId(formattedValue)\n }\n }\n }\n\n // Set up specific formatting necessary by operators\n\n if (operator === 'near') {\n let lng\n let lat\n let maxDistance\n let minDistance\n\n if (Array.isArray(formattedValue)) {\n ;[lng, lat, maxDistance, minDistance] = formattedValue\n }\n\n if (typeof formattedValue === 'string') {\n ;[lng, lat, maxDistance, minDistance] = createArrayFromCommaDelineated(formattedValue)\n }\n\n if (lng == null || lat == null || (maxDistance == null && minDistance == null)) {\n formattedValue = undefined\n } else {\n formattedValue = {\n $geometry: { type: 'Point', coordinates: [parseFloat(lng), parseFloat(lat)] },\n }\n\n if (maxDistance) {\n formattedValue.$maxDistance = parseFloat(maxDistance)\n }\n if (minDistance) {\n formattedValue.$minDistance = parseFloat(minDistance)\n }\n }\n }\n\n if (operator === 'within' || operator === 'intersects') {\n formattedValue = {\n $geometry: formattedValue,\n }\n }\n\n if (path !== '_id' || (path === '_id' && hasCustomID && field.type === 'text')) {\n if (operator === 'contains' && !Types.ObjectId.isValid(formattedValue)) {\n formattedValue = {\n $options: 'i',\n $regex: formattedValue.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&'),\n }\n }\n\n if (operator === 'exists') {\n formattedValue = formattedValue === 'true' || formattedValue === true\n\n return buildExistsQuery(formattedValue, path)\n }\n }\n\n if (\n (path === '_id' || path === 'parent') &&\n operator === 'like' &&\n formattedValue.length === 24 &&\n !hasCustomID\n ) {\n formattedOperator = 'equals'\n }\n\n if (operator === 'exists') {\n formattedValue = formattedValue === 'true' || formattedValue === true\n\n // Clearable fields\n if (['relationship', 'select', 'upload'].includes(field.type)) {\n if (formattedValue) {\n return {\n rawQuery: {\n $and: [{ [path]: { $exists: true } }, { [path]: { $ne: null } }],\n },\n }\n } else {\n return {\n rawQuery: {\n $or: [{ [path]: { $exists: false } }, { [path]: { $eq: null } }],\n },\n }\n }\n }\n }\n\n return { operator: formattedOperator, val: formattedValue }\n}\n"],"names":["Types","createArrayFromCommaDelineated","buildExistsQuery","formattedValue","path","rawQuery","$and","$exists","$ne","$or","$eq","sanitizeQueryValue","field","hasCustomID","operator","val","formattedOperator","split","length","isValid","ObjectId","undefined","includes","map","id","type","parsedNumber","parseFloat","Number","isNaN","Array","isArray","reduce","formattedValues","inVal","newValues","push","toLowerCase","arrayVal","Boolean","Date","parse","value","relationTo","lng","lat","maxDistance","minDistance","$geometry","coordinates","$maxDistance","$minDistance","$options","$regex","replace"],"mappings":"AAEA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,8BAA8B,QAAQ,UAAS;AAUxD,MAAMC,mBAAmB,CAACC,gBAAgBC;IACxC,IAAID,gBAAgB;QAClB,OAAO;YACLE,UAAU;gBACRC,MAAM;oBACJ;wBAAE,CAACF,KAAK,EAAE;4BAAEG,SAAS;wBAAK;oBAAE;oBAC5B;wBAAE,CAACH,KAAK,EAAE;4BAAEI,KAAK;wBAAK;oBAAE;oBACxB;wBAAE,CAACJ,KAAK,EAAE;4BAAEI,KAAK;wBAAG;oBAAE;iBACvB;YACH;QACF;IACF,OAAO;QACL,OAAO;YACLH,UAAU;gBACRI,KAAK;oBACH;wBAAE,CAACL,KAAK,EAAE;4BAAEG,SAAS;wBAAM;oBAAE;oBAC7B;wBAAE,CAACH,KAAK,EAAE;4BAAEM,KAAK;wBAAK;oBAAE;oBACxB;wBAAE,CAACN,KAAK,EAAE;4BAAEM,KAAK;wBAAG;oBAAE;iBACvB;YACH;QACF;IACF;AACF;AAEA,OAAO,MAAMC,qBAAqB,CAAC,EACjCC,KAAK,EACLC,WAAW,EACXC,QAAQ,EACRV,IAAI,EACJW,GAAG,EACoB;IAKvB,IAAIZ,iBAAiBY;IACrB,IAAIC,oBAAoBF;IAExB,yBAAyB;IACzB,IAAIV,SAAS,OAAO;QAClB,IAAI,OAAOW,QAAQ,YAAYA,IAAIE,KAAK,CAAC,KAAKC,MAAM,KAAK,GAAG;YAC1D,IAAI,CAACL,aAAa;gBAChB,MAAMM,UAAUnB,MAAMoB,QAAQ,CAACD,OAAO,CAACJ;gBAEvC,IAAI,CAACI,SAAS;oBACZ,OAAO;wBAAEL,UAAUE;wBAAmBD,KAAKM;oBAAU;gBACvD,OAAO;oBACL,IAAI;wBAAC;wBAAM;qBAAS,CAACC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M,KAAK;gCAAK;4BAAE;yBAAE;oBAClE;gBACF;YACF;QACF;IACF;IAEA,OAAO;QAAEI,UAAUE;QAAmBD,KAAKZ;IAAe;AAC5D,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"queryDrafts.d.ts","sourceRoot":"","sources":["../src/queryDrafts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"queryDrafts.d.ts","sourceRoot":"","sources":["../src/queryDrafts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,SAAS,CAAA;AAY1D,eAAO,MAAM,WAAW,EAAE,WAqIzB,CAAA"}
|