@shware/workflow 9.0.0 → 9.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/dist/postgres-js.cjs +11 -1
- package/dist/postgres-js.cjs.map +1 -1
- package/dist/postgres-js.d.cts +6 -0
- package/dist/postgres-js.d.cts.map +1 -1
- package/dist/postgres-js.d.mts +6 -0
- package/dist/postgres-js.d.mts.map +1 -1
- package/dist/postgres-js.mjs +11 -2
- package/dist/postgres-js.mjs.map +1 -1
- package/dist/store/sql.cjs.map +1 -1
- package/dist/store/sql.d.cts +7 -4
- package/dist/store/sql.d.cts.map +1 -1
- package/dist/store/sql.d.mts +7 -4
- package/dist/store/sql.d.mts.map +1 -1
- package/dist/store/sql.mjs.map +1 -1
- package/package.json +1 -1
package/dist/postgres-js.cjs
CHANGED
|
@@ -9,10 +9,19 @@ postgres = require_runtime.__toESM(postgres, 1);
|
|
|
9
9
|
* (`postgres` is an optional peer dependency; import this subpath only when
|
|
10
10
|
* you use it). On Cloudflare the connection string is Hyperdrive's.
|
|
11
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* A JS array as a Postgres array literal (`{"a","b"}`), one level deep. `sql.unsafe` sends an
|
|
14
|
+
* array parameter as `String(array)` (`a,b`, and `''` for an empty one), which `$1::text[]`
|
|
15
|
+
* rejects with "malformed array literal"; the literal form parses whatever the column type.
|
|
16
|
+
*/
|
|
17
|
+
function pgArrayLiteral(items) {
|
|
18
|
+
const element = (item) => item === null || item === void 0 ? "NULL" : `"${String(item).replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}"`;
|
|
19
|
+
return `{${items.map(element).join(",")}}`;
|
|
20
|
+
}
|
|
12
21
|
/** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */
|
|
13
22
|
function postgresJsClient(sql, inTransaction = false) {
|
|
14
23
|
return {
|
|
15
|
-
query: (text, params = []) => sql.unsafe(text, params),
|
|
24
|
+
query: (text, params = []) => sql.unsafe(text, params.map((param) => Array.isArray(param) ? pgArrayLiteral(param) : param)),
|
|
16
25
|
transaction: (fn) => inTransaction ? fn(postgresJsClient(sql, true)) : sql.begin((tx) => fn(postgresJsClient(tx, true)))
|
|
17
26
|
};
|
|
18
27
|
}
|
|
@@ -35,6 +44,7 @@ function postgresJsStore(connectionString, options = {}) {
|
|
|
35
44
|
close: () => sql.end({ timeout: 5 })
|
|
36
45
|
};
|
|
37
46
|
}
|
|
47
|
+
exports.pgArrayLiteral = pgArrayLiteral;
|
|
38
48
|
exports.postgresJsClient = postgresJsClient;
|
|
39
49
|
exports.postgresJsStore = postgresJsStore;
|
|
40
50
|
|
package/dist/postgres-js.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-js.cjs","names":["PostgresJourneyStore"],"sources":["../src/postgres-js.ts"],"sourcesContent":["import postgres from 'postgres';\nimport type { StoreLease } from './store/index';\nimport {\n PostgresJourneyStore,\n type PostgresJourneyStoreOptions,\n type SqlClientLike,\n} from './store/postgres';\n\n/**\n * `@shware/workflow/postgres-js` — the Postgres store over postgres.js\n * (`postgres` is an optional peer dependency; import this subpath only when\n * you use it). On Cloudflare the connection string is Hyperdrive's.\n */\n\n/** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */\nexport function postgresJsClient(\n sql: postgres.Sql | postgres.TransactionSql,\n inTransaction = false\n): SqlClientLike {\n return {\n query: <T>(text: string, params: readonly unknown[] = []) =>\n sql.unsafe(text
|
|
1
|
+
{"version":3,"file":"postgres-js.cjs","names":["PostgresJourneyStore"],"sources":["../src/postgres-js.ts"],"sourcesContent":["import postgres from 'postgres';\nimport type { StoreLease } from './store/index';\nimport {\n PostgresJourneyStore,\n type PostgresJourneyStoreOptions,\n type SqlClientLike,\n} from './store/postgres';\n\n/**\n * `@shware/workflow/postgres-js` — the Postgres store over postgres.js\n * (`postgres` is an optional peer dependency; import this subpath only when\n * you use it). On Cloudflare the connection string is Hyperdrive's.\n */\n\n/**\n * A JS array as a Postgres array literal (`{\"a\",\"b\"}`), one level deep. `sql.unsafe` sends an\n * array parameter as `String(array)` (`a,b`, and `''` for an empty one), which `$1::text[]`\n * rejects with \"malformed array literal\"; the literal form parses whatever the column type.\n */\nexport function pgArrayLiteral(\n items: readonly (string | number | bigint | boolean | null | undefined)[]\n): string {\n const element = (item: (typeof items)[number]) =>\n item === null || item === undefined\n ? 'NULL'\n : `\"${String(item).replaceAll('\\\\', '\\\\\\\\').replaceAll('\"', '\\\\\"')}\"`;\n return `{${items.map(element).join(',')}}`;\n}\n\n/** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */\nexport function postgresJsClient(\n sql: postgres.Sql | postgres.TransactionSql,\n inTransaction = false\n): SqlClientLike {\n return {\n query: <T>(text: string, params: readonly unknown[] = []) =>\n sql.unsafe(\n text,\n params.map((param) =>\n Array.isArray(param)\n ? pgArrayLiteral(param as Parameters<typeof pgArrayLiteral>[0])\n : param\n ) as never\n ) as unknown as Promise<T[]>,\n transaction: <T>(fn: (tx: SqlClientLike) => Promise<T>) =>\n inTransaction\n ? fn(postgresJsClient(sql, true))\n : ((sql as postgres.Sql).begin((tx) => fn(postgresJsClient(tx, true))) as Promise<T>),\n };\n}\n\nexport interface PostgresJsStoreOptions extends PostgresJourneyStoreOptions {\n /**\n * postgres.js options. Defaults suit a Worker with Hyperdrive: one\n * connection per request/run, closed after 2 s idle, no type fetch on\n * connect, prepared statements (Hyperdrive caches them).\n */\n connection?: postgres.Options<Record<string, never>>;\n}\n\n/**\n * Open a Postgres-backed store for one request or workflow run. The lease's\n * `close` ends the client — a Worker cannot share a socket across requests,\n * and Hyperdrive keeps the real pool next to the database.\n */\nexport function postgresJsStore(\n connectionString: string,\n options: PostgresJsStoreOptions = {}\n): Required<StoreLease> {\n const { connection, ...storeOptions } = options;\n const sql = postgres(connectionString, {\n max: 1,\n // A journey run lives for days: between steps it sleeps or waits, and a run holding its\n // connection through that holds one per sleeping instance — hundreds of them exhaust the\n // database. Idle connections close and the next query opens a fresh one.\n idle_timeout: 2,\n fetch_types: false,\n prepare: true,\n ...connection,\n });\n return {\n store: new PostgresJourneyStore(postgresJsClient(sql), storeOptions),\n close: () => sql.end({ timeout: 5 }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,SAAgB,eACd,OACQ;CACR,MAAM,WAAW,SACf,SAAS,QAAQ,SAAS,KAAA,IACtB,SACA,IAAI,OAAO,IAAI,CAAC,CAAC,WAAW,MAAM,MAAM,CAAC,CAAC,WAAW,MAAK,MAAK,EAAE;CACvE,OAAO,IAAI,MAAM,IAAI,OAAO,CAAC,CAAC,KAAK,GAAG,EAAE;AAC1C;;AAGA,SAAgB,iBACd,KACA,gBAAgB,OACD;CACf,OAAO;EACL,QAAW,MAAc,SAA6B,CAAC,MACrD,IAAI,OACF,MACA,OAAO,KAAK,UACV,MAAM,QAAQ,KAAK,IACf,eAAe,KAA6C,IAC5D,KACN,CACF;EACF,cAAiB,OACf,gBACI,GAAG,iBAAiB,KAAK,IAAI,CAAC,IAC5B,IAAqB,OAAO,OAAO,GAAG,iBAAiB,IAAI,IAAI,CAAC,CAAC;CAC3E;AACF;;;;;;AAgBA,SAAgB,gBACd,kBACA,UAAkC,CAAC,GACb;CACtB,MAAM,EAAE,YAAY,GAAG,iBAAiB;CACxC,MAAM,OAAA,GAAM,SAAA,QAAA,CAAS,kBAAkB;EACrC,KAAK;EAIL,cAAc;EACd,aAAa;EACb,SAAS;EACT,GAAG;CACL,CAAC;CACD,OAAO;EACL,OAAO,IAAIA,uBAAAA,qBAAqB,iBAAiB,GAAG,GAAG,YAAY;EACnE,aAAa,IAAI,IAAI,EAAE,SAAS,EAAE,CAAC;CACrC;AACF"}
|
package/dist/postgres-js.d.cts
CHANGED
|
@@ -7,6 +7,12 @@ import postgres from "postgres";
|
|
|
7
7
|
* (`postgres` is an optional peer dependency; import this subpath only when
|
|
8
8
|
* you use it). On Cloudflare the connection string is Hyperdrive's.
|
|
9
9
|
*/
|
|
10
|
+
/**
|
|
11
|
+
* A JS array as a Postgres array literal (`{"a","b"}`), one level deep. `sql.unsafe` sends an
|
|
12
|
+
* array parameter as `String(array)` (`a,b`, and `''` for an empty one), which `$1::text[]`
|
|
13
|
+
* rejects with "malformed array literal"; the literal form parses whatever the column type.
|
|
14
|
+
*/
|
|
15
|
+
export declare function pgArrayLiteral(items: readonly (string | number | bigint | boolean | null | undefined)[]): string;
|
|
10
16
|
/** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */
|
|
11
17
|
export declare function postgresJsClient(sql: postgres.Sql | postgres.TransactionSql, inTransaction?: boolean): SqlClientLike;
|
|
12
18
|
export interface PostgresJsStoreOptions extends PostgresJourneyStoreOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-js.d.cts","names":[],"sources":["../src/postgres-js.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"postgres-js.d.cts","names":[],"sources":["../src/postgres-js.ts"],"mappings":";;;;;;;;;;;;;;wBAmBgB,eACd;;wBAUc,iBACd,KAAK,SAAS,MAAM,SAAS,gBAC7B,0BACC;iBAkBc,+BAA+B;;;;;;EAM9C,aAAa,SAAS,QAAQ;;;;;;;wBAQhB,gBACd,0BACA,UAAS,yBACR,SAAS"}
|
package/dist/postgres-js.d.mts
CHANGED
|
@@ -7,6 +7,12 @@ import postgres from "postgres";
|
|
|
7
7
|
* (`postgres` is an optional peer dependency; import this subpath only when
|
|
8
8
|
* you use it). On Cloudflare the connection string is Hyperdrive's.
|
|
9
9
|
*/
|
|
10
|
+
/**
|
|
11
|
+
* A JS array as a Postgres array literal (`{"a","b"}`), one level deep. `sql.unsafe` sends an
|
|
12
|
+
* array parameter as `String(array)` (`a,b`, and `''` for an empty one), which `$1::text[]`
|
|
13
|
+
* rejects with "malformed array literal"; the literal form parses whatever the column type.
|
|
14
|
+
*/
|
|
15
|
+
export declare function pgArrayLiteral(items: readonly (string | number | bigint | boolean | null | undefined)[]): string;
|
|
10
16
|
/** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */
|
|
11
17
|
export declare function postgresJsClient(sql: postgres.Sql | postgres.TransactionSql, inTransaction?: boolean): SqlClientLike;
|
|
12
18
|
export interface PostgresJsStoreOptions extends PostgresJourneyStoreOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-js.d.mts","names":[],"sources":["../src/postgres-js.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"postgres-js.d.mts","names":[],"sources":["../src/postgres-js.ts"],"mappings":";;;;;;;;;;;;;;wBAmBgB,eACd;;wBAUc,iBACd,KAAK,SAAS,MAAM,SAAS,gBAC7B,0BACC;iBAkBc,+BAA+B;;;;;;EAM9C,aAAa,SAAS,QAAQ;;;;;;;wBAQhB,gBACd,0BACA,UAAS,yBACR,SAAS"}
|
package/dist/postgres-js.mjs
CHANGED
|
@@ -6,10 +6,19 @@ import postgres from "postgres";
|
|
|
6
6
|
* (`postgres` is an optional peer dependency; import this subpath only when
|
|
7
7
|
* you use it). On Cloudflare the connection string is Hyperdrive's.
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* A JS array as a Postgres array literal (`{"a","b"}`), one level deep. `sql.unsafe` sends an
|
|
11
|
+
* array parameter as `String(array)` (`a,b`, and `''` for an empty one), which `$1::text[]`
|
|
12
|
+
* rejects with "malformed array literal"; the literal form parses whatever the column type.
|
|
13
|
+
*/
|
|
14
|
+
function pgArrayLiteral(items) {
|
|
15
|
+
const element = (item) => item === null || item === void 0 ? "NULL" : `"${String(item).replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}"`;
|
|
16
|
+
return `{${items.map(element).join(",")}}`;
|
|
17
|
+
}
|
|
9
18
|
/** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */
|
|
10
19
|
function postgresJsClient(sql, inTransaction = false) {
|
|
11
20
|
return {
|
|
12
|
-
query: (text, params = []) => sql.unsafe(text, params),
|
|
21
|
+
query: (text, params = []) => sql.unsafe(text, params.map((param) => Array.isArray(param) ? pgArrayLiteral(param) : param)),
|
|
13
22
|
transaction: (fn) => inTransaction ? fn(postgresJsClient(sql, true)) : sql.begin((tx) => fn(postgresJsClient(tx, true)))
|
|
14
23
|
};
|
|
15
24
|
}
|
|
@@ -32,6 +41,6 @@ function postgresJsStore(connectionString, options = {}) {
|
|
|
32
41
|
close: () => sql.end({ timeout: 5 })
|
|
33
42
|
};
|
|
34
43
|
}
|
|
35
|
-
export { postgresJsClient, postgresJsStore };
|
|
44
|
+
export { pgArrayLiteral, postgresJsClient, postgresJsStore };
|
|
36
45
|
|
|
37
46
|
//# sourceMappingURL=postgres-js.mjs.map
|
package/dist/postgres-js.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-js.mjs","names":[],"sources":["../src/postgres-js.ts"],"sourcesContent":["import postgres from 'postgres';\nimport type { StoreLease } from './store/index';\nimport {\n PostgresJourneyStore,\n type PostgresJourneyStoreOptions,\n type SqlClientLike,\n} from './store/postgres';\n\n/**\n * `@shware/workflow/postgres-js` — the Postgres store over postgres.js\n * (`postgres` is an optional peer dependency; import this subpath only when\n * you use it). On Cloudflare the connection string is Hyperdrive's.\n */\n\n/** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */\nexport function postgresJsClient(\n sql: postgres.Sql | postgres.TransactionSql,\n inTransaction = false\n): SqlClientLike {\n return {\n query: <T>(text: string, params: readonly unknown[] = []) =>\n sql.unsafe(text
|
|
1
|
+
{"version":3,"file":"postgres-js.mjs","names":[],"sources":["../src/postgres-js.ts"],"sourcesContent":["import postgres from 'postgres';\nimport type { StoreLease } from './store/index';\nimport {\n PostgresJourneyStore,\n type PostgresJourneyStoreOptions,\n type SqlClientLike,\n} from './store/postgres';\n\n/**\n * `@shware/workflow/postgres-js` — the Postgres store over postgres.js\n * (`postgres` is an optional peer dependency; import this subpath only when\n * you use it). On Cloudflare the connection string is Hyperdrive's.\n */\n\n/**\n * A JS array as a Postgres array literal (`{\"a\",\"b\"}`), one level deep. `sql.unsafe` sends an\n * array parameter as `String(array)` (`a,b`, and `''` for an empty one), which `$1::text[]`\n * rejects with \"malformed array literal\"; the literal form parses whatever the column type.\n */\nexport function pgArrayLiteral(\n items: readonly (string | number | bigint | boolean | null | undefined)[]\n): string {\n const element = (item: (typeof items)[number]) =>\n item === null || item === undefined\n ? 'NULL'\n : `\"${String(item).replaceAll('\\\\', '\\\\\\\\').replaceAll('\"', '\\\\\"')}\"`;\n return `{${items.map(element).join(',')}}`;\n}\n\n/** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */\nexport function postgresJsClient(\n sql: postgres.Sql | postgres.TransactionSql,\n inTransaction = false\n): SqlClientLike {\n return {\n query: <T>(text: string, params: readonly unknown[] = []) =>\n sql.unsafe(\n text,\n params.map((param) =>\n Array.isArray(param)\n ? pgArrayLiteral(param as Parameters<typeof pgArrayLiteral>[0])\n : param\n ) as never\n ) as unknown as Promise<T[]>,\n transaction: <T>(fn: (tx: SqlClientLike) => Promise<T>) =>\n inTransaction\n ? fn(postgresJsClient(sql, true))\n : ((sql as postgres.Sql).begin((tx) => fn(postgresJsClient(tx, true))) as Promise<T>),\n };\n}\n\nexport interface PostgresJsStoreOptions extends PostgresJourneyStoreOptions {\n /**\n * postgres.js options. Defaults suit a Worker with Hyperdrive: one\n * connection per request/run, closed after 2 s idle, no type fetch on\n * connect, prepared statements (Hyperdrive caches them).\n */\n connection?: postgres.Options<Record<string, never>>;\n}\n\n/**\n * Open a Postgres-backed store for one request or workflow run. The lease's\n * `close` ends the client — a Worker cannot share a socket across requests,\n * and Hyperdrive keeps the real pool next to the database.\n */\nexport function postgresJsStore(\n connectionString: string,\n options: PostgresJsStoreOptions = {}\n): Required<StoreLease> {\n const { connection, ...storeOptions } = options;\n const sql = postgres(connectionString, {\n max: 1,\n // A journey run lives for days: between steps it sleeps or waits, and a run holding its\n // connection through that holds one per sleeping instance — hundreds of them exhaust the\n // database. Idle connections close and the next query opens a fresh one.\n idle_timeout: 2,\n fetch_types: false,\n prepare: true,\n ...connection,\n });\n return {\n store: new PostgresJourneyStore(postgresJsClient(sql), storeOptions),\n close: () => sql.end({ timeout: 5 }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,SAAgB,eACd,OACQ;CACR,MAAM,WAAW,SACf,SAAS,QAAQ,SAAS,KAAA,IACtB,SACA,IAAI,OAAO,IAAI,CAAC,CAAC,WAAW,MAAM,MAAM,CAAC,CAAC,WAAW,MAAK,MAAK,EAAE;CACvE,OAAO,IAAI,MAAM,IAAI,OAAO,CAAC,CAAC,KAAK,GAAG,EAAE;AAC1C;;AAGA,SAAgB,iBACd,KACA,gBAAgB,OACD;CACf,OAAO;EACL,QAAW,MAAc,SAA6B,CAAC,MACrD,IAAI,OACF,MACA,OAAO,KAAK,UACV,MAAM,QAAQ,KAAK,IACf,eAAe,KAA6C,IAC5D,KACN,CACF;EACF,cAAiB,OACf,gBACI,GAAG,iBAAiB,KAAK,IAAI,CAAC,IAC5B,IAAqB,OAAO,OAAO,GAAG,iBAAiB,IAAI,IAAI,CAAC,CAAC;CAC3E;AACF;;;;;;AAgBA,SAAgB,gBACd,kBACA,UAAkC,CAAC,GACb;CACtB,MAAM,EAAE,YAAY,GAAG,iBAAiB;CACxC,MAAM,MAAM,SAAS,kBAAkB;EACrC,KAAK;EAIL,cAAc;EACd,aAAa;EACb,SAAS;EACT,GAAG;CACL,CAAC;CACD,OAAO;EACL,OAAO,IAAI,qBAAqB,iBAAiB,GAAG,GAAG,YAAY;EACnE,aAAa,IAAI,IAAI,EAAE,SAAS,EAAE,CAAC;CACrC;AACF"}
|
package/dist/store/sql.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.cjs","names":["Buffer"],"sources":["../../src/store/sql.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\n/**\n * The smallest SQL client this store needs: parameterized queries (`$1`, `$2`,\n * …) and a transaction scope. It is deliberately not postgres.js, pg or\n * drizzle — the app wraps whichever it already uses in a few lines:\n *\n * const client: SqlClientLike = {\n * query: (text, params) =>
|
|
1
|
+
{"version":3,"file":"sql.cjs","names":["Buffer"],"sources":["../../src/store/sql.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\n/**\n * The smallest SQL client this store needs: parameterized queries (`$1`, `$2`,\n * …) and a transaction scope. It is deliberately not postgres.js, pg or\n * drizzle — the app wraps whichever it already uses in a few lines:\n *\n * const client: SqlClientLike = {\n * query: (text, params) => pg.query(text, params).then((r) => r.rows), // pg\n * transaction: (fn) => withTransaction((tx) => fn(wrap(tx))),\n * };\n *\n * For postgres.js use `postgresJsClient` (`@shware/workflow/postgres-js`): its\n * `unsafe` sends a JS array parameter as `String(array)`, which the store's\n * `= ANY($1::text[])` queries reject, so that wrapper writes arrays as Postgres\n * array literals. jsonb columns may come back parsed (postgres.js, pg) or as\n * strings (some drivers); both are accepted.\n */\nexport interface SqlClientLike {\n query<T = Record<string, unknown>>(text: string, params?: readonly unknown[]): Promise<T[]>;\n transaction<T>(fn: (tx: SqlClientLike) => Promise<T>): Promise<T>;\n}\n\n/**\n * UUID v7 (time-ordered) for event rows, generated here so the store has no\n * dependency: 48-bit ms timestamp, version 7, RFC 4122 variant, 74 random bits.\n */\nexport function uuidv7(now = Date.now()): string {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n bytes[0] = (now / 2 ** 40) & 0xff;\n bytes[1] = (now / 2 ** 32) & 0xff;\n bytes[2] = (now / 2 ** 24) & 0xff;\n bytes[3] = (now / 2 ** 16) & 0xff;\n bytes[4] = (now / 2 ** 8) & 0xff;\n bytes[5] = now & 0xff;\n bytes[6] = (bytes[6] & 0x0f) | 0x70;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Buffer.from(bytes).toString('hex');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n"],"mappings":";;;;;;;AA2BA,SAAgB,OAAO,MAAM,KAAK,IAAI,GAAW;CAC/C,MAAM,wBAAQ,IAAI,WAAW,EAAE;CAC/B,OAAO,gBAAgB,KAAK;CAC5B,MAAM,KAAM,MAAM,KAAK,KAAM;CAC7B,MAAM,KAAM,MAAM,KAAK,KAAM;CAC7B,MAAM,KAAM,MAAM,KAAK,KAAM;CAC7B,MAAM,KAAM,MAAM,KAAK,KAAM;CAC7B,MAAM,KAAM,MAAM,MAAU;CAC5B,MAAM,KAAK,MAAM;CACjB,MAAM,KAAM,MAAM,KAAK,KAAQ;CAC/B,MAAM,KAAM,MAAM,KAAK,KAAQ;CAC/B,MAAM,MAAMA,YAAAA,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,KAAK;CAC7C,OAAO,GAAG,IAAI,MAAM,GAAG,CAAC,EAAE,GAAG,IAAI,MAAM,GAAG,EAAE,EAAE,GAAG,IAAI,MAAM,IAAI,EAAE,EAAE,GAAG,IAAI,MAAM,IAAI,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE;AACzG"}
|
package/dist/store/sql.d.cts
CHANGED
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
* drizzle — the app wraps whichever it already uses in a few lines:
|
|
5
5
|
*
|
|
6
6
|
* const client: SqlClientLike = {
|
|
7
|
-
* query: (text, params) =>
|
|
8
|
-
* transaction: (fn) =>
|
|
7
|
+
* query: (text, params) => pg.query(text, params).then((r) => r.rows), // pg
|
|
8
|
+
* transaction: (fn) => withTransaction((tx) => fn(wrap(tx))),
|
|
9
9
|
* };
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* For postgres.js use `postgresJsClient` (`@shware/workflow/postgres-js`): its
|
|
12
|
+
* `unsafe` sends a JS array parameter as `String(array)`, which the store's
|
|
13
|
+
* `= ANY($1::text[])` queries reject, so that wrapper writes arrays as Postgres
|
|
14
|
+
* array literals. jsonb columns may come back parsed (postgres.js, pg) or as
|
|
15
|
+
* strings (some drivers); both are accepted.
|
|
13
16
|
*/
|
|
14
17
|
export interface SqlClientLike {
|
|
15
18
|
query<T = Record<string, unknown>>(text: string, params?: readonly unknown[]): Promise<T[]>;
|
package/dist/store/sql.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.d.cts","names":[],"sources":["../../src/store/sql.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sql.d.cts","names":[],"sources":["../../src/store/sql.ts"],"mappings":";;;;;;;;;;;;;;;;iBAkBiB;EACf,MAAM,IAAI,yBAAyB,cAAc,8BAA8B,QAAQ;EACvF,YAAY,GAAG,KAAK,IAAI,kBAAkB,QAAQ,KAAK,QAAQ;;;;;;wBAOjD,OAAO"}
|
package/dist/store/sql.d.mts
CHANGED
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
* drizzle — the app wraps whichever it already uses in a few lines:
|
|
5
5
|
*
|
|
6
6
|
* const client: SqlClientLike = {
|
|
7
|
-
* query: (text, params) =>
|
|
8
|
-
* transaction: (fn) =>
|
|
7
|
+
* query: (text, params) => pg.query(text, params).then((r) => r.rows), // pg
|
|
8
|
+
* transaction: (fn) => withTransaction((tx) => fn(wrap(tx))),
|
|
9
9
|
* };
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* For postgres.js use `postgresJsClient` (`@shware/workflow/postgres-js`): its
|
|
12
|
+
* `unsafe` sends a JS array parameter as `String(array)`, which the store's
|
|
13
|
+
* `= ANY($1::text[])` queries reject, so that wrapper writes arrays as Postgres
|
|
14
|
+
* array literals. jsonb columns may come back parsed (postgres.js, pg) or as
|
|
15
|
+
* strings (some drivers); both are accepted.
|
|
13
16
|
*/
|
|
14
17
|
export interface SqlClientLike {
|
|
15
18
|
query<T = Record<string, unknown>>(text: string, params?: readonly unknown[]): Promise<T[]>;
|
package/dist/store/sql.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.d.mts","names":[],"sources":["../../src/store/sql.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sql.d.mts","names":[],"sources":["../../src/store/sql.ts"],"mappings":";;;;;;;;;;;;;;;;iBAkBiB;EACf,MAAM,IAAI,yBAAyB,cAAc,8BAA8B,QAAQ;EACvF,YAAY,GAAG,KAAK,IAAI,kBAAkB,QAAQ,KAAK,QAAQ;;;;;;wBAOjD,OAAO"}
|
package/dist/store/sql.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.mjs","names":[],"sources":["../../src/store/sql.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\n/**\n * The smallest SQL client this store needs: parameterized queries (`$1`, `$2`,\n * …) and a transaction scope. It is deliberately not postgres.js, pg or\n * drizzle — the app wraps whichever it already uses in a few lines:\n *\n * const client: SqlClientLike = {\n * query: (text, params) =>
|
|
1
|
+
{"version":3,"file":"sql.mjs","names":[],"sources":["../../src/store/sql.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\n/**\n * The smallest SQL client this store needs: parameterized queries (`$1`, `$2`,\n * …) and a transaction scope. It is deliberately not postgres.js, pg or\n * drizzle — the app wraps whichever it already uses in a few lines:\n *\n * const client: SqlClientLike = {\n * query: (text, params) => pg.query(text, params).then((r) => r.rows), // pg\n * transaction: (fn) => withTransaction((tx) => fn(wrap(tx))),\n * };\n *\n * For postgres.js use `postgresJsClient` (`@shware/workflow/postgres-js`): its\n * `unsafe` sends a JS array parameter as `String(array)`, which the store's\n * `= ANY($1::text[])` queries reject, so that wrapper writes arrays as Postgres\n * array literals. jsonb columns may come back parsed (postgres.js, pg) or as\n * strings (some drivers); both are accepted.\n */\nexport interface SqlClientLike {\n query<T = Record<string, unknown>>(text: string, params?: readonly unknown[]): Promise<T[]>;\n transaction<T>(fn: (tx: SqlClientLike) => Promise<T>): Promise<T>;\n}\n\n/**\n * UUID v7 (time-ordered) for event rows, generated here so the store has no\n * dependency: 48-bit ms timestamp, version 7, RFC 4122 variant, 74 random bits.\n */\nexport function uuidv7(now = Date.now()): string {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n bytes[0] = (now / 2 ** 40) & 0xff;\n bytes[1] = (now / 2 ** 32) & 0xff;\n bytes[2] = (now / 2 ** 24) & 0xff;\n bytes[3] = (now / 2 ** 16) & 0xff;\n bytes[4] = (now / 2 ** 8) & 0xff;\n bytes[5] = now & 0xff;\n bytes[6] = (bytes[6] & 0x0f) | 0x70;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Buffer.from(bytes).toString('hex');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n"],"mappings":";;;;;;AA2BA,SAAgB,OAAO,MAAM,KAAK,IAAI,GAAW;CAC/C,MAAM,wBAAQ,IAAI,WAAW,EAAE;CAC/B,OAAO,gBAAgB,KAAK;CAC5B,MAAM,KAAM,MAAM,KAAK,KAAM;CAC7B,MAAM,KAAM,MAAM,KAAK,KAAM;CAC7B,MAAM,KAAM,MAAM,KAAK,KAAM;CAC7B,MAAM,KAAM,MAAM,KAAK,KAAM;CAC7B,MAAM,KAAM,MAAM,MAAU;CAC5B,MAAM,KAAK,MAAM;CACjB,MAAM,KAAM,MAAM,KAAK,KAAQ;CAC/B,MAAM,KAAM,MAAM,KAAK,KAAQ;CAC/B,MAAM,MAAM,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,KAAK;CAC7C,OAAO,GAAG,IAAI,MAAM,GAAG,CAAC,EAAE,GAAG,IAAI,MAAM,GAAG,EAAE,EAAE,GAAG,IAAI,MAAM,IAAI,EAAE,EAAE,GAAG,IAAI,MAAM,IAAI,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE;AACzG"}
|