@payloadcms/drizzle 4.0.0-internal.21664f3 → 4.0.0-internal.2f0d313
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/createTableName.d.ts.map +1 -1
- package/dist/createTableName.js +2 -7
- package/dist/createTableName.js.map +1 -1
- package/dist/exports/postgres.d.ts +2 -0
- package/dist/exports/postgres.d.ts.map +1 -1
- package/dist/exports/postgres.js +2 -0
- package/dist/exports/postgres.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.d.ts +15 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.d.ts.map +1 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.js +25 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.js.map +1 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.spec.js +91 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.spec.js.map +1 -0
- package/dist/postgres/query/postgresUnaccent.d.ts +13 -0
- package/dist/postgres/query/postgresUnaccent.d.ts.map +1 -0
- package/dist/postgres/query/postgresUnaccent.js +40 -0
- package/dist/postgres/query/postgresUnaccent.js.map +1 -0
- package/dist/postgres/query/postgresUnaccent.spec.js +71 -0
- package/dist/postgres/query/postgresUnaccent.spec.js.map +1 -0
- package/dist/postgres/types.d.ts +13 -2
- package/dist/postgres/types.d.ts.map +1 -1
- package/dist/postgres/types.js.map +1 -1
- package/dist/queries/buildOperatorConstraint.d.ts +22 -0
- package/dist/queries/buildOperatorConstraint.d.ts.map +1 -0
- package/dist/queries/buildOperatorConstraint.js +63 -0
- package/dist/queries/buildOperatorConstraint.js.map +1 -0
- package/dist/queries/buildOperatorConstraint.spec.js +348 -0
- package/dist/queries/buildOperatorConstraint.spec.js.map +1 -0
- package/dist/queries/operatorMap.d.ts +7 -3
- package/dist/queries/operatorMap.d.ts.map +1 -1
- package/dist/queries/operatorMap.js.map +1 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +53 -6
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/validateOperatorHandlers.d.ts +8 -0
- package/dist/queries/validateOperatorHandlers.d.ts.map +1 -0
- package/dist/queries/validateOperatorHandlers.js +30 -0
- package/dist/queries/validateOperatorHandlers.js.map +1 -0
- package/dist/queries/validateOperatorHandlers.spec.js +142 -0
- package/dist/queries/validateOperatorHandlers.spec.js.map +1 -0
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +5 -4
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/buildRawSchema.spec.js +230 -0
- package/dist/schema/buildRawSchema.spec.js.map +1 -0
- package/dist/schema/traverseFields.js +5 -5
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/types.d.ts +50 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/updateJobs.d.ts.map +1 -1
- package/dist/updateJobs.js +37 -0
- package/dist/updateJobs.js.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts +1 -5
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.js.map +1 -1
- package/dist/utilities/validateIdentifierLength.d.ts +7 -0
- package/dist/utilities/validateIdentifierLength.d.ts.map +1 -0
- package/dist/utilities/validateIdentifierLength.js +14 -0
- package/dist/utilities/validateIdentifierLength.js.map +1 -0
- package/dist/utilities/validateIdentifierLength.spec.js +19 -0
- package/dist/utilities/validateIdentifierLength.spec.js.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"sourcesContent":["import type { Block, Field, FlattenedBlock } from 'payload'\n\nimport {\n fieldAffectsData,\n fieldHasSubFields,\n fieldShouldBeLocalized,\n tabHasName,\n} from 'payload/shared'\n\nimport type { RawTable } from '../types.js'\n\ntype Args = {\n block: Block\n localized: boolean\n
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"sourcesContent":["import type { Block, Field, FlattenedBlock } from 'payload'\n\nimport {\n fieldAffectsData,\n fieldHasSubFields,\n fieldShouldBeLocalized,\n tabHasName,\n} from 'payload/shared'\n\nimport type { RawTable } from '../types.js'\n\ntype Args = {\n block: Block\n localized: boolean\n parentIsLocalized: boolean\n table: RawTable\n tableLocales?: RawTable\n}\n\nconst getFlattenedFieldNames = (args: {\n fields: Field[]\n parentIsLocalized: boolean\n prefix?: string\n}): { localized?: boolean; name: string }[] => {\n const { fields, parentIsLocalized, prefix = '' } = args\n return fields.reduce((fieldsToUse, field) => {\n let fieldPrefix = prefix\n\n if (\n ['array', 'blocks', 'relationship', 'upload'].includes(field.type) ||\n ('hasMany' in field && field.hasMany === true)\n ) {\n return fieldsToUse\n }\n\n if (fieldHasSubFields(field)) {\n fieldPrefix = 'name' in field ? `${prefix}${field.name}_` : prefix\n return [\n ...fieldsToUse,\n ...getFlattenedFieldNames({\n fields: field.fields,\n parentIsLocalized: parentIsLocalized || ('localized' in field && field.localized),\n prefix: fieldPrefix,\n }),\n ]\n }\n\n if (field.type === 'tabs') {\n return [\n ...fieldsToUse,\n ...field.tabs.reduce((tabFields, tab) => {\n fieldPrefix = 'name' in tab ? `${prefix}_${tab.name}` : prefix\n return [\n ...tabFields,\n ...(tabHasName(tab)\n ? [{ ...tab, type: 'tab' }]\n : getFlattenedFieldNames({\n fields: tab.fields,\n parentIsLocalized: parentIsLocalized || tab.localized,\n prefix: fieldPrefix,\n })),\n ]\n }, []),\n ]\n }\n\n if (fieldAffectsData(field)) {\n return [\n ...fieldsToUse,\n {\n name: `${fieldPrefix}${field.name}`,\n localized: fieldShouldBeLocalized({ field, parentIsLocalized }),\n },\n ]\n }\n\n return fieldsToUse\n }, [])\n}\n\n/**\n * returns true if all the fields in a block are identical to the existing table\n */\nexport const validateExistingBlockIsIdentical = ({\n block,\n localized,\n parentIsLocalized,\n table,\n tableLocales,\n}: Args): boolean => {\n const fieldNames = getFlattenedFieldNames({\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || localized,\n })\n\n const missingField =\n // ensure every field from the config is in the matching table\n fieldNames.find(({ name, localized }) => {\n const fieldTable = localized && tableLocales ? tableLocales : table\n return Object.keys(fieldTable.columns).indexOf(name) === -1\n }) ||\n // ensure every table column is matched for every field from the config\n Object.keys(table).find((fieldName) => {\n if (!['_locale', '_order', '_parentID', '_path', '_uuid'].includes(fieldName)) {\n return fieldNames.findIndex((field) => field.name) === -1\n }\n })\n\n if (missingField) {\n return false\n }\n\n return Boolean(localized) === Boolean(table.columns._locale)\n}\n\nexport const InternalBlockTableNameIndex = Symbol('InternalBlockTableNameIndex')\nexport const setInternalBlockIndex = (block: FlattenedBlock, index: number) => {\n block[InternalBlockTableNameIndex] = index\n}\n\nexport const resolveBlockTableName = (block: FlattenedBlock, originalTableName: string) => {\n if (!block[InternalBlockTableNameIndex]) {\n return originalTableName\n }\n\n return `${originalTableName}_${block[InternalBlockTableNameIndex]}`\n}\n"],"names":["fieldAffectsData","fieldHasSubFields","fieldShouldBeLocalized","tabHasName","getFlattenedFieldNames","args","fields","parentIsLocalized","prefix","reduce","fieldsToUse","field","fieldPrefix","includes","type","hasMany","name","localized","tabs","tabFields","tab","validateExistingBlockIsIdentical","block","table","tableLocales","fieldNames","missingField","find","fieldTable","Object","keys","columns","indexOf","fieldName","findIndex","Boolean","_locale","InternalBlockTableNameIndex","Symbol","setInternalBlockIndex","index","resolveBlockTableName","originalTableName"],"mappings":"AAEA,SACEA,gBAAgB,EAChBC,iBAAiB,EACjBC,sBAAsB,EACtBC,UAAU,QACL,iBAAgB;AAYvB,MAAMC,yBAAyB,CAACC;IAK9B,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,SAAS,EAAE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ACP;IACL,MAAMC,aAAarB,uBAAuB;QACxCE,QAAQgB,MAAMhB,MAAM;QACpBC,mBAAmBA,qBAAqBU;IAC1C;IAEA,MAAMS,eACJ,8DAA8D;IAC9DD,WAAWE,IAAI,CAAC,CAAC,EAAEX,IAAI,EAAEC,SAAS,EAAE;QAClC,MAAMW,aAAaX,aAAaO,eAAeA,eAAeD;QAC9D,OAAOM,OAAOC,IAAI,CAACF,WAAWG,OAAO,EAAEC,OAAO,CAAChB,UAAU,CAAC;IAC5D,MACA,uEAAuE;IACvEa,OAAOC,IAAI,CAACP,OAAOI,IAAI,CAAC,CAACM;QACvB,IAAI,CAAC;YAAC;YAAW;YAAU;YAAa;YAAS;SAAQ,CAACpB,QAAQ,CAACoB,YAAY;YAC7E,OAAOR,WAAWS,SAAS,CAAC,CAACvB,QAAUA,MAAMK,IAAI,MAAM,CAAC;QAC1D;IACF;IAEF,IAAIU,cAAc;QAChB,OAAO;IACT;IAEA,OAAOS,QAAQlB,eAAekB,QAAQZ,MAAMQ,OAAO,CAACK,OAAO;AAC7D,EAAC;AAED,OAAO,MAAMC,8BAA8BC,OAAO,+BAA8B;AAChF,OAAO,MAAMC,wBAAwB,CAACjB,OAAuBkB;IAC3DlB,KAAK,CAACe,4BAA4B,GAAGG;AACvC,EAAC;AAED,OAAO,MAAMC,wBAAwB,CAACnB,OAAuBoB;IAC3D,IAAI,CAACpB,KAAK,CAACe,4BAA4B,EAAE;QACvC,OAAOK;IACT;IAEA,OAAO,GAAGA,kBAAkB,CAAC,EAAEpB,KAAK,CAACe,4BAA4B,EAAE;AACrE,EAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Postgres max identifier length (NAMEDATALEN - 1). */
|
|
2
|
+
export declare const maxIdentifierLength = 63;
|
|
3
|
+
/**
|
|
4
|
+
* Throws if a table or enum identifier exceeds the Postgres 63-char limit.
|
|
5
|
+
*/
|
|
6
|
+
export declare const validateIdentifierLength: (name: string) => string;
|
|
7
|
+
//# sourceMappingURL=validateIdentifierLength.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateIdentifierLength.d.ts","sourceRoot":"","sources":["../../src/utilities/validateIdentifierLength.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC;;GAEG;AACH,eAAO,MAAM,wBAAwB,SAAU,MAAM,KAAG,MAUvD,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { APIError } from 'payload';
|
|
2
|
+
/** Postgres max identifier length (NAMEDATALEN - 1). */ export const maxIdentifierLength = 63;
|
|
3
|
+
/**
|
|
4
|
+
* Throws if a table or enum identifier exceeds the Postgres 63-char limit.
|
|
5
|
+
*/ export const validateIdentifierLength = (name)=>{
|
|
6
|
+
if (name.length > maxIdentifierLength) {
|
|
7
|
+
throw new APIError(`Exceeded max identifier length for table or enum name of ${maxIdentifierLength} characters. Invalid name: ${name}.
|
|
8
|
+
Tip: You can use the dbName property to reduce the table name length.
|
|
9
|
+
`);
|
|
10
|
+
}
|
|
11
|
+
return name;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=validateIdentifierLength.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/validateIdentifierLength.ts"],"sourcesContent":["import { APIError } from 'payload'\n\n/** Postgres max identifier length (NAMEDATALEN - 1). */\nexport const maxIdentifierLength = 63\n\n/**\n * Throws if a table or enum identifier exceeds the Postgres 63-char limit.\n */\nexport const validateIdentifierLength = (name: string): string => {\n if (name.length > maxIdentifierLength) {\n throw new APIError(\n `Exceeded max identifier length for table or enum name of ${maxIdentifierLength} characters. Invalid name: ${name}.\nTip: You can use the dbName property to reduce the table name length.\n `,\n )\n }\n\n return name\n}\n"],"names":["APIError","maxIdentifierLength","validateIdentifierLength","name","length"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,UAAS;AAElC,sDAAsD,GACtD,OAAO,MAAMC,sBAAsB,GAAE;AAErC;;CAEC,GACD,OAAO,MAAMC,2BAA2B,CAACC;IACvC,IAAIA,KAAKC,MAAM,GAAGH,qBAAqB;QACrC,MAAM,IAAID,SACR,CAAC,yDAAyD,EAAEC,oBAAoB,2BAA2B,EAAEE,KAAK;;MAElH,CAAC;IAEL;IAEA,OAAOA;AACT,EAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { maxIdentifierLength, validateIdentifierLength } from './validateIdentifierLength.js';
|
|
3
|
+
describe('validateIdentifierLength', ()=>{
|
|
4
|
+
it('should return the name unchanged when at or under the 63-char limit', ()=>{
|
|
5
|
+
const name = 'a'.repeat(maxIdentifierLength);
|
|
6
|
+
expect(validateIdentifierLength(name)).toBe(name);
|
|
7
|
+
});
|
|
8
|
+
it('should throw when the name exceeds the 63-char limit', ()=>{
|
|
9
|
+
const name = 'a'.repeat(maxIdentifierLength + 1);
|
|
10
|
+
expect(()=>validateIdentifierLength(name)).toThrow('Exceeded max identifier length');
|
|
11
|
+
});
|
|
12
|
+
it('should include the invalid name and the dbName tip in the error', ()=>{
|
|
13
|
+
const name = `some_long_table_name${'x'.repeat(maxIdentifierLength)}_locales`;
|
|
14
|
+
expect(()=>validateIdentifierLength(name)).toThrow(name);
|
|
15
|
+
expect(()=>validateIdentifierLength(name)).toThrow('You can use the dbName property to reduce the table name length');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=validateIdentifierLength.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/validateIdentifierLength.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { maxIdentifierLength, validateIdentifierLength } from './validateIdentifierLength.js'\n\ndescribe('validateIdentifierLength', () => {\n it('should return the name unchanged when at or under the 63-char limit', () => {\n const name = 'a'.repeat(maxIdentifierLength)\n\n expect(validateIdentifierLength(name)).toBe(name)\n })\n\n it('should throw when the name exceeds the 63-char limit', () => {\n const name = 'a'.repeat(maxIdentifierLength + 1)\n\n expect(() => validateIdentifierLength(name)).toThrow('Exceeded max identifier length')\n })\n\n it('should include the invalid name and the dbName tip in the error', () => {\n const name = `some_long_table_name${'x'.repeat(maxIdentifierLength)}_locales`\n\n expect(() => validateIdentifierLength(name)).toThrow(name)\n expect(() => validateIdentifierLength(name)).toThrow(\n 'You can use the dbName property to reduce the table name length',\n )\n })\n})\n"],"names":["describe","expect","it","maxIdentifierLength","validateIdentifierLength","name","repeat","toBe","toThrow"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,mBAAmB,EAAEC,wBAAwB,QAAQ,gCAA+B;AAE7FJ,SAAS,4BAA4B;IACnCE,GAAG,uEAAuE;QACxE,MAAMG,OAAO,IAAIC,MAAM,CAACH;QAExBF,OAAOG,yBAAyBC,OAAOE,IAAI,CAACF;IAC9C;IAEAH,GAAG,wDAAwD;QACzD,MAAMG,OAAO,IAAIC,MAAM,CAACH,sBAAsB;QAE9CF,OAAO,IAAMG,yBAAyBC,OAAOG,OAAO,CAAC;IACvD;IAEAN,GAAG,mEAAmE;QACpE,MAAMG,OAAO,CAAC,oBAAoB,EAAE,IAAIC,MAAM,CAACH,qBAAqB,QAAQ,CAAC;QAE7EF,OAAO,IAAMG,yBAAyBC,OAAOG,OAAO,CAACH;QACrDJ,OAAO,IAAMG,yBAAyBC,OAAOG,OAAO,CAClD;IAEJ;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/drizzle",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.2f0d313",
|
|
4
4
|
"description": "A library of shared functions used by different payload database adapters",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"@types/pg": "8.20.0",
|
|
56
56
|
"@types/to-snake-case": "1.0.0",
|
|
57
57
|
"@payloadcms/eslint-config": "3.28.0",
|
|
58
|
-
"payload": "4.0.0-internal.
|
|
58
|
+
"payload": "4.0.0-internal.2f0d313"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"payload": "4.0.0-internal.
|
|
61
|
+
"payload": "4.0.0-internal.2f0d313"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "pnpm build:swc && pnpm build:types",
|