@gscdump/engine-sqlite 0.6.3 → 0.7.5
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 +3 -3
- package/dist/index.d.mts +886 -2
- package/dist/index.mjs +345 -4
- package/dist/r2-manifest-schema.d.mts +877 -0
- package/dist/r2-manifest-schema.mjs +80 -0
- package/package.json +10 -5
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import { index, integer, primaryKey, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
|
|
3
|
+
const r2Manifest = sqliteTable("r2_manifest", {
|
|
4
|
+
id: text("id").primaryKey(),
|
|
5
|
+
userId: integer("user_id").notNull(),
|
|
6
|
+
siteId: text("site_id"),
|
|
7
|
+
table: text("table").notNull(),
|
|
8
|
+
partition: text("partition").notNull(),
|
|
9
|
+
objectKey: text("object_key").notNull(),
|
|
10
|
+
rowCount: integer("row_count").notNull().default(0),
|
|
11
|
+
bytes: integer("bytes").notNull().default(0),
|
|
12
|
+
createdAt: integer("created_at").notNull(),
|
|
13
|
+
retiredAt: integer("retired_at"),
|
|
14
|
+
tier: text("tier"),
|
|
15
|
+
searchType: text("search_type"),
|
|
16
|
+
schemaVersion: integer("schema_version")
|
|
17
|
+
}, (t) => [
|
|
18
|
+
index("idx_r2_manifest_live").on(t.userId, t.siteId, t.table, t.partition, t.retiredAt),
|
|
19
|
+
index("idx_r2_manifest_retired").on(t.retiredAt),
|
|
20
|
+
index("idx_r2_manifest_tier").on(t.userId, t.siteId, t.table, t.tier, t.retiredAt),
|
|
21
|
+
unique("r2_manifest_object_key_unique").on(t.objectKey)
|
|
22
|
+
]);
|
|
23
|
+
const r2WriteErrors = sqliteTable("r2_write_errors", {
|
|
24
|
+
id: text("id").primaryKey(),
|
|
25
|
+
userId: integer("user_id").notNull(),
|
|
26
|
+
siteId: text("site_id"),
|
|
27
|
+
table: text("table"),
|
|
28
|
+
date: text("date"),
|
|
29
|
+
error: text("error").notNull(),
|
|
30
|
+
createdAt: integer("created_at").notNull().default(sql`(unixepoch())`)
|
|
31
|
+
}, (t) => [index("idx_r2_write_errors_user").on(t.userId, t.createdAt), index("idx_r2_write_errors_created").on(t.createdAt)]);
|
|
32
|
+
const r2ShadowDiffs = sqliteTable("r2_shadow_diffs", {
|
|
33
|
+
id: text("id").primaryKey(),
|
|
34
|
+
userId: integer("user_id").notNull(),
|
|
35
|
+
siteId: text("site_id"),
|
|
36
|
+
endpoint: text("endpoint").notNull(),
|
|
37
|
+
diff: text("diff").notNull(),
|
|
38
|
+
createdAt: integer("created_at").notNull().default(sql`(unixepoch())`)
|
|
39
|
+
}, (t) => [index("idx_r2_shadow_diffs_user").on(t.userId, t.createdAt), index("idx_r2_shadow_diffs_endpoint").on(t.endpoint, t.createdAt)]);
|
|
40
|
+
const r2Locks = sqliteTable("r2_locks", {
|
|
41
|
+
scope: text("scope").primaryKey(),
|
|
42
|
+
holderId: text("holder_id").notNull(),
|
|
43
|
+
acquiredAt: integer("acquired_at").notNull(),
|
|
44
|
+
expiresAt: integer("expires_at").notNull()
|
|
45
|
+
}, (t) => [index("idx_r2_locks_expires").on(t.expiresAt)]);
|
|
46
|
+
const r2Watermarks = sqliteTable("r2_watermarks", {
|
|
47
|
+
userId: integer("user_id").notNull(),
|
|
48
|
+
siteId: text("site_id").notNull().default(""),
|
|
49
|
+
table: text("table").notNull(),
|
|
50
|
+
newestDateSynced: text("newest_date_synced").notNull(),
|
|
51
|
+
oldestDateSynced: text("oldest_date_synced").notNull(),
|
|
52
|
+
lastSyncAt: integer("last_sync_at").notNull()
|
|
53
|
+
}, (t) => [primaryKey({ columns: [
|
|
54
|
+
t.userId,
|
|
55
|
+
t.siteId,
|
|
56
|
+
t.table
|
|
57
|
+
] })]);
|
|
58
|
+
const r2SyncStates = sqliteTable("r2_sync_states", {
|
|
59
|
+
userId: integer("user_id").notNull(),
|
|
60
|
+
siteId: text("site_id").notNull().default(""),
|
|
61
|
+
table: text("table").notNull(),
|
|
62
|
+
date: text("date").notNull(),
|
|
63
|
+
searchType: text("search_type").notNull().default(""),
|
|
64
|
+
state: text("state", { enum: [
|
|
65
|
+
"pending",
|
|
66
|
+
"inflight",
|
|
67
|
+
"done",
|
|
68
|
+
"failed"
|
|
69
|
+
] }).notNull(),
|
|
70
|
+
updatedAt: integer("updated_at").notNull(),
|
|
71
|
+
attempts: integer("attempts").notNull().default(0),
|
|
72
|
+
error: text("error")
|
|
73
|
+
}, (t) => [primaryKey({ columns: [
|
|
74
|
+
t.userId,
|
|
75
|
+
t.siteId,
|
|
76
|
+
t.table,
|
|
77
|
+
t.date,
|
|
78
|
+
t.searchType
|
|
79
|
+
] }), index("idx_r2_sync_states_state").on(t.state)]);
|
|
80
|
+
export { r2Locks, r2Manifest, r2ShadowDiffs, r2SyncStates, r2Watermarks, r2WriteErrors };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/engine-sqlite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.5",
|
|
5
5
|
"description": "SQLite / D1 engine adapter for @gscdump/analysis — typed analytics over sqlite-proxy executors (Cloudflare D1, libsql).",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -23,7 +23,13 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"types": "./dist/index.d.mts",
|
|
26
|
-
"import": "./dist/index.mjs"
|
|
26
|
+
"import": "./dist/index.mjs",
|
|
27
|
+
"default": "./dist/index.mjs"
|
|
28
|
+
},
|
|
29
|
+
"./r2-manifest-schema": {
|
|
30
|
+
"types": "./dist/r2-manifest-schema.d.mts",
|
|
31
|
+
"import": "./dist/r2-manifest-schema.mjs",
|
|
32
|
+
"default": "./dist/r2-manifest-schema.mjs"
|
|
27
33
|
}
|
|
28
34
|
},
|
|
29
35
|
"main": "./dist/index.mjs",
|
|
@@ -38,9 +44,8 @@
|
|
|
38
44
|
"drizzle-orm": "^0.45.2"
|
|
39
45
|
},
|
|
40
46
|
"dependencies": {
|
|
41
|
-
"@gscdump/engine": "0.
|
|
42
|
-
"gscdump": "0.
|
|
43
|
-
"@gscdump/analysis": "0.6.3"
|
|
47
|
+
"@gscdump/engine": "0.7.5",
|
|
48
|
+
"gscdump": "0.7.5"
|
|
44
49
|
},
|
|
45
50
|
"devDependencies": {
|
|
46
51
|
"drizzle-orm": "^0.45.2",
|