@trycompai/db 1.1.2 → 1.2.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/dist/index.mjs DELETED
@@ -1,13 +0,0 @@
1
- import {
2
- __toESM,
3
- require_prisma
4
- } from "./chunk-Y7OSPXHC.mjs";
5
-
6
- // src/client.ts
7
- var import_prisma = __toESM(require_prisma());
8
- var globalForPrisma = global;
9
- var db = globalForPrisma.prisma || new import_prisma.PrismaClient();
10
- if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = db;
11
- export {
12
- db
13
- };
@@ -1,18 +0,0 @@
1
- -- Create function to generate prefixed CUID with sortable timestamp (compact)
2
- CREATE OR REPLACE FUNCTION generate_prefixed_cuid(prefix text)
3
- RETURNS text AS $$
4
- DECLARE
5
- timestamp_hex text;
6
- random_hex text;
7
- BEGIN
8
- -- Generate timestamp component (seconds since epoch) as hex
9
- timestamp_hex = LOWER(TO_HEX(EXTRACT(EPOCH FROM NOW())::BIGINT));
10
-
11
- -- Generate 8 random bytes and encode as hex (16 characters)
12
- -- Ensure we call the function from the correct schema if pgcrypto is installed elsewhere
13
- random_hex = encode(gen_random_bytes(8), 'hex');
14
-
15
- -- Combine prefix, timestamp, and random hex string
16
- RETURN prefix || '_' || timestamp_hex || random_hex;
17
- END;
18
- $$ LANGUAGE plpgsql;
@@ -1,12 +0,0 @@
1
- -- Create function to generate a random secret
2
- CREATE OR REPLACE FUNCTION generate_random_secret(length integer DEFAULT 32)
3
- RETURNS text AS $$
4
- DECLARE
5
- result text;
6
- BEGIN
7
- -- Generate random bytes and encode as hex
8
- -- Using gen_random_bytes from pgcrypto extension
9
- result = encode(gen_random_bytes(length), 'hex');
10
- RETURN result;
11
- END;
12
- $$ LANGUAGE plpgsql;