@ceramicnetwork/indexing 1.1.0-rc.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 +31 -0
- package/lib/__tests__/chunks.util.d.ts +2 -0
- package/lib/__tests__/chunks.util.d.ts.map +1 -0
- package/lib/__tests__/chunks.util.js +8 -0
- package/lib/__tests__/chunks.util.js.map +1 -0
- package/lib/__tests__/read-csv-fixture.util.d.ts +5 -0
- package/lib/__tests__/read-csv-fixture.util.d.ts.map +1 -0
- package/lib/__tests__/read-csv-fixture.util.js +35 -0
- package/lib/__tests__/read-csv-fixture.util.js.map +1 -0
- package/lib/as-table-name.util.d.ts +3 -0
- package/lib/as-table-name.util.d.ts.map +1 -0
- package/lib/as-table-name.util.js +4 -0
- package/lib/as-table-name.util.js.map +1 -0
- package/lib/build-indexing.d.ts +13 -0
- package/lib/build-indexing.d.ts.map +1 -0
- package/lib/build-indexing.js +55 -0
- package/lib/build-indexing.js.map +1 -0
- package/lib/column-name.util.d.ts +2 -0
- package/lib/column-name.util.d.ts.map +1 -0
- package/lib/column-name.util.js +5 -0
- package/lib/column-name.util.js.map +1 -0
- package/lib/config.d.ts +2 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +2 -0
- package/lib/config.js.map +1 -0
- package/lib/database-index-api.d.ts +94 -0
- package/lib/database-index-api.d.ts.map +1 -0
- package/lib/database-index-api.js +228 -0
- package/lib/database-index-api.js.map +1 -0
- package/lib/history-sync/interfaces.d.ts +52 -0
- package/lib/history-sync/interfaces.d.ts.map +1 -0
- package/lib/history-sync/interfaces.js +11 -0
- package/lib/history-sync/interfaces.js.map +1 -0
- package/lib/history-sync/sync-api.d.ts +82 -0
- package/lib/history-sync/sync-api.d.ts.map +1 -0
- package/lib/history-sync/sync-api.js +276 -0
- package/lib/history-sync/sync-api.js.map +1 -0
- package/lib/history-sync/utils.d.ts +15 -0
- package/lib/history-sync/utils.d.ts.map +1 -0
- package/lib/history-sync/utils.js +23 -0
- package/lib/history-sync/utils.js.map +1 -0
- package/lib/history-sync/workers/rebuild-anchor.d.ts +15 -0
- package/lib/history-sync/workers/rebuild-anchor.d.ts.map +1 -0
- package/lib/history-sync/workers/rebuild-anchor.js +96 -0
- package/lib/history-sync/workers/rebuild-anchor.js.map +1 -0
- package/lib/history-sync/workers/sync.d.ts +24 -0
- package/lib/history-sync/workers/sync.d.ts.map +1 -0
- package/lib/history-sync/workers/sync.js +77 -0
- package/lib/history-sync/workers/sync.js.map +1 -0
- package/lib/index-query-not-available.error.d.ts +5 -0
- package/lib/index-query-not-available.error.d.ts.map +1 -0
- package/lib/index-query-not-available.error.js +6 -0
- package/lib/index-query-not-available.error.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/insertion-order.d.ts +15 -0
- package/lib/insertion-order.d.ts.map +1 -0
- package/lib/insertion-order.js +180 -0
- package/lib/insertion-order.js.map +1 -0
- package/lib/local-index-api.d.ts +30 -0
- package/lib/local-index-api.d.ts.map +1 -0
- package/lib/local-index-api.js +118 -0
- package/lib/local-index-api.js.map +1 -0
- package/lib/make-index-api.d.ts +9 -0
- package/lib/make-index-api.d.ts.map +1 -0
- package/lib/make-index-api.js +27 -0
- package/lib/make-index-api.js.map +1 -0
- package/lib/migrations/1-create-model-table.d.ts +34 -0
- package/lib/migrations/1-create-model-table.d.ts.map +1 -0
- package/lib/migrations/1-create-model-table.js +243 -0
- package/lib/migrations/1-create-model-table.js.map +1 -0
- package/lib/migrations/cdb-schema-verification.d.ts +15 -0
- package/lib/migrations/cdb-schema-verification.d.ts.map +1 -0
- package/lib/migrations/cdb-schema-verification.js +272 -0
- package/lib/migrations/cdb-schema-verification.js.map +1 -0
- package/lib/parse-pagination.d.ts +18 -0
- package/lib/parse-pagination.d.ts.map +1 -0
- package/lib/parse-pagination.js +23 -0
- package/lib/parse-pagination.js.map +1 -0
- package/lib/query-filter-converter.d.ts +12 -0
- package/lib/query-filter-converter.d.ts.map +1 -0
- package/lib/query-filter-converter.js +231 -0
- package/lib/query-filter-converter.js.map +1 -0
- package/lib/query-filter-parser.d.ts +63 -0
- package/lib/query-filter-parser.d.ts.map +1 -0
- package/lib/query-filter-parser.js +178 -0
- package/lib/query-filter-parser.js.map +1 -0
- package/lib/tables-manager.d.ts +44 -0
- package/lib/tables-manager.d.ts.map +1 -0
- package/lib/tables-manager.js +218 -0
- package/lib/tables-manager.js.map +1 -0
- package/lib/unsupported-ordering-error.d.ts +4 -0
- package/lib/unsupported-ordering-error.d.ts.map +1 -0
- package/lib/unsupported-ordering-error.js +6 -0
- package/lib/unsupported-ordering-error.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { UnreachableCaseError } from '@ceramicnetwork/common';
|
|
2
|
+
import { INDEXED_MODEL_CONFIG_TABLE_NAME, fieldsIndexName } from '../database-index-api.js';
|
|
3
|
+
import { CONFIG_TABLE_NAME } from '../config.js';
|
|
4
|
+
import { addColumnPrefix } from '../column-name.util.js';
|
|
5
|
+
export var DatabaseType;
|
|
6
|
+
(function (DatabaseType) {
|
|
7
|
+
DatabaseType["POSTGRES"] = "postgres";
|
|
8
|
+
DatabaseType["SQLITE"] = "sqlite";
|
|
9
|
+
})(DatabaseType || (DatabaseType = {}));
|
|
10
|
+
export var ColumnType;
|
|
11
|
+
(function (ColumnType) {
|
|
12
|
+
ColumnType[ColumnType["STRING"] = 0] = "STRING";
|
|
13
|
+
})(ColumnType || (ColumnType = {}));
|
|
14
|
+
export function indexNameFromTableName(tableName) {
|
|
15
|
+
return `idx_${tableName.substring(tableName.length - 10)}`;
|
|
16
|
+
}
|
|
17
|
+
export function defaultIndices(tableName) {
|
|
18
|
+
const indexName = indexNameFromTableName(tableName);
|
|
19
|
+
const indices = [
|
|
20
|
+
{
|
|
21
|
+
keys: ['stream_id'],
|
|
22
|
+
name: `${indexName}_stream_id`,
|
|
23
|
+
indexType: 'btree',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
keys: ['last_anchored_at'],
|
|
27
|
+
name: `${indexName}_last_anchored_at`,
|
|
28
|
+
indexType: 'btree',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
keys: ['first_anchored_at'],
|
|
32
|
+
name: `${indexName}_first_anchored_at`,
|
|
33
|
+
indexType: 'btree',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
keys: ['created_at'],
|
|
37
|
+
name: `${indexName}_created_at`,
|
|
38
|
+
indexType: 'hash',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
keys: ['updated_at'],
|
|
42
|
+
name: `${indexName}_updated_at`,
|
|
43
|
+
indexType: 'btree',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
keys: ['last_anchored_at', 'created_at'],
|
|
47
|
+
name: `${indexName}_last_anchored_at_created_at`,
|
|
48
|
+
indexType: 'btree',
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
return {
|
|
52
|
+
indexName: indexName,
|
|
53
|
+
indices: indices,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function getDefaultCDBDatabaseConfig(networkName) {
|
|
57
|
+
switch (networkName) {
|
|
58
|
+
case 'mainnet':
|
|
59
|
+
case 'elp': {
|
|
60
|
+
return {
|
|
61
|
+
enable_historical_sync: true,
|
|
62
|
+
allow_queries_before_historical_sync: true,
|
|
63
|
+
run_historical_sync_worker: false,
|
|
64
|
+
};
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case 'testnet-clay':
|
|
68
|
+
return {
|
|
69
|
+
enable_historical_sync: true,
|
|
70
|
+
allow_queries_before_historical_sync: true,
|
|
71
|
+
run_historical_sync_worker: false,
|
|
72
|
+
};
|
|
73
|
+
break;
|
|
74
|
+
case 'local':
|
|
75
|
+
return {
|
|
76
|
+
enable_historical_sync: false,
|
|
77
|
+
allow_queries_before_historical_sync: true,
|
|
78
|
+
run_historical_sync_worker: false,
|
|
79
|
+
};
|
|
80
|
+
break;
|
|
81
|
+
case 'dev-unstable':
|
|
82
|
+
return {
|
|
83
|
+
enable_historical_sync: false,
|
|
84
|
+
allow_queries_before_historical_sync: true,
|
|
85
|
+
run_historical_sync_worker: false,
|
|
86
|
+
};
|
|
87
|
+
break;
|
|
88
|
+
case 'inmemory':
|
|
89
|
+
return {
|
|
90
|
+
enable_historical_sync: false,
|
|
91
|
+
allow_queries_before_historical_sync: true,
|
|
92
|
+
run_historical_sync_worker: false,
|
|
93
|
+
};
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
throw new Error(`Invalid network provided during table creation: ${networkName}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function createExtraColumns(table, indexName, extraColumns) {
|
|
100
|
+
for (const column of extraColumns) {
|
|
101
|
+
const columnName = addColumnPrefix(column.name);
|
|
102
|
+
switch (column.type) {
|
|
103
|
+
case ColumnType.STRING:
|
|
104
|
+
table.string(columnName, 1024).notNullable();
|
|
105
|
+
table.index([columnName], `idx_${indexName}_${columnName}`);
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
throw new UnreachableCaseError(column.type, `Invalid column type`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export async function createPostgresModelTable(dataSource, tableName, extraColumns) {
|
|
113
|
+
await dataSource.schema.createTable(tableName, function (table) {
|
|
114
|
+
const idx = defaultIndices(tableName);
|
|
115
|
+
table
|
|
116
|
+
.string('stream_id')
|
|
117
|
+
.primary(`idx_${idx.indexName}_pkey`)
|
|
118
|
+
.unique(`constr_${idx.indexName}_unique`);
|
|
119
|
+
table.string('controller_did', 1024).notNullable();
|
|
120
|
+
table.jsonb('stream_content').notNullable();
|
|
121
|
+
table.string('tip').notNullable();
|
|
122
|
+
table.dateTime('last_anchored_at').nullable();
|
|
123
|
+
table.dateTime('first_anchored_at').nullable();
|
|
124
|
+
table.dateTime('created_at').notNullable().defaultTo(dataSource.fn.now());
|
|
125
|
+
table.dateTime('updated_at').notNullable().defaultTo(dataSource.fn.now());
|
|
126
|
+
createExtraColumns(table, idx.indexName, extraColumns);
|
|
127
|
+
for (const indexToCreate of idx.indices) {
|
|
128
|
+
table.index(indexToCreate.keys, indexToCreate.name, {
|
|
129
|
+
storageEngineIndexType: indexToCreate.indexType,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
export async function createSqliteModelTable(dataSource, tableName, extraColumns) {
|
|
135
|
+
await dataSource.schema.createTable(tableName, (table) => {
|
|
136
|
+
const idx = defaultIndices(tableName);
|
|
137
|
+
table.string('stream_id', 1024).primary().unique().notNullable();
|
|
138
|
+
table.string('controller_did', 1024).notNullable();
|
|
139
|
+
table.string('stream_content').notNullable();
|
|
140
|
+
table.string('tip').notNullable();
|
|
141
|
+
table.integer('last_anchored_at').nullable();
|
|
142
|
+
table.integer('first_anchored_at').nullable();
|
|
143
|
+
table.integer('created_at').notNullable();
|
|
144
|
+
table.integer('updated_at').notNullable();
|
|
145
|
+
createExtraColumns(table, tableName, extraColumns);
|
|
146
|
+
for (const indexToCreate of idx.indices) {
|
|
147
|
+
table.index(indexToCreate.keys, indexToCreate.name, {
|
|
148
|
+
storageEngineIndexType: indexToCreate.indexType,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function rawIndexQuery(tableName, index, json_indices) {
|
|
154
|
+
const indexName = fieldsIndexName(index, tableName);
|
|
155
|
+
return `CREATE INDEX ${indexName} ON ${tableName} (${json_indices.join(',')})`;
|
|
156
|
+
}
|
|
157
|
+
export async function createPostgresIndices(dataSource, tableName, indices) {
|
|
158
|
+
for (const index of indices) {
|
|
159
|
+
const json_indices = [];
|
|
160
|
+
for (const field of index.fields) {
|
|
161
|
+
const path = field.path.map((p) => `'${p}'`);
|
|
162
|
+
json_indices.push(`(stream_content->${path.join('->')})`);
|
|
163
|
+
}
|
|
164
|
+
const raw = rawIndexQuery(tableName, index, json_indices);
|
|
165
|
+
await dataSource.schema.raw(raw);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
export async function createSqliteIndices(dataSource, tableName, indices) {
|
|
169
|
+
for (const index of indices) {
|
|
170
|
+
const json_indices = [];
|
|
171
|
+
for (const field of index.fields) {
|
|
172
|
+
const path = field.path.join('.');
|
|
173
|
+
json_indices.push(`json_extract(stream_content, '$.${path}')`);
|
|
174
|
+
}
|
|
175
|
+
const raw = rawIndexQuery(tableName, index, json_indices);
|
|
176
|
+
await dataSource.schema.raw(raw);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
export async function createConfigTable(dataSource, tableName, network, jsonb_support) {
|
|
180
|
+
const NETWORK_DEFAULT_CONFIG = getDefaultCDBDatabaseConfig(network);
|
|
181
|
+
switch (tableName) {
|
|
182
|
+
case INDEXED_MODEL_CONFIG_TABLE_NAME:
|
|
183
|
+
await dataSource.schema.createTable(tableName, function (table) {
|
|
184
|
+
table.string('model', 1024).unique().notNullable().primary();
|
|
185
|
+
table.boolean('is_indexed').notNullable().defaultTo(true);
|
|
186
|
+
table.boolean('enable_historical_sync').notNullable().defaultTo(false);
|
|
187
|
+
table.dateTime('created_at').notNullable().defaultTo(dataSource.fn.now());
|
|
188
|
+
table.dateTime('updated_at').notNullable().defaultTo(dataSource.fn.now());
|
|
189
|
+
table.string('updated_by', 1024).notNullable();
|
|
190
|
+
if (jsonb_support) {
|
|
191
|
+
table.jsonb('indices').nullable();
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
table.json('indices').nullable();
|
|
195
|
+
}
|
|
196
|
+
table.index(['is_indexed'], `idx_ceramic_is_indexed`, {
|
|
197
|
+
indexType: 'btree',
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
break;
|
|
201
|
+
case CONFIG_TABLE_NAME:
|
|
202
|
+
await dataSource.schema.createTable(tableName, function (table) {
|
|
203
|
+
table.string('option', 1024).notNullable().unique(`constr_config_option_unique`);
|
|
204
|
+
table.string('value', 1024).notNullable();
|
|
205
|
+
table.dateTime('created_at').notNullable().defaultTo(dataSource.fn.now());
|
|
206
|
+
table.dateTime('updated_at').notNullable().defaultTo(dataSource.fn.now());
|
|
207
|
+
table.string('updated_by', 1024).nullable();
|
|
208
|
+
});
|
|
209
|
+
await dataSource.into(tableName).insert({ option: 'network', value: network });
|
|
210
|
+
await dataSource.into(tableName).insert({
|
|
211
|
+
option: 'allow-queries-before-historical-sync',
|
|
212
|
+
value: NETWORK_DEFAULT_CONFIG['allow_queries_before_historical_sync'],
|
|
213
|
+
});
|
|
214
|
+
await dataSource.into(tableName).insert({
|
|
215
|
+
option: 'run-historical-sync-worker',
|
|
216
|
+
value: NETWORK_DEFAULT_CONFIG['run_historical_sync_worker'],
|
|
217
|
+
});
|
|
218
|
+
break;
|
|
219
|
+
default:
|
|
220
|
+
throw new Error(`Invalid config table creation requested: ${tableName}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export async function migrateConfigTable(dataSource, tableName, jsonb_support) {
|
|
224
|
+
switch (tableName) {
|
|
225
|
+
case INDEXED_MODEL_CONFIG_TABLE_NAME:
|
|
226
|
+
if (!(await dataSource.schema.hasColumn(tableName, 'indices'))) {
|
|
227
|
+
await dataSource.schema.alterTable(tableName, (table) => {
|
|
228
|
+
if (jsonb_support) {
|
|
229
|
+
table.jsonb('indices').nullable();
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
table.json('indices').nullable();
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
case CONFIG_TABLE_NAME:
|
|
238
|
+
break;
|
|
239
|
+
default:
|
|
240
|
+
throw new Error(`Invalid config table migration requested: ${tableName}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=1-create-model-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1-create-model-table.js","sourceRoot":"","sources":["../../src/migrations/1-create-model-table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAyB,MAAM,wBAAwB,CAAA;AACpF,OAAO,EAAE,+BAA+B,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;AACnB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAQD,MAAM,CAAN,IAAY,UAEX;AAFD,WAAY,UAAU;IACpB,+CAAM,CAAA;AACR,CAAC,EAFW,UAAU,KAAV,UAAU,QAErB;AAyBD,MAAM,UAAU,sBAAsB,CAAC,SAAiB;IACtD,OAAO,OAAO,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,CAAA;AAC5D,CAAC;AAKD,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,MAAM,SAAS,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAA;IAInD,MAAM,OAAO,GAAsB;QACjC;YACE,IAAI,EAAE,CAAC,WAAW,CAAC;YACnB,IAAI,EAAE,GAAG,SAAS,YAAY;YAC9B,SAAS,EAAE,OAAO;SACnB;QACD;YACE,IAAI,EAAE,CAAC,kBAAkB,CAAC;YAC1B,IAAI,EAAE,GAAG,SAAS,mBAAmB;YACrC,SAAS,EAAE,OAAO;SACnB;QACD;YACE,IAAI,EAAE,CAAC,mBAAmB,CAAC;YAC3B,IAAI,EAAE,GAAG,SAAS,oBAAoB;YACtC,SAAS,EAAE,OAAO;SACnB;QACD;YACE,IAAI,EAAE,CAAC,YAAY,CAAC;YACpB,IAAI,EAAE,GAAG,SAAS,aAAa;YAC/B,SAAS,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
+
import { DatabaseType } from './1-create-model-table.js';
|
|
2
|
+
interface ColumnInfo {
|
|
3
|
+
defaultValue: any;
|
|
4
|
+
type: string;
|
|
5
|
+
maxLength: number | string | null;
|
|
6
|
+
nullable: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare type TableInfo = Record<string, ColumnInfo>;
|
|
9
|
+
declare type TableName = 'COMMON_TABLE' | 'CONFIG_TABLE_MODEL_INDEX' | 'CONFIG_TABLE';
|
|
10
|
+
declare type StructuresRecord = Record<TableName, TableInfo> & {
|
|
11
|
+
RELATION_COLUMN: ColumnInfo;
|
|
12
|
+
};
|
|
13
|
+
export declare const STRUCTURES: Record<DatabaseType, StructuresRecord>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=cdb-schema-verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdb-schema-verification.d.ts","sourceRoot":"","sources":["../../src/migrations/cdb-schema-verification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAGxD,UAAU,UAAU;IAClB,YAAY,EAAE,GAAG,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACjC,QAAQ,EAAE,OAAO,CAAA;CAClB;AACD,aAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAC3C,aAAK,SAAS,GAAG,cAAc,GAAG,0BAA0B,GAAG,cAAc,CAAA;AAC7E,aAAK,gBAAgB,GAAG,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG;IAAE,eAAe,EAAE,UAAU,CAAA;CAAE,CAAA;AAEtF,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,gBAAgB,CA6S7D,CAAA"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { DatabaseType } from './1-create-model-table.js';
|
|
2
|
+
export const STRUCTURES = {
|
|
3
|
+
[DatabaseType.POSTGRES]: {
|
|
4
|
+
RELATION_COLUMN: {
|
|
5
|
+
type: 'character varying',
|
|
6
|
+
maxLength: 1024,
|
|
7
|
+
nullable: false,
|
|
8
|
+
defaultValue: null,
|
|
9
|
+
},
|
|
10
|
+
COMMON_TABLE: {
|
|
11
|
+
stream_id: {
|
|
12
|
+
type: 'character varying',
|
|
13
|
+
maxLength: 255,
|
|
14
|
+
nullable: false,
|
|
15
|
+
defaultValue: null,
|
|
16
|
+
},
|
|
17
|
+
controller_did: {
|
|
18
|
+
type: 'character varying',
|
|
19
|
+
maxLength: 1024,
|
|
20
|
+
nullable: false,
|
|
21
|
+
defaultValue: null,
|
|
22
|
+
},
|
|
23
|
+
stream_content: {
|
|
24
|
+
type: 'jsonb',
|
|
25
|
+
maxLength: null,
|
|
26
|
+
nullable: false,
|
|
27
|
+
defaultValue: null,
|
|
28
|
+
},
|
|
29
|
+
tip: {
|
|
30
|
+
type: 'character varying',
|
|
31
|
+
maxLength: 255,
|
|
32
|
+
nullable: false,
|
|
33
|
+
defaultValue: null,
|
|
34
|
+
},
|
|
35
|
+
last_anchored_at: {
|
|
36
|
+
type: 'timestamp with time zone',
|
|
37
|
+
maxLength: null,
|
|
38
|
+
nullable: true,
|
|
39
|
+
defaultValue: null,
|
|
40
|
+
},
|
|
41
|
+
first_anchored_at: {
|
|
42
|
+
type: 'timestamp with time zone',
|
|
43
|
+
maxLength: null,
|
|
44
|
+
nullable: true,
|
|
45
|
+
defaultValue: null,
|
|
46
|
+
},
|
|
47
|
+
created_at: {
|
|
48
|
+
type: 'timestamp with time zone',
|
|
49
|
+
maxLength: null,
|
|
50
|
+
nullable: false,
|
|
51
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
52
|
+
},
|
|
53
|
+
updated_at: {
|
|
54
|
+
type: 'timestamp with time zone',
|
|
55
|
+
maxLength: null,
|
|
56
|
+
nullable: false,
|
|
57
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
CONFIG_TABLE_MODEL_INDEX: {
|
|
61
|
+
model: {
|
|
62
|
+
type: 'character varying',
|
|
63
|
+
maxLength: 1024,
|
|
64
|
+
nullable: false,
|
|
65
|
+
defaultValue: null,
|
|
66
|
+
},
|
|
67
|
+
is_indexed: {
|
|
68
|
+
type: 'boolean',
|
|
69
|
+
maxLength: null,
|
|
70
|
+
nullable: false,
|
|
71
|
+
defaultValue: 'true',
|
|
72
|
+
},
|
|
73
|
+
enable_historical_sync: {
|
|
74
|
+
type: 'boolean',
|
|
75
|
+
maxLength: null,
|
|
76
|
+
nullable: false,
|
|
77
|
+
defaultValue: 'false',
|
|
78
|
+
},
|
|
79
|
+
created_at: {
|
|
80
|
+
type: 'timestamp with time zone',
|
|
81
|
+
maxLength: null,
|
|
82
|
+
nullable: false,
|
|
83
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
84
|
+
},
|
|
85
|
+
updated_at: {
|
|
86
|
+
type: 'timestamp with time zone',
|
|
87
|
+
maxLength: null,
|
|
88
|
+
nullable: false,
|
|
89
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
90
|
+
},
|
|
91
|
+
updated_by: {
|
|
92
|
+
type: 'character varying',
|
|
93
|
+
maxLength: 1024,
|
|
94
|
+
nullable: false,
|
|
95
|
+
defaultValue: null,
|
|
96
|
+
},
|
|
97
|
+
indices: {
|
|
98
|
+
type: 'jsonb',
|
|
99
|
+
maxLength: null,
|
|
100
|
+
nullable: true,
|
|
101
|
+
defaultValue: null,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
CONFIG_TABLE: {
|
|
105
|
+
option: {
|
|
106
|
+
type: 'character varying',
|
|
107
|
+
maxLength: 1024,
|
|
108
|
+
nullable: false,
|
|
109
|
+
defaultValue: null,
|
|
110
|
+
},
|
|
111
|
+
value: {
|
|
112
|
+
type: 'character varying',
|
|
113
|
+
maxLength: 1024,
|
|
114
|
+
nullable: false,
|
|
115
|
+
defaultValue: null,
|
|
116
|
+
},
|
|
117
|
+
created_at: {
|
|
118
|
+
type: 'timestamp with time zone',
|
|
119
|
+
maxLength: null,
|
|
120
|
+
nullable: false,
|
|
121
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
122
|
+
},
|
|
123
|
+
updated_at: {
|
|
124
|
+
type: 'timestamp with time zone',
|
|
125
|
+
maxLength: null,
|
|
126
|
+
nullable: false,
|
|
127
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
128
|
+
},
|
|
129
|
+
updated_by: {
|
|
130
|
+
type: 'character varying',
|
|
131
|
+
maxLength: 1024,
|
|
132
|
+
nullable: true,
|
|
133
|
+
defaultValue: null,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
[DatabaseType.SQLITE]: {
|
|
138
|
+
RELATION_COLUMN: {
|
|
139
|
+
type: 'varchar',
|
|
140
|
+
maxLength: '1024',
|
|
141
|
+
nullable: false,
|
|
142
|
+
defaultValue: null,
|
|
143
|
+
},
|
|
144
|
+
COMMON_TABLE: {
|
|
145
|
+
stream_id: {
|
|
146
|
+
type: 'varchar',
|
|
147
|
+
maxLength: '1024',
|
|
148
|
+
nullable: false,
|
|
149
|
+
defaultValue: null,
|
|
150
|
+
},
|
|
151
|
+
controller_did: {
|
|
152
|
+
type: 'varchar',
|
|
153
|
+
maxLength: '1024',
|
|
154
|
+
nullable: false,
|
|
155
|
+
defaultValue: null,
|
|
156
|
+
},
|
|
157
|
+
stream_content: {
|
|
158
|
+
type: 'varchar',
|
|
159
|
+
maxLength: '255',
|
|
160
|
+
nullable: false,
|
|
161
|
+
defaultValue: null,
|
|
162
|
+
},
|
|
163
|
+
tip: {
|
|
164
|
+
type: 'varchar',
|
|
165
|
+
maxLength: '255',
|
|
166
|
+
nullable: false,
|
|
167
|
+
defaultValue: null,
|
|
168
|
+
},
|
|
169
|
+
last_anchored_at: {
|
|
170
|
+
type: 'integer',
|
|
171
|
+
maxLength: null,
|
|
172
|
+
nullable: true,
|
|
173
|
+
defaultValue: null,
|
|
174
|
+
},
|
|
175
|
+
first_anchored_at: {
|
|
176
|
+
type: 'integer',
|
|
177
|
+
maxLength: null,
|
|
178
|
+
nullable: true,
|
|
179
|
+
defaultValue: null,
|
|
180
|
+
},
|
|
181
|
+
created_at: {
|
|
182
|
+
type: 'integer',
|
|
183
|
+
maxLength: null,
|
|
184
|
+
nullable: false,
|
|
185
|
+
defaultValue: null,
|
|
186
|
+
},
|
|
187
|
+
updated_at: {
|
|
188
|
+
type: 'integer',
|
|
189
|
+
maxLength: null,
|
|
190
|
+
nullable: false,
|
|
191
|
+
defaultValue: null,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
CONFIG_TABLE_MODEL_INDEX: {
|
|
195
|
+
model: {
|
|
196
|
+
type: 'varchar',
|
|
197
|
+
maxLength: '1024',
|
|
198
|
+
nullable: false,
|
|
199
|
+
defaultValue: null,
|
|
200
|
+
},
|
|
201
|
+
is_indexed: {
|
|
202
|
+
type: 'boolean',
|
|
203
|
+
maxLength: null,
|
|
204
|
+
nullable: false,
|
|
205
|
+
defaultValue: "'1'",
|
|
206
|
+
},
|
|
207
|
+
enable_historical_sync: {
|
|
208
|
+
type: 'boolean',
|
|
209
|
+
maxLength: null,
|
|
210
|
+
nullable: false,
|
|
211
|
+
defaultValue: "'0'",
|
|
212
|
+
},
|
|
213
|
+
created_at: {
|
|
214
|
+
type: 'datetime',
|
|
215
|
+
maxLength: null,
|
|
216
|
+
nullable: false,
|
|
217
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
218
|
+
},
|
|
219
|
+
updated_at: {
|
|
220
|
+
type: 'datetime',
|
|
221
|
+
maxLength: null,
|
|
222
|
+
nullable: false,
|
|
223
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
224
|
+
},
|
|
225
|
+
updated_by: {
|
|
226
|
+
type: 'varchar',
|
|
227
|
+
maxLength: '1024',
|
|
228
|
+
nullable: false,
|
|
229
|
+
defaultValue: null,
|
|
230
|
+
},
|
|
231
|
+
indices: {
|
|
232
|
+
type: 'json',
|
|
233
|
+
maxLength: null,
|
|
234
|
+
nullable: true,
|
|
235
|
+
defaultValue: null,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
CONFIG_TABLE: {
|
|
239
|
+
option: {
|
|
240
|
+
type: 'varchar',
|
|
241
|
+
maxLength: '1024',
|
|
242
|
+
nullable: false,
|
|
243
|
+
defaultValue: null,
|
|
244
|
+
},
|
|
245
|
+
value: {
|
|
246
|
+
type: 'varchar',
|
|
247
|
+
maxLength: '1024',
|
|
248
|
+
nullable: false,
|
|
249
|
+
defaultValue: null,
|
|
250
|
+
},
|
|
251
|
+
created_at: {
|
|
252
|
+
type: 'datetime',
|
|
253
|
+
maxLength: null,
|
|
254
|
+
nullable: false,
|
|
255
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
256
|
+
},
|
|
257
|
+
updated_at: {
|
|
258
|
+
type: 'datetime',
|
|
259
|
+
maxLength: null,
|
|
260
|
+
nullable: false,
|
|
261
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
262
|
+
},
|
|
263
|
+
updated_by: {
|
|
264
|
+
type: 'varchar',
|
|
265
|
+
maxLength: '1024',
|
|
266
|
+
nullable: true,
|
|
267
|
+
defaultValue: null,
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
//# sourceMappingURL=cdb-schema-verification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdb-schema-verification.js","sourceRoot":"","sources":["../../src/migrations/cdb-schema-verification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAaxD,MAAM,CAAC,MAAM,UAAU,GAA2C;IAChE,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE;QAKvB,eAAe,EAAE;YACf,IAAI,EAAE,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gBACf,YAAY,EAAE,IAAI;aACnB;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,UAAU;gBAChB,SAAS,EAAE,IAAI;gBACf,QAAQ,EAAE,KAAK;gBACf,YAAY,EAAE,mBAAmB;aAClC;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,UAAU;gBAChB,SAAS,EAAE,IAAI;gBACf,QAAQ,EAAE,KAAK;gBACf,YAAY,EAAE,mBAAmB;aAClC;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,SAAS;gBACf,SAAS,EAAE,MAAM;gBACjB,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;aACnB;SACF;KACF;CACF,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Pagination } from '@ceramicnetwork/common';
|
|
2
|
+
export declare enum PaginationKind {
|
|
3
|
+
FORWARD = 0,
|
|
4
|
+
BACKWARD = 1
|
|
5
|
+
}
|
|
6
|
+
export declare type ForwardPaginationQuery = {
|
|
7
|
+
kind: PaginationKind.FORWARD;
|
|
8
|
+
first: number;
|
|
9
|
+
after?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type BackwardPaginationQuery = {
|
|
12
|
+
kind: PaginationKind.BACKWARD;
|
|
13
|
+
last: number;
|
|
14
|
+
before?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare type PaginationQuery = ForwardPaginationQuery | BackwardPaginationQuery;
|
|
17
|
+
export declare function parsePagination(query: Pagination): PaginationQuery;
|
|
18
|
+
//# sourceMappingURL=parse-pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-pagination.d.ts","sourceRoot":"","sources":["../src/parse-pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD,oBAAY,cAAc;IACxB,OAAO,IAAA;IACP,QAAQ,IAAA;CACT;AAED,oBAAY,sBAAsB,GAAG;IACnC,IAAI,EAAE,cAAc,CAAC,OAAO,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,oBAAY,uBAAuB,GAAG;IACpC,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAA;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,oBAAY,eAAe,GAAG,sBAAsB,GAAG,uBAAuB,CAAA;AAE9E,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,CAelE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export var PaginationKind;
|
|
2
|
+
(function (PaginationKind) {
|
|
3
|
+
PaginationKind[PaginationKind["FORWARD"] = 0] = "FORWARD";
|
|
4
|
+
PaginationKind[PaginationKind["BACKWARD"] = 1] = "BACKWARD";
|
|
5
|
+
})(PaginationKind || (PaginationKind = {}));
|
|
6
|
+
export function parsePagination(query) {
|
|
7
|
+
if ('first' in query) {
|
|
8
|
+
return {
|
|
9
|
+
kind: PaginationKind.FORWARD,
|
|
10
|
+
first: query.first,
|
|
11
|
+
after: query.after,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
else if ('last' in query) {
|
|
15
|
+
return {
|
|
16
|
+
kind: PaginationKind.BACKWARD,
|
|
17
|
+
last: query.last,
|
|
18
|
+
before: query.before,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
throw new Error('Invalid pagination query');
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=parse-pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-pagination.js","sourceRoot":"","sources":["../src/parse-pagination.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yDAAO,CAAA;IACP,2DAAQ,CAAA;AACV,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAgBD,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,IAAI,OAAO,IAAI,KAAK,EAAE;QACpB,OAAO;YACL,IAAI,EAAE,cAAc,CAAC,OAAO;YAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAA;KACF;SAAM,IAAI,MAAM,IAAI,KAAK,EAAE;QAC1B,OAAO;YACL,IAAI,EAAE,cAAc,CAAC,QAAQ;YAC7B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAA;KACF;IACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Knex } from 'knex';
|
|
2
|
+
import { QueryFilters } from './query-filter-parser.js';
|
|
3
|
+
export declare const DATA_FIELD = "stream_content";
|
|
4
|
+
export declare function contentKey(field: string): string;
|
|
5
|
+
declare type DBQuery = Knex.QueryBuilder;
|
|
6
|
+
export declare type ConvertedQueryFilter = {
|
|
7
|
+
where: (query: DBQuery) => DBQuery;
|
|
8
|
+
select: Array<string>;
|
|
9
|
+
};
|
|
10
|
+
export declare function convertQueryFilter(filter?: QueryFilters): ConvertedQueryFilter;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=query-filter-converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-filter-converter.d.ts","sourceRoot":"","sources":["../src/query-filter-converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAIL,YAAY,EAEb,MAAM,0BAA0B,CAAA;AAEjC,eAAO,MAAM,UAAU,mBAAmB,CAAA;AAE1C,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,aAAK,OAAO,GAAG,IAAI,CAAC,YAAY,CAAA;AA+QhC,oBAAY,oBAAoB,GAAG;IACjC,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAA;IAClC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CACtB,CAAA;AAED,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,oBAAoB,CAY9E"}
|