@memberjunction/integration-engine 6.2.0-edge.4 → 6.2.0-edge.6

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.
Files changed (52) hide show
  1. package/dist/BaseIntegrationConnector.d.ts.map +1 -1
  2. package/dist/BaseIntegrationConnector.js +22 -4
  3. package/dist/BaseIntegrationConnector.js.map +1 -1
  4. package/dist/BaseRESTIntegrationConnector.d.ts +2 -2
  5. package/dist/BaseRESTIntegrationConnector.d.ts.map +1 -1
  6. package/dist/BaseRESTIntegrationConnector.js +34 -4
  7. package/dist/BaseRESTIntegrationConnector.js.map +1 -1
  8. package/dist/CatalogScope.d.ts +152 -0
  9. package/dist/CatalogScope.d.ts.map +1 -0
  10. package/dist/CatalogScope.js +399 -0
  11. package/dist/CatalogScope.js.map +1 -0
  12. package/dist/CatalogSource.d.ts +53 -0
  13. package/dist/CatalogSource.d.ts.map +1 -0
  14. package/dist/CatalogSource.js +82 -0
  15. package/dist/CatalogSource.js.map +1 -0
  16. package/dist/CatalogWriter.d.ts +216 -0
  17. package/dist/CatalogWriter.d.ts.map +1 -0
  18. package/dist/CatalogWriter.js +457 -0
  19. package/dist/CatalogWriter.js.map +1 -0
  20. package/dist/CompanyIntegrationCatalogStore.d.ts +109 -0
  21. package/dist/CompanyIntegrationCatalogStore.d.ts.map +1 -0
  22. package/dist/CompanyIntegrationCatalogStore.js +229 -0
  23. package/dist/CompanyIntegrationCatalogStore.js.map +1 -0
  24. package/dist/DiscoveryWatchdog.d.ts +38 -1
  25. package/dist/DiscoveryWatchdog.d.ts.map +1 -1
  26. package/dist/DiscoveryWatchdog.js +56 -1
  27. package/dist/DiscoveryWatchdog.js.map +1 -1
  28. package/dist/IntegrationActionGenerator.d.ts.map +1 -1
  29. package/dist/IntegrationActionGenerator.js +33 -26
  30. package/dist/IntegrationActionGenerator.js.map +1 -1
  31. package/dist/IntegrationConnectorCreationPipeline.d.ts +141 -4
  32. package/dist/IntegrationConnectorCreationPipeline.d.ts.map +1 -1
  33. package/dist/IntegrationConnectorCreationPipeline.js +521 -64
  34. package/dist/IntegrationConnectorCreationPipeline.js.map +1 -1
  35. package/dist/IntegrationEngine.d.ts +13 -0
  36. package/dist/IntegrationEngine.d.ts.map +1 -1
  37. package/dist/IntegrationEngine.js +257 -166
  38. package/dist/IntegrationEngine.js.map +1 -1
  39. package/dist/IntegrationSchemaSync.d.ts +97 -0
  40. package/dist/IntegrationSchemaSync.d.ts.map +1 -1
  41. package/dist/IntegrationSchemaSync.js +300 -49
  42. package/dist/IntegrationSchemaSync.js.map +1 -1
  43. package/dist/MatchEngine.d.ts.map +1 -1
  44. package/dist/MatchEngine.js +6 -0
  45. package/dist/MatchEngine.js.map +1 -1
  46. package/dist/index.d.ts +8 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +6 -0
  49. package/dist/index.js.map +1 -1
  50. package/dist/types.d.ts +21 -0
  51. package/dist/types.d.ts.map +1 -1
  52. package/package.json +7 -7
@@ -0,0 +1,82 @@
1
+ import { LogError } from '@memberjunction/core';
2
+ import { IntegrationEngineBase } from '@memberjunction/integration-engine-base';
3
+ import { PerConnectionCatalogWriter, SharedCatalogWriter } from './CatalogWriter.js';
4
+ const CONFIG_KEY = 'catalogSource';
5
+ const ENV_KEY = 'MJ_INTEGRATION_CATALOG_SOURCE';
6
+ function normalise(value) {
7
+ if (typeof value !== 'string')
8
+ return undefined;
9
+ const v = value.trim().toLowerCase();
10
+ if (v === 'perconnection' || v === 'per-connection')
11
+ return 'PerConnection';
12
+ if (v === 'shared')
13
+ return 'Shared';
14
+ return undefined;
15
+ }
16
+ /** The global override, or undefined when unset. */
17
+ export function GlobalCatalogSourceOverride() {
18
+ return normalise(process.env[ENV_KEY]);
19
+ }
20
+ /**
21
+ * Which catalog this connection uses.
22
+ *
23
+ * An unparseable `Configuration` is treated as "no opinion" rather than as an error: that column
24
+ * carries a dozen unrelated settings, and letting one bad character anywhere in it flip a
25
+ * connection's catalog would be a far worse failure than ignoring it.
26
+ */
27
+ export function ResolveCatalogSource(companyIntegration) {
28
+ const override = GlobalCatalogSourceOverride();
29
+ if (override)
30
+ return override;
31
+ const raw = companyIntegration.Configuration;
32
+ if (!raw)
33
+ return 'Shared';
34
+ try {
35
+ const parsed = JSON.parse(raw);
36
+ return normalise(parsed?.[CONFIG_KEY]) ?? 'Shared';
37
+ }
38
+ catch {
39
+ return 'Shared';
40
+ }
41
+ }
42
+ /**
43
+ * The writer for this connection's catalog.
44
+ *
45
+ * FAIL-LOUD, not fail-safe. A connection set to 'PerConnection' that has entity maps but no
46
+ * per-connection catalog rows has not been backfilled, and answering from the shared catalog would
47
+ * be indistinguishable from success: the sync would run, on a different set of objects, and report
48
+ * nothing wrong. So it refuses, and the message names the connection, what it found, and the way
49
+ * out.
50
+ *
51
+ * The "has entity maps" part matters. A brand-new connection legitimately has neither maps nor
52
+ * catalog rows — that is the state right before its first discovery, not a missing backfill — so
53
+ * requiring rows there would refuse every new connector on the very flag that is supposed to be
54
+ * safe to turn on.
55
+ */
56
+ export function BuildCatalogWriter(md, companyIntegration, contextUser, source) {
57
+ const resolved = source ?? ResolveCatalogSource(companyIntegration);
58
+ if (resolved === 'Shared') {
59
+ return new SharedCatalogWriter(md, companyIntegration.IntegrationID, contextUser);
60
+ }
61
+ const engine = IntegrationEngineBase.Instance;
62
+ const hasCatalog = engine.HasCompanyIntegrationCatalog(companyIntegration.ID);
63
+ if (!hasCatalog) {
64
+ const mapCount = engine.GetEntityMapsForCompanyIntegration(companyIntegration.ID).length;
65
+ if (mapCount > 0) {
66
+ throw new Error(`PER_CONNECTION_CATALOG_MISSING: connection ${companyIntegration.ID} `
67
+ + `("${companyIntegration.Name ?? 'unnamed'}") is set to the per-connection catalog and has `
68
+ + `${mapCount} entity map(s), but no rows in its own catalog. It has not been backfilled. `
69
+ + `Run the catalog backfill for this connection, or set its Configuration.${CONFIG_KEY} `
70
+ + `back to "shared". Refusing to read the shared catalog, which carries objects this `
71
+ + `connection never discovered and omits the ones only it has — the sync would run on the `
72
+ + `wrong set and report success.`);
73
+ }
74
+ // No maps and no rows: a connection that has not discovered anything yet. Nothing to fall
75
+ // back FROM, so this is the ordinary pre-discovery state and the per-connection writer is
76
+ // exactly right — it is about to create the rows.
77
+ LogError(`[CatalogSource] Connection ${companyIntegration.ID} is per-connection with an empty catalog `
78
+ + `and no entity maps — treating as pre-discovery.`);
79
+ }
80
+ return new PerConnectionCatalogWriter(md, companyIntegration.ID, companyIntegration.IntegrationID, contextUser, new Date());
81
+ }
82
+ //# sourceMappingURL=CatalogSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatalogSource.js","sourceRoot":"","sources":["../src/CatalogSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAiB,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AA2BpG,MAAM,UAAU,GAAG,eAAe,CAAC;AACnC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AAEhD,SAAS,SAAS,CAAC,KAAc;IAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,IAAI,CAAC,KAAK,eAAe,IAAI,CAAC,KAAK,gBAAgB;QAAE,OAAO,eAAe,CAAC;IAC5E,IAAI,CAAC,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IACpC,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,2BAA2B;IACvC,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,kBAA8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EAA0E,UAAU,GAAG;kBACvF,oFAAoF;kBACpF,yFAAyF;kBACzF,+BAA+B,CACpC,CAAC;QACN,CAAC;QACD,0FAA0F;QAC1F,0FAA0F;QAC1F,kDAAkD;QAClD,QAAQ,CACJ,8BAA8B,kBAAkB,CAAC,EAAE,2CAA2C;cAC5F,iDAAiD,CACtD,CAAC;IACN,CAAC;IACD,OAAO,IAAI,0BAA0B,CACjC,EAAE,EAAE,kBAAkB,CAAC,EAAE,EAAE,kBAAkB,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,216 @@
1
+ import { IMetadataProvider, UserInfo } from '@memberjunction/core';
2
+ import type { MJIntegrationObjectEntity, MJIntegrationObjectFieldEntity } from '@memberjunction/core-entities';
3
+ import { CatalogProvenance } from '@memberjunction/integration-engine-base';
4
+ /**
5
+ * Reads and creates for one catalog, scoped to whatever "this connector" means for it.
6
+ *
7
+ * `ObjectsInScope` deliberately returns rows of EVERY status. Disabled rows are load-bearing: an
8
+ * object the source dropped is disabled rather than deleted, and if it reappears the overlay must
9
+ * find and reactivate that row. Matching active rows only would attempt a second row with the same
10
+ * name and hit the unique constraint instead.
11
+ *
12
+ * These read straight from the database rather than the engine cache, deliberately. The cache is
13
+ * refreshed between discovery passes, not within one, so the write path must be able to see rows a
14
+ * previous pass of the SAME run just persisted. It is also what makes the per-connection catalog
15
+ * writable at all: its cached rows are read-only projections with no `Save()`.
16
+ */
17
+ export interface CatalogWriter {
18
+ readonly Source: 'Shared' | 'PerConnection';
19
+ ObjectsInScope(): Promise<MJIntegrationObjectEntity[]>;
20
+ FieldsForObject(objectID: string): Promise<MJIntegrationObjectFieldEntity[]>;
21
+ /**
22
+ * Lowercased ids of the given objects that already carry a primary key, from one two-column
23
+ * scan per 200 owners. The classify stage used to load every object's fields as entity
24
+ * objects just to ask `some(IsPrimaryKey)`; the keyed majority needs nothing else.
25
+ */
26
+ KeyedObjectIDs(objectIDs: readonly string[]): Promise<Set<string>>;
27
+ NewObjectRow(): Promise<MJIntegrationObjectEntity>;
28
+ NewFieldRow(): Promise<MJIntegrationObjectFieldEntity>;
29
+ LoadObject(objectID: string): Promise<MJIntegrationObjectEntity | null>;
30
+ LoadField(fieldID: string): Promise<MJIntegrationObjectFieldEntity | null>;
31
+ /**
32
+ * Write the columns saying who a newly-created object belongs to and where its shape came from.
33
+ * A no-op on the shared catalog beyond the integration id, which is the only ownership it has.
34
+ */
35
+ StampNewObject(row: MJIntegrationObjectEntity, declaredObjectID: string | null, provenance: CatalogProvenance): void;
36
+ /** The field counterpart of {@link StampNewObject}. */
37
+ StampNewField(row: MJIntegrationObjectFieldEntity, declaredFieldID: string | null, provenance: CatalogProvenance): void;
38
+ /** Record that this row was seen — and optionally sampled — by the discovery now running. */
39
+ MarkSeen(row: MJIntegrationObjectEntity | MJIntegrationObjectFieldEntity, sampled: boolean): void;
40
+ /**
41
+ * Retire an object/field that an AUTHORITATIVE discovery no longer returns.
42
+ *
43
+ * The two catalogs differ here on purpose, which is why this is a writer method and not an
44
+ * `if` at the call site:
45
+ * - SHARED rows are DISABLED, never deleted. They are the declared metadata every other
46
+ * connection of the connector still reads, and a missing row there is unrecoverable.
47
+ * - PER-CONNECTION OBJECTS are DELETED. plan.md: "Removed tables are more than deselected,
48
+ * they just dont exist, its likely a cascade delete." Nothing else owns them, and leaving
49
+ * tombstones would make the connection's catalog drift from its source forever.
50
+ *
51
+ * Returns whether the row is gone (`deleted`) so the caller can report honestly; the mirror
52
+ * TABLE and its data are never touched either way.
53
+ */
54
+ /**
55
+ * Reset the connector-DECLARED columns of an existing row from the declared definition,
56
+ * before discovery overlays it.
57
+ *
58
+ * plan.md: a refresh uses IO/IOF as the source of truth and REPLACES what is in CIO/CIOF,
59
+ * because the per-connection row is a projection, not an accumulator. Without this an open-app
60
+ * upgrade that changes a declared APIPath or page size never reaches a connection that has
61
+ * already discovered once. Shared writers no-op: there the row IS the declaration.
62
+ */
63
+ RebaseFromDeclared(row: MJIntegrationObjectEntity | MJIntegrationObjectFieldEntity, declared: MJIntegrationObjectEntity | MJIntegrationObjectFieldEntity | null, kind: 'object' | 'field'): string[];
64
+ /**
65
+ * MJ-CAT-21 — an EXISTING per-connection row has just been matched to a declaration. Rebase it, and record
66
+ * that it is now a declared row rather than one this connection merely found.
67
+ *
68
+ * The second half is the load-bearing one. A field this connection discovered BEFORE the
69
+ * connector declared it keeps `MetadataSource = 'Discovered'`, and `decidePKPromotion` reads
70
+ * exactly that to rule that a declared primary key cannot include it — so a rebase on its own
71
+ * sets `IsPrimaryKey` and has it demoted again a few statements later, which is precisely how
72
+ * PheedLoop 1.4.6's new `eventCode` key reached a connection's catalog as an ordinary column.
73
+ * A row that now has a declaration is no longer merely discovered.
74
+ *
75
+ * Not `StampNewField`: that one also clears `IsSelected` and resets `FirstSeenAt`, which would
76
+ * deselect a table the customer chose and forget when the field first appeared.
77
+ *
78
+ * Shared writers no-op — there the row IS the declaration, and writing provenance onto it
79
+ * would be writing it onto itself.
80
+ */
81
+ AdoptDeclaration(row: MJIntegrationObjectEntity | MJIntegrationObjectFieldEntity, declared: MJIntegrationObjectEntity | MJIntegrationObjectFieldEntity | null, kind: 'object' | 'field'): string[];
82
+ RetireObject(row: MJIntegrationObjectEntity): Promise<{
83
+ ok: boolean;
84
+ deleted: boolean;
85
+ }>;
86
+ RetireField(row: MJIntegrationObjectFieldEntity): Promise<{
87
+ ok: boolean;
88
+ deleted: boolean;
89
+ }>;
90
+ }
91
+ /** A catalog read that did not succeed: the entity, the filter and the provider's own message. */
92
+ export declare class CompanyIntegrationCatalogReadFailed extends Error {
93
+ readonly EntityName: string;
94
+ readonly Filter: string;
95
+ constructor(entityName: string, filter: string, message: string);
96
+ }
97
+ export declare class SharedCatalogWriter implements CatalogWriter {
98
+ private readonly md;
99
+ private readonly integrationID;
100
+ private readonly contextUser;
101
+ readonly Source: "Shared";
102
+ private static readonly OBJECTS;
103
+ private static readonly FIELDS;
104
+ constructor(md: IMetadataProvider, integrationID: string, contextUser: UserInfo);
105
+ ObjectsInScope(): Promise<MJIntegrationObjectEntity[]>;
106
+ FieldsForObject(objectID: string): Promise<MJIntegrationObjectFieldEntity[]>;
107
+ KeyedObjectIDs(objectIDs: readonly string[]): Promise<Set<string>>;
108
+ /**
109
+ * The four calls below exist to hand the caller a row it is about to mutate and Save, so they
110
+ * are the write boundary — guarding them, rather than the reads above, keeps the declared floor
111
+ * readable while making a runtime write to it impossible. See `strictDeclaredCatalog`.
112
+ */
113
+ private refuseIfStrict;
114
+ NewObjectRow(): Promise<MJIntegrationObjectEntity>;
115
+ NewFieldRow(): Promise<MJIntegrationObjectFieldEntity>;
116
+ LoadObject(id: string): Promise<MJIntegrationObjectEntity | null>;
117
+ LoadField(id: string): Promise<MJIntegrationObjectFieldEntity | null>;
118
+ /** The shared catalog records ownership as the integration id and nothing else. */
119
+ StampNewObject(row: MJIntegrationObjectEntity): void;
120
+ StampNewField(): void;
121
+ /** The shared row IS the declaration; there is nothing to rebase it from. */
122
+ RebaseFromDeclared(): string[];
123
+ /** Likewise: the shared row cannot adopt a declaration, because it is one. */
124
+ AdoptDeclaration(): string[];
125
+ /** Shared rows are the declared floor for every other connection — disable, never delete. */
126
+ RetireObject(row: MJIntegrationObjectEntity): Promise<{
127
+ ok: boolean;
128
+ deleted: boolean;
129
+ }>;
130
+ RetireField(row: MJIntegrationObjectFieldEntity): Promise<{
131
+ ok: boolean;
132
+ deleted: boolean;
133
+ }>;
134
+ MarkSeen(): void;
135
+ }
136
+ /** One connection's own catalog. */
137
+ export declare class PerConnectionCatalogWriter implements CatalogWriter {
138
+ private readonly md;
139
+ private readonly companyIntegrationID;
140
+ private readonly integrationID;
141
+ private readonly contextUser;
142
+ /** Stamped on every row this run touches, so "when did we last see this" is answerable. */
143
+ private readonly seenAt;
144
+ readonly Source: "PerConnection";
145
+ constructor(md: IMetadataProvider, companyIntegrationID: string, integrationID: string, contextUser: UserInfo,
146
+ /** Stamped on every row this run touches, so "when did we last see this" is answerable. */
147
+ seenAt: Date);
148
+ ObjectsInScope(): Promise<MJIntegrationObjectEntity[]>;
149
+ FieldsForObject(objectID: string): Promise<MJIntegrationObjectFieldEntity[]>;
150
+ KeyedObjectIDs(objectIDs: readonly string[]): Promise<Set<string>>;
151
+ NewObjectRow(): Promise<MJIntegrationObjectEntity>;
152
+ NewFieldRow(): Promise<MJIntegrationObjectFieldEntity>;
153
+ LoadObject(id: string): Promise<MJIntegrationObjectEntity | null>;
154
+ LoadField(id: string): Promise<MJIntegrationObjectFieldEntity | null>;
155
+ /**
156
+ * A new per-connection object records the connection it belongs to, the declared row it was
157
+ * matched to (null when the object exists only for this connection — the case the shared
158
+ * catalog cannot represent at all), where its shape came from, and when it was first seen.
159
+ *
160
+ * `IsSelected` starts FALSE. Catalog membership is not sync selection, and keeping them apart
161
+ * is the point of the table: conflating them is why a newly-discovered object arriving disabled
162
+ * disappeared from schema introspection, key inference and migration, with no error anywhere.
163
+ */
164
+ StampNewObject(row: MJIntegrationObjectEntity, declaredObjectID: string | null, provenance: CatalogProvenance): void;
165
+ StampNewField(row: MJIntegrationObjectFieldEntity, declaredFieldID: string | null, provenance: CatalogProvenance): void;
166
+ /**
167
+ * Copy the declared columns back over this connection's row so discovery overlays a CURRENT
168
+ * declaration rather than its own previous output. Returns the columns that actually moved,
169
+ * for the merge log. A row with no declared match (an object that exists only for this
170
+ * connection) has nothing to rebase from and is left alone.
171
+ */
172
+ RebaseFromDeclared(row: MJIntegrationObjectEntity | MJIntegrationObjectFieldEntity, declared: MJIntegrationObjectEntity | MJIntegrationObjectFieldEntity | null, kind: 'object' | 'field'): string[];
173
+ AdoptDeclaration(row: MJIntegrationObjectEntity | MJIntegrationObjectFieldEntity, declared: MJIntegrationObjectEntity | MJIntegrationObjectFieldEntity | null, kind: 'object' | 'field'): string[];
174
+ /**
175
+ * Delete, not disable — see the interface comment.
176
+ *
177
+ * Order matters and there is no ON DELETE CASCADE in the migration (deletes are deliberately
178
+ * explicit, so nothing disappears as a side effect of an unrelated write):
179
+ * 1. NULL out inbound dependency edges. `RelatedCompanyIntegrationObjectID` is self-
180
+ * referencing, so another object's field may point at this one; deleting underneath it
181
+ * would violate that FK and abort the whole persist. Nulling drops the edge and keeps the
182
+ * referencing field alive, which is right — the field still exists in the source, only
183
+ * the thing it pointed at is gone.
184
+ * 2. Delete this object's own fields (the FK child rows).
185
+ * 3. Delete the object.
186
+ */
187
+ RetireObject(row: MJIntegrationObjectEntity): Promise<{
188
+ ok: boolean;
189
+ deleted: boolean;
190
+ }>;
191
+ /**
192
+ * DISABLE, never delete — unlike the object above.
193
+ *
194
+ * The delete rule is dictated for TABLES and only tables: plan.md says "for tables only, if
195
+ * its not there after discovery algorithm, just removes it", and again "columns that are in
196
+ * MJC already never get removed, tables maybe if discovery objects doesnt find them, NEVER
197
+ * columns".
198
+ *
199
+ * The reason is in everything.txt: "sometimes, a column may be missing. If that is the case,
200
+ * then it doesnt automatically conclude the column no longer exist ... typically just may mean
201
+ * there is no more values". A column absent from one sample is absent from a SAMPLE, not from
202
+ * the source. Deleting the row destroys what only this connection knows about it — the
203
+ * observed width, the provenance, the selection state — so the next sample that does see it
204
+ * starts from nothing instead of reactivating. Disabling keeps all of it and reverses itself
205
+ * on rediscovery, which is what the shared catalog has always done.
206
+ *
207
+ * A field DOES get deleted when its OBJECT is removed; that cascade lives in RetireObject and
208
+ * is the table rule, not this one.
209
+ */
210
+ RetireField(row: MJIntegrationObjectFieldEntity): Promise<{
211
+ ok: boolean;
212
+ deleted: boolean;
213
+ }>;
214
+ MarkSeen(row: MJIntegrationObjectEntity | MJIntegrationObjectFieldEntity, sampled: boolean): void;
215
+ }
216
+ //# sourceMappingURL=CatalogWriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatalogWriter.d.ts","sourceRoot":"","sources":["../src/CatalogWriter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,iBAAiB,EAAoC,QAAQ,EAAE,MAAM,sBA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