@lbu/store
Advanced tools
Comparing version 0.0.47 to 0.0.48
@@ -14,2 +14,4 @@ import * as minioVendor from "minio"; | ||
export type Postgres = postgresVendor.Sql<{}>; | ||
/** | ||
@@ -16,0 +18,0 @@ * Create a new minio client. |
{ | ||
"name": "@lbu/store", | ||
"version": "0.0.47", | ||
"version": "0.0.48", | ||
"description": "Postgres & S3-compatible wrappers for common things", | ||
@@ -18,4 +18,4 @@ "main": "./index.js", | ||
"dependencies": { | ||
"@lbu/insight": "0.0.47", | ||
"@lbu/stdlib": "0.0.47", | ||
"@lbu/insight": "0.0.48", | ||
"@lbu/stdlib": "0.0.48", | ||
"@types/minio": "7.0.6", | ||
@@ -47,3 +47,3 @@ "mime-types": "2.1.27", | ||
}, | ||
"gitHead": "dfa862b4fec0f02530fc036fc6890c8d1b35aae3" | ||
"gitHead": "31e2fa269fce94851e5d102d866dd77f78d8f9d3" | ||
} |
@@ -9,22 +9,20 @@ // Generated by @lbu/code-gen | ||
* @param sql | ||
* @param { StoreFileStoreWhere} where | ||
* @param { StoreFileStoreWhere} [where] | ||
* @returns {Promise<StoreFileStore[]>} | ||
*/ | ||
fileStoreSelect: ( | ||
sql, | ||
where, | ||
) => sql`SELECT fs."id", fs."bucketName", fs."contentLength", fs."contentType", fs."filename", fs."createdAt", fs."updatedAt" FROM "fileStore" fs | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR fs."id" = ${ | ||
where.id ?? null | ||
fileStoreSelect: (sql, where) => sql` | ||
SELECT fs."id", fs."bucketName", fs."contentLength", fs."contentType", fs."filename", fs."createdAt", fs."updatedAt" FROM "fileStore" fs | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR fs."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.idIn ?? null | ||
where?.idIn ?? null | ||
}, NULL) IS NULL OR fs."id" = ANY (${sql.array( | ||
where?.idIn ?? [], | ||
)}::uuid[])) AND (COALESCE(${ | ||
where.bucketName ?? null | ||
where?.bucketName ?? null | ||
}, NULL) IS NULL OR fs."bucketName" = ${ | ||
where.bucketName ?? null | ||
where?.bucketName ?? null | ||
}) AND (COALESCE(${ | ||
where.bucketNameLike ?? null | ||
}, NULL) IS NULL OR fs."bucketName" LIKE ${`%${where.bucketNameLike}%`}) | ||
where?.bucketNameLike ?? null | ||
}, NULL) IS NULL OR fs."bucketName" LIKE ${`%${where?.bucketNameLike}%`}) | ||
`, | ||
@@ -34,22 +32,23 @@ | ||
* @param sql | ||
* @param { StoreFileStoreWhere} where | ||
* @param { StoreFileStoreWhere} [where] | ||
* @returns {Promise<number>} | ||
*/ | ||
fileStoreCount: async (sql, where) => { | ||
const result = await sql`SELECT count(*) as "genCount" FROM "fileStore" fs | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR fs."id" = ${ | ||
where.id ?? null | ||
const result = await sql` | ||
SELECT count(*) AS "genCount" FROM "fileStore" fs | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR fs."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.idIn ?? null | ||
where?.idIn ?? null | ||
}, NULL) IS NULL OR fs."id" = ANY (${sql.array( | ||
where?.idIn ?? [], | ||
)}::uuid[])) AND (COALESCE(${ | ||
where.bucketName ?? null | ||
where?.bucketName ?? null | ||
}, NULL) IS NULL OR fs."bucketName" = ${ | ||
where.bucketName ?? null | ||
where?.bucketName ?? null | ||
}) AND (COALESCE(${ | ||
where.bucketNameLike ?? null | ||
}, NULL) IS NULL OR fs."bucketName" LIKE ${`%${where.bucketNameLike}%`}) | ||
where?.bucketNameLike ?? null | ||
}, NULL) IS NULL OR fs."bucketName" LIKE ${`%${where?.bucketNameLike}%`}) | ||
`; | ||
return result?.[0]?.genCount ?? 0; | ||
return parseInt(result?.[0]?.genCount ?? "0"); | ||
}, | ||
@@ -59,19 +58,20 @@ | ||
* @param sql | ||
* @param { StoreFileStoreWhere} where | ||
* @param { StoreFileStoreWhere} [where] | ||
* @returns {Promise<*[]>} | ||
*/ | ||
fileStoreDelete: (sql, where) => sql`DELETE FROM "fileStore" fs | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR fs."id" = ${ | ||
where.id ?? null | ||
fileStoreDelete: (sql, where) => sql` | ||
DELETE FROM "fileStore" fs | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR fs."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.idIn ?? null | ||
where?.idIn ?? null | ||
}, NULL) IS NULL OR fs."id" = ANY (${sql.array( | ||
where?.idIn ?? [], | ||
)}::uuid[])) AND (COALESCE(${ | ||
where.bucketName ?? null | ||
where?.bucketName ?? null | ||
}, NULL) IS NULL OR fs."bucketName" = ${ | ||
where.bucketName ?? null | ||
where?.bucketName ?? null | ||
}) AND (COALESCE(${ | ||
where.bucketNameLike ?? null | ||
}, NULL) IS NULL OR fs."bucketName" LIKE ${`%${where.bucketNameLike}%`}) | ||
where?.bucketNameLike ?? null | ||
}, NULL) IS NULL OR fs."bucketName" LIKE ${`%${where?.bucketNameLike}%`}) | ||
`, | ||
@@ -112,21 +112,22 @@ | ||
* @param { StoreFileStoreInsertPartial_Input} value | ||
* @param { StoreFileStoreWhere} where | ||
* @param { StoreFileStoreWhere} [where] | ||
* @returns {Promise<StoreFileStore[]>} | ||
*/ | ||
fileStoreUpdate: async (sql, value, where) => { | ||
await sql`INSERT INTO "fileStoreHistory" ("fileStoreId", "bucketName", "contentLength", "contentType", "filename", "createdAt") | ||
await sql` | ||
INSERT INTO "fileStoreHistory" ("fileStoreId", "bucketName", "contentLength", "contentType", "filename", "createdAt") | ||
SELECT id, "bucketName", "contentLength", "contentType", "filename", COALESCE("updatedAt", "createdAt", now()) FROM "fileStore" fs | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR fs."id" = ${ | ||
where.id ?? null | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR fs."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.idIn ?? null | ||
where?.idIn ?? null | ||
}, NULL) IS NULL OR fs."id" = ANY (${sql.array( | ||
where?.idIn ?? [], | ||
)}::uuid[])) AND (COALESCE(${ | ||
where.bucketName ?? null | ||
where?.bucketName ?? null | ||
}, NULL) IS NULL OR fs."bucketName" = ${ | ||
where.bucketName ?? null | ||
where?.bucketName ?? null | ||
}) AND (COALESCE(${ | ||
where.bucketNameLike ?? null | ||
}, NULL) IS NULL OR fs."bucketName" LIKE ${`%${where.bucketNameLike}%`}) | ||
where?.bucketNameLike ?? null | ||
}, NULL) IS NULL OR fs."bucketName" LIKE ${`%${where?.bucketNameLike}%`}) | ||
`; | ||
@@ -200,48 +201,45 @@ let query = `UPDATE "fileStore" fs SET `; | ||
* @param sql | ||
* @param { StoreFileStoreWhere} where | ||
* @param { StoreFileStoreWhere} [where] | ||
* @returns {Promise<(StoreFileStore & (history: StoreFileStore[]))[]>} | ||
*/ | ||
fileStoreSelectHistory: ( | ||
sql, | ||
where, | ||
) => sql`SELECT fs."id", fs."bucketName", fs."contentLength", fs."contentType", fs."filename", fs."createdAt", fs."updatedAt", array_agg(to_jsonb(fsh.*)) as history FROM "fileStore" fs LEFT JOIN "fileStoreHistory" fsh ON fs.id = fsh."fileStoreId" | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR fs."id" = ${ | ||
where.id ?? null | ||
fileStoreSelectHistory: (sql, where) => sql` | ||
SELECT fs."id", fs."bucketName", fs."contentLength", fs."contentType", fs."filename", fs."createdAt", fs."updatedAt", array_agg(to_jsonb(fsh.*)) AS history FROM "fileStore" fs LEFT JOIN "fileStoreHistory" fsh ON fs.id = fsh."fileStoreId" | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR fs."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.idIn ?? null | ||
where?.idIn ?? null | ||
}, NULL) IS NULL OR fs."id" = ANY (${sql.array( | ||
where?.idIn ?? [], | ||
)}::uuid[])) AND (COALESCE(${ | ||
where.bucketName ?? null | ||
where?.bucketName ?? null | ||
}, NULL) IS NULL OR fs."bucketName" = ${ | ||
where.bucketName ?? null | ||
where?.bucketName ?? null | ||
}) AND (COALESCE(${ | ||
where.bucketNameLike ?? null | ||
}, NULL) IS NULL OR fs."bucketName" LIKE ${`%${where.bucketNameLike}%`}) | ||
GROUP BY fs.id`, | ||
where?.bucketNameLike ?? null | ||
}, NULL) IS NULL OR fs."bucketName" LIKE ${`%${where?.bucketNameLike}%`}) | ||
GROUP BY fs.id | ||
`, | ||
/** | ||
* @param sql | ||
* @param { StoreSessionStoreWhere} where | ||
* @param { StoreSessionStoreWhere} [where] | ||
* @returns {Promise<StoreSessionStore[]>} | ||
*/ | ||
sessionStoreSelect: ( | ||
sql, | ||
where, | ||
) => sql`SELECT ss."id", ss."expires", ss."data", ss."createdAt", ss."updatedAt" FROM "sessionStore" ss | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR ss."id" = ${ | ||
where.id ?? null | ||
sessionStoreSelect: (sql, where) => sql` | ||
SELECT ss."id", ss."expires", ss."data", ss."createdAt", ss."updatedAt" FROM "sessionStore" ss | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR ss."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.idIn ?? null | ||
where?.idIn ?? null | ||
}, NULL) IS NULL OR ss."id" = ANY (${sql.array( | ||
where?.idIn ?? [], | ||
)}::uuid[])) AND (COALESCE(${ | ||
where.expires ?? null | ||
}, NULL) IS NULL OR ss."expires" = ${where.expires ?? null}) AND (COALESCE(${ | ||
where.expiresGreaterThan ?? null | ||
where?.expires ?? null | ||
}, NULL) IS NULL OR ss."expires" = ${where?.expires ?? null}) AND (COALESCE(${ | ||
where?.expiresGreaterThan ?? null | ||
}, NULL) IS NULL OR ss."expires" > ${ | ||
where.expiresGreaterThan ?? null | ||
where?.expiresGreaterThan ?? null | ||
}) AND (COALESCE(${ | ||
where.expiresLowerThan ?? null | ||
}, NULL) IS NULL OR ss."expires" < ${where.expiresLowerThan ?? null}) | ||
where?.expiresLowerThan ?? null | ||
}, NULL) IS NULL OR ss."expires" < ${where?.expiresLowerThan ?? null}) | ||
`, | ||
@@ -251,26 +249,27 @@ | ||
* @param sql | ||
* @param { StoreSessionStoreWhere} where | ||
* @param { StoreSessionStoreWhere} [where] | ||
* @returns {Promise<number>} | ||
*/ | ||
sessionStoreCount: async (sql, where) => { | ||
const result = await sql`SELECT count(*) as "genCount" FROM "sessionStore" ss | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR ss."id" = ${ | ||
where.id ?? null | ||
const result = await sql` | ||
SELECT count(*) AS "genCount" FROM "sessionStore" ss | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR ss."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.idIn ?? null | ||
where?.idIn ?? null | ||
}, NULL) IS NULL OR ss."id" = ANY (${sql.array( | ||
where?.idIn ?? [], | ||
)}::uuid[])) AND (COALESCE(${ | ||
where.expires ?? null | ||
where?.expires ?? null | ||
}, NULL) IS NULL OR ss."expires" = ${ | ||
where.expires ?? null | ||
where?.expires ?? null | ||
}) AND (COALESCE(${ | ||
where.expiresGreaterThan ?? null | ||
where?.expiresGreaterThan ?? null | ||
}, NULL) IS NULL OR ss."expires" > ${ | ||
where.expiresGreaterThan ?? null | ||
where?.expiresGreaterThan ?? null | ||
}) AND (COALESCE(${ | ||
where.expiresLowerThan ?? null | ||
}, NULL) IS NULL OR ss."expires" < ${where.expiresLowerThan ?? null}) | ||
where?.expiresLowerThan ?? null | ||
}, NULL) IS NULL OR ss."expires" < ${where?.expiresLowerThan ?? null}) | ||
`; | ||
return result?.[0]?.genCount ?? 0; | ||
return parseInt(result?.[0]?.genCount ?? "0"); | ||
}, | ||
@@ -280,21 +279,22 @@ | ||
* @param sql | ||
* @param { StoreSessionStoreWhere} where | ||
* @param { StoreSessionStoreWhere} [where] | ||
* @returns {Promise<*[]>} | ||
*/ | ||
sessionStoreDelete: (sql, where) => sql`DELETE FROM "sessionStore" ss | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR ss."id" = ${ | ||
where.id ?? null | ||
sessionStoreDelete: (sql, where) => sql` | ||
DELETE FROM "sessionStore" ss | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR ss."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.idIn ?? null | ||
where?.idIn ?? null | ||
}, NULL) IS NULL OR ss."id" = ANY (${sql.array( | ||
where?.idIn ?? [], | ||
)}::uuid[])) AND (COALESCE(${ | ||
where.expires ?? null | ||
}, NULL) IS NULL OR ss."expires" = ${where.expires ?? null}) AND (COALESCE(${ | ||
where.expiresGreaterThan ?? null | ||
where?.expires ?? null | ||
}, NULL) IS NULL OR ss."expires" = ${where?.expires ?? null}) AND (COALESCE(${ | ||
where?.expiresGreaterThan ?? null | ||
}, NULL) IS NULL OR ss."expires" > ${ | ||
where.expiresGreaterThan ?? null | ||
where?.expiresGreaterThan ?? null | ||
}) AND (COALESCE(${ | ||
where.expiresLowerThan ?? null | ||
}, NULL) IS NULL OR ss."expires" < ${where.expiresLowerThan ?? null}) | ||
where?.expiresLowerThan ?? null | ||
}, NULL) IS NULL OR ss."expires" < ${where?.expiresLowerThan ?? null}) | ||
`, | ||
@@ -333,3 +333,3 @@ | ||
* @param { StoreSessionStoreInsertPartial_Input} value | ||
* @param { StoreSessionStoreWhere} where | ||
* @param { StoreSessionStoreWhere} [where] | ||
* @returns {Promise<StoreSessionStore[]>} | ||
@@ -441,20 +441,20 @@ */ | ||
* @param sql | ||
* @param { StoreJobQueueWhere} where | ||
* @param { StoreJobQueueWhere} [where] | ||
* @returns {Promise<StoreJobQueue[]>} | ||
*/ | ||
jobQueueSelect: ( | ||
sql, | ||
where, | ||
) => sql`SELECT jq."id", jq."isComplete", jq."priority", jq."scheduledAt", jq."name", jq."data", jq."createdAt", jq."updatedAt" FROM "jobQueue" jq | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR jq."id" = ${ | ||
where.id ?? null | ||
}) AND (COALESCE(${where.idGreaterThan ?? null}, NULL) IS NULL OR jq."id" > ${ | ||
where.idGreaterThan ?? null | ||
}) AND (COALESCE(${where.idLowerThan ?? null}, NULL) IS NULL OR jq."id" < ${ | ||
where.idLowerThan ?? null | ||
}) AND (COALESCE(${where.name ?? null}, NULL) IS NULL OR jq."name" = ${ | ||
where.name ?? null | ||
jobQueueSelect: (sql, where) => sql` | ||
SELECT jq."id", jq."isComplete", jq."priority", jq."scheduledAt", jq."name", jq."data", jq."createdAt", jq."updatedAt" FROM "jobQueue" jq | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR jq."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.nameLike ?? null | ||
}, NULL) IS NULL OR jq."name" LIKE ${`%${where.nameLike}%`}) | ||
where?.idGreaterThan ?? null | ||
}, NULL) IS NULL OR jq."id" > ${ | ||
where?.idGreaterThan ?? null | ||
}) AND (COALESCE(${where?.idLowerThan ?? null}, NULL) IS NULL OR jq."id" < ${ | ||
where?.idLowerThan ?? null | ||
}) AND (COALESCE(${where?.name ?? null}, NULL) IS NULL OR jq."name" = ${ | ||
where?.name ?? null | ||
}) AND (COALESCE(${ | ||
where?.nameLike ?? null | ||
}, NULL) IS NULL OR jq."name" LIKE ${`%${where?.nameLike}%`}) | ||
`, | ||
@@ -464,22 +464,25 @@ | ||
* @param sql | ||
* @param { StoreJobQueueWhere} where | ||
* @param { StoreJobQueueWhere} [where] | ||
* @returns {Promise<number>} | ||
*/ | ||
jobQueueCount: async (sql, where) => { | ||
const result = await sql`SELECT count(*) as "genCount" FROM "jobQueue" jq | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR jq."id" = ${ | ||
where.id ?? null | ||
const result = await sql` | ||
SELECT count(*) AS "genCount" FROM "jobQueue" jq | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR jq."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.idGreaterThan ?? null | ||
where?.idGreaterThan ?? null | ||
}, NULL) IS NULL OR jq."id" > ${ | ||
where.idGreaterThan ?? null | ||
}) AND (COALESCE(${where.idLowerThan ?? null}, NULL) IS NULL OR jq."id" < ${ | ||
where.idLowerThan ?? null | ||
}) AND (COALESCE(${where.name ?? null}, NULL) IS NULL OR jq."name" = ${ | ||
where.name ?? null | ||
where?.idGreaterThan ?? null | ||
}) AND (COALESCE(${ | ||
where.nameLike ?? null | ||
}, NULL) IS NULL OR jq."name" LIKE ${`%${where.nameLike}%`}) | ||
where?.idLowerThan ?? null | ||
}, NULL) IS NULL OR jq."id" < ${ | ||
where?.idLowerThan ?? null | ||
}) AND (COALESCE(${where?.name ?? null}, NULL) IS NULL OR jq."name" = ${ | ||
where?.name ?? null | ||
}) AND (COALESCE(${ | ||
where?.nameLike ?? null | ||
}, NULL) IS NULL OR jq."name" LIKE ${`%${where?.nameLike}%`}) | ||
`; | ||
return result?.[0]?.genCount ?? 0; | ||
return parseInt(result?.[0]?.genCount ?? "0"); | ||
}, | ||
@@ -489,17 +492,20 @@ | ||
* @param sql | ||
* @param { StoreJobQueueWhere} where | ||
* @param { StoreJobQueueWhere} [where] | ||
* @returns {Promise<*[]>} | ||
*/ | ||
jobQueueDelete: (sql, where) => sql`DELETE FROM "jobQueue" jq | ||
WHERE (COALESCE(${where.id ?? null}, NULL) IS NULL OR jq."id" = ${ | ||
where.id ?? null | ||
}) AND (COALESCE(${where.idGreaterThan ?? null}, NULL) IS NULL OR jq."id" > ${ | ||
where.idGreaterThan ?? null | ||
}) AND (COALESCE(${where.idLowerThan ?? null}, NULL) IS NULL OR jq."id" < ${ | ||
where.idLowerThan ?? null | ||
}) AND (COALESCE(${where.name ?? null}, NULL) IS NULL OR jq."name" = ${ | ||
where.name ?? null | ||
jobQueueDelete: (sql, where) => sql` | ||
DELETE FROM "jobQueue" jq | ||
WHERE (COALESCE(${where?.id ?? null}, NULL) IS NULL OR jq."id" = ${ | ||
where?.id ?? null | ||
}) AND (COALESCE(${ | ||
where.nameLike ?? null | ||
}, NULL) IS NULL OR jq."name" LIKE ${`%${where.nameLike}%`}) | ||
where?.idGreaterThan ?? null | ||
}, NULL) IS NULL OR jq."id" > ${ | ||
where?.idGreaterThan ?? null | ||
}) AND (COALESCE(${where?.idLowerThan ?? null}, NULL) IS NULL OR jq."id" < ${ | ||
where?.idLowerThan ?? null | ||
}) AND (COALESCE(${where?.name ?? null}, NULL) IS NULL OR jq."name" = ${ | ||
where?.name ?? null | ||
}) AND (COALESCE(${ | ||
where?.nameLike ?? null | ||
}, NULL) IS NULL OR jq."name" LIKE ${`%${where?.nameLike}%`}) | ||
`, | ||
@@ -541,3 +547,3 @@ | ||
* @param { StoreJobQueueInsertPartial_Input} value | ||
* @param { StoreJobQueueWhere} where | ||
* @param { StoreJobQueueWhere} [where] | ||
* @returns {Promise<StoreJobQueue[]>} | ||
@@ -544,0 +550,0 @@ */ |
77189
2195
+ Added@lbu/insight@0.0.48(transitive)
+ Added@lbu/stdlib@0.0.48(transitive)
- Removed@lbu/insight@0.0.47(transitive)
- Removed@lbu/stdlib@0.0.47(transitive)
Updated@lbu/insight@0.0.48
Updated@lbu/stdlib@0.0.48