@simplysf/simply-aep 0.15.9 → 0.16.0
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/README.md +358 -17
- package/lib/commands/simply/aep/generate/domain.d.ts +21 -0
- package/lib/commands/simply/aep/generate/domain.js +41 -0
- package/lib/commands/simply/aep/generate/domain.js.map +1 -0
- package/lib/commands/simply/aep/generate/selector.d.ts +21 -0
- package/lib/commands/simply/aep/generate/selector.js +41 -0
- package/lib/commands/simply/aep/generate/selector.js.map +1 -0
- package/lib/commands/simply/aep/generate/service.d.ts +21 -0
- package/lib/commands/simply/aep/generate/service.js +45 -0
- package/lib/commands/simply/aep/generate/service.js.map +1 -0
- package/lib/commands/simply/aep/generate/unit-of-work.d.ts +22 -0
- package/lib/commands/simply/aep/generate/unit-of-work.js +42 -0
- package/lib/commands/simply/aep/generate/unit-of-work.js.map +1 -0
- package/lib/commands/simply/aep/generate.d.ts +25 -0
- package/lib/commands/simply/aep/generate.js +45 -0
- package/lib/commands/simply/aep/generate.js.map +1 -0
- package/lib/common/generate/flags.d.ts +27 -0
- package/lib/common/generate/flags.js +63 -0
- package/lib/common/generate/flags.js.map +1 -0
- package/lib/common/generate/runGeneration.d.ts +52 -0
- package/lib/common/generate/runGeneration.js +196 -0
- package/lib/common/generate/runGeneration.js.map +1 -0
- package/messages/simply.aep.generate.common.md +78 -0
- package/messages/simply.aep.generate.domain.md +19 -0
- package/messages/simply.aep.generate.md +37 -0
- package/messages/simply.aep.generate.selector.md +19 -0
- package/messages/simply.aep.generate.service.md +23 -0
- package/messages/simply.aep.generate.unit-of-work.md +23 -0
- package/oclif.manifest.json +747 -1
- package/package.json +5 -4
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { type GenerateCommandResult } from '../../../../common/generate/runGeneration.js';
|
|
3
|
+
/** Generates a service facade, interface, implementation, exception, and test, and (at4dx) its binding. */
|
|
4
|
+
export default class AepGenerateService extends SfCommand<GenerateCommandResult> {
|
|
5
|
+
static readonly summary: string;
|
|
6
|
+
static readonly description: string;
|
|
7
|
+
static readonly examples: string[];
|
|
8
|
+
static readonly flags: {
|
|
9
|
+
'output-dir': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
overwrite: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
flavor: import("@oclif/core/interfaces").OptionFlag<import("@simplysf/simply-aep-core").Flavor, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
prefix: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'service-basename': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
};
|
|
20
|
+
run(): Promise<GenerateCommandResult>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
18
|
+
import { generateService } from '@simplysf/simply-aep-core';
|
|
19
|
+
import { runGeneration } from '../../../../common/generate/runGeneration.js';
|
|
20
|
+
import { flavorFlags, generateWriteFlags, optionalOrgFlags } from '../../../../common/generate/flags.js';
|
|
21
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
22
|
+
const messages = Messages.loadMessages('@simplysf/simply-aep', 'simply.aep.generate.service');
|
|
23
|
+
/** Generates a service facade, interface, implementation, exception, and test, and (at4dx) its binding. */
|
|
24
|
+
export default class AepGenerateService extends SfCommand {
|
|
25
|
+
static summary = messages.getMessage('summary');
|
|
26
|
+
static description = messages.getMessage('description');
|
|
27
|
+
static examples = messages.getMessages('examples');
|
|
28
|
+
static flags = {
|
|
29
|
+
...SfCommand.baseFlags,
|
|
30
|
+
...optionalOrgFlags,
|
|
31
|
+
'service-basename': Flags.string({
|
|
32
|
+
summary: messages.getMessage('flags.service-basename.summary'),
|
|
33
|
+
required: true,
|
|
34
|
+
}),
|
|
35
|
+
...flavorFlags,
|
|
36
|
+
...generateWriteFlags,
|
|
37
|
+
};
|
|
38
|
+
async run() {
|
|
39
|
+
const { flags } = await this.parse(AepGenerateService);
|
|
40
|
+
// An explicit --api-version is all an org would have been used for, so don't connect.
|
|
41
|
+
const connection = flags['api-version'] ? undefined : flags['target-org']?.getConnection(flags['api-version']);
|
|
42
|
+
return runGeneration(generateService, connection, flags, this);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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,sFAAsF;QACtF,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QAC/G,OAAO,aAAa,CAAC,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { type GenerateCommandResult } from '../../../../common/generate/runGeneration.js';
|
|
3
|
+
/** Generates an AT4DX unit-of-work binding, or prints the fflib Application entry to add by hand. */
|
|
4
|
+
export default class AepGenerateUnitOfWork extends SfCommand<GenerateCommandResult> {
|
|
5
|
+
static readonly summary: string;
|
|
6
|
+
static readonly description: string;
|
|
7
|
+
static readonly examples: string[];
|
|
8
|
+
static readonly flags: {
|
|
9
|
+
'output-dir': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
overwrite: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
sequence: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
flavor: import("@oclif/core/interfaces").OptionFlag<import("@simplysf/simply-aep-core").Flavor, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
prefix: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
sobject: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org>;
|
|
19
|
+
'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
};
|
|
21
|
+
run(): Promise<GenerateCommandResult>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
18
|
+
import { generateUnitOfWork } from '@simplysf/simply-aep-core';
|
|
19
|
+
import { requireConnection } from '@simplysf/simply-plugin-kit';
|
|
20
|
+
import { runGeneration } from '../../../../common/generate/runGeneration.js';
|
|
21
|
+
import { flavorFlags, generateWriteFlags, orgFlags, sobjectFlag } from '../../../../common/generate/flags.js';
|
|
22
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
23
|
+
const messages = Messages.loadMessages('@simplysf/simply-aep', 'simply.aep.generate.unit-of-work');
|
|
24
|
+
/** Generates an AT4DX unit-of-work binding, or prints the fflib Application entry to add by hand. */
|
|
25
|
+
export default class AepGenerateUnitOfWork extends SfCommand {
|
|
26
|
+
static summary = messages.getMessage('summary');
|
|
27
|
+
static description = messages.getMessage('description');
|
|
28
|
+
static examples = messages.getMessages('examples');
|
|
29
|
+
static flags = {
|
|
30
|
+
...SfCommand.baseFlags,
|
|
31
|
+
...orgFlags,
|
|
32
|
+
sobject: sobjectFlag,
|
|
33
|
+
...flavorFlags,
|
|
34
|
+
sequence: Flags.string({ summary: messages.getMessage('flags.sequence.summary') }),
|
|
35
|
+
...generateWriteFlags,
|
|
36
|
+
};
|
|
37
|
+
async run() {
|
|
38
|
+
const { flags } = await this.parse(AepGenerateUnitOfWork);
|
|
39
|
+
return runGeneration(generateUnitOfWork, requireConnection(flags), flags, this);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=unit-of-work.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit-of-work.js","sourceRoot":"","sources":["../../../../../src/commands/simply/aep/generate/unit-of-work.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,aAAa,EAA8B,MAAM,8CAA8C,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAE9G,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,sBAAsB,EAAE,kCAAkC,CAAC,CAAC;AAEnG,qGAAqG;AACrG,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,SAAgC;IAC1E,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,GAAG,SAAS,CAAC,SAAS;QACtB,GAAG,QAAQ;QACX,OAAO,EAAE,WAAW;QACpB,GAAG,WAAW;QACd,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,wBAAwB,CAAC,EAAE,CAAC;QAClF,GAAG,kBAAkB;KACtB,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAC1D,OAAO,aAAa,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAClF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { type GenerateCommandResult } from '../../../common/generate/runGeneration.js';
|
|
3
|
+
/** Generates the selector, domain, and unit-of-work layers selected, from one SObject describe. */
|
|
4
|
+
export default class AepGenerate extends SfCommand<GenerateCommandResult> {
|
|
5
|
+
static readonly summary: string;
|
|
6
|
+
static readonly description: string;
|
|
7
|
+
static readonly examples: string[];
|
|
8
|
+
static readonly flags: {
|
|
9
|
+
'output-dir': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
overwrite: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
selector: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
domain: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
'unit-of-work': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
sequence: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
flavor: import("@oclif/core/interfaces").OptionFlag<import("@simplysf/simply-aep-core").Flavor, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
prefix: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
sobject: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org>;
|
|
22
|
+
'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
};
|
|
24
|
+
run(): Promise<GenerateCommandResult>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
18
|
+
import { generate } from '@simplysf/simply-aep-core';
|
|
19
|
+
import { requireConnection } from '@simplysf/simply-plugin-kit';
|
|
20
|
+
import { runGeneration } from '../../../common/generate/runGeneration.js';
|
|
21
|
+
import { flavorFlags, generateWriteFlags, orgFlags, sobjectFlag } from '../../../common/generate/flags.js';
|
|
22
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
23
|
+
const messages = Messages.loadMessages('@simplysf/simply-aep', 'simply.aep.generate');
|
|
24
|
+
/** Generates the selector, domain, and unit-of-work layers selected, from one SObject describe. */
|
|
25
|
+
export default class AepGenerate extends SfCommand {
|
|
26
|
+
static summary = messages.getMessage('summary');
|
|
27
|
+
static description = messages.getMessage('description');
|
|
28
|
+
static examples = messages.getMessages('examples');
|
|
29
|
+
static flags = {
|
|
30
|
+
...SfCommand.baseFlags,
|
|
31
|
+
...orgFlags,
|
|
32
|
+
sobject: sobjectFlag,
|
|
33
|
+
...flavorFlags,
|
|
34
|
+
selector: Flags.boolean({ summary: messages.getMessage('flags.selector.summary'), default: false }),
|
|
35
|
+
domain: Flags.boolean({ summary: messages.getMessage('flags.domain.summary'), default: false }),
|
|
36
|
+
'unit-of-work': Flags.boolean({ summary: messages.getMessage('flags.unit-of-work.summary'), default: false }),
|
|
37
|
+
sequence: Flags.string({ summary: messages.getMessage('flags.sequence.summary') }),
|
|
38
|
+
...generateWriteFlags,
|
|
39
|
+
};
|
|
40
|
+
async run() {
|
|
41
|
+
const { flags } = await this.parse(AepGenerate);
|
|
42
|
+
return runGeneration(generate, requireConnection(flags), flags, this);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/commands/simply/aep/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;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AAE,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,4BAA4B,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC7G,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,wBAAwB,CAAC,EAAE,CAAC;QAClF,GAAG,kBAAkB;KACtB,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAChD,OAAO,aAAa,CAAC,QAAQ,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Flavor } from '@simplysf/simply-aep-core';
|
|
2
|
+
/** The flags every `simply aep generate` command declares: where to write, and the write guards. */
|
|
3
|
+
export declare const generateWriteFlags: {
|
|
4
|
+
'output-dir': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
5
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
overwrite: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
};
|
|
9
|
+
/** `--flavor` and `--prefix`, for the generators that support both frameworks. */
|
|
10
|
+
export declare const flavorFlags: {
|
|
11
|
+
flavor: import("@oclif/core/interfaces").OptionFlag<Flavor, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
prefix: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* `--target-org`/`--api-version` for the generators that describe an SObject: the plugin kit's pair,
|
|
16
|
+
* keeping apx's `-a` short form. Read with the kit's `requireConnection`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const orgFlags: {
|
|
19
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org>;
|
|
21
|
+
};
|
|
22
|
+
/** The same, with the org optional, for `generate service` — which only uses one for its API version. */
|
|
23
|
+
export declare const optionalOrgFlags: {
|
|
24
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
+
};
|
|
27
|
+
export declare const sobjectFlag: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
+
import { DEFAULT_OUTPUT_PATH } from '@simplysf/simply-aep-core';
|
|
19
|
+
import { targetOrgFlags } from '@simplysf/simply-plugin-kit';
|
|
20
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
21
|
+
const messages = Messages.loadMessages('@simplysf/simply-aep', 'simply.aep.generate.common');
|
|
22
|
+
const FLAVORS = ['at4dx', 'fflib'];
|
|
23
|
+
/** The flags every `simply aep generate` command declares: where to write, and the write guards. */
|
|
24
|
+
export const generateWriteFlags = {
|
|
25
|
+
'output-dir': Flags.directory({
|
|
26
|
+
char: 'd',
|
|
27
|
+
summary: messages.getMessage('flags.output-dir.summary'),
|
|
28
|
+
description: messages.getMessage('flags.output-dir.description'),
|
|
29
|
+
default: DEFAULT_OUTPUT_PATH,
|
|
30
|
+
}),
|
|
31
|
+
'dry-run': Flags.boolean({ summary: messages.getMessage('flags.dry-run.summary'), default: false }),
|
|
32
|
+
overwrite: Flags.boolean({ summary: messages.getMessage('flags.overwrite.summary'), default: false }),
|
|
33
|
+
force: Flags.boolean({ summary: messages.getMessage('flags.force.summary'), default: false }),
|
|
34
|
+
};
|
|
35
|
+
/** `--flavor` and `--prefix`, for the generators that support both frameworks. */
|
|
36
|
+
export const flavorFlags = {
|
|
37
|
+
flavor: Flags.custom({ options: [...FLAVORS] })({
|
|
38
|
+
char: 'f',
|
|
39
|
+
summary: messages.getMessage('flags.flavor.summary'),
|
|
40
|
+
description: messages.getMessage('flags.flavor.description'),
|
|
41
|
+
required: true,
|
|
42
|
+
}),
|
|
43
|
+
prefix: Flags.string({ summary: messages.getMessage('flags.prefix.summary') }),
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* `--target-org`/`--api-version` for the generators that describe an SObject: the plugin kit's pair,
|
|
47
|
+
* keeping apx's `-a` short form. Read with the kit's `requireConnection`.
|
|
48
|
+
*/
|
|
49
|
+
export const orgFlags = {
|
|
50
|
+
...targetOrgFlags,
|
|
51
|
+
'api-version': Flags.orgApiVersion({ char: 'a' }),
|
|
52
|
+
};
|
|
53
|
+
/** The same, with the org optional, for `generate service` — which only uses one for its API version. */
|
|
54
|
+
export const optionalOrgFlags = {
|
|
55
|
+
'target-org': Flags.optionalOrg({ char: 'o', summary: messages.getMessage('flags.optional-target-org.summary') }),
|
|
56
|
+
'api-version': Flags.orgApiVersion({ char: 'a' }),
|
|
57
|
+
};
|
|
58
|
+
export const sobjectFlag = Flags.string({
|
|
59
|
+
char: 's',
|
|
60
|
+
summary: messages.getMessage('flags.sobject.summary'),
|
|
61
|
+
required: true,
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../../src/common/generate/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAe,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,sBAAsB,EAAE,4BAA4B,CAAC,CAAC;AAE7F,MAAM,OAAO,GAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAEtD,oGAAoG;AACpG,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC;QAC5B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC;QACxD,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC;QAChE,OAAO,EAAE,mBAAmB;KAC7B,CAAC;IACF,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE,OAAO,EAAE,KAAK,E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AC,MAAM,CAAC;IACtC,IAAI,EAAE,GAAG;IACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC;IACrD,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type Connection } from '@salesforce/core';
|
|
2
|
+
import type { SfCommand } from '@salesforce/sf-plugins-core';
|
|
3
|
+
import { type AepCommandResult, type GenerationIssue, type GenerationUseCase } from '@simplysf/simply-aep-core';
|
|
4
|
+
/**
|
|
5
|
+
* What every `simply aep generate` command returns under `--json`. On `--dry-run`, `wouldCreate` lists
|
|
6
|
+
* the planned files that don't exist yet and `wouldOverwrite` the ones that do, which a real run
|
|
7
|
+
* replaces with `--overwrite` and otherwise refuses.
|
|
8
|
+
*/
|
|
9
|
+
export type GenerateCommandResult = AepCommandResult & {
|
|
10
|
+
wouldOverwrite?: string[];
|
|
11
|
+
issues: GenerationIssue[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The flag behind each use-case option, for every option any generator takes. A use case whose
|
|
15
|
+
* schema has a key missing here can't be driven from the CLI — `test/.../generate/parity.test.ts`
|
|
16
|
+
* checks every command against it, so that fails CI instead of silently dropping the option.
|
|
17
|
+
*/
|
|
18
|
+
export declare const FLAG_BY_OPTION: Readonly<Record<string, string>>;
|
|
19
|
+
/** The flags every generator declares that aren't options of the use case. */
|
|
20
|
+
export declare const CLI_ONLY_FLAGS: ReadonlySet<string>;
|
|
21
|
+
/**
|
|
22
|
+
* @param useCase - The generator.
|
|
23
|
+
* @param flags - The command's parsed flags.
|
|
24
|
+
* @returns The use case's options, read from the flags `FLAG_BY_OPTION` names.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toOptions(useCase: GenerationUseCase, flags: Record<string, unknown>): Record<string, unknown>;
|
|
27
|
+
/** Where `runGeneration` writes: the calling command, whose output methods already go quiet under `--json`. */
|
|
28
|
+
export type GenerationReporter = Pick<SfCommand<unknown>, 'log' | 'warn' | 'table'>;
|
|
29
|
+
type WriteFlags = {
|
|
30
|
+
'dry-run': boolean;
|
|
31
|
+
overwrite: boolean;
|
|
32
|
+
force: boolean;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @param error - What a use case threw.
|
|
36
|
+
* @returns The error to throw from the command: a message-catalog `SfError` for the codes users can act on.
|
|
37
|
+
*/
|
|
38
|
+
export declare function toGenerateCliError(error: unknown): Error;
|
|
39
|
+
/**
|
|
40
|
+
* The CLI path for every generator: plan, validate what the planned binding records would
|
|
41
|
+
* introduce, then report a dry run or write — refusing to replace existing files without
|
|
42
|
+
* `--overwrite`, or to introduce an error-severity issue without `--force`. See
|
|
43
|
+
* docs/design/0045-migrate-apx-into-simply-aep.md.
|
|
44
|
+
*
|
|
45
|
+
* @param useCase - The generator.
|
|
46
|
+
* @param connection - The org connection, when the generator uses one.
|
|
47
|
+
* @param flags - The command's parsed flags.
|
|
48
|
+
* @param reporter - Where human-readable output goes; no-ops under `--json`.
|
|
49
|
+
* @returns The `--json` result.
|
|
50
|
+
*/
|
|
51
|
+
export declare function runGeneration(useCase: GenerationUseCase, connection: Connection | undefined, flags: WriteFlags & Record<string, unknown>, reporter: GenerationReporter): Promise<GenerateCommandResult>;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages, SfError, SfProject } from '@salesforce/core';
|
|
17
|
+
import { isAepGenerationError, planValidation, renderGenerationPlan, renderGenerationResult, } from '@simplysf/simply-aep-core';
|
|
18
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
19
|
+
const messages = Messages.loadMessages('@simplysf/simply-aep', 'simply.aep.generate.common');
|
|
20
|
+
/**
|
|
21
|
+
* The flag behind each use-case option, for every option any generator takes. A use case whose
|
|
22
|
+
* schema has a key missing here can't be driven from the CLI — `test/.../generate/parity.test.ts`
|
|
23
|
+
* checks every command against it, so that fails CI instead of silently dropping the option.
|
|
24
|
+
*/
|
|
25
|
+
export const FLAG_BY_OPTION = {
|
|
26
|
+
outputPath: 'output-dir',
|
|
27
|
+
apiVersion: 'api-version',
|
|
28
|
+
sobject: 'sobject',
|
|
29
|
+
flavor: 'flavor',
|
|
30
|
+
prefix: 'prefix',
|
|
31
|
+
bindingSequence: 'sequence',
|
|
32
|
+
selector: 'selector',
|
|
33
|
+
domain: 'domain',
|
|
34
|
+
unitOfWork: 'unit-of-work',
|
|
35
|
+
serviceBasename: 'service-basename',
|
|
36
|
+
};
|
|
37
|
+
/** The flags every generator declares that aren't options of the use case. */
|
|
38
|
+
export const CLI_ONLY_FLAGS = new Set([
|
|
39
|
+
'target-org',
|
|
40
|
+
'dry-run',
|
|
41
|
+
'overwrite',
|
|
42
|
+
'force',
|
|
43
|
+
'json',
|
|
44
|
+
'flags-dir',
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* @param useCase - The generator.
|
|
48
|
+
* @param flags - The command's parsed flags.
|
|
49
|
+
* @returns The use case's options, read from the flags `FLAG_BY_OPTION` names.
|
|
50
|
+
*/
|
|
51
|
+
export function toOptions(useCase, flags) {
|
|
52
|
+
const shape = useCase.descriptor.optionsSchema.shape;
|
|
53
|
+
return Object.fromEntries(Object.keys(shape).map((key) => {
|
|
54
|
+
// parity.test.ts catches this against the pinned core; this covers running against a newer one.
|
|
55
|
+
const flag = FLAG_BY_OPTION[key];
|
|
56
|
+
if (!flag)
|
|
57
|
+
throw new SfError(`${useCase.descriptor.id} takes option ${key}, which no flag sets.`, 'UnmappedOption');
|
|
58
|
+
return [key, flags[flag]];
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Parses the options with the use case's own schema before planning, so each issue can name its flag.
|
|
63
|
+
*
|
|
64
|
+
* @param useCase - The generator.
|
|
65
|
+
* @param options - From `toOptions`.
|
|
66
|
+
* @throws {SfError} `InvalidOptions`, one line per issue, each prefixed with the flag it came from.
|
|
67
|
+
*/
|
|
68
|
+
function validateOptions(useCase, options) {
|
|
69
|
+
const parsed = useCase.descriptor.optionsSchema.safeParse(options);
|
|
70
|
+
if (parsed.success)
|
|
71
|
+
return;
|
|
72
|
+
const lines = parsed.error.issues.map((issue) => {
|
|
73
|
+
const flag = FLAG_BY_OPTION[String(issue.path[0])];
|
|
74
|
+
// Cross-field rules, such as the aggregate's "select at least one", already name their flags.
|
|
75
|
+
return flag && !issue.message.includes(`--${flag}`) ? `--${flag}: ${issue.message}` : issue.message;
|
|
76
|
+
});
|
|
77
|
+
throw messages.createError('error.invalidOptions', [lines.join('\n')]);
|
|
78
|
+
}
|
|
79
|
+
const ISSUE_TABLE_COLUMNS = [
|
|
80
|
+
{ key: 'severity', name: 'SEVERITY' },
|
|
81
|
+
{ key: 'rule', name: 'RULE' },
|
|
82
|
+
{ key: 'message', name: 'MESSAGE' },
|
|
83
|
+
];
|
|
84
|
+
/**
|
|
85
|
+
* Generators also run outside a Salesforce DX project, e.g. in a scratch folder, and then validate
|
|
86
|
+
* against `--output-dir` alone. Any other failure, such as a malformed `sfdx-project.json`, is thrown
|
|
87
|
+
* rather than quietly narrowing the scan.
|
|
88
|
+
*
|
|
89
|
+
* @returns The project's package directories, or none outside a Salesforce DX project.
|
|
90
|
+
*/
|
|
91
|
+
async function packageDirectories() {
|
|
92
|
+
try {
|
|
93
|
+
const project = await SfProject.resolve();
|
|
94
|
+
return project.getPackageDirectories().map((dir) => dir.fullPath);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (error instanceof Error && error.name === 'InvalidProjectWorkspaceError')
|
|
98
|
+
return [];
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @param error - What a use case threw.
|
|
104
|
+
* @returns The error to throw from the command: a message-catalog `SfError` for the codes users can act on.
|
|
105
|
+
*/
|
|
106
|
+
export function toGenerateCliError(error) {
|
|
107
|
+
if (isAepGenerationError(error)) {
|
|
108
|
+
const data = error.data;
|
|
109
|
+
switch (error.code) {
|
|
110
|
+
case 'sobject-not-found':
|
|
111
|
+
return messages.createError('error.sobjectNotFound', [data?.sobject]);
|
|
112
|
+
case 'describe-failed':
|
|
113
|
+
return data?.cause instanceof Error ? data.cause : error;
|
|
114
|
+
case 'nothing-selected':
|
|
115
|
+
return messages.createError('error.nothingSelected');
|
|
116
|
+
case 'file-exists':
|
|
117
|
+
return messages.createError('error.filesExist', [(data?.absolutePaths ?? []).join('\n')]);
|
|
118
|
+
case 'org-required':
|
|
119
|
+
case 'cancelled':
|
|
120
|
+
case 'duplicate-path':
|
|
121
|
+
case 'write-failed':
|
|
122
|
+
case 'invalid-developer-name':
|
|
123
|
+
case 'invalid-path':
|
|
124
|
+
case 'template-missing':
|
|
125
|
+
case 'template-empty':
|
|
126
|
+
return new SfError(error.message, 'AepGenerationError');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The CLI path for every generator: plan, validate what the planned binding records would
|
|
133
|
+
* introduce, then report a dry run or write — refusing to replace existing files without
|
|
134
|
+
* `--overwrite`, or to introduce an error-severity issue without `--force`. See
|
|
135
|
+
* docs/design/0045-migrate-apx-into-simply-aep.md.
|
|
136
|
+
*
|
|
137
|
+
* @param useCase - The generator.
|
|
138
|
+
* @param connection - The org connection, when the generator uses one.
|
|
139
|
+
* @param flags - The command's parsed flags.
|
|
140
|
+
* @param reporter - Where human-readable output goes; no-ops under `--json`.
|
|
141
|
+
* @returns The `--json` result.
|
|
142
|
+
*/
|
|
143
|
+
export async function runGeneration(useCase, connection, flags, reporter) {
|
|
144
|
+
const commandId = useCase.descriptor.id;
|
|
145
|
+
try {
|
|
146
|
+
const options = toOptions(useCase, flags);
|
|
147
|
+
validateOptions(useCase, options);
|
|
148
|
+
// TODO(phase 4): pass an AepUseCaseContext to plan/apply so Ctrl-C reaches the engine's
|
|
149
|
+
// cancellation checks (`signal`) and interactive mode can report `onProgress`.
|
|
150
|
+
const preview = await useCase.plan(connection, options);
|
|
151
|
+
const issues = planValidation(preview, [...(await packageDirectories()), preview.baseDir]);
|
|
152
|
+
if (issues.length > 0) {
|
|
153
|
+
reporter.table({
|
|
154
|
+
data: issues.map((issue) => ({ severity: issue.severity, rule: issue.rule, message: issue.message })),
|
|
155
|
+
columns: ISSUE_TABLE_COLUMNS,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const hasErrors = issues.some((issue) => issue.severity === 'error');
|
|
159
|
+
const existing = preview.files.filter((file) => file.status === 'exists');
|
|
160
|
+
const overwritePolicy = flags.overwrite ? 'overwrite' : 'error';
|
|
161
|
+
if (flags['dry-run']) {
|
|
162
|
+
for (const line of renderGenerationPlan(preview, overwritePolicy))
|
|
163
|
+
reporter.log(line);
|
|
164
|
+
const result = {
|
|
165
|
+
baseDir: preview.baseDir,
|
|
166
|
+
created: [],
|
|
167
|
+
skipped: [],
|
|
168
|
+
wouldCreate: preview.files.filter((file) => file.status !== 'exists').map((file) => file.absolutePath),
|
|
169
|
+
...(preview.manualSteps ? { manualSteps: preview.manualSteps } : {}),
|
|
170
|
+
};
|
|
171
|
+
// The summary line counts every planned file, new or existing.
|
|
172
|
+
const planned = { ...result, wouldCreate: preview.files.map((file) => file.absolutePath) };
|
|
173
|
+
for (const line of renderGenerationResult(planned, { commandId }))
|
|
174
|
+
reporter.log(line);
|
|
175
|
+
if (existing.length > 0 && !flags.overwrite) {
|
|
176
|
+
reporter.warn(messages.getMessage('warning.dryRunWouldOverwrite', [existing.length]));
|
|
177
|
+
}
|
|
178
|
+
if (hasErrors && !flags.force)
|
|
179
|
+
reporter.warn(messages.getMessage('warning.dryRunWouldRefuse'));
|
|
180
|
+
return { ...result, wouldOverwrite: existing.map((file) => file.absolutePath), issues };
|
|
181
|
+
}
|
|
182
|
+
if (existing.length > 0 && !flags.overwrite) {
|
|
183
|
+
throw messages.createError('error.filesExist', [existing.map((file) => file.absolutePath).join('\n')]);
|
|
184
|
+
}
|
|
185
|
+
if (hasErrors && !flags.force)
|
|
186
|
+
throw messages.createError('error.validationFailed');
|
|
187
|
+
const outcome = await useCase.apply(connection, preview, { overwrite: overwritePolicy });
|
|
188
|
+
for (const line of renderGenerationResult(outcome, { commandId }))
|
|
189
|
+
reporter.log(line);
|
|
190
|
+
return { ...outcome, issues };
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
throw error instanceof SfError ? error : toGenerateCliError(error);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=runGeneration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runGeneration.js","sourceRoot":"","sources":["../../../src/common/generate/runGeneration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAmB,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEjF,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,sBAAsB,GAIvB,MAAM,2BAA2B,CAAC;AAEnC,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,Y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