@payloadcms/db-mongodb 4.0.0-internal.ea6e8f8 → 4.0.0-internal.ee5d8bd
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.
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +0 -1
- package/dist/connect.js.map +1 -1
- package/dist/count.d.ts.map +1 -1
- package/dist/count.js +4 -33
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.d.ts.map +1 -1
- package/dist/countGlobalVersions.js +0 -1
- package/dist/countGlobalVersions.js.map +1 -1
- package/dist/countVersions.d.ts.map +1 -1
- package/dist/countVersions.js +4 -36
- package/dist/countVersions.js.map +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +0 -22
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +3 -16
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +0 -1
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +1 -20
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +0 -1
- package/dist/deleteVersions.js.map +1 -1
- package/dist/exports/migration-utils.d.ts +0 -1
- package/dist/exports/migration-utils.d.ts.map +1 -1
- package/dist/exports/migration-utils.js +0 -1
- package/dist/exports/migration-utils.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +8 -44
- package/dist/find.js.map +1 -1
- package/dist/findDistinct.d.ts.map +1 -1
- package/dist/findDistinct.js +11 -70
- package/dist/findDistinct.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +5 -34
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +2 -10
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +5 -43
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +5 -49
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/models/buildGlobalModel.d.ts.map +1 -1
- package/dist/models/buildGlobalModel.js +1 -30
- package/dist/models/buildGlobalModel.js.map +1 -1
- package/dist/models/buildSchema.d.ts.map +1 -1
- package/dist/models/buildSchema.js +10 -30
- package/dist/models/buildSchema.js.map +1 -1
- package/dist/predefinedMigrations/migrateSizesToVariants.js.map +1 -1
- package/dist/queries/buildAndOrConditions.d.ts +2 -4
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +1 -3
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +2 -4
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +1 -3
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/buildSearchParams.d.ts +2 -4
- package/dist/queries/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +44 -175
- package/dist/queries/buildSearchParams.js.map +1 -1
- package/dist/queries/getBuildQueryPlugin.d.ts +1 -3
- package/dist/queries/getBuildQueryPlugin.d.ts.map +1 -1
- package/dist/queries/getBuildQueryPlugin.js +1 -3
- package/dist/queries/getBuildQueryPlugin.js.map +1 -1
- package/dist/queries/parseParams.d.ts +2 -4
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +1 -5
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +7 -38
- package/dist/queryDrafts.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +7 -55
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
- package/dist/transactions/rollbackTransaction.js +9 -10
- package/dist/transactions/rollbackTransaction.js.map +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +7 -87
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +0 -1
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateMany.d.ts.map +1 -1
- package/dist/updateMany.js +1 -3
- package/dist/updateMany.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +2 -28
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +0 -1
- package/dist/updateVersion.js.map +1 -1
- package/dist/utilities/aggregatePaginate.d.ts +1 -2
- package/dist/utilities/aggregatePaginate.d.ts.map +1 -1
- package/dist/utilities/aggregatePaginate.js +4 -18
- package/dist/utilities/aggregatePaginate.js.map +1 -1
- package/dist/utilities/buildJoinAggregation.d.ts +2 -4
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
- package/dist/utilities/buildJoinAggregation.js +23 -118
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- package/dist/utilities/resolveJoins.d.ts +2 -6
- package/dist/utilities/resolveJoins.d.ts.map +1 -1
- package/dist/utilities/resolveJoins.js +26 -114
- package/dist/utilities/resolveJoins.js.map +1 -1
- package/package.json +16 -19
- package/dist/deleteBranchGlobal.d.ts +0 -10
- package/dist/deleteBranchGlobal.d.ts.map +0 -1
- package/dist/deleteBranchGlobal.js +0 -22
- package/dist/deleteBranchGlobal.js.map +0 -1
- package/dist/predefinedMigrations/branching.d.ts +0 -4
- package/dist/predefinedMigrations/branching.d.ts.map +0 -1
- package/dist/predefinedMigrations/branching.js +0 -9
- package/dist/predefinedMigrations/branching.js.map +0 -1
- package/dist/predefinedMigrations/migrateBranching.d.ts +0 -15
- package/dist/predefinedMigrations/migrateBranching.d.ts.map +0 -1
- package/dist/predefinedMigrations/migrateBranching.js +0 -88
- package/dist/predefinedMigrations/migrateBranching.js.map +0 -1
- package/dist/queries/buildBranchVisibility.d.ts +0 -11
- package/dist/queries/buildBranchVisibility.d.ts.map +0 -1
- package/dist/queries/buildBranchVisibility.js +0 -204
- package/dist/queries/buildBranchVisibility.js.map +0 -1
- package/dist/upsertBranchGlobalChange.d.ts +0 -3
- package/dist/upsertBranchGlobalChange.d.ts.map +0 -1
- package/dist/upsertBranchGlobalChange.js +0 -28
- package/dist/upsertBranchGlobalChange.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.ee5d8bd",
|
|
4
4
|
"description": "The officially supported MongoDB database adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/payloadcms/payload.git",
|
|
9
|
-
"directory": "packages/db-mongodb"
|
|
10
|
-
},
|
|
11
6
|
"license": "MIT",
|
|
12
7
|
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
13
8
|
"maintainers": [
|
|
@@ -17,8 +12,19 @@
|
|
|
17
12
|
"url": "https://payloadcms.com"
|
|
18
13
|
}
|
|
19
14
|
],
|
|
20
|
-
"
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/payloadcms/payload.git",
|
|
18
|
+
"directory": "packages/db-mongodb"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"predefinedMigrations"
|
|
23
|
+
],
|
|
21
24
|
"type": "module",
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
22
28
|
"exports": {
|
|
23
29
|
".": {
|
|
24
30
|
"import": "./dist/index.js",
|
|
@@ -36,12 +42,6 @@
|
|
|
36
42
|
"default": "./dist/exports/internal.js"
|
|
37
43
|
}
|
|
38
44
|
},
|
|
39
|
-
"main": "./dist/index.js",
|
|
40
|
-
"types": "./dist/index.d.ts",
|
|
41
|
-
"files": [
|
|
42
|
-
"dist",
|
|
43
|
-
"predefinedMigrations"
|
|
44
|
-
],
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"mongoose": "9.9.2",
|
|
47
47
|
"mongoose-paginate-v2": "1.9.4",
|
|
@@ -53,19 +53,16 @@
|
|
|
53
53
|
"@types/prompts": "^2.4.5",
|
|
54
54
|
"mongodb": "7.5.0",
|
|
55
55
|
"mongodb-memory-server": "10.1.4",
|
|
56
|
-
"payload": "4.0.0-internal.
|
|
57
|
-
"@payloadcms/eslint-config": "3.28.0"
|
|
56
|
+
"payload": "4.0.0-internal.ee5d8bd"
|
|
58
57
|
},
|
|
59
58
|
"peerDependencies": {
|
|
60
|
-
"payload": "4.0.0-internal.
|
|
59
|
+
"payload": "4.0.0-internal.ee5d8bd"
|
|
61
60
|
},
|
|
62
61
|
"scripts": {
|
|
63
62
|
"build": "pnpm build:types && pnpm build:swc",
|
|
64
63
|
"build:debug": "pnpm build",
|
|
65
64
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc-build --strip-leading-paths",
|
|
66
65
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
67
|
-
"clean": "rimraf -g {dist,*.tsbuildinfo}"
|
|
68
|
-
"lint": "eslint .",
|
|
69
|
-
"lint:fix": "eslint . --fix"
|
|
66
|
+
"clean": "rimraf -g {dist,*.tsbuildinfo}"
|
|
70
67
|
}
|
|
71
68
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DeleteBranchGlobal } from 'payload';
|
|
2
|
-
/**
|
|
3
|
-
* Drops a branch's copy of a global.
|
|
4
|
-
*
|
|
5
|
-
* Every global lives in one discriminated collection here, so the branch's copy is a
|
|
6
|
-
* sibling row identified by `globalType` and `_branch` — addressed directly rather than
|
|
7
|
-
* through any generic delete, since no other part of Payload deletes a global.
|
|
8
|
-
*/
|
|
9
|
-
export declare const deleteBranchGlobal: DeleteBranchGlobal;
|
|
10
|
-
//# sourceMappingURL=deleteBranchGlobal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deleteBranchGlobal.d.ts","sourceRoot":"","sources":["../src/deleteBranchGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAOjD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAUhC,CAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getGlobal } from './utilities/getEntity.js';
|
|
2
|
-
import { getSession } from './utilities/getSession.js';
|
|
3
|
-
/**
|
|
4
|
-
* Drops a branch's copy of a global.
|
|
5
|
-
*
|
|
6
|
-
* Every global lives in one discriminated collection here, so the branch's copy is a
|
|
7
|
-
* sibling row identified by `globalType` and `_branch` — addressed directly rather than
|
|
8
|
-
* through any generic delete, since no other part of Payload deletes a global.
|
|
9
|
-
*/ export const deleteBranchGlobal = async function deleteBranchGlobal({ branch, globalSlug, req }) {
|
|
10
|
-
const { Model } = getGlobal({
|
|
11
|
-
adapter: this,
|
|
12
|
-
globalSlug
|
|
13
|
-
});
|
|
14
|
-
await Model.deleteOne({
|
|
15
|
-
_branch: branch,
|
|
16
|
-
globalType: globalSlug
|
|
17
|
-
}, {
|
|
18
|
-
session: await getSession(this, req)
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=deleteBranchGlobal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deleteBranchGlobal.ts"],"sourcesContent":["import type { DeleteBranchGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\n\n/**\n * Drops a branch's copy of a global.\n *\n * Every global lives in one discriminated collection here, so the branch's copy is a\n * sibling row identified by `globalType` and `_branch` — addressed directly rather than\n * through any generic delete, since no other part of Payload deletes a global.\n */\nexport const deleteBranchGlobal: DeleteBranchGlobal = async function deleteBranchGlobal(\n this: MongooseAdapter,\n { branch, globalSlug, req },\n) {\n const { Model } = getGlobal({ adapter: this, globalSlug })\n\n await Model.deleteOne(\n { _branch: branch, globalType: globalSlug },\n { session: await getSession(this, req) },\n )\n}\n"],"names":["getGlobal","getSession","deleteBranchGlobal","branch","globalSlug","req","Model","adapter","deleteOne","_branch","globalType","session"],"mappings":"AAIA,SAASA,SAAS,QAAQ,2BAA0B;AACpD,SAASC,UAAU,QAAQ,4BAA2B;AAEtD;;;;;;CAMC,GACD,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EAAEC,MAAM,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAE3B,MAAM,EAAEC,KAAK,EAAE,GAAGN,UAAU;QAAEO,SAAS,IAAI;QAAEH;IAAW;IAExD,MAAME,MAAME,SAAS,CACnB;QAAEC,SAASN;QAAQO,YAAYN;IAAW,GAC1C;QAAEO,SAAS,MAAMV,WAAW,IAAI,EAAEI;IAAK;AAE3C,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"branching.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/branching.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,OAAO,8EAA8E,CAAA;AAC3F,QAAA,MAAM,KAAK,mEAIV,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/predefinedMigrations/branching.ts"],"sourcesContent":["const imports = `import { migrateBranching } from '@payloadcms/db-mongodb/migration-utils'`\nconst upSQL = ` await migrateBranching({\n payload,\n session,\n })\n`\n\nexport { imports, upSQL }\n"],"names":["imports","upSQL"],"mappings":"AAAA,MAAMA,UAAU,CAAC,yEAAyE,CAAC;AAC3F,MAAMC,QAAQ,CAAC;;;;AAIf,CAAC;AAED,SAASD,OAAO,EAAEC,KAAK,GAAE"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ClientSession } from 'mongoose';
|
|
2
|
-
import type { Payload } from 'payload';
|
|
3
|
-
type BranchingMigrationArgs = {
|
|
4
|
-
payload: Payload;
|
|
5
|
-
session?: ClientSession;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Backfills branch identity before replacing legacy indexes with the current schema indexes.
|
|
9
|
-
*
|
|
10
|
-
* Run this generated migration after enabling branching. Backfill errors stop the migration
|
|
11
|
-
* before any indexes are removed, so uniqueness conflicts remain visible and recoverable.
|
|
12
|
-
*/
|
|
13
|
-
export declare const migrateBranching: ({ payload, session, }: BranchingMigrationArgs) => Promise<void>;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=migrateBranching.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrateBranching.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/migrateBranching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAOtC,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,CAAA;AAQD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,0BAG1B,sBAAsB,KAAG,OAAO,CAAC,IAAI,CAqEvC,CAAA"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { branchField, MAIN_BRANCH } from 'payload';
|
|
2
|
-
const legacyMainFilter = {
|
|
3
|
-
$or: [
|
|
4
|
-
{
|
|
5
|
-
[branchField]: {
|
|
6
|
-
$exists: false
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
[branchField]: null
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Backfills branch identity before replacing legacy indexes with the current schema indexes.
|
|
16
|
-
*
|
|
17
|
-
* Run this generated migration after enabling branching. Backfill errors stop the migration
|
|
18
|
-
* before any indexes are removed, so uniqueness conflicts remain visible and recoverable.
|
|
19
|
-
*/ export const migrateBranching = async ({ payload, session })=>{
|
|
20
|
-
const branching = payload.config.branching;
|
|
21
|
-
if (!branching?.enabled) {
|
|
22
|
-
payload.logger.info({
|
|
23
|
-
msg: 'Branching is not enabled, skipping branching migration'
|
|
24
|
-
});
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const adapter = payload.db;
|
|
28
|
-
const modelsToSync = new Set();
|
|
29
|
-
const updateOptions = session ? {
|
|
30
|
-
session
|
|
31
|
-
} : {};
|
|
32
|
-
payload.logger.info({
|
|
33
|
-
msg: 'Starting branching data and index migration'
|
|
34
|
-
});
|
|
35
|
-
for (const collectionSlug of branching.branchableCollections){
|
|
36
|
-
const collectionModel = adapter.collections[collectionSlug];
|
|
37
|
-
const versionModel = adapter.versions[collectionSlug];
|
|
38
|
-
if (!collectionModel) {
|
|
39
|
-
throw new Error(`Could not find MongoDB model for branchable collection "${collectionSlug}".`);
|
|
40
|
-
}
|
|
41
|
-
await collectionModel.collection.updateMany(legacyMainFilter, {
|
|
42
|
-
$set: {
|
|
43
|
-
[branchField]: MAIN_BRANCH
|
|
44
|
-
}
|
|
45
|
-
}, updateOptions);
|
|
46
|
-
modelsToSync.add(collectionModel);
|
|
47
|
-
if (versionModel) {
|
|
48
|
-
await versionModel.collection.updateMany(legacyMainFilter, {
|
|
49
|
-
$set: {
|
|
50
|
-
[branchField]: MAIN_BRANCH
|
|
51
|
-
}
|
|
52
|
-
}, updateOptions);
|
|
53
|
-
modelsToSync.add(versionModel);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (branching.branchableGlobals.size) {
|
|
57
|
-
await adapter.globals.collection.updateMany({
|
|
58
|
-
...legacyMainFilter,
|
|
59
|
-
globalType: {
|
|
60
|
-
$in: Array.from(branching.branchableGlobals)
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
$set: {
|
|
64
|
-
[branchField]: MAIN_BRANCH
|
|
65
|
-
}
|
|
66
|
-
}, updateOptions);
|
|
67
|
-
modelsToSync.add(adapter.globals);
|
|
68
|
-
for (const globalSlug of branching.branchableGlobals){
|
|
69
|
-
const versionModel = adapter.versions[globalSlug];
|
|
70
|
-
if (versionModel) {
|
|
71
|
-
await versionModel.collection.updateMany(legacyMainFilter, {
|
|
72
|
-
$set: {
|
|
73
|
-
[branchField]: MAIN_BRANCH
|
|
74
|
-
}
|
|
75
|
-
}, updateOptions);
|
|
76
|
-
modelsToSync.add(versionModel);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
for (const model of modelsToSync){
|
|
81
|
-
await model.syncIndexes();
|
|
82
|
-
}
|
|
83
|
-
payload.logger.info({
|
|
84
|
-
msg: 'Branching data and index migration completed successfully'
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
//# sourceMappingURL=migrateBranching.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/predefinedMigrations/migrateBranching.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\nimport type { Payload } from 'payload'\n\nimport { branchField, MAIN_BRANCH } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\nimport type { CollectionModel, GlobalModel } from '../types.js'\n\ntype BranchingMigrationArgs = {\n payload: Payload\n session?: ClientSession\n}\n\ntype SyncableModel = CollectionModel | GlobalModel\n\nconst legacyMainFilter = {\n $or: [{ [branchField]: { $exists: false } }, { [branchField]: null }],\n}\n\n/**\n * Backfills branch identity before replacing legacy indexes with the current schema indexes.\n *\n * Run this generated migration after enabling branching. Backfill errors stop the migration\n * before any indexes are removed, so uniqueness conflicts remain visible and recoverable.\n */\nexport const migrateBranching = async ({\n payload,\n session,\n}: BranchingMigrationArgs): Promise<void> => {\n const branching = payload.config.branching\n\n if (!branching?.enabled) {\n payload.logger.info({ msg: 'Branching is not enabled, skipping branching migration' })\n return\n }\n\n const adapter = payload.db as MongooseAdapter\n const modelsToSync = new Set<SyncableModel>()\n const updateOptions = session ? { session } : {}\n\n payload.logger.info({ msg: 'Starting branching data and index migration' })\n\n for (const collectionSlug of branching.branchableCollections) {\n const collectionModel = adapter.collections[collectionSlug]\n const versionModel = adapter.versions[collectionSlug]\n\n if (!collectionModel) {\n throw new Error(`Could not find MongoDB model for branchable collection \"${collectionSlug}\".`)\n }\n\n await collectionModel.collection.updateMany(\n legacyMainFilter,\n { $set: { [branchField]: MAIN_BRANCH } },\n updateOptions,\n )\n modelsToSync.add(collectionModel)\n\n if (versionModel) {\n await versionModel.collection.updateMany(\n legacyMainFilter,\n { $set: { [branchField]: MAIN_BRANCH } },\n updateOptions,\n )\n modelsToSync.add(versionModel)\n }\n }\n\n if (branching.branchableGlobals.size) {\n await adapter.globals.collection.updateMany(\n {\n ...legacyMainFilter,\n globalType: { $in: Array.from(branching.branchableGlobals) },\n },\n { $set: { [branchField]: MAIN_BRANCH } },\n updateOptions,\n )\n modelsToSync.add(adapter.globals)\n\n for (const globalSlug of branching.branchableGlobals) {\n const versionModel = adapter.versions[globalSlug]\n\n if (versionModel) {\n await versionModel.collection.updateMany(\n legacyMainFilter,\n { $set: { [branchField]: MAIN_BRANCH } },\n updateOptions,\n )\n modelsToSync.add(versionModel)\n }\n }\n }\n\n for (const model of modelsToSync) {\n await model.syncIndexes()\n }\n\n payload.logger.info({ msg: 'Branching data and index migration completed successfully' })\n}\n"],"names":["branchField","MAIN_BRANCH","legacyMainFilter","$or","$exists","migrateBranching","payload","session","branching","config","enabled","logger","info","msg","adapter","db","modelsToSync","Set","updateOptions","collectionSlug","branchableCollections","collectionModel","collections","versionModel","versions","Error","collection","updateMany","$set","add","branchableGlobals","size","globals","globalType","$in","Array","from","globalSlug","model","syncIndexes"],"mappings":"AAGA,SAASA,WAAW,EAAEC,WAAW,QAAQ,UAAS;AAYlD,MAAMC,mBAAmB;IACvBC,KAAK;QAAC;YAAE,CAACH,YAAY,EAAE;gBAAEI,SAAS;YAAM;QAAE;QAAG;YAAE,CAACJ,YAAY,EAAE;QAAK;KAAE;AACvE;AAEA;;;;;CAKC,GACD,OAAO,MAAMK,mBAAmB,OAAO,EACrCC,OAAO,EACPC,OAAO,EACgB;IACvB,MAAMC,YAAYF,QAAQG,MAAM,CAACD,SAAS;IAE1C,IAAI,CAACA,WAAWE,SAAS;QACvBJ,QAAQK,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAAyD;QACpF;IACF;IAEA,MAAMC,UAAUR,QAAQS,EAAE;IAC1B,MAAMC,eAAe,IAAIC;IACzB,MAAMC,gBAAgBX,UAAU;QAAEA;IAAQ,IAAI,CAAC;IAE/CD,QAAQK,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK;IAA8C;IAEzE,KAAK,MAAMM,kBAAkBX,UAAUY,qBAAqB,CAAE;QAC5D,MAAMC,kBAAkBP,QAAQQ,WAAW,CAACH,eAAe;QAC3D,MAAMI,eAAeT,QAAQU,QAAQ,CAACL,eAAe;QAErD,IAAI,CAACE,iBAAiB;YACpB,MAAM,IAAII,MAAM,CAAC,wDAAwD,EAAEN,eAAe,EAAE,CAAC;QAC/F;QAEA,MAAME,gBAAgBK,UAAU,CAACC,UAAU,CACzCzB,kBACA;YAAE0B,MAAM;gBAAE,CAAC5B,YAAY,EAAEC;YAAY;QAAE,GACvCiB;QAEFF,aAAaa,GAAG,CAACR;QAEjB,IAAIE,cAAc;YAChB,MAAMA,aAAaG,UAAU,CAACC,UAAU,CACtCzB,kBACA;gBAAE0B,MAAM;oBAAE,CAAC5B,YAAY,EAAEC;gBAAY;YAAE,GACvCiB;YAEFF,aAAaa,GAAG,CAACN;QACnB;IACF;IAEA,IAAIf,UAAUsB,iBAAiB,CAACC,IAAI,EAAE;QACpC,MAAMjB,QAAQkB,OAAO,CAACN,UAAU,CAACC,UAAU,CACzC;YACE,GAAGzB,gBAAgB;YACnB+B,YAAY;gBAAEC,KAAKC,MAAMC,IAAI,CAAC5B,UAAUsB,iBAAiB;YAAE;QAC7D,GACA;YAAEF,MAAM;gBAAE,CAAC5B,YAAY,EAAEC;YAAY;QAAE,GACvCiB;QAEFF,aAAaa,GAAG,CAACf,QAAQkB,OAAO;QAEhC,KAAK,MAAMK,cAAc7B,UAAUsB,iBAAiB,CAAE;YACpD,MAAMP,eAAeT,QAAQU,QAAQ,CAACa,WAAW;YAEjD,IAAId,cAAc;gBAChB,MAAMA,aAAaG,UAAU,CAACC,UAAU,CACtCzB,kBACA;oBAAE0B,MAAM;wBAAE,CAAC5B,YAAY,EAAEC;oBAAY;gBAAE,GACvCiB;gBAEFF,aAAaa,GAAG,CAACN;YACnB;QACF;IACF;IAEA,KAAK,MAAMe,SAAStB,aAAc;QAChC,MAAMsB,MAAMC,WAAW;IACzB;IAEAjC,QAAQK,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK;IAA4D;AACzF,EAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { PipelineStage } from 'mongoose';
|
|
2
|
-
import type { MongooseAdapter } from '../index.js';
|
|
3
|
-
type BranchVisibilityStage = Exclude<PipelineStage, PipelineStage.Merge | PipelineStage.Out>;
|
|
4
|
-
export declare const buildBranchVisibilityStages: ({ adapter, branch, collectionSlug, mode, }: {
|
|
5
|
-
adapter: MongooseAdapter;
|
|
6
|
-
branch: string;
|
|
7
|
-
collectionSlug: string;
|
|
8
|
-
mode?: 'documents' | 'drafts' | 'history';
|
|
9
|
-
}) => BranchVisibilityStage[];
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=buildBranchVisibility.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildBranchVisibility.d.ts","sourceRoot":"","sources":["../../src/queries/buildBranchVisibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAI7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,KAAK,qBAAqB,GAAG,OAAO,CAAC,aAAa,EAAE,aAAa,CAAC,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;AAE5F,eAAO,MAAM,2BAA2B,+CAKrC;IACD,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAA;CAC1C,KAAG,qBAAqB,EAmGxB,CAAA"}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { branchChangesCollectionSlug, MAIN_BRANCH } from 'payload';
|
|
2
|
-
const lookupField = '__payloadBranchChange';
|
|
3
|
-
export const buildBranchVisibilityStages = ({ adapter, branch, collectionSlug, mode = 'documents' })=>{
|
|
4
|
-
const branchChangesModel = adapter.collections[branchChangesCollectionSlug];
|
|
5
|
-
if (!branchChangesModel) {
|
|
6
|
-
throw new Error(`Collection model "${branchChangesCollectionSlug}" is not initialized.`);
|
|
7
|
-
}
|
|
8
|
-
const canonicalIDExpression = mode === 'documents' ? {
|
|
9
|
-
$ifNull: [
|
|
10
|
-
'$_branchDocID',
|
|
11
|
-
'$_id'
|
|
12
|
-
]
|
|
13
|
-
} : {
|
|
14
|
-
$ifNull: [
|
|
15
|
-
'$_branchParent',
|
|
16
|
-
'$parent'
|
|
17
|
-
]
|
|
18
|
-
};
|
|
19
|
-
const hasNoMatchingChange = {
|
|
20
|
-
$eq: [
|
|
21
|
-
{
|
|
22
|
-
$size: `$${lookupField}`
|
|
23
|
-
},
|
|
24
|
-
0
|
|
25
|
-
]
|
|
26
|
-
};
|
|
27
|
-
const operation = {
|
|
28
|
-
$arrayElemAt: [
|
|
29
|
-
`$${lookupField}.operation`,
|
|
30
|
-
0
|
|
31
|
-
]
|
|
32
|
-
};
|
|
33
|
-
const mainVisibility = mode === 'history' ? {
|
|
34
|
-
$or: [
|
|
35
|
-
hasNoMatchingChange,
|
|
36
|
-
{
|
|
37
|
-
$and: [
|
|
38
|
-
{
|
|
39
|
-
$ne: [
|
|
40
|
-
operation,
|
|
41
|
-
'create'
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
$or: [
|
|
46
|
-
{
|
|
47
|
-
$and: [
|
|
48
|
-
{
|
|
49
|
-
$eq: [
|
|
50
|
-
{
|
|
51
|
-
$arrayElemAt: [
|
|
52
|
-
`$${lookupField}.baseVersionID`,
|
|
53
|
-
0
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
null
|
|
57
|
-
]
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
$eq: [
|
|
61
|
-
{
|
|
62
|
-
$arrayElemAt: [
|
|
63
|
-
`$${lookupField}.baseVersionUpdatedAt`,
|
|
64
|
-
0
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
null
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
$eq: [
|
|
74
|
-
{
|
|
75
|
-
$toString: '$_id'
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
$arrayElemAt: [
|
|
79
|
-
`$${lookupField}.baseVersionID`,
|
|
80
|
-
0
|
|
81
|
-
]
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
$lte: [
|
|
87
|
-
'$updatedAt',
|
|
88
|
-
{
|
|
89
|
-
$arrayElemAt: [
|
|
90
|
-
`$${lookupField}.baseVersionUpdatedAt`,
|
|
91
|
-
0
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
} : hasNoMatchingChange;
|
|
102
|
-
const branchVisibility = mode === 'history' ? true : {
|
|
103
|
-
$ne: [
|
|
104
|
-
operation,
|
|
105
|
-
'delete'
|
|
106
|
-
]
|
|
107
|
-
};
|
|
108
|
-
return [
|
|
109
|
-
{
|
|
110
|
-
$match: {
|
|
111
|
-
_branch: {
|
|
112
|
-
$in: [
|
|
113
|
-
MAIN_BRANCH,
|
|
114
|
-
branch
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
$lookup: {
|
|
121
|
-
as: lookupField,
|
|
122
|
-
from: branchChangesModel.collection.name,
|
|
123
|
-
let: {
|
|
124
|
-
canonicalDocumentID: {
|
|
125
|
-
$toString: canonicalIDExpression
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
pipeline: [
|
|
129
|
-
{
|
|
130
|
-
$match: {
|
|
131
|
-
$expr: {
|
|
132
|
-
$and: [
|
|
133
|
-
{
|
|
134
|
-
$eq: [
|
|
135
|
-
'$branch',
|
|
136
|
-
branch
|
|
137
|
-
]
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
$eq: [
|
|
141
|
-
'$collectionSlug',
|
|
142
|
-
collectionSlug
|
|
143
|
-
]
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
$eq: [
|
|
147
|
-
'$documentID',
|
|
148
|
-
'$$canonicalDocumentID'
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
]
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
$project: {
|
|
157
|
-
baseVersionID: 1,
|
|
158
|
-
baseVersionUpdatedAt: 1,
|
|
159
|
-
operation: 1
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
$limit: 1
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
$match: {
|
|
170
|
-
$expr: {
|
|
171
|
-
$or: [
|
|
172
|
-
{
|
|
173
|
-
$and: [
|
|
174
|
-
{
|
|
175
|
-
$eq: [
|
|
176
|
-
'$_branch',
|
|
177
|
-
MAIN_BRANCH
|
|
178
|
-
]
|
|
179
|
-
},
|
|
180
|
-
mainVisibility
|
|
181
|
-
]
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
$and: [
|
|
185
|
-
{
|
|
186
|
-
$eq: [
|
|
187
|
-
'$_branch',
|
|
188
|
-
branch
|
|
189
|
-
]
|
|
190
|
-
},
|
|
191
|
-
branchVisibility
|
|
192
|
-
]
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
$unset: lookupField
|
|
200
|
-
}
|
|
201
|
-
];
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
//# sourceMappingURL=buildBranchVisibility.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/queries/buildBranchVisibility.ts"],"sourcesContent":["import type { PipelineStage } from 'mongoose'\n\nimport { branchChangesCollectionSlug, MAIN_BRANCH } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nconst lookupField = '__payloadBranchChange'\n\ntype BranchVisibilityStage = Exclude<PipelineStage, PipelineStage.Merge | PipelineStage.Out>\n\nexport const buildBranchVisibilityStages = ({\n adapter,\n branch,\n collectionSlug,\n mode = 'documents',\n}: {\n adapter: MongooseAdapter\n branch: string\n collectionSlug: string\n mode?: 'documents' | 'drafts' | 'history'\n}): BranchVisibilityStage[] => {\n const branchChangesModel = adapter.collections[branchChangesCollectionSlug]\n\n if (!branchChangesModel) {\n throw new Error(`Collection model \"${branchChangesCollectionSlug}\" is not initialized.`)\n }\n\n const canonicalIDExpression =\n mode === 'documents'\n ? { $ifNull: ['$_branchDocID', '$_id'] }\n : { $ifNull: ['$_branchParent', '$parent'] }\n const hasNoMatchingChange = { $eq: [{ $size: `$${lookupField}` }, 0] }\n const operation = { $arrayElemAt: [`$${lookupField}.operation`, 0] }\n const mainVisibility =\n mode === 'history'\n ? {\n $or: [\n hasNoMatchingChange,\n {\n $and: [\n { $ne: [operation, 'create'] },\n {\n $or: [\n {\n $and: [\n {\n $eq: [{ $arrayElemAt: [`$${lookupField}.baseVersionID`, 0] }, null],\n },\n {\n $eq: [\n { $arrayElemAt: [`$${lookupField}.baseVersionUpdatedAt`, 0] },\n null,\n ],\n },\n ],\n },\n {\n $eq: [\n { $toString: '$_id' },\n { $arrayElemAt: [`$${lookupField}.baseVersionID`, 0] },\n ],\n },\n {\n $lte: [\n '$updatedAt',\n { $arrayElemAt: [`$${lookupField}.baseVersionUpdatedAt`, 0] },\n ],\n },\n ],\n },\n ],\n },\n ],\n }\n : hasNoMatchingChange\n const branchVisibility = mode === 'history' ? true : { $ne: [operation, 'delete'] }\n\n return [\n { $match: { _branch: { $in: [MAIN_BRANCH, branch] } } },\n {\n $lookup: {\n as: lookupField,\n from: branchChangesModel.collection.name,\n let: { canonicalDocumentID: { $toString: canonicalIDExpression } },\n pipeline: [\n {\n $match: {\n $expr: {\n $and: [\n { $eq: ['$branch', branch] },\n { $eq: ['$collectionSlug', collectionSlug] },\n { $eq: ['$documentID', '$$canonicalDocumentID'] },\n ],\n },\n },\n },\n {\n $project: {\n baseVersionID: 1,\n baseVersionUpdatedAt: 1,\n operation: 1,\n },\n },\n { $limit: 1 },\n ],\n },\n },\n {\n $match: {\n $expr: {\n $or: [\n { $and: [{ $eq: ['$_branch', MAIN_BRANCH] }, mainVisibility] },\n { $and: [{ $eq: ['$_branch', branch] }, branchVisibility] },\n ],\n },\n },\n },\n { $unset: lookupField },\n ]\n}\n"],"names":["branchChangesCollectionSlug","MAIN_BRANCH","lookupField","buildBranchVisibilityStages","adapter","branch","collectionSlug","mode","branchChangesModel","collections","Error","canonicalIDExpression","$ifNull","hasNoMatchingChange","$eq","$size","operation","$arrayElemAt","mainVisibility","$or","$and","$ne","$toString","$lte","branchVisibility","$match","_branch","$in","$lookup","as","from","collection","name","let","canonicalDocumentID","pipeline","$expr","$project","baseVersionID","baseVersionUpdatedAt","$limit","$unset"],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upsertBranchGlobalChange.d.ts","sourceRoot":"","sources":["../src/upsertBranchGlobalChange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAQvD,eAAO,MAAM,wBAAwB,EAAE,wBAuBpC,CAAA"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { branchChangesCollectionSlug } from 'payload';
|
|
2
|
-
import { getSession } from './utilities/getSession.js';
|
|
3
|
-
export const upsertBranchGlobalChange = async function upsertBranchGlobalChange({ branch, globalSlug, req }) {
|
|
4
|
-
const Model = this.collections[branchChangesCollectionSlug];
|
|
5
|
-
const now = new Date().toISOString();
|
|
6
|
-
if (!Model) {
|
|
7
|
-
throw new Error(`Collection model "${branchChangesCollectionSlug}" is not initialized.`);
|
|
8
|
-
}
|
|
9
|
-
await Model.updateOne({
|
|
10
|
-
branch,
|
|
11
|
-
globalSlug
|
|
12
|
-
}, {
|
|
13
|
-
$setOnInsert: {
|
|
14
|
-
branch,
|
|
15
|
-
createdAt: now,
|
|
16
|
-
entityType: 'global',
|
|
17
|
-
globalSlug,
|
|
18
|
-
operation: 'update',
|
|
19
|
-
updatedAt: now
|
|
20
|
-
}
|
|
21
|
-
}, {
|
|
22
|
-
session: await getSession(this, req),
|
|
23
|
-
timestamps: false,
|
|
24
|
-
upsert: true
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=upsertBranchGlobalChange.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/upsertBranchGlobalChange.ts"],"sourcesContent":["import type { UpsertBranchGlobalChange } from 'payload'\n\nimport { branchChangesCollectionSlug } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getSession } from './utilities/getSession.js'\n\nexport const upsertBranchGlobalChange: UpsertBranchGlobalChange =\n async function upsertBranchGlobalChange(this: MongooseAdapter, { branch, globalSlug, req }) {\n const Model = this.collections[branchChangesCollectionSlug]\n const now = new Date().toISOString()\n\n if (!Model) {\n throw new Error(`Collection model \"${branchChangesCollectionSlug}\" is not initialized.`)\n }\n\n await Model.updateOne(\n { branch, globalSlug },\n {\n $setOnInsert: {\n branch,\n createdAt: now,\n entityType: 'global',\n globalSlug,\n operation: 'update',\n updatedAt: now,\n },\n },\n { session: await getSession(this, req), timestamps: false, upsert: true },\n )\n }\n"],"names":["branchChangesCollectionSlug","getSession","upsertBranchGlobalChange","branch","globalSlug","req","Model","collections","now","Date","toISOString","Error","updateOne","$setOnInsert","createdAt","entityType","operation","updatedAt","session","timestamps","upsert"],"mappings":"AAEA,SAASA,2BAA2B,QAAQ,UAAS;AAIrD,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,MAAMC,2BACX,eAAeA,yBAAgD,EAAEC,MAAM,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACxF,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACP,4BAA4B;IAC3D,MAAMQ,MAAM,IAAIC,OAAOC,WAAW;IAElC,IAAI,CAACJ,OAAO;QACV,MAAM,IAAIK,MAAM,CAAC,kBAAkB,EAAEX,4BAA4B,qBAAqB,CAAC;IACzF;IAEA,MAAMM,MAAMM,SAAS,CACnB;QAAET;QAAQC;IAAW,GACrB;QACES,cAAc;YACZV;YACAW,WAAWN;YACXO,YAAY;YACZX;YACAY,WAAW;YACXC,WAAWT;QACb;IACF,GACA;QAAEU,SAAS,MAAMjB,WAAW,IAAI,EAAEI;QAAMc,YAAY;QAAOC,QAAQ;IAAK;AAE5E,EAAC"}
|