@kudos-protocol/storage-sqlite 0.0.1
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/LICENSE +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.ts +686 -0
- package/dist/schema.js +62 -0
- package/dist/schema.js.map +1 -0
- package/dist/sqlite-storage.d.ts +22 -0
- package/dist/sqlite-storage.js +312 -0
- package/dist/sqlite-storage.js.map +1 -0
- package/drizzle/0000_classy_lake.sql +53 -0
- package/drizzle/0001_wooden_the_professor.sql +2 -0
- package/drizzle/meta/0000_snapshot.json +361 -0
- package/drizzle/meta/0001_snapshot.json +375 -0
- package/drizzle/meta/_journal.json +20 -0
- package/drizzle.config.ts +7 -0
- package/package.json +34 -0
- package/src/__tests__/sqlite-storage.test.ts +1131 -0
- package/src/index.ts +2 -0
- package/src/schema.ts +82 -0
- package/src/sqlite-storage.ts +425 -0
- package/tsconfig.json +9 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "6",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"id": "89fe7068-44ae-414b-90c9-9cf8adc749e3",
|
|
5
|
+
"prevId": "20b17b89-42df-4849-be51-99c4bf358162",
|
|
6
|
+
"tables": {
|
|
7
|
+
"events": {
|
|
8
|
+
"name": "events",
|
|
9
|
+
"columns": {
|
|
10
|
+
"pool_id": {
|
|
11
|
+
"name": "pool_id",
|
|
12
|
+
"type": "text",
|
|
13
|
+
"primaryKey": false,
|
|
14
|
+
"notNull": true,
|
|
15
|
+
"autoincrement": false
|
|
16
|
+
},
|
|
17
|
+
"event_id": {
|
|
18
|
+
"name": "event_id",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true,
|
|
22
|
+
"autoincrement": false
|
|
23
|
+
},
|
|
24
|
+
"recipient": {
|
|
25
|
+
"name": "recipient",
|
|
26
|
+
"type": "text",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": true,
|
|
29
|
+
"autoincrement": false
|
|
30
|
+
},
|
|
31
|
+
"sender": {
|
|
32
|
+
"name": "sender",
|
|
33
|
+
"type": "text",
|
|
34
|
+
"primaryKey": false,
|
|
35
|
+
"notNull": true,
|
|
36
|
+
"autoincrement": false
|
|
37
|
+
},
|
|
38
|
+
"ts": {
|
|
39
|
+
"name": "ts",
|
|
40
|
+
"type": "text",
|
|
41
|
+
"primaryKey": false,
|
|
42
|
+
"notNull": true,
|
|
43
|
+
"autoincrement": false
|
|
44
|
+
},
|
|
45
|
+
"scope_id": {
|
|
46
|
+
"name": "scope_id",
|
|
47
|
+
"type": "text",
|
|
48
|
+
"primaryKey": false,
|
|
49
|
+
"notNull": false,
|
|
50
|
+
"autoincrement": false
|
|
51
|
+
},
|
|
52
|
+
"kudos": {
|
|
53
|
+
"name": "kudos",
|
|
54
|
+
"type": "integer",
|
|
55
|
+
"primaryKey": false,
|
|
56
|
+
"notNull": true,
|
|
57
|
+
"autoincrement": false,
|
|
58
|
+
"default": 1
|
|
59
|
+
},
|
|
60
|
+
"emoji": {
|
|
61
|
+
"name": "emoji",
|
|
62
|
+
"type": "text",
|
|
63
|
+
"primaryKey": false,
|
|
64
|
+
"notNull": false,
|
|
65
|
+
"autoincrement": false
|
|
66
|
+
},
|
|
67
|
+
"title": {
|
|
68
|
+
"name": "title",
|
|
69
|
+
"type": "text",
|
|
70
|
+
"primaryKey": false,
|
|
71
|
+
"notNull": false,
|
|
72
|
+
"autoincrement": false
|
|
73
|
+
},
|
|
74
|
+
"visibility": {
|
|
75
|
+
"name": "visibility",
|
|
76
|
+
"type": "text",
|
|
77
|
+
"primaryKey": false,
|
|
78
|
+
"notNull": true,
|
|
79
|
+
"autoincrement": false,
|
|
80
|
+
"default": "'PRIVATE'"
|
|
81
|
+
},
|
|
82
|
+
"meta": {
|
|
83
|
+
"name": "meta",
|
|
84
|
+
"type": "text",
|
|
85
|
+
"primaryKey": false,
|
|
86
|
+
"notNull": false,
|
|
87
|
+
"autoincrement": false
|
|
88
|
+
},
|
|
89
|
+
"inserted_at": {
|
|
90
|
+
"name": "inserted_at",
|
|
91
|
+
"type": "text",
|
|
92
|
+
"primaryKey": false,
|
|
93
|
+
"notNull": true,
|
|
94
|
+
"autoincrement": false,
|
|
95
|
+
"default": "(datetime('now'))"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"indexes": {
|
|
99
|
+
"idx_events_pool_ts_id": {
|
|
100
|
+
"name": "idx_events_pool_ts_id",
|
|
101
|
+
"columns": [
|
|
102
|
+
"pool_id",
|
|
103
|
+
"ts",
|
|
104
|
+
"event_id"
|
|
105
|
+
],
|
|
106
|
+
"isUnique": false
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"foreignKeys": {},
|
|
110
|
+
"compositePrimaryKeys": {
|
|
111
|
+
"events_pool_id_event_id_pk": {
|
|
112
|
+
"columns": [
|
|
113
|
+
"pool_id",
|
|
114
|
+
"event_id"
|
|
115
|
+
],
|
|
116
|
+
"name": "events_pool_id_event_id_pk"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"uniqueConstraints": {},
|
|
120
|
+
"checkConstraints": {}
|
|
121
|
+
},
|
|
122
|
+
"outbox": {
|
|
123
|
+
"name": "outbox",
|
|
124
|
+
"columns": {
|
|
125
|
+
"id": {
|
|
126
|
+
"name": "id",
|
|
127
|
+
"type": "integer",
|
|
128
|
+
"primaryKey": true,
|
|
129
|
+
"notNull": true,
|
|
130
|
+
"autoincrement": true
|
|
131
|
+
},
|
|
132
|
+
"pool_id": {
|
|
133
|
+
"name": "pool_id",
|
|
134
|
+
"type": "text",
|
|
135
|
+
"primaryKey": false,
|
|
136
|
+
"notNull": true,
|
|
137
|
+
"autoincrement": false
|
|
138
|
+
},
|
|
139
|
+
"event_id": {
|
|
140
|
+
"name": "event_id",
|
|
141
|
+
"type": "text",
|
|
142
|
+
"primaryKey": false,
|
|
143
|
+
"notNull": true,
|
|
144
|
+
"autoincrement": false
|
|
145
|
+
},
|
|
146
|
+
"payload": {
|
|
147
|
+
"name": "payload",
|
|
148
|
+
"type": "text",
|
|
149
|
+
"primaryKey": false,
|
|
150
|
+
"notNull": true,
|
|
151
|
+
"autoincrement": false
|
|
152
|
+
},
|
|
153
|
+
"created_at": {
|
|
154
|
+
"name": "created_at",
|
|
155
|
+
"type": "text",
|
|
156
|
+
"primaryKey": false,
|
|
157
|
+
"notNull": true,
|
|
158
|
+
"autoincrement": false,
|
|
159
|
+
"default": "(datetime('now'))"
|
|
160
|
+
},
|
|
161
|
+
"delivered": {
|
|
162
|
+
"name": "delivered",
|
|
163
|
+
"type": "integer",
|
|
164
|
+
"primaryKey": false,
|
|
165
|
+
"notNull": true,
|
|
166
|
+
"autoincrement": false,
|
|
167
|
+
"default": 0
|
|
168
|
+
},
|
|
169
|
+
"delivered_at": {
|
|
170
|
+
"name": "delivered_at",
|
|
171
|
+
"type": "text",
|
|
172
|
+
"primaryKey": false,
|
|
173
|
+
"notNull": false,
|
|
174
|
+
"autoincrement": false
|
|
175
|
+
},
|
|
176
|
+
"attempts": {
|
|
177
|
+
"name": "attempts",
|
|
178
|
+
"type": "integer",
|
|
179
|
+
"primaryKey": false,
|
|
180
|
+
"notNull": true,
|
|
181
|
+
"autoincrement": false,
|
|
182
|
+
"default": 0
|
|
183
|
+
},
|
|
184
|
+
"last_error": {
|
|
185
|
+
"name": "last_error",
|
|
186
|
+
"type": "text",
|
|
187
|
+
"primaryKey": false,
|
|
188
|
+
"notNull": false,
|
|
189
|
+
"autoincrement": false
|
|
190
|
+
},
|
|
191
|
+
"leased_at": {
|
|
192
|
+
"name": "leased_at",
|
|
193
|
+
"type": "text",
|
|
194
|
+
"primaryKey": false,
|
|
195
|
+
"notNull": false,
|
|
196
|
+
"autoincrement": false
|
|
197
|
+
},
|
|
198
|
+
"lease_id": {
|
|
199
|
+
"name": "lease_id",
|
|
200
|
+
"type": "text",
|
|
201
|
+
"primaryKey": false,
|
|
202
|
+
"notNull": false,
|
|
203
|
+
"autoincrement": false
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"indexes": {
|
|
207
|
+
"idx_outbox_pending": {
|
|
208
|
+
"name": "idx_outbox_pending",
|
|
209
|
+
"columns": [
|
|
210
|
+
"delivered",
|
|
211
|
+
"created_at"
|
|
212
|
+
],
|
|
213
|
+
"isUnique": false
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
"foreignKeys": {},
|
|
217
|
+
"compositePrimaryKeys": {},
|
|
218
|
+
"uniqueConstraints": {},
|
|
219
|
+
"checkConstraints": {}
|
|
220
|
+
},
|
|
221
|
+
"pool_recipient_totals": {
|
|
222
|
+
"name": "pool_recipient_totals",
|
|
223
|
+
"columns": {
|
|
224
|
+
"pool_id": {
|
|
225
|
+
"name": "pool_id",
|
|
226
|
+
"type": "text",
|
|
227
|
+
"primaryKey": false,
|
|
228
|
+
"notNull": true,
|
|
229
|
+
"autoincrement": false
|
|
230
|
+
},
|
|
231
|
+
"recipient": {
|
|
232
|
+
"name": "recipient",
|
|
233
|
+
"type": "text",
|
|
234
|
+
"primaryKey": false,
|
|
235
|
+
"notNull": true,
|
|
236
|
+
"autoincrement": false
|
|
237
|
+
},
|
|
238
|
+
"kudos": {
|
|
239
|
+
"name": "kudos",
|
|
240
|
+
"type": "integer",
|
|
241
|
+
"primaryKey": false,
|
|
242
|
+
"notNull": true,
|
|
243
|
+
"autoincrement": false,
|
|
244
|
+
"default": 0
|
|
245
|
+
},
|
|
246
|
+
"emojis": {
|
|
247
|
+
"name": "emojis",
|
|
248
|
+
"type": "text",
|
|
249
|
+
"primaryKey": false,
|
|
250
|
+
"notNull": true,
|
|
251
|
+
"autoincrement": false,
|
|
252
|
+
"default": "'[]'"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"indexes": {
|
|
256
|
+
"idx_recipient_totals_by_kudos": {
|
|
257
|
+
"name": "idx_recipient_totals_by_kudos",
|
|
258
|
+
"columns": [
|
|
259
|
+
"pool_id",
|
|
260
|
+
"kudos"
|
|
261
|
+
],
|
|
262
|
+
"isUnique": false
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
"foreignKeys": {},
|
|
266
|
+
"compositePrimaryKeys": {
|
|
267
|
+
"pool_recipient_totals_pool_id_recipient_pk": {
|
|
268
|
+
"columns": [
|
|
269
|
+
"pool_id",
|
|
270
|
+
"recipient"
|
|
271
|
+
],
|
|
272
|
+
"name": "pool_recipient_totals_pool_id_recipient_pk"
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
"uniqueConstraints": {},
|
|
276
|
+
"checkConstraints": {}
|
|
277
|
+
},
|
|
278
|
+
"pool_scope_latest": {
|
|
279
|
+
"name": "pool_scope_latest",
|
|
280
|
+
"columns": {
|
|
281
|
+
"pool_id": {
|
|
282
|
+
"name": "pool_id",
|
|
283
|
+
"type": "text",
|
|
284
|
+
"primaryKey": false,
|
|
285
|
+
"notNull": true,
|
|
286
|
+
"autoincrement": false
|
|
287
|
+
},
|
|
288
|
+
"recipient": {
|
|
289
|
+
"name": "recipient",
|
|
290
|
+
"type": "text",
|
|
291
|
+
"primaryKey": false,
|
|
292
|
+
"notNull": true,
|
|
293
|
+
"autoincrement": false
|
|
294
|
+
},
|
|
295
|
+
"scope_id": {
|
|
296
|
+
"name": "scope_id",
|
|
297
|
+
"type": "text",
|
|
298
|
+
"primaryKey": false,
|
|
299
|
+
"notNull": true,
|
|
300
|
+
"autoincrement": false
|
|
301
|
+
},
|
|
302
|
+
"event_id": {
|
|
303
|
+
"name": "event_id",
|
|
304
|
+
"type": "text",
|
|
305
|
+
"primaryKey": false,
|
|
306
|
+
"notNull": true,
|
|
307
|
+
"autoincrement": false
|
|
308
|
+
},
|
|
309
|
+
"kudos": {
|
|
310
|
+
"name": "kudos",
|
|
311
|
+
"type": "integer",
|
|
312
|
+
"primaryKey": false,
|
|
313
|
+
"notNull": true,
|
|
314
|
+
"autoincrement": false
|
|
315
|
+
},
|
|
316
|
+
"ts": {
|
|
317
|
+
"name": "ts",
|
|
318
|
+
"type": "text",
|
|
319
|
+
"primaryKey": false,
|
|
320
|
+
"notNull": true,
|
|
321
|
+
"autoincrement": false
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
"indexes": {},
|
|
325
|
+
"foreignKeys": {},
|
|
326
|
+
"compositePrimaryKeys": {
|
|
327
|
+
"pool_scope_latest_pool_id_recipient_scope_id_pk": {
|
|
328
|
+
"columns": [
|
|
329
|
+
"pool_id",
|
|
330
|
+
"recipient",
|
|
331
|
+
"scope_id"
|
|
332
|
+
],
|
|
333
|
+
"name": "pool_scope_latest_pool_id_recipient_scope_id_pk"
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
"uniqueConstraints": {},
|
|
337
|
+
"checkConstraints": {}
|
|
338
|
+
},
|
|
339
|
+
"pool_totals": {
|
|
340
|
+
"name": "pool_totals",
|
|
341
|
+
"columns": {
|
|
342
|
+
"pool_id": {
|
|
343
|
+
"name": "pool_id",
|
|
344
|
+
"type": "text",
|
|
345
|
+
"primaryKey": true,
|
|
346
|
+
"notNull": true,
|
|
347
|
+
"autoincrement": false
|
|
348
|
+
},
|
|
349
|
+
"kudos": {
|
|
350
|
+
"name": "kudos",
|
|
351
|
+
"type": "integer",
|
|
352
|
+
"primaryKey": false,
|
|
353
|
+
"notNull": true,
|
|
354
|
+
"autoincrement": false,
|
|
355
|
+
"default": 0
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
"indexes": {},
|
|
359
|
+
"foreignKeys": {},
|
|
360
|
+
"compositePrimaryKeys": {},
|
|
361
|
+
"uniqueConstraints": {},
|
|
362
|
+
"checkConstraints": {}
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
"views": {},
|
|
366
|
+
"enums": {},
|
|
367
|
+
"_meta": {
|
|
368
|
+
"schemas": {},
|
|
369
|
+
"tables": {},
|
|
370
|
+
"columns": {}
|
|
371
|
+
},
|
|
372
|
+
"internal": {
|
|
373
|
+
"indexes": {}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "7",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"entries": [
|
|
5
|
+
{
|
|
6
|
+
"idx": 0,
|
|
7
|
+
"version": "6",
|
|
8
|
+
"when": 1772629288541,
|
|
9
|
+
"tag": "0000_classy_lake",
|
|
10
|
+
"breakpoints": true
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idx": 1,
|
|
14
|
+
"version": "6",
|
|
15
|
+
"when": 1772630797735,
|
|
16
|
+
"tag": "0001_wooden_the_professor",
|
|
17
|
+
"breakpoints": true
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kudos-protocol/storage-sqlite",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"better-sqlite3": "^11",
|
|
16
|
+
"drizzle-orm": "^0.39",
|
|
17
|
+
"@kudos-protocol/pool-core": "0.0.1",
|
|
18
|
+
"@kudos-protocol/ports": "0.0.1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/better-sqlite3": "^7",
|
|
22
|
+
"@types/node": "^22",
|
|
23
|
+
"drizzle-kit": "^0.30",
|
|
24
|
+
"typescript": "^5.8",
|
|
25
|
+
"vitest": "^2.1"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"db:generate": "drizzle-kit generate",
|
|
32
|
+
"db:push": "drizzle-kit push"
|
|
33
|
+
}
|
|
34
|
+
}
|