clanka 0.26.1 → 0.28.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 +2 -3
- package/dist/Acp.test.js +0 -1
- package/dist/Acp.test.js.map +1 -1
- package/dist/AcpImage.test.js +0 -1
- package/dist/AcpImage.test.js.map +1 -1
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +1 -2
- package/dist/Agent.js.map +1 -1
- package/dist/Agent.test.js +0 -1
- package/dist/Agent.test.js.map +1 -1
- package/dist/AgentCallerConfig.test.js +0 -1
- package/dist/AgentCallerConfig.test.js.map +1 -1
- package/dist/AgentExecutor.d.ts +2 -3
- package/dist/AgentExecutor.d.ts.map +1 -1
- package/dist/AgentExecutor.js +4 -13
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentImage.test.js +0 -1
- package/dist/AgentImage.test.js.map +1 -1
- package/dist/AgentSkills.test.js +0 -2
- package/dist/AgentSkills.test.js.map +1 -1
- package/dist/AgentTools.d.ts +2 -235
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +2 -32
- package/dist/AgentTools.js.map +1 -1
- package/dist/ClaudeAgent.test.js +0 -1
- package/dist/ClaudeAgent.test.js.map +1 -1
- package/dist/McpServers.d.ts +20 -1
- package/dist/McpServers.d.ts.map +1 -1
- package/dist/McpServers.js +12 -5
- package/dist/McpServers.js.map +1 -1
- package/dist/McpServers.test.js +115 -0
- package/dist/McpServers.test.js.map +1 -1
- package/dist/ScriptFormatting.d.ts +5 -0
- package/dist/ScriptFormatting.d.ts.map +1 -1
- package/dist/ScriptFormatting.js +255 -53
- package/dist/ScriptFormatting.js.map +1 -1
- package/dist/ScriptFormatting.test.js +16 -0
- package/dist/ScriptFormatting.test.js.map +1 -1
- package/dist/bin/{Latch-DOdbsGMQ.mjs → Latch-BE6_TYRL.mjs} +1 -1
- package/dist/bin/{McpClient-B-FFG6Pg.mjs → McpClient-DCt4v5W5.mjs} +2 -2
- package/dist/bin/{OutputFormatter-DhhP2i-7.mjs → OutputFormatter-DaFv_C_I.mjs} +2 -3
- package/dist/bin/{Schema-CFdSO6iH.mjs → Schema-B3MiG1aD.mjs} +204 -568
- package/dist/bin/cli.mjs +5098 -2472
- package/dist/bin/{upgrade-C4aOEWJH.mjs → upgrade-WqgIU_21.mjs} +3 -3
- package/dist/cli.js +2 -25
- package/dist/cli.js.map +1 -1
- package/dist/fixtures/McpFakeServer.d.ts +4 -0
- package/dist/fixtures/McpFakeServer.d.ts.map +1 -1
- package/dist/fixtures/McpFakeServer.js +13 -0
- package/dist/fixtures/McpFakeServer.js.map +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -7
- package/src/Acp.test.ts +0 -1
- package/src/AcpImage.test.ts +0 -1
- package/src/Agent.test.ts +0 -1
- package/src/Agent.ts +0 -4
- package/src/AgentCallerConfig.test.ts +0 -1
- package/src/AgentExecutor.ts +4 -16
- package/src/AgentImage.test.ts +0 -1
- package/src/AgentSkills.test.ts +0 -2
- package/src/AgentTools.ts +4 -41
- package/src/ClaudeAgent.test.ts +0 -1
- package/src/McpServers.test.ts +198 -0
- package/src/McpServers.ts +44 -4
- package/src/ScriptFormatting.test.ts +20 -0
- package/src/ScriptFormatting.ts +234 -47
- package/src/cli.ts +1 -56
- package/src/fixtures/McpFakeServer.ts +17 -1
- package/src/index.ts +0 -10
- package/dist/ChunkRepo.d.ts +0 -173
- package/dist/ChunkRepo.d.ts.map +0 -1
- package/dist/ChunkRepo.js +0 -168
- package/dist/ChunkRepo.js.map +0 -1
- package/dist/ChunkRepo.test.d.ts +0 -2
- package/dist/ChunkRepo.test.d.ts.map +0 -1
- package/dist/ChunkRepo.test.js +0 -63
- package/dist/ChunkRepo.test.js.map +0 -1
- package/dist/CodeChunker.d.ts +0 -84
- package/dist/CodeChunker.d.ts.map +0 -1
- package/dist/CodeChunker.js +0 -658
- package/dist/CodeChunker.js.map +0 -1
- package/dist/CodeChunker.test.d.ts +0 -2
- package/dist/CodeChunker.test.d.ts.map +0 -1
- package/dist/CodeChunker.test.js +0 -434
- package/dist/CodeChunker.test.js.map +0 -1
- package/dist/SemanticSearch/Service.d.ts +0 -31
- package/dist/SemanticSearch/Service.d.ts.map +0 -1
- package/dist/SemanticSearch/Service.js +0 -29
- package/dist/SemanticSearch/Service.js.map +0 -1
- package/dist/SemanticSearch.d.ts +0 -34
- package/dist/SemanticSearch.d.ts.map +0 -1
- package/dist/SemanticSearch.js +0 -171
- package/dist/SemanticSearch.js.map +0 -1
- package/dist/SemanticSearch.test.d.ts +0 -2
- package/dist/SemanticSearch.test.d.ts.map +0 -1
- package/dist/SemanticSearch.test.js +0 -34
- package/dist/SemanticSearch.test.js.map +0 -1
- package/dist/Sqlite.d.ts +0 -15
- package/dist/Sqlite.d.ts.map +0 -1
- package/dist/Sqlite.js +0 -44
- package/dist/Sqlite.js.map +0 -1
- package/dist/bin/AiError-DBaKz35C.mjs +0 -2723
- package/dist/bin/SemanticSearch-C3a7LAQr.mjs +0 -2558
- package/src/ChunkRepo.test.ts +0 -89
- package/src/ChunkRepo.ts +0 -260
- package/src/CodeChunker.test.ts +0 -493
- package/src/CodeChunker.ts +0 -1018
- package/src/SemanticSearch/Service.ts +0 -50
- package/src/SemanticSearch.test.ts +0 -51
- package/src/SemanticSearch.ts +0 -282
- package/src/Sqlite.ts +0 -60
package/src/ChunkRepo.test.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { mkdtemp, rm } from "node:fs/promises"
|
|
2
|
-
import { tmpdir } from "node:os"
|
|
3
|
-
import { join } from "node:path"
|
|
4
|
-
import * as NodeServices from "@effect/platform-node/NodeServices"
|
|
5
|
-
import { assert, describe, it } from "@effect/vitest"
|
|
6
|
-
import * as Effect from "effect/Effect"
|
|
7
|
-
import * as Layer from "effect/Layer"
|
|
8
|
-
import * as EmbeddingModel from "effect/ai/EmbeddingModel"
|
|
9
|
-
import * as SqlClient from "effect/sql/SqlClient"
|
|
10
|
-
import { Chunk, ChunkRepo, layer, SyncId } from "./ChunkRepo.ts"
|
|
11
|
-
import { SqliteLayer } from "./Sqlite.ts"
|
|
12
|
-
|
|
13
|
-
const withDatabase = Effect.acquireRelease(
|
|
14
|
-
Effect.promise(() => mkdtemp(join(tmpdir(), "clanka-"))),
|
|
15
|
-
(directory) => Effect.promise(() => rm(directory, { recursive: true })),
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
const sqliteLayer = (database: string) =>
|
|
19
|
-
SqliteLayer(database).pipe(Layer.provide(NodeServices.layer))
|
|
20
|
-
|
|
21
|
-
describe("ChunkRepo", () => {
|
|
22
|
-
it.live("backfills and synchronizes the vec0 index", () =>
|
|
23
|
-
Effect.gen(function* () {
|
|
24
|
-
const directory = yield* withDatabase
|
|
25
|
-
const database = join(directory, "search.sqlite")
|
|
26
|
-
const existingVector = new Float32Array([0, 1, 0])
|
|
27
|
-
|
|
28
|
-
yield* Effect.gen(function* () {
|
|
29
|
-
const sql = yield* SqlClient.SqlClient
|
|
30
|
-
yield* sql`INSERT INTO chunks(path, content, hash, vector, syncId)
|
|
31
|
-
VALUES ('existing.ts', 'existing', 'existing', ${existingVector}, 'sync')`
|
|
32
|
-
}).pipe(Effect.provide(sqliteLayer(database)), Effect.scoped)
|
|
33
|
-
|
|
34
|
-
const databaseLayer = sqliteLayer(database)
|
|
35
|
-
const repoLayer = Layer.merge(
|
|
36
|
-
layer.pipe(Layer.provide(databaseLayer)),
|
|
37
|
-
databaseLayer,
|
|
38
|
-
).pipe(Layer.provide(Layer.succeed(EmbeddingModel.Dimensions, 3)))
|
|
39
|
-
|
|
40
|
-
yield* Effect.gen(function* () {
|
|
41
|
-
const repo = yield* ChunkRepo
|
|
42
|
-
const sql = yield* SqlClient.SqlClient
|
|
43
|
-
|
|
44
|
-
const backfilled = yield* repo.search({
|
|
45
|
-
vector: existingVector,
|
|
46
|
-
limit: 1,
|
|
47
|
-
})
|
|
48
|
-
assert.strictEqual(backfilled[0]?.path, "existing.ts")
|
|
49
|
-
|
|
50
|
-
const inserted = yield* repo.insert(
|
|
51
|
-
Chunk.insert.make({
|
|
52
|
-
path: "inserted.ts",
|
|
53
|
-
content: "inserted",
|
|
54
|
-
hash: "inserted",
|
|
55
|
-
vector: new Float32Array([1, 0, 0]),
|
|
56
|
-
syncId: SyncId.make("sync"),
|
|
57
|
-
}),
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
const insertedResult = yield* repo.search({
|
|
61
|
-
vector: new Float32Array([1, 0, 0]),
|
|
62
|
-
limit: 1,
|
|
63
|
-
})
|
|
64
|
-
assert.strictEqual(insertedResult[0]?.id, inserted.id)
|
|
65
|
-
|
|
66
|
-
yield* sql`UPDATE chunks
|
|
67
|
-
SET vector = ${new Float32Array([0, 0, 1])}
|
|
68
|
-
WHERE id = ${inserted.id}`
|
|
69
|
-
|
|
70
|
-
const updatedResult = yield* repo.search({
|
|
71
|
-
vector: new Float32Array([0, 0, 1]),
|
|
72
|
-
limit: 1,
|
|
73
|
-
})
|
|
74
|
-
assert.strictEqual(updatedResult[0]?.id, inserted.id)
|
|
75
|
-
|
|
76
|
-
yield* repo.deleteByPath("inserted.ts")
|
|
77
|
-
|
|
78
|
-
const deletedResult = yield* repo.search({
|
|
79
|
-
vector: new Float32Array([0, 0, 1]),
|
|
80
|
-
limit: 2,
|
|
81
|
-
})
|
|
82
|
-
assert.deepStrictEqual(
|
|
83
|
-
deletedResult.map((chunk) => chunk.path),
|
|
84
|
-
["existing.ts"],
|
|
85
|
-
)
|
|
86
|
-
}).pipe(Effect.provide(repoLayer), Effect.scoped)
|
|
87
|
-
}),
|
|
88
|
-
)
|
|
89
|
-
})
|
package/src/ChunkRepo.ts
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
/** @effect-diagnostics schemaNumber:off */
|
|
2
|
-
import * as Effect from "effect/Effect"
|
|
3
|
-
import * as Layer from "effect/Layer"
|
|
4
|
-
import * as Schema from "effect/Schema"
|
|
5
|
-
import * as SchemaTransformation from "effect/SchemaTransformation"
|
|
6
|
-
import * as Context from "effect/Context"
|
|
7
|
-
import * as Model from "effect/schema/Model"
|
|
8
|
-
import * as SqlClient from "effect/sql/SqlClient"
|
|
9
|
-
import * as SqlError from "effect/sql/SqlError"
|
|
10
|
-
import * as SqlModel from "effect/sql/SqlModel"
|
|
11
|
-
import * as SqlSchema from "effect/sql/SqlSchema"
|
|
12
|
-
import type * as Cause from "effect/Cause"
|
|
13
|
-
import type * as Option from "effect/Option"
|
|
14
|
-
import * as EmbeddingModel from "effect/ai/EmbeddingModel"
|
|
15
|
-
import * as SqlResolver from "effect/sql/SqlResolver"
|
|
16
|
-
import * as RequestResolver from "effect/RequestResolver"
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @since 1.0.0
|
|
20
|
-
* @category Models
|
|
21
|
-
*/
|
|
22
|
-
export const ChunkId = Schema.Number.pipe(Schema.brand("ChunkRepo/ChunkId"))
|
|
23
|
-
/**
|
|
24
|
-
* @since 1.0.0
|
|
25
|
-
* @category Models
|
|
26
|
-
*/
|
|
27
|
-
export type ChunkId = typeof ChunkId.Type
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @since 1.0.0
|
|
31
|
-
* @category Models
|
|
32
|
-
*/
|
|
33
|
-
export const SyncId = Schema.String.pipe(Schema.brand("ChunkRepo/SyncId"))
|
|
34
|
-
/**
|
|
35
|
-
* @since 1.0.0
|
|
36
|
-
* @category Models
|
|
37
|
-
*/
|
|
38
|
-
export type SyncId = typeof SyncId.Type
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @since 1.0.0
|
|
42
|
-
* @category Models
|
|
43
|
-
*/
|
|
44
|
-
export const Float32ArraySchema = Schema.instanceOf<
|
|
45
|
-
Float32ArrayConstructor,
|
|
46
|
-
Float32Array
|
|
47
|
-
>(Float32Array)
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @since 1.0.0
|
|
51
|
-
* @category Models
|
|
52
|
-
*/
|
|
53
|
-
export const Float32ArrayFromArray = Schema.Array(Schema.Number).pipe(
|
|
54
|
-
Schema.decodeTo(
|
|
55
|
-
Float32ArraySchema,
|
|
56
|
-
SchemaTransformation.transform({
|
|
57
|
-
decode: (arr) => new Float32Array(arr),
|
|
58
|
-
encode: (array) => Array.from(array),
|
|
59
|
-
}),
|
|
60
|
-
),
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @since 1.0.0
|
|
65
|
-
* @category Models
|
|
66
|
-
*/
|
|
67
|
-
export const Float32ArrayField = Model.Field({
|
|
68
|
-
insert: Float32ArraySchema,
|
|
69
|
-
update: Float32ArraySchema,
|
|
70
|
-
jsonCreate: Float32ArrayFromArray,
|
|
71
|
-
jsonUpdate: Float32ArrayFromArray,
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @since 1.0.0
|
|
76
|
-
* @category Models
|
|
77
|
-
*/
|
|
78
|
-
export class Chunk extends Model.Class<Chunk>("Chunk")({
|
|
79
|
-
id: ChunkId.pipe(Model.FieldExcept(["insert", "jsonCreate"])),
|
|
80
|
-
path: Schema.String,
|
|
81
|
-
content: Schema.String,
|
|
82
|
-
hash: Schema.String,
|
|
83
|
-
vector: Float32ArrayField,
|
|
84
|
-
syncId: SyncId,
|
|
85
|
-
}) {}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @since 1.0.0
|
|
89
|
-
* @category Services
|
|
90
|
-
*/
|
|
91
|
-
export class ChunkRepo extends Context.Service<
|
|
92
|
-
ChunkRepo,
|
|
93
|
-
{
|
|
94
|
-
insert(
|
|
95
|
-
chunk: typeof Chunk.insert.Type,
|
|
96
|
-
): Effect.Effect<Chunk, ChunkRepoError>
|
|
97
|
-
|
|
98
|
-
findById(
|
|
99
|
-
id: ChunkId,
|
|
100
|
-
): Effect.Effect<Chunk, ChunkRepoError | Cause.NoSuchElementError>
|
|
101
|
-
|
|
102
|
-
exists(hash: string): Effect.Effect<Option.Option<ChunkId>, ChunkRepoError>
|
|
103
|
-
|
|
104
|
-
search(options: {
|
|
105
|
-
readonly vector: Float32Array
|
|
106
|
-
readonly limit: number
|
|
107
|
-
}): Effect.Effect<Array<Chunk>, ChunkRepoError>
|
|
108
|
-
|
|
109
|
-
quantize: Effect.Effect<void, ChunkRepoError>
|
|
110
|
-
|
|
111
|
-
setSyncId(
|
|
112
|
-
chunkId: ChunkId,
|
|
113
|
-
syncId: SyncId,
|
|
114
|
-
): Effect.Effect<void, ChunkRepoError>
|
|
115
|
-
deleteByPath(path: string): Effect.Effect<void, ChunkRepoError>
|
|
116
|
-
deleteForSyncId(syncId: SyncId): Effect.Effect<void, ChunkRepoError>
|
|
117
|
-
}
|
|
118
|
-
>()("clanka/ChunkRepo") {}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @since 1.0.0
|
|
122
|
-
* @category Errors
|
|
123
|
-
*/
|
|
124
|
-
export class ChunkRepoError extends Schema.TaggedError<ChunkRepoError>()(
|
|
125
|
-
"ChunkRepoError",
|
|
126
|
-
{
|
|
127
|
-
reason: Schema.Union([SqlError.SqlError]),
|
|
128
|
-
},
|
|
129
|
-
) {
|
|
130
|
-
readonly cause = this.reason
|
|
131
|
-
readonly message = this.reason.message
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @since 1.0.0
|
|
136
|
-
* @category Layers
|
|
137
|
-
*/
|
|
138
|
-
export const layer = Layer.effect(
|
|
139
|
-
ChunkRepo,
|
|
140
|
-
Effect.gen(function* () {
|
|
141
|
-
const sql = yield* SqlClient.SqlClient
|
|
142
|
-
const dimensions = yield* EmbeddingModel.Dimensions
|
|
143
|
-
|
|
144
|
-
yield* Effect.gen(function* () {
|
|
145
|
-
yield* sql`CREATE VIRTUAL TABLE IF NOT EXISTS chunk_vectors USING vec0(
|
|
146
|
-
vector float[${sql.literal(String(dimensions))}]
|
|
147
|
-
)`
|
|
148
|
-
yield* sql`CREATE TRIGGER IF NOT EXISTS chunks_vector_insert
|
|
149
|
-
AFTER INSERT ON chunks
|
|
150
|
-
BEGIN
|
|
151
|
-
INSERT INTO chunk_vectors(rowid, vector) VALUES (new.id, new.vector);
|
|
152
|
-
END`
|
|
153
|
-
yield* sql`CREATE TRIGGER IF NOT EXISTS chunks_vector_update
|
|
154
|
-
AFTER UPDATE OF vector ON chunks
|
|
155
|
-
BEGIN
|
|
156
|
-
DELETE FROM chunk_vectors WHERE rowid = old.id;
|
|
157
|
-
INSERT INTO chunk_vectors(rowid, vector) VALUES (new.id, new.vector);
|
|
158
|
-
END`
|
|
159
|
-
yield* sql`CREATE TRIGGER IF NOT EXISTS chunks_vector_delete
|
|
160
|
-
AFTER DELETE ON chunks
|
|
161
|
-
BEGIN
|
|
162
|
-
DELETE FROM chunk_vectors WHERE rowid = old.id;
|
|
163
|
-
END`
|
|
164
|
-
yield* sql`DELETE FROM chunk_vectors
|
|
165
|
-
WHERE rowid NOT IN (SELECT id FROM chunks)`
|
|
166
|
-
yield* sql`INSERT INTO chunk_vectors(rowid, vector)
|
|
167
|
-
SELECT id, vector FROM chunks
|
|
168
|
-
WHERE id NOT IN (SELECT rowid FROM chunk_vectors)`
|
|
169
|
-
}).pipe(sql.withTransaction)
|
|
170
|
-
|
|
171
|
-
const loaders = yield* SqlModel.makeResolvers(Chunk, {
|
|
172
|
-
tableName: "chunks",
|
|
173
|
-
idColumn: "id",
|
|
174
|
-
spanPrefix: "ChunkRepo",
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
const search = SqlSchema.findAll({
|
|
178
|
-
Request: Schema.Struct({
|
|
179
|
-
vector: Float32ArraySchema,
|
|
180
|
-
limit: Schema.Number,
|
|
181
|
-
}),
|
|
182
|
-
Result: Chunk,
|
|
183
|
-
execute: ({ vector, limit }) =>
|
|
184
|
-
sql`
|
|
185
|
-
select chunks.id, chunks.path, chunks.content, chunks.hash, chunks.syncId
|
|
186
|
-
from chunk_vectors
|
|
187
|
-
JOIN chunks ON chunks.id = chunk_vectors.rowid
|
|
188
|
-
WHERE chunk_vectors.vector MATCH ${vector}
|
|
189
|
-
AND k = CAST(${limit} AS INTEGER)
|
|
190
|
-
ORDER BY chunk_vectors.distance
|
|
191
|
-
`,
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
const exists = SqlResolver.findById({
|
|
195
|
-
Id: Schema.String, // hash
|
|
196
|
-
Result: Schema.Struct({
|
|
197
|
-
id: ChunkId,
|
|
198
|
-
hash: Schema.String,
|
|
199
|
-
}),
|
|
200
|
-
ResultId(result) {
|
|
201
|
-
return result.hash
|
|
202
|
-
},
|
|
203
|
-
execute: (hashes) =>
|
|
204
|
-
sql`select id, hash from chunks where ${sql.in("hash", hashes)}`,
|
|
205
|
-
}).pipe(RequestResolver.setDelay(5))
|
|
206
|
-
|
|
207
|
-
const insertResolver = loaders.insert.pipe(RequestResolver.setDelay(5))
|
|
208
|
-
const findByIdResolver = loaders.findById.pipe(RequestResolver.setDelay(5))
|
|
209
|
-
|
|
210
|
-
return ChunkRepo.of({
|
|
211
|
-
insert: (insert) =>
|
|
212
|
-
SqlResolver.request(insert, insertResolver).pipe(
|
|
213
|
-
Effect.catchTags(
|
|
214
|
-
{
|
|
215
|
-
SchemaError: Effect.die,
|
|
216
|
-
ResultLengthMismatch: Effect.die,
|
|
217
|
-
},
|
|
218
|
-
(reason) => Effect.fail(new ChunkRepoError({ reason })),
|
|
219
|
-
),
|
|
220
|
-
),
|
|
221
|
-
findById: (id) =>
|
|
222
|
-
SqlResolver.request(id, findByIdResolver).pipe(
|
|
223
|
-
Effect.catchTags({
|
|
224
|
-
SchemaError: Effect.die,
|
|
225
|
-
SqlError: (reason) => Effect.fail(new ChunkRepoError({ reason })),
|
|
226
|
-
}),
|
|
227
|
-
),
|
|
228
|
-
exists: (hash) =>
|
|
229
|
-
SqlResolver.request(hash, exists).pipe(
|
|
230
|
-
Effect.map((result) => result.id),
|
|
231
|
-
Effect.catchNoSuchElement,
|
|
232
|
-
Effect.catchTags({
|
|
233
|
-
SqlError: (reason) => Effect.fail(new ChunkRepoError({ reason })),
|
|
234
|
-
SchemaError: Effect.die,
|
|
235
|
-
}),
|
|
236
|
-
),
|
|
237
|
-
search: Effect.fn("ChunkRepo.search")(function* (options) {
|
|
238
|
-
return yield* search(options as any).pipe(
|
|
239
|
-
Effect.catchTags({
|
|
240
|
-
SqlError: (reason) => Effect.fail(new ChunkRepoError({ reason })),
|
|
241
|
-
SchemaError: Effect.die,
|
|
242
|
-
}),
|
|
243
|
-
)
|
|
244
|
-
}),
|
|
245
|
-
quantize: Effect.void,
|
|
246
|
-
setSyncId: (chunkId, syncId) =>
|
|
247
|
-
sql`update chunks set syncId = ${syncId} where id = ${chunkId}`.pipe(
|
|
248
|
-
Effect.mapError((reason) => new ChunkRepoError({ reason })),
|
|
249
|
-
),
|
|
250
|
-
deleteByPath: (path) =>
|
|
251
|
-
sql`delete from chunks where path = ${path}`.pipe(
|
|
252
|
-
Effect.mapError((reason) => new ChunkRepoError({ reason })),
|
|
253
|
-
),
|
|
254
|
-
deleteForSyncId: (syncId) =>
|
|
255
|
-
sql`delete from chunks where syncId != ${syncId}`.pipe(
|
|
256
|
-
Effect.mapError((reason) => new ChunkRepoError({ reason })),
|
|
257
|
-
),
|
|
258
|
-
})
|
|
259
|
-
}),
|
|
260
|
-
)
|