logic-sdk 0.4.0 → 0.5.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 +39 -13
- package/dist/ai.d.ts +16 -26
- package/dist/ai.js +8 -21
- package/dist/cloudflare.d.ts +55 -0
- package/dist/cloudflare.js +85 -0
- package/dist/drizzle/pg.d.ts +237 -0
- package/dist/drizzle/pg.js +67 -0
- package/dist/drizzle/sqlite.d.ts +242 -0
- package/dist/drizzle/sqlite.js +194 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.js +45 -0
- package/dist/fetch.d.ts +15 -18
- package/dist/fetch.js +18 -55
- package/dist/index.d.ts +75 -379
- package/dist/index.js +228 -181
- package/dist/jobs.d.ts +44 -0
- package/dist/jobs.js +252 -0
- package/dist/node.d.ts +26 -0
- package/dist/node.js +76 -0
- package/dist/orpc.d.ts +10 -17
- package/dist/orpc.js +19 -28
- package/dist/pg-boss.d.ts +55 -0
- package/dist/pg-boss.js +211 -0
- package/dist/postgres.d.ts +28 -0
- package/dist/postgres.js +82 -0
- package/dist/schedule.d.ts +23 -0
- package/dist/schedule.js +109 -0
- package/dist/sqlite.d.ts +9 -0
- package/dist/sqlite.js +65 -0
- package/dist/stored-jobs.d.ts +64 -0
- package/dist/stored-jobs.js +188 -0
- package/dist/testing.d.ts +50 -14
- package/dist/testing.js +198 -46
- package/dist/types.d.ts +653 -0
- package/dist/types.js +6 -0
- package/package.json +45 -7
- package/skills/logic-sdk/SKILL.md +114 -0
- package/src/ai.ts +23 -46
- package/src/cloudflare.ts +107 -0
- package/src/drizzle/pg.ts +111 -0
- package/src/drizzle/sqlite.ts +236 -0
- package/src/errors.ts +59 -0
- package/src/fetch.ts +17 -65
- package/src/index.ts +384 -558
- package/src/jobs.ts +296 -0
- package/src/node.ts +99 -0
- package/src/orpc.ts +24 -42
- package/src/pg-boss.ts +242 -0
- package/src/postgres.ts +90 -0
- package/src/schedule.ts +129 -0
- package/src/sqlite.ts +74 -0
- package/src/stored-jobs.ts +260 -0
- package/src/testing.ts +252 -55
- package/src/types.ts +683 -0
- package/dist/drizzle.d.ts +0 -18
- package/dist/drizzle.js +0 -23
- package/src/drizzle.ts +0 -39
package/dist/drizzle.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { DatabaseAdapter } from "./index.ts";
|
|
2
|
-
/** Anything with Drizzle's `transaction(fn)`: a database or a transaction (nested = savepoint). */
|
|
3
|
-
interface Transactional {
|
|
4
|
-
transaction<T>(fn: (tx: any) => Promise<T>, config?: any): Promise<T>;
|
|
5
|
-
}
|
|
6
|
-
/** The transaction type of a Drizzle database: `type Tx = DrizzleTx<typeof db>`. */
|
|
7
|
-
export type DrizzleTx<Db extends Transactional> = Parameters<Parameters<Db["transaction"]>[0]>[0];
|
|
8
|
-
/** What queries get: the database minus write methods. A type-level guard, not a runtime one. */
|
|
9
|
-
export type DrizzleReader<Db> = Omit<Db, "insert" | "update" | "delete" | "execute" | "transaction" | "batch" | "run" | "refreshMaterializedView">;
|
|
10
|
-
/**
|
|
11
|
-
* Use a Drizzle database for mutations. Needs a driver with interactive transactions
|
|
12
|
-
* (node-postgres, postgres.js, PGlite, Neon websocket, Hyperdrive, better-sqlite3, libsql...).
|
|
13
|
-
* Not D1 or HTTP drivers.
|
|
14
|
-
*/
|
|
15
|
-
export declare function drizzleAdapter<Db extends Transactional>(db: Db): DatabaseAdapter<Db, DrizzleTx<Db>>;
|
|
16
|
-
/** The SQLSTATE of a driver error, also when Drizzle wraps it (`DrizzleQueryError.cause`). Use it to map constraints. */
|
|
17
|
-
export declare function sqlState(error: unknown): string | undefined;
|
|
18
|
-
export {};
|
package/dist/drizzle.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Use a Drizzle database for mutations. Needs a driver with interactive transactions
|
|
3
|
-
* (node-postgres, postgres.js, PGlite, Neon websocket, Hyperdrive, better-sqlite3, libsql...).
|
|
4
|
-
* Not D1 or HTTP drivers.
|
|
5
|
-
*/
|
|
6
|
-
export function drizzleAdapter(db) {
|
|
7
|
-
return {
|
|
8
|
-
db,
|
|
9
|
-
transactions: "interactive",
|
|
10
|
-
transaction: (fn) => db.transaction(fn),
|
|
11
|
-
nest: (tx) => drizzleAdapter(tx),
|
|
12
|
-
retryable: (e) => RETRYABLE.has(sqlState(e) ?? ""),
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/** Postgres: serialization_failure, deadlock_detected. The transaction lost a race; running it again is the fix. */
|
|
16
|
-
const RETRYABLE = new Set(["40001", "40P01"]);
|
|
17
|
-
/** The SQLSTATE of a driver error, also when Drizzle wraps it (`DrizzleQueryError.cause`). Use it to map constraints. */
|
|
18
|
-
export function sqlState(error) {
|
|
19
|
-
for (let e = error, i = 0; e && i < 5; e = e.cause, i++)
|
|
20
|
-
if (typeof e.code === "string")
|
|
21
|
-
return e.code;
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
package/src/drizzle.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { DatabaseAdapter } from "./index.ts";
|
|
2
|
-
|
|
3
|
-
/** Anything with Drizzle's `transaction(fn)`: a database or a transaction (nested = savepoint). */
|
|
4
|
-
interface Transactional {
|
|
5
|
-
transaction<T>(fn: (tx: any) => Promise<T>, config?: any): Promise<T>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/** The transaction type of a Drizzle database: `type Tx = DrizzleTx<typeof db>`. */
|
|
9
|
-
export type DrizzleTx<Db extends Transactional> = Parameters<Parameters<Db["transaction"]>[0]>[0];
|
|
10
|
-
|
|
11
|
-
/** What queries get: the database minus write methods. A type-level guard, not a runtime one. */
|
|
12
|
-
export type DrizzleReader<Db> = Omit<
|
|
13
|
-
Db,
|
|
14
|
-
"insert" | "update" | "delete" | "execute" | "transaction" | "batch" | "run" | "refreshMaterializedView"
|
|
15
|
-
>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Use a Drizzle database for mutations. Needs a driver with interactive transactions
|
|
19
|
-
* (node-postgres, postgres.js, PGlite, Neon websocket, Hyperdrive, better-sqlite3, libsql...).
|
|
20
|
-
* Not D1 or HTTP drivers.
|
|
21
|
-
*/
|
|
22
|
-
export function drizzleAdapter<Db extends Transactional>(db: Db): DatabaseAdapter<Db, DrizzleTx<Db>> {
|
|
23
|
-
return {
|
|
24
|
-
db,
|
|
25
|
-
transactions: "interactive",
|
|
26
|
-
transaction: (fn) => db.transaction(fn),
|
|
27
|
-
nest: (tx) => drizzleAdapter(tx),
|
|
28
|
-
retryable: (e) => RETRYABLE.has(sqlState(e) ?? ""),
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Postgres: serialization_failure, deadlock_detected. The transaction lost a race; running it again is the fix. */
|
|
33
|
-
const RETRYABLE = new Set(["40001", "40P01"]);
|
|
34
|
-
|
|
35
|
-
/** The SQLSTATE of a driver error, also when Drizzle wraps it (`DrizzleQueryError.cause`). Use it to map constraints. */
|
|
36
|
-
export function sqlState(error: unknown): string | undefined {
|
|
37
|
-
for (let e: any = error, i = 0; e && i < 5; e = e.cause, i++) if (typeof e.code === "string") return e.code;
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|