medusa-test-utils 1.1.45 → 2.0.0-rc-20241001083650

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. package/dist/database.d.ts +2 -0
  2. package/dist/database.d.ts.map +1 -0
  3. package/dist/database.js +100 -146
  4. package/dist/database.js.map +1 -1
  5. package/dist/events.d.ts +3 -0
  6. package/dist/events.d.ts.map +1 -0
  7. package/dist/events.js +41 -0
  8. package/dist/events.js.map +1 -0
  9. package/dist/id-map.d.ts +3 -2
  10. package/dist/id-map.d.ts.map +1 -0
  11. package/dist/id-map.js +8 -11
  12. package/dist/id-map.js.map +1 -1
  13. package/dist/index.d.ts +5 -4
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +5 -7
  16. package/dist/index.js.map +1 -1
  17. package/dist/init-modules.d.ts +2 -1
  18. package/dist/init-modules.d.ts.map +1 -0
  19. package/dist/init-modules.js +39 -97
  20. package/dist/init-modules.js.map +1 -1
  21. package/dist/jest.d.ts +1 -0
  22. package/dist/jest.d.ts.map +1 -0
  23. package/dist/jest.js +15 -64
  24. package/dist/jest.js.map +1 -1
  25. package/dist/medusa-test-runner-utils/bootstrap-app.d.ts +10 -5
  26. package/dist/medusa-test-runner-utils/bootstrap-app.d.ts.map +1 -0
  27. package/dist/medusa-test-runner-utils/bootstrap-app.js +53 -147
  28. package/dist/medusa-test-runner-utils/bootstrap-app.js.map +1 -1
  29. package/dist/medusa-test-runner-utils/clear-instances.d.ts +8 -0
  30. package/dist/medusa-test-runner-utils/clear-instances.d.ts.map +1 -0
  31. package/dist/medusa-test-runner-utils/clear-instances.js +14 -0
  32. package/dist/medusa-test-runner-utils/clear-instances.js.map +1 -0
  33. package/dist/medusa-test-runner-utils/config.d.ts +5 -0
  34. package/dist/medusa-test-runner-utils/config.d.ts.map +1 -0
  35. package/dist/medusa-test-runner-utils/config.js +28 -0
  36. package/dist/medusa-test-runner-utils/config.js.map +1 -0
  37. package/dist/medusa-test-runner-utils/index.d.ts +6 -0
  38. package/dist/medusa-test-runner-utils/index.d.ts.map +1 -0
  39. package/dist/medusa-test-runner-utils/index.js +22 -0
  40. package/dist/medusa-test-runner-utils/index.js.map +1 -0
  41. package/dist/medusa-test-runner-utils/use-db.d.ts +15 -12
  42. package/dist/medusa-test-runner-utils/use-db.d.ts.map +1 -0
  43. package/dist/medusa-test-runner-utils/use-db.js +51 -143
  44. package/dist/medusa-test-runner-utils/use-db.js.map +1 -1
  45. package/dist/medusa-test-runner-utils/utils.d.ts +2 -0
  46. package/dist/medusa-test-runner-utils/utils.d.ts.map +1 -0
  47. package/dist/medusa-test-runner-utils/utils.js +10 -0
  48. package/dist/medusa-test-runner-utils/utils.js.map +1 -0
  49. package/dist/medusa-test-runner.d.ts +16 -6
  50. package/dist/medusa-test-runner.d.ts.map +1 -0
  51. package/dist/medusa-test-runner.js +123 -343
  52. package/dist/medusa-test-runner.js.map +1 -1
  53. package/dist/mock-event-bus-service.d.ts +5 -4
  54. package/dist/mock-event-bus-service.d.ts.map +1 -0
  55. package/dist/mock-event-bus-service.js +13 -51
  56. package/dist/mock-event-bus-service.js.map +1 -1
  57. package/dist/module-test-runner.d.ts +4 -2
  58. package/dist/module-test-runner.d.ts.map +1 -0
  59. package/dist/module-test-runner.js +117 -132
  60. package/dist/module-test-runner.js.map +1 -1
  61. package/dist/tsconfig.tsbuildinfo +1 -0
  62. package/package.json +27 -39
  63. package/dist/mock-manager.d.ts +0 -9
  64. package/dist/mock-manager.js +0 -30
  65. package/dist/mock-manager.js.map +0 -1
  66. package/dist/mock-repository.d.ts +0 -51
  67. package/dist/mock-repository.js +0 -193
  68. package/dist/mock-repository.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,oDAAiC;AACjC,2CAAwB;AACxB,2CAAwB;AACxB,0CAAuB"}
@@ -1,12 +1,15 @@
1
- import { DataSource } from "typeorm";
2
- export function initDb({ cwd, database_extra, env, force_modules_migration, dbUrl, dbSchema, }: {
3
- cwd: any;
4
- database_extra: any;
5
- env: any;
6
- force_modules_migration: any;
7
- dbUrl?: string | undefined;
8
- dbSchema?: string | undefined;
9
- }): Promise<{
10
- dbDataSource: DataSource;
11
- pgConnection: any;
12
- }>;
1
+ import type { MedusaAppLoader } from "@medusajs/framework";
2
+ import { MedusaContainer } from "@medusajs/framework/types";
3
+ /**
4
+ * Initiates the database connection
5
+ */
6
+ export declare function initDb(): Promise<import("knex").Knex<any, any>>;
7
+ /**
8
+ * Migrates the database
9
+ */
10
+ export declare function migrateDatabase(appLoader: MedusaAppLoader): Promise<void>;
11
+ /**
12
+ * Syncs links with the databse
13
+ */
14
+ export declare function syncLinks(appLoader: MedusaAppLoader, directory: string, container: MedusaContainer): Promise<void>;
15
+ //# sourceMappingURL=use-db.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-db.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/use-db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAG3D;;GAEG;AACH,wBAAsB,MAAM,2CAS3B;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,eAAe,iBAO/D;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,SAAS,EAAE,eAAe,EAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,eAAe,iBAe3B"}
@@ -1,148 +1,56 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- var __read = (this && this.__read) || function (o, n) {
49
- var m = typeof Symbol === "function" && o[Symbol.iterator];
50
- if (!m) return o;
51
- var i = m.call(o), r, ar = [], e;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initDb = initDb;
4
+ exports.migrateDatabase = migrateDatabase;
5
+ exports.syncLinks = syncLinks;
6
+ const path_1 = require("path");
7
+ const utils_1 = require("@medusajs/framework/utils");
8
+ /**
9
+ * Initiates the database connection
10
+ */
11
+ async function initDb() {
12
+ const { pgConnectionLoader, featureFlagsLoader } = await import("@medusajs/framework");
13
+ const pgConnection = pgConnectionLoader();
14
+ await featureFlagsLoader();
15
+ return pgConnection;
16
+ }
17
+ /**
18
+ * Migrates the database
19
+ */
20
+ async function migrateDatabase(appLoader) {
52
21
  try {
53
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
22
+ await appLoader.runModulesMigrations();
54
23
  }
55
- catch (error) { e = { error: error }; }
56
- finally {
57
- try {
58
- if (r && !r.done && (m = i["return"])) m.call(i);
59
- }
60
- finally { if (e) throw e.error; }
24
+ catch (err) {
25
+ console.error("Something went wrong while running the migrations");
26
+ throw err;
61
27
  }
62
- return ar;
63
- };
64
- var path = require("path");
65
- var getConfigFile = require("medusa-core-utils").getConfigFile;
66
- var asValue = require("awilix").asValue;
67
- var _a = require("@medusajs/utils"), isObject = _a.isObject, createMedusaContainer = _a.createMedusaContainer, MedusaV2Flag = _a.MedusaV2Flag;
68
- var DataSource = require("typeorm").DataSource;
69
- var ContainerRegistrationKeys = require("@medusajs/utils").ContainerRegistrationKeys;
70
- var logger = require("@medusajs/medusa-cli/dist/reporter").logger;
71
- module.exports = {
72
- initDb: function (_a) {
73
- var cwd = _a.cwd,
74
- // use for v1 datasource only
75
- database_extra = _a.database_extra, env = _a.env, force_modules_migration = _a.force_modules_migration, _b = _a.dbUrl, dbUrl = _b === void 0 ? "" : _b, _c = _a.dbSchema, dbSchema = _c === void 0 ? "public" : _c;
76
- return __awaiter(this, void 0, void 0, function () {
77
- var configModuleLoader, configModule, featureFlagsLoader, featureFlagRouter, modelsLoader, entities, migrationDir, _d, getEnabledMigrations, getModuleSharedResources, _e, moduleMigrations, moduleModels, enabledMigrations, enabledEntities, dbDataSource, pgConnectionLoader, featureFlagLoader, container, featureFlagRouter_1, pgConnection, migrateMedusaApp;
78
- var _f;
79
- return __generator(this, function (_g) {
80
- switch (_g.label) {
81
- case 0:
82
- if (isObject(env)) {
83
- Object.entries(env).forEach(function (_a) {
84
- var _b = __read(_a, 2), k = _b[0], v = _b[1];
85
- return (process.env[k] = v);
86
- });
87
- }
88
- configModuleLoader = require("@medusajs/medusa/dist/loaders/config").default;
89
- configModule = configModuleLoader(cwd);
90
- featureFlagsLoader = require("@medusajs/medusa/dist/loaders/feature-flags").default;
91
- featureFlagRouter = featureFlagsLoader(configModule);
92
- modelsLoader = require("@medusajs/medusa/dist/loaders/models").default;
93
- entities = modelsLoader({}, { register: false });
94
- migrationDir = path.resolve(path.join(cwd, "../../", "node_modules", "@medusajs", "medusa", "dist", "migrations", "*.js"));
95
- _d = require("@medusajs/medusa/dist/commands/utils/get-migrations"), getEnabledMigrations = _d.getEnabledMigrations, getModuleSharedResources = _d.getModuleSharedResources;
96
- _e = getModuleSharedResources(configModule, featureFlagRouter), moduleMigrations = _e.migrations, moduleModels = _e.models;
97
- enabledMigrations = getEnabledMigrations([migrationDir], function (flag) {
98
- return featureFlagRouter.isFeatureEnabled(flag);
99
- });
100
- enabledEntities = entities.filter(function (e) { return typeof e.isFeatureEnabled === "undefined" || e.isFeatureEnabled(); });
101
- dbDataSource = new DataSource({
102
- type: "postgres",
103
- url: dbUrl || configModule.projectConfig.database_url,
104
- entities: enabledEntities.concat(moduleModels),
105
- migrations: enabledMigrations.concat(moduleMigrations),
106
- extra: database_extra !== null && database_extra !== void 0 ? database_extra : {},
107
- //name: "integration-tests",
108
- schema: dbSchema,
109
- });
110
- return [4 /*yield*/, dbDataSource.initialize()];
111
- case 1:
112
- _g.sent();
113
- return [4 /*yield*/, dbDataSource.runMigrations()];
114
- case 2:
115
- _g.sent();
116
- if (!(force_modules_migration ||
117
- featureFlagRouter.isFeatureEnabled(MedusaV2Flag.key))) return [3 /*break*/, 6];
118
- pgConnectionLoader = require("@medusajs/medusa/dist/loaders/pg-connection").default;
119
- featureFlagLoader = require("@medusajs/medusa/dist/loaders/feature-flags").default;
120
- container = createMedusaContainer();
121
- return [4 /*yield*/, featureFlagLoader(configModule)];
122
- case 3:
123
- featureFlagRouter_1 = _g.sent();
124
- return [4 /*yield*/, pgConnectionLoader({
125
- configModule: __assign(__assign({}, configModule), { projectConfig: __assign(__assign({}, configModule.projectConfig), { database_url: dbUrl || configModule.projectConfig.database_url }) }),
126
- container: container,
127
- })];
128
- case 4:
129
- pgConnection = _g.sent();
130
- container.register((_f = {},
131
- _f[ContainerRegistrationKeys.CONFIG_MODULE] = asValue(configModule),
132
- _f[ContainerRegistrationKeys.LOGGER] = asValue(logger),
133
- _f[ContainerRegistrationKeys.MANAGER] = asValue(dbDataSource.manager),
134
- _f[ContainerRegistrationKeys.PG_CONNECTION] = asValue(pgConnection),
135
- _f.featureFlagRouter = asValue(featureFlagRouter_1),
136
- _f));
137
- migrateMedusaApp = require("@medusajs/medusa/dist/loaders/medusa-app").migrateMedusaApp;
138
- return [4 /*yield*/, migrateMedusaApp({ configModule: configModule, container: container }, { registerInContainer: false })];
139
- case 5:
140
- _g.sent();
141
- _g.label = 6;
142
- case 6: return [2 /*return*/, { dbDataSource: dbDataSource, pgConnection: pgConnection }];
143
- }
144
- });
28
+ }
29
+ /**
30
+ * Syncs links with the databse
31
+ */
32
+ async function syncLinks(appLoader, directory, container) {
33
+ try {
34
+ await loadCustomLinks(directory, container);
35
+ const planner = await appLoader.getLinksExecutionPlanner();
36
+ const actionPlan = await planner.createPlan();
37
+ actionPlan.forEach((action) => {
38
+ console.log(`Sync links: "${action.action}" ${action.tableName}`);
145
39
  });
146
- },
147
- };
40
+ await planner.executePlan(actionPlan);
41
+ }
42
+ catch (err) {
43
+ console.error("Something went wrong while syncing links");
44
+ throw err;
45
+ }
46
+ }
47
+ async function loadCustomLinks(directory, container) {
48
+ // TODO: move to framework once settle down
49
+ const { getResolvedPlugins, } = require("@medusajs/medusa/loaders/helpers/resolve-plugins");
50
+ const configModule = container.resolve(utils_1.ContainerRegistrationKeys.CONFIG_MODULE);
51
+ const plugins = getResolvedPlugins(directory, configModule, true) || [];
52
+ const linksSourcePaths = plugins.map((plugin) => (0, path_1.join)(plugin.resolve, "links"));
53
+ const { LinkLoader } = await import("@medusajs/framework");
54
+ await new LinkLoader(linksSourcePaths).load();
55
+ }
148
56
  //# sourceMappingURL=use-db.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-db.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/use-db.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEpB,IAAA,aAAa,GAAK,OAAO,CAAC,mBAAmB,CAAC,cAAjC,CAAiC;AAC9C,IAAA,OAAO,GAAK,OAAO,CAAC,QAAQ,CAAC,QAAtB,CAAsB;AAC/B,IAAA,KAIF,OAAO,CAAC,iBAAiB,CAAC,EAH5B,QAAQ,cAAA,EACR,qBAAqB,2BAAA,EACrB,YAAY,kBACgB,CAAA;AACtB,IAAA,UAAU,GAAK,OAAO,CAAC,SAAS,CAAC,WAAvB,CAAuB;AACjC,IAAA,yBAAyB,GAAK,OAAO,CAAC,iBAAiB,CAAC,0BAA/B,CAA+B;AACxD,IAAA,MAAM,GAAK,OAAO,CAAC,oCAAoC,CAAC,OAAlD,CAAkD;AAEhE,MAAM,CAAC,OAAO,GAAG;IACf,MA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AG,CAAC,CAAC,MAAM,EAAE,EAAE,CAC9C,IAAA,WAAI,EAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAC9B,CAAA;IAED,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAC1D,MAAM,IAAI,UAAU,CAAC,gBAAgB,CAAC,CAAC,IAAI,EAAE,CAAA;AAC/C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function applyEnvVarsToProcess(env?: Record<any, any>): void;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,QAI3D"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyEnvVarsToProcess = applyEnvVarsToProcess;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ function applyEnvVarsToProcess(env) {
6
+ if ((0, utils_1.isObject)(env)) {
7
+ Object.entries(env).forEach(([k, v]) => (process.env[k] = v));
8
+ }
9
+ }
10
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/utils.ts"],"names":[],"mappings":";;AAEA,sDAIC;AAND,qDAAoD;AAEpD,SAAgB,qBAAqB,CAAC,GAAsB;IAC1D,IAAI,IAAA,gBAAQ,EAAC,GAAG,CAAC,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC/D,CAAC;AACH,CAAC"}
@@ -1,21 +1,31 @@
1
- import { MedusaContainer } from "@medusajs/types";
2
- export interface MedusaSuiteOptions<TService = unknown> {
3
- dbUtils: any;
1
+ import { MedusaAppOutput } from "@medusajs/framework/modules-sdk";
2
+ import { MedusaContainer } from "@medusajs/framework/types";
3
+ export interface MedusaSuiteOptions {
4
4
  dbConnection: any;
5
5
  getContainer: () => MedusaContainer;
6
6
  api: any;
7
+ dbUtils: {
8
+ create: (dbName: string) => Promise<void>;
9
+ teardown: (options: {
10
+ schema?: string;
11
+ }) => Promise<void>;
12
+ shutdown: (dbName: string) => Promise<void>;
13
+ };
7
14
  dbConfig: {
8
15
  dbName: string;
9
16
  schema: string;
10
17
  clientUrl: string;
11
18
  };
19
+ getMedusaApp: () => MedusaAppOutput;
12
20
  }
13
- export declare function medusaIntegrationTestRunner({ moduleName, dbName, schema, env, force_modules_migration, debug, testSuite, }: {
21
+ export declare function medusaIntegrationTestRunner({ moduleName, dbName, medusaConfigFile, schema, env, debug, inApp, testSuite, }: {
14
22
  moduleName?: string;
15
23
  env?: Record<string, any>;
16
24
  dbName?: string;
25
+ medusaConfigFile?: string;
17
26
  schema?: string;
18
27
  debug?: boolean;
19
- force_modules_migration?: boolean;
20
- testSuite: <TService = unknown>(options: MedusaSuiteOptions<TService>) => void;
28
+ inApp?: boolean;
29
+ testSuite: (options: MedusaSuiteOptions) => void;
21
30
  }): void;
31
+ //# sourceMappingURL=medusa-test-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"medusa-test-runner.d.ts","sourceRoot":"","sources":["../src/medusa-test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAAiB,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAiB1E,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,GAAG,CAAA;IACjB,YAAY,EAAE,MAAM,eAAe,CAAA;IACnC,GAAG,EAAE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