@powersync/service-module-postgres-storage 0.1.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/CHANGELOG.md +17 -0
- package/LICENSE +67 -0
- package/README.md +67 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/@types/index.d.ts +7 -0
- package/dist/@types/migrations/PostgresMigrationAgent.d.ts +12 -0
- package/dist/@types/migrations/PostgresMigrationStore.d.ts +14 -0
- package/dist/@types/migrations/migration-utils.d.ts +3 -0
- package/dist/@types/migrations/scripts/1684951997326-init.d.ts +3 -0
- package/dist/@types/module/PostgresStorageModule.d.ts +6 -0
- package/dist/@types/storage/PostgresBucketStorageFactory.d.ts +42 -0
- package/dist/@types/storage/PostgresCompactor.d.ts +40 -0
- package/dist/@types/storage/PostgresStorageProvider.d.ts +5 -0
- package/dist/@types/storage/PostgresSyncRulesStorage.d.ts +46 -0
- package/dist/@types/storage/PostgresTestStorageFactoryGenerator.d.ts +13 -0
- package/dist/@types/storage/batch/OperationBatch.d.ts +47 -0
- package/dist/@types/storage/batch/PostgresBucketBatch.d.ts +90 -0
- package/dist/@types/storage/batch/PostgresPersistedBatch.d.ts +64 -0
- package/dist/@types/storage/checkpoints/PostgresWriteCheckpointAPI.d.ts +20 -0
- package/dist/@types/storage/storage-index.d.ts +5 -0
- package/dist/@types/storage/sync-rules/PostgresPersistedSyncRulesContent.d.ts +17 -0
- package/dist/@types/types/codecs.d.ts +61 -0
- package/dist/@types/types/models/ActiveCheckpoint.d.ts +12 -0
- package/dist/@types/types/models/ActiveCheckpointNotification.d.ts +19 -0
- package/dist/@types/types/models/BucketData.d.ts +22 -0
- package/dist/@types/types/models/BucketParameters.d.ts +11 -0
- package/dist/@types/types/models/CurrentData.d.ts +22 -0
- package/dist/@types/types/models/Instance.d.ts +6 -0
- package/dist/@types/types/models/Migration.d.ts +12 -0
- package/dist/@types/types/models/SourceTable.d.ts +31 -0
- package/dist/@types/types/models/SyncRules.d.ts +47 -0
- package/dist/@types/types/models/WriteCheckpoint.d.ts +15 -0
- package/dist/@types/types/models/models-index.d.ts +10 -0
- package/dist/@types/types/types.d.ts +94 -0
- package/dist/@types/utils/bson.d.ts +6 -0
- package/dist/@types/utils/bucket-data.d.ts +18 -0
- package/dist/@types/utils/db.d.ts +8 -0
- package/dist/@types/utils/ts-codec.d.ts +5 -0
- package/dist/@types/utils/utils-index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/PostgresMigrationAgent.js +36 -0
- package/dist/migrations/PostgresMigrationAgent.js.map +1 -0
- package/dist/migrations/PostgresMigrationStore.js +60 -0
- package/dist/migrations/PostgresMigrationStore.js.map +1 -0
- package/dist/migrations/migration-utils.js +13 -0
- package/dist/migrations/migration-utils.js.map +1 -0
- package/dist/migrations/scripts/1684951997326-init.js +196 -0
- package/dist/migrations/scripts/1684951997326-init.js.map +1 -0
- package/dist/module/PostgresStorageModule.js +23 -0
- package/dist/module/PostgresStorageModule.js.map +1 -0
- package/dist/storage/PostgresBucketStorageFactory.js +433 -0
- package/dist/storage/PostgresBucketStorageFactory.js.map +1 -0
- package/dist/storage/PostgresCompactor.js +298 -0
- package/dist/storage/PostgresCompactor.js.map +1 -0
- package/dist/storage/PostgresStorageProvider.js +35 -0
- package/dist/storage/PostgresStorageProvider.js.map +1 -0
- package/dist/storage/PostgresSyncRulesStorage.js +619 -0
- package/dist/storage/PostgresSyncRulesStorage.js.map +1 -0
- package/dist/storage/PostgresTestStorageFactoryGenerator.js +110 -0
- package/dist/storage/PostgresTestStorageFactoryGenerator.js.map +1 -0
- package/dist/storage/batch/OperationBatch.js +93 -0
- package/dist/storage/batch/OperationBatch.js.map +1 -0
- package/dist/storage/batch/PostgresBucketBatch.js +732 -0
- package/dist/storage/batch/PostgresBucketBatch.js.map +1 -0
- package/dist/storage/batch/PostgresPersistedBatch.js +367 -0
- package/dist/storage/batch/PostgresPersistedBatch.js.map +1 -0
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js +148 -0
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js.map +1 -0
- package/dist/storage/storage-index.js +6 -0
- package/dist/storage/storage-index.js.map +1 -0
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +58 -0
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +1 -0
- package/dist/types/codecs.js +97 -0
- package/dist/types/codecs.js.map +1 -0
- package/dist/types/models/ActiveCheckpoint.js +12 -0
- package/dist/types/models/ActiveCheckpoint.js.map +1 -0
- package/dist/types/models/ActiveCheckpointNotification.js +8 -0
- package/dist/types/models/ActiveCheckpointNotification.js.map +1 -0
- package/dist/types/models/BucketData.js +23 -0
- package/dist/types/models/BucketData.js.map +1 -0
- package/dist/types/models/BucketParameters.js +11 -0
- package/dist/types/models/BucketParameters.js.map +1 -0
- package/dist/types/models/CurrentData.js +16 -0
- package/dist/types/models/CurrentData.js.map +1 -0
- package/dist/types/models/Instance.js +5 -0
- package/dist/types/models/Instance.js.map +1 -0
- package/dist/types/models/Migration.js +12 -0
- package/dist/types/models/Migration.js.map +1 -0
- package/dist/types/models/SourceTable.js +24 -0
- package/dist/types/models/SourceTable.js.map +1 -0
- package/dist/types/models/SyncRules.js +47 -0
- package/dist/types/models/SyncRules.js.map +1 -0
- package/dist/types/models/WriteCheckpoint.js +13 -0
- package/dist/types/models/WriteCheckpoint.js.map +1 -0
- package/dist/types/models/models-index.js +11 -0
- package/dist/types/models/models-index.js.map +1 -0
- package/dist/types/types.js +46 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/bson.js +16 -0
- package/dist/utils/bson.js.map +1 -0
- package/dist/utils/bucket-data.js +25 -0
- package/dist/utils/bucket-data.js.map +1 -0
- package/dist/utils/db.js +24 -0
- package/dist/utils/db.js.map +1 -0
- package/dist/utils/ts-codec.js +11 -0
- package/dist/utils/ts-codec.js.map +1 -0
- package/dist/utils/utils-index.js +5 -0
- package/dist/utils/utils-index.js.map +1 -0
- package/package.json +50 -0
- package/src/index.ts +10 -0
- package/src/migrations/PostgresMigrationAgent.ts +46 -0
- package/src/migrations/PostgresMigrationStore.ts +70 -0
- package/src/migrations/migration-utils.ts +14 -0
- package/src/migrations/scripts/1684951997326-init.ts +141 -0
- package/src/module/PostgresStorageModule.ts +30 -0
- package/src/storage/PostgresBucketStorageFactory.ts +496 -0
- package/src/storage/PostgresCompactor.ts +366 -0
- package/src/storage/PostgresStorageProvider.ts +42 -0
- package/src/storage/PostgresSyncRulesStorage.ts +666 -0
- package/src/storage/PostgresTestStorageFactoryGenerator.ts +61 -0
- package/src/storage/batch/OperationBatch.ts +101 -0
- package/src/storage/batch/PostgresBucketBatch.ts +885 -0
- package/src/storage/batch/PostgresPersistedBatch.ts +441 -0
- package/src/storage/checkpoints/PostgresWriteCheckpointAPI.ts +176 -0
- package/src/storage/storage-index.ts +5 -0
- package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +67 -0
- package/src/types/codecs.ts +136 -0
- package/src/types/models/ActiveCheckpoint.ts +15 -0
- package/src/types/models/ActiveCheckpointNotification.ts +14 -0
- package/src/types/models/BucketData.ts +26 -0
- package/src/types/models/BucketParameters.ts +14 -0
- package/src/types/models/CurrentData.ts +23 -0
- package/src/types/models/Instance.ts +8 -0
- package/src/types/models/Migration.ts +19 -0
- package/src/types/models/SourceTable.ts +32 -0
- package/src/types/models/SyncRules.ts +50 -0
- package/src/types/models/WriteCheckpoint.ts +20 -0
- package/src/types/models/models-index.ts +10 -0
- package/src/types/types.ts +73 -0
- package/src/utils/bson.ts +17 -0
- package/src/utils/bucket-data.ts +25 -0
- package/src/utils/db.ts +27 -0
- package/src/utils/ts-codec.ts +14 -0
- package/src/utils/utils-index.ts +4 -0
- package/test/src/__snapshots__/storage.test.ts.snap +9 -0
- package/test/src/__snapshots__/storage_sync.test.ts.snap +332 -0
- package/test/src/env.ts +6 -0
- package/test/src/migrations.test.ts +34 -0
- package/test/src/setup.ts +16 -0
- package/test/src/storage.test.ts +131 -0
- package/test/src/storage_compacting.test.ts +5 -0
- package/test/src/storage_sync.test.ts +12 -0
- package/test/src/util.ts +34 -0
- package/test/tsconfig.json +20 -0
- package/tsconfig.json +36 -0
- package/vitest.config.ts +13 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { framework } from '@powersync/service-core';
|
|
54
|
+
import { PostgresMigrationAgent } from '../migrations/PostgresMigrationAgent.js';
|
|
55
|
+
import { normalizePostgresStorageConfig } from '../types/types.js';
|
|
56
|
+
import { PostgresBucketStorageFactory } from './PostgresBucketStorageFactory.js';
|
|
57
|
+
export const PostgresTestStorageFactoryGenerator = (factoryOptions) => {
|
|
58
|
+
return async (options) => {
|
|
59
|
+
try {
|
|
60
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
61
|
+
try {
|
|
62
|
+
const migrationManager = new framework.MigrationManager();
|
|
63
|
+
const BASE_CONFIG = {
|
|
64
|
+
type: 'postgresql',
|
|
65
|
+
uri: factoryOptions.url,
|
|
66
|
+
sslmode: 'disable'
|
|
67
|
+
};
|
|
68
|
+
const TEST_CONNECTION_OPTIONS = normalizePostgresStorageConfig(BASE_CONFIG);
|
|
69
|
+
const migrationAgent = __addDisposableResource(env_1, factoryOptions.migrationAgent
|
|
70
|
+
? factoryOptions.migrationAgent(BASE_CONFIG)
|
|
71
|
+
: new PostgresMigrationAgent(BASE_CONFIG), true);
|
|
72
|
+
migrationManager.registerMigrationAgent(migrationAgent);
|
|
73
|
+
const mockServiceContext = { configuration: { storage: BASE_CONFIG } };
|
|
74
|
+
if (!options?.doNotClear) {
|
|
75
|
+
await migrationManager.migrate({
|
|
76
|
+
direction: framework.migrations.Direction.Down,
|
|
77
|
+
migrationContext: {
|
|
78
|
+
service_context: mockServiceContext
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
await migrationManager.migrate({
|
|
83
|
+
direction: framework.migrations.Direction.Up,
|
|
84
|
+
migrationContext: {
|
|
85
|
+
service_context: mockServiceContext
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return new PostgresBucketStorageFactory({
|
|
89
|
+
config: TEST_CONNECTION_OPTIONS,
|
|
90
|
+
slot_name_prefix: 'test_'
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch (e_1) {
|
|
94
|
+
env_1.error = e_1;
|
|
95
|
+
env_1.hasError = true;
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
const result_1 = __disposeResources(env_1);
|
|
99
|
+
if (result_1)
|
|
100
|
+
await result_1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (ex) {
|
|
104
|
+
// Vitest does not display these errors nicely when using the `await using` syntx
|
|
105
|
+
console.error(ex, ex.cause);
|
|
106
|
+
throw ex;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=PostgresTestStorageFactoryGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresTestStorageFactoryGenerator.js","sourceRoot":"","sources":["../../src/storage/PostgresTestStorageFactoryGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAiE,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OA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,4BAA4B,CAAC;oBACtC,MAAM,EAAE,uBAAuB;oBAC/B,gBAAgB,EAAE,OAAO;iBAC1B,CAAC,CAAC;;;;;;;;;;;SACJ;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,iFAAiF;YACjF,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;YAC5B,MAAM,EAAE,CAAC;QACX,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TODO share this implementation better in the core package.
|
|
3
|
+
* There are some subtle differences in this implementation.
|
|
4
|
+
*/
|
|
5
|
+
import { storage, utils } from '@powersync/service-core';
|
|
6
|
+
/**
|
|
7
|
+
* Batch of input operations.
|
|
8
|
+
*
|
|
9
|
+
* We accumulate operations up to MAX_RECORD_BATCH_SIZE,
|
|
10
|
+
* then further split into sub-batches if MAX_CURRENT_DATA_BATCH_SIZE is exceeded.
|
|
11
|
+
*/
|
|
12
|
+
export class OperationBatch {
|
|
13
|
+
options;
|
|
14
|
+
batch = [];
|
|
15
|
+
currentSize = 0;
|
|
16
|
+
maxBatchCount;
|
|
17
|
+
maxRecordSize;
|
|
18
|
+
maxCurrentDataBatchSize;
|
|
19
|
+
get length() {
|
|
20
|
+
return this.batch.length;
|
|
21
|
+
}
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.maxBatchCount = options.max_record_count;
|
|
25
|
+
this.maxRecordSize = options.max_estimated_size;
|
|
26
|
+
this.maxCurrentDataBatchSize = options.max_current_data_batch_size;
|
|
27
|
+
}
|
|
28
|
+
push(op) {
|
|
29
|
+
this.batch.push(op);
|
|
30
|
+
this.currentSize += op.estimatedSize;
|
|
31
|
+
}
|
|
32
|
+
shouldFlush() {
|
|
33
|
+
return this.batch.length >= this.maxBatchCount || this.currentSize > this.maxCurrentDataBatchSize;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param sizes Map of source key to estimated size of the current_data document, or undefined if current_data is not persisted.
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
*batched(sizes) {
|
|
41
|
+
if (sizes == null) {
|
|
42
|
+
yield this.batch;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let currentBatch = [];
|
|
46
|
+
let currentBatchSize = 0;
|
|
47
|
+
for (let op of this.batch) {
|
|
48
|
+
const key = op.internalBeforeKey;
|
|
49
|
+
const size = sizes.get(key) ?? 0;
|
|
50
|
+
if (currentBatchSize + size > this.maxCurrentDataBatchSize && currentBatch.length > 0) {
|
|
51
|
+
yield currentBatch;
|
|
52
|
+
currentBatch = [];
|
|
53
|
+
currentBatchSize = 0;
|
|
54
|
+
}
|
|
55
|
+
currentBatchSize += size;
|
|
56
|
+
currentBatch.push(op);
|
|
57
|
+
}
|
|
58
|
+
if (currentBatch.length > 0) {
|
|
59
|
+
yield currentBatch;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export class RecordOperation {
|
|
64
|
+
record;
|
|
65
|
+
afterId;
|
|
66
|
+
beforeId;
|
|
67
|
+
internalBeforeKey;
|
|
68
|
+
internalAfterKey;
|
|
69
|
+
estimatedSize;
|
|
70
|
+
constructor(record) {
|
|
71
|
+
this.record = record;
|
|
72
|
+
const afterId = record.afterReplicaId ?? null;
|
|
73
|
+
const beforeId = record.beforeReplicaId ?? record.afterReplicaId;
|
|
74
|
+
this.afterId = afterId;
|
|
75
|
+
this.beforeId = beforeId;
|
|
76
|
+
this.internalBeforeKey = cacheKey(record.sourceTable.id, beforeId);
|
|
77
|
+
this.internalAfterKey = afterId ? cacheKey(record.sourceTable.id, afterId) : null;
|
|
78
|
+
this.estimatedSize = utils.estimateRowSize(record.before) + utils.estimateRowSize(record.after);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* In-memory cache key - must not be persisted.
|
|
83
|
+
*/
|
|
84
|
+
export function cacheKey(sourceTableId, id) {
|
|
85
|
+
return encodedCacheKey(sourceTableId, storage.serializeReplicaId(id));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Calculates a cache key for a stored ReplicaId. This is usually stored as a bytea/Buffer.
|
|
89
|
+
*/
|
|
90
|
+
export function encodedCacheKey(sourceTableId, storedKey) {
|
|
91
|
+
return `${sourceTableId}.${storedKey.toString('base64')}`;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=OperationBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationBatch.js","sourceRoot":"","sources":["../../../src/storage/batch/OperationBatch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGzD;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAYH;IAXtB,KAAK,GAAsB,EAAE,CAAC;IAC9B,WAAW,GAAW,CAAC,CAAC;IAEf,aAAa,CAAS;IACtB,aAAa,CAAS;IACtB,uBAAuB,CAAS;IAEzC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,YAAsB,OAAqC;QAArC,YAAO,GAAP,OAAO,CAA8B;QACzD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC;QAChD,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IACrE,CAAC;IAED,IAAI,CAAC,EAAmB;QACtB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,aAAa,CAAC;IACvC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAA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