@payloadcms/drizzle 3.62.0 → 3.63.0-canary.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/createJSONQuery/index.d.ts.map +1 -1
- package/dist/postgres/createJSONQuery/index.js +2 -0
- package/dist/postgres/createJSONQuery/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/findMigrationDir.d.ts +0 -16
- package/dist/findMigrationDir.d.ts.map +0 -1
- package/dist/findMigrationDir.js +0 -38
- package/dist/findMigrationDir.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/postgres/createJSONQuery/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAqBzD,eAAO,MAAM,eAAe,8CAA+C,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/postgres/createJSONQuery/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAqBzD,eAAO,MAAM,eAAe,8CAA+C,mBAAmB,WA8B7F,CAAA"}
|
|
@@ -28,6 +28,7 @@ export const createJSONQuery = ({ column, operator, pathSegments, value })=>{
|
|
|
28
28
|
'in',
|
|
29
29
|
'not_in'
|
|
30
30
|
].includes(operator) && Array.isArray(value)) {
|
|
31
|
+
sql = '(';
|
|
31
32
|
value.forEach((item, i)=>{
|
|
32
33
|
sql = `${sql}${createJSONQuery({
|
|
33
34
|
column,
|
|
@@ -36,6 +37,7 @@ export const createJSONQuery = ({ column, operator, pathSegments, value })=>{
|
|
|
36
37
|
value: item
|
|
37
38
|
})}${i === value.length - 1 ? '' : ` ${operator === 'in' ? 'OR' : 'AND'} `}`;
|
|
38
39
|
});
|
|
40
|
+
sql = `${sql})`;
|
|
39
41
|
} else if (operator === 'exists') {
|
|
40
42
|
sql = `${value === false ? 'NOT ' : ''}jsonb_path_exists(${columnName}, '${fullPath}')`;
|
|
41
43
|
} else if ([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/postgres/createJSONQuery/index.ts"],"sourcesContent":["import type { CreateJSONQueryArgs } from '../../types.js'\n\nconst operatorMap: Record<string, string> = {\n contains: '~',\n equals: '==',\n in: 'in',\n like: 'like_regex',\n not_equals: '!=',\n not_in: 'in',\n not_like: '!like_regex',\n}\n\nconst sanitizeValue = (value: unknown, operator?: string) => {\n if (typeof value === 'string') {\n // ignore casing with like or not_like\n return `\"${['like', 'not_like'].includes(operator) ? '(?i)' : ''}${value}\"`\n }\n\n return value as string\n}\n\nexport const createJSONQuery = ({ column, operator, pathSegments, value }: CreateJSONQueryArgs) => {\n const columnName = typeof column === 'object' ? column.name : column\n const jsonPaths = pathSegments\n .slice(1)\n .map((key) => {\n return `${key}[*]`\n })\n .join('.')\n\n const fullPath = pathSegments.length === 1 ? '$[*]' : `$.${jsonPaths}`\n\n let sql = ''\n\n if (['in', 'not_in'].includes(operator) && Array.isArray(value)) {\n value.forEach((item, i) => {\n sql = `${sql}${createJSONQuery({ column, operator: operator === 'in' ? 'equals' : 'not_equals', pathSegments, value: item })}${i === value.length - 1 ? '' : ` ${operator === 'in' ? 'OR' : 'AND'} `}`\n })\n } else if (operator === 'exists') {\n sql = `${value === false ? 'NOT ' : ''}jsonb_path_exists(${columnName}, '${fullPath}')`\n } else if (['not_like'].includes(operator)) {\n const mappedOperator = operatorMap[operator]\n\n sql = `NOT jsonb_path_exists(${columnName}, '${fullPath} ? (@ ${mappedOperator.substring(1)} ${sanitizeValue(value, operator)})')`\n } else {\n sql = `jsonb_path_exists(${columnName}, '${fullPath} ? (@ ${operatorMap[operator]} ${sanitizeValue(value, operator)})')`\n }\n\n return sql\n}\n"],"names":["operatorMap","contains","equals","in","like","not_equals","not_in","not_like","sanitizeValue","value","operator","includes","createJSONQuery","column","pathSegments","columnName","name","jsonPaths","slice","map","key","join","fullPath","length","sql","Array","isArray","forEach","item","i","mappedOperator","substring"],"mappings":"AAEA,MAAMA,cAAsC;IAC1CC,UAAU;IACVC,QAAQ;IACRC,IAAI;IACJC,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,UAAU;AACZ;AAEA,MAAMC,gBAAgB,CAACC,OAAgBC;IACrC,IAAI,OAAOD,UAAU,UAAU;QAC7B,sCAAsC;QACtC,OAAO,CAAC,CAAC,EAAE;YAAC;YAAQ;SAAW,CAACE,QAAQ,CAACD,YAAY,SAAS,KAAKD,MAAM,CAAC,CAAC;IAC7E;IAEA,OAAOA;AACT;AAEA,OAAO,MAAMG,kBAAkB,CAAC,EAAEC,MAAM,EAAEH,QAAQ,EAAEI,YAAY,EAAEL,KAAK,EAAuB;IAC5F,MAAMM,aAAa,OAAOF,WAAW,WAAWA,OAAOG,IAAI,GAAGH;IAC9D,MAAMI,YAAYH,aACfI,KAAK,CAAC,GACNC,GAAG,CAAC,CAACC;QACJ,OAAO,GAAGA,IAAI,GAAG,CAAC;IACpB,GACCC,IAAI,CAAC;IAER,MAAMC,WAAWR,aAAaS,MAAM,KAAK,IAAI,SAAS,CAAC,EAAE,EAAEN,WAAW;IAEtE,IAAIO,MAAM;IAEV,IAAI;QAAC;QAAM;KAAS,CAACb,QAAQ,CAACD,aAAae,MAAMC,OAAO,CAACjB,QAAQ;QAC/
|
|
1
|
+
{"version":3,"sources":["../../../src/postgres/createJSONQuery/index.ts"],"sourcesContent":["import type { CreateJSONQueryArgs } from '../../types.js'\n\nconst operatorMap: Record<string, string> = {\n contains: '~',\n equals: '==',\n in: 'in',\n like: 'like_regex',\n not_equals: '!=',\n not_in: 'in',\n not_like: '!like_regex',\n}\n\nconst sanitizeValue = (value: unknown, operator?: string) => {\n if (typeof value === 'string') {\n // ignore casing with like or not_like\n return `\"${['like', 'not_like'].includes(operator) ? '(?i)' : ''}${value}\"`\n }\n\n return value as string\n}\n\nexport const createJSONQuery = ({ column, operator, pathSegments, value }: CreateJSONQueryArgs) => {\n const columnName = typeof column === 'object' ? column.name : column\n const jsonPaths = pathSegments\n .slice(1)\n .map((key) => {\n return `${key}[*]`\n })\n .join('.')\n\n const fullPath = pathSegments.length === 1 ? '$[*]' : `$.${jsonPaths}`\n\n let sql = ''\n\n if (['in', 'not_in'].includes(operator) && Array.isArray(value)) {\n sql = '('\n value.forEach((item, i) => {\n sql = `${sql}${createJSONQuery({ column, operator: operator === 'in' ? 'equals' : 'not_equals', pathSegments, value: item })}${i === value.length - 1 ? '' : ` ${operator === 'in' ? 'OR' : 'AND'} `}`\n })\n sql = `${sql})`\n } else if (operator === 'exists') {\n sql = `${value === false ? 'NOT ' : ''}jsonb_path_exists(${columnName}, '${fullPath}')`\n } else if (['not_like'].includes(operator)) {\n const mappedOperator = operatorMap[operator]\n\n sql = `NOT jsonb_path_exists(${columnName}, '${fullPath} ? (@ ${mappedOperator.substring(1)} ${sanitizeValue(value, operator)})')`\n } else {\n sql = `jsonb_path_exists(${columnName}, '${fullPath} ? (@ ${operatorMap[operator]} ${sanitizeValue(value, operator)})')`\n }\n\n return sql\n}\n"],"names":["operatorMap","contains","equals","in","like","not_equals","not_in","not_like","sanitizeValue","value","operator","includes","createJSONQuery","column","pathSegments","columnName","name","jsonPaths","slice","map","key","join","fullPath","length","sql","Array","isArray","forEach","item","i","mappedOperator","substring"],"mappings":"AAEA,MAAMA,cAAsC;IAC1CC,UAAU;IACVC,QAAQ;IACRC,IAAI;IACJC,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,UAAU;AACZ;AAEA,MAAMC,gBAAgB,CAACC,OAAgBC;IACrC,IAAI,OAAOD,UAAU,UAAU;QAC7B,sCAAsC;QACtC,OAAO,CAAC,CAAC,EAAE;YAAC;YAAQ;SAAW,CAACE,QAAQ,CAACD,YAAY,SAAS,KAAKD,MAAM,CAAC,CAAC;IAC7E;IAEA,OAAOA;AACT;AAEA,OAAO,MAAMG,kBAAkB,CAAC,EAAEC,MAA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AcC,OAAOC,UAAU,GAAG,CAAC;IAC1H;IAEA,OAAOc;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/drizzle",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.63.0-canary.1",
|
|
4
4
|
"description": "A library of shared functions used by different payload database adapters",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@types/pg": "8.10.2",
|
|
61
61
|
"@types/to-snake-case": "1.0.0",
|
|
62
62
|
"@payloadcms/eslint-config": "3.28.0",
|
|
63
|
-
"payload": "3.
|
|
63
|
+
"payload": "3.63.0-canary.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"payload": "3.
|
|
66
|
+
"payload": "3.63.0-canary.1"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "pnpm build:swc && pnpm build:types",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Attempt to find migrations directory.
|
|
3
|
-
*
|
|
4
|
-
* Checks for the following directories in order:
|
|
5
|
-
* - `migrationDir` argument from Payload config
|
|
6
|
-
* - `src/migrations`
|
|
7
|
-
* - `dist/migrations`
|
|
8
|
-
* - `migrations`
|
|
9
|
-
*
|
|
10
|
-
* Defaults to `src/migrations`
|
|
11
|
-
*
|
|
12
|
-
* @param migrationDir
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
export declare function findMigrationDir(migrationDir?: string): string;
|
|
16
|
-
//# sourceMappingURL=findMigrationDir.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findMigrationDir.d.ts","sourceRoot":"","sources":["../src/findMigrationDir.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAyB9D"}
|
package/dist/findMigrationDir.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
/**
|
|
4
|
-
* Attempt to find migrations directory.
|
|
5
|
-
*
|
|
6
|
-
* Checks for the following directories in order:
|
|
7
|
-
* - `migrationDir` argument from Payload config
|
|
8
|
-
* - `src/migrations`
|
|
9
|
-
* - `dist/migrations`
|
|
10
|
-
* - `migrations`
|
|
11
|
-
*
|
|
12
|
-
* Defaults to `src/migrations`
|
|
13
|
-
*
|
|
14
|
-
* @param migrationDir
|
|
15
|
-
* @returns
|
|
16
|
-
*/ export function findMigrationDir(migrationDir) {
|
|
17
|
-
const cwd = process.cwd();
|
|
18
|
-
const srcDir = path.resolve(cwd, 'src/migrations');
|
|
19
|
-
const distDir = path.resolve(cwd, 'dist/migrations');
|
|
20
|
-
const relativeMigrations = path.resolve(cwd, 'migrations');
|
|
21
|
-
// Use arg if provided
|
|
22
|
-
if (migrationDir) {
|
|
23
|
-
return migrationDir;
|
|
24
|
-
}
|
|
25
|
-
// Check other common locations
|
|
26
|
-
if (fs.existsSync(srcDir)) {
|
|
27
|
-
return srcDir;
|
|
28
|
-
}
|
|
29
|
-
if (fs.existsSync(distDir)) {
|
|
30
|
-
return distDir;
|
|
31
|
-
}
|
|
32
|
-
if (fs.existsSync(relativeMigrations)) {
|
|
33
|
-
return relativeMigrations;
|
|
34
|
-
}
|
|
35
|
-
return srcDir;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=findMigrationDir.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findMigrationDir.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\n\n/**\n * Attempt to find migrations directory.\n *\n * Checks for the following directories in order:\n * - `migrationDir` argument from Payload config\n * - `src/migrations`\n * - `dist/migrations`\n * - `migrations`\n *\n * Defaults to `src/migrations`\n *\n * @param migrationDir\n * @returns\n */\nexport function findMigrationDir(migrationDir?: string): string {\n const cwd = process.cwd()\n const srcDir = path.resolve(cwd, 'src/migrations')\n const distDir = path.resolve(cwd, 'dist/migrations')\n const relativeMigrations = path.resolve(cwd, 'migrations')\n\n // Use arg if provided\n if (migrationDir) {\n return migrationDir\n }\n\n // Check other common locations\n if (fs.existsSync(srcDir)) {\n return srcDir\n }\n\n if (fs.existsSync(distDir)) {\n return distDir\n }\n\n if (fs.existsSync(relativeMigrations)) {\n return relativeMigrations\n }\n\n return srcDir\n}\n"],"names":["fs","path","findMigrationDir","migrationDir","cwd","process","srcDir","resolve","distDir","relativeMigrations","existsSync"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AAEvB;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASC,iBAAiBC,YAAqB;IACpD,MAAMC,MAAMC,QAAQD,GAAG;IACvB,MAAME,SAASL,KAAKM,OAAO,CAACH,KAAK;IACjC,MAAMI,UAAUP,KAAKM,OAAO,CAACH,KAAK;IAClC,MAAMK,qBAAqBR,KAAKM,OAAO,CAACH,KAAK;IAE7C,sBAAsB;IACtB,IAAID,cAAc;QAChB,OAAOA;IACT;IAEA,+BAA+B;IAC/B,IAAIH,GAAGU,UAAU,CAACJ,SAAS;QACzB,OAAOA;IACT;IAEA,IAAIN,GAAGU,UAAU,CAACF,UAAU;QAC1B,OAAOA;IACT;IAEA,IAAIR,GAAGU,UAAU,CAACD,qBAAqB;QACrC,OAAOA;IACT;IAEA,OAAOH;AACT"}
|