payload 3.62.0-internal.7fb5145 → 3.62.0-internal.ec3a6fa
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/auth/cookies.spec.js +1 -0
- package/dist/auth/cookies.spec.js.map +1 -1
- package/dist/bin/generateImportMap/generateImportMap.spec.js +2 -1
- package/dist/bin/generateImportMap/generateImportMap.spec.js.map +1 -1
- package/dist/collections/config/useAsTitle.spec.js +1 -0
- package/dist/collections/config/useAsTitle.spec.js.map +1 -1
- package/dist/config/types.d.ts +5 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/migrations/findMigrationDir.spec.js +2 -1
- package/dist/database/migrations/findMigrationDir.spec.js.map +1 -1
- package/dist/database/migrations/readMigrationFiles.d.ts.map +1 -1
- package/dist/database/migrations/readMigrationFiles.js +1 -3
- package/dist/database/migrations/readMigrationFiles.js.map +1 -1
- package/dist/fields/config/reservedFieldNames.spec.js +1 -0
- package/dist/fields/config/reservedFieldNames.spec.js.map +1 -1
- package/dist/fields/config/sanitize.spec.js +1 -0
- package/dist/fields/config/sanitize.spec.js.map +1 -1
- package/dist/fields/validations.spec.js +2 -2
- package/dist/fields/validations.spec.js.map +1 -1
- package/dist/index.bundled.d.ts +6 -0
- package/dist/queues/config/types/index.d.ts +1 -0
- package/dist/queues/config/types/index.d.ts.map +1 -1
- package/dist/queues/config/types/index.js.map +1 -1
- package/dist/uploads/mimeTypeValidator.spec.js +1 -0
- package/dist/uploads/mimeTypeValidator.spec.js.map +1 -1
- package/dist/utilities/addSelectGenericsToGeneratedTypes.spec.js +3 -2
- package/dist/utilities/addSelectGenericsToGeneratedTypes.spec.js.map +1 -1
- package/dist/utilities/combineWhereConstraints.spec.js +1 -0
- package/dist/utilities/combineWhereConstraints.spec.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +1 -0
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/flattenTopLevelFields.spec.js +1 -0
- package/dist/utilities/flattenTopLevelFields.spec.js.map +1 -1
- package/dist/utilities/formatLabels.spec.js +1 -0
- package/dist/utilities/formatLabels.spec.js.map +1 -1
- package/dist/utilities/getFieldByPath.spec.js +1 -0
- package/dist/utilities/getFieldByPath.spec.js.map +1 -1
- package/dist/utilities/getFieldPermissions.spec.js +1 -0
- package/dist/utilities/getFieldPermissions.spec.js.map +1 -1
- package/dist/utilities/getSafeRedirect.spec.js +1 -0
- package/dist/utilities/getSafeRedirect.spec.js.map +1 -1
- package/dist/utilities/sanitizePermissions.spec.js +1 -0
- package/dist/utilities/sanitizePermissions.spec.js.map +1 -1
- package/dist/utilities/sanitizeUserDataForEmail.spec.js +1 -0
- package/dist/utilities/sanitizeUserDataForEmail.spec.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/database/migrations/readMigrationFiles.ts"],"sourcesContent":["import fs from 'fs'\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/database/migrations/readMigrationFiles.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\n\nimport type { Payload } from '../../index.js'\nimport type { Migration } from '../types.js'\n\n/**\n * Read the migration files from disk\n */\nexport const readMigrationFiles = async ({\n payload,\n}: {\n payload: Payload\n}): Promise<Migration[]> => {\n if (!fs.existsSync(payload.db.migrationDir)) {\n payload.logger.error({\n msg: `No migration directory found at ${payload.db.migrationDir}`,\n })\n return []\n }\n\n payload.logger.info({\n msg: `Reading migration files from ${payload.db.migrationDir}`,\n })\n\n const files = fs\n .readdirSync(payload.db.migrationDir)\n .sort()\n .filter((f) => {\n return (f.endsWith('.ts') || f.endsWith('.js')) && f !== 'index.js' && f !== 'index.ts'\n })\n .map((file) => {\n return path.resolve(payload.db.migrationDir, file)\n })\n\n return Promise.all(\n files.map(async (filePath) => {\n let migration = await import(filePath.replaceAll('\\\\', '/'))\n if ('default' in migration) {\n migration = migration.default\n }\n\n const result: Migration = {\n name: path.basename(filePath).split('.')[0]!,\n down: migration.down,\n up: migration.up,\n }\n\n return result\n }),\n )\n}\n"],"names":["fs","path","readMigrationFiles","payload","existsSync","db","migrationDir","logger","error","msg","info","files","readdirSync","sort","filter","f","endsWith","map","file","resolve","Promise","all","filePath","migration","replaceAll","default","result","name","basename","split","down","up"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AAKvB;;CAEC,GACD,OAAO,MAAMC,qBAAqB,OAAO,EACvCC,OAAO,EAGR;IACC,IAAI,CAACH,GAAGI,UAAU,CAACD,QAAQE,EAAE,CAACC,YAAY,GAAG;QAC3CH,QAAQI,MAAM,CAACC,KAAK,CAAC;YACnBC,KAAK,CAAC,gCAAgC,EAAEN,QAAQE,EAAE,CAACC,YAAY,EAAE;QACnE;QACA,OAAO,EAAE;IACX;IAEAH,QAAQI,MAAM,CAACG,IAAI,CAAC;QAClBD,KAAK,CAAC,6BAA6B,EAAEN,QAAQE,EAAE,CAACC,YAAY,EAAE;IAChE;IAEA,MAAMK,QAAQX,GACXY,WAAW,CAACT,QAAQE,EAAE,CAACC,YAAY,EACnCO,IAAI,GACJC,MAAM,CAAC,CAACC;QACP,OAAO,AAACA,CAAAA,EAAEC,QAAQ,CAAC,UAAUD,EAAEC,QAAQ,CAAC,MAAK,KAAMD,MAAM,cAAcA,MAAM;IAC/E,GACCE,GAAG,CAAC,CAACC;QACJ,OAAOjB,KAAKkB,OAAO,CAAChB,QAAQE,EAAE,CAACC,YAAY,EAAEY;IAC/C;IAEF,OAAOE,QAAQC,GAAG,CAChBV,MAAMM,GAAG,CAAC,OAAOK;QACf,IAAIC,YAAY,MAAM,MAAM,CAACD,SAASE,UAAU,CAAC,MAAM;QACvD,IAAI,aAAaD,WAAW;YAC1BA,YAAYA,UAAUE,OAAO;QAC/B;QAEA,MAAMC,SAAoB;YACxBC,MAAM1B,KAAK2B,QAAQ,CAACN,UAAUO,KAAK,CAAC,IAAI,CAAC,EAAE;YAC3CC,MAAMP,UAAUO,IAAI;YACpBC,IAAIR,UAAUQ,EAAE;QAClB;QAEA,OAAOL;IACT;AAEJ,EAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReservedFieldName } from '../../errors/index.js';
|
|
2
2
|
import { sanitizeCollection } from '../../collections/config/sanitize.js';
|
|
3
|
+
import { describe, it, expect } from 'vitest';
|
|
3
4
|
describe('reservedFieldNames - collections -', ()=>{
|
|
4
5
|
const config = {
|
|
5
6
|
collections: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/config/reservedFieldNames.spec.ts"],"sourcesContent":["import type { Config } from '../../config/types.js'\nimport type { CollectionConfig, Field } from '../../index.js'\n\nimport { ReservedFieldName } from '../../errors/index.js'\nimport { sanitizeCollection } from '../../collections/config/sanitize.js'\n\ndescribe('reservedFieldNames - collections -', () => {\n const config = {\n collections: [],\n globals: [],\n } as Partial<Config>\n\n describe('uploads -', () => {\n const collectionWithUploads: CollectionConfig = {\n slug: 'collection-with-uploads',\n fields: [],\n upload: true,\n }\n\n it('should throw on file', async () => {\n const fields: Field[] = [\n {\n name: 'file',\n type: 'text',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [\n {\n ...collectionWithUploads,\n fields,\n },\n ],\n },\n {\n ...collectionWithUploads,\n fields,\n },\n )\n }).rejects.toThrow(ReservedFieldName)\n })\n\n it('should not throw on a custom field', async () => {\n const fields: Field[] = [\n {\n name: 'customField',\n type: 'text',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [\n {\n ...collectionWithUploads,\n fields,\n },\n ],\n },\n {\n ...collectionWithUploads,\n fields,\n },\n )\n }).not.toThrow()\n })\n })\n\n describe('auth -', () => {\n const collectionWithAuth: CollectionConfig = {\n slug: 'collection-with-auth',\n auth: {\n loginWithUsername: true,\n useAPIKey: true,\n verify: true,\n },\n fields: [],\n }\n\n it('should throw on hash', async () => {\n const fields: Field[] = [\n {\n name: 'hash',\n type: 'text',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [\n {\n ...collectionWithAuth,\n fields,\n },\n ],\n },\n {\n ...collectionWithAuth,\n fields,\n },\n )\n }).rejects.toThrow(ReservedFieldName)\n })\n\n it('should throw on salt', async () => {\n const fields: Field[] = [\n {\n name: 'salt',\n type: 'text',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [\n {\n ...collectionWithAuth,\n fields,\n },\n ],\n },\n {\n ...collectionWithAuth,\n fields,\n },\n )\n }).rejects.toThrow(ReservedFieldName)\n })\n\n it('should not throw on a custom field', async () => {\n const fields: Field[] = [\n {\n name: 'customField',\n type: 'text',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [\n {\n ...collectionWithAuth,\n fields,\n },\n ],\n },\n {\n ...collectionWithAuth,\n fields,\n },\n )\n }).not.toThrow()\n })\n })\n})\n"],"names":["ReservedFieldName","sanitizeCollection","describe","config","collections","globals","collectionWithUploads","slug","fields","upload","
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/config/reservedFieldNames.spec.ts"],"sourcesContent":["import type { Config } from '../../config/types.js'\nimport type { CollectionConfig, Field } from '../../index.js'\n\nimport { ReservedFieldName } from '../../errors/index.js'\nimport { sanitizeCollection } from '../../collections/config/sanitize.js'\nimport { describe, it, expect } from 'vitest'\n\ndescribe('reservedFieldNames - collections -', () => {\n const config = {\n collections: [],\n globals: [],\n } as Partial<Config>\n\n describe('uploads -', () => {\n const collectionWithUploads: CollectionConfig = {\n slug: 'collection-with-uploads',\n fields: [],\n upload: true,\n }\n\n it('should throw on file', async () => {\n const fields: Field[] = [\n {\n name: 'file',\n type: 'text',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [\n {\n ...collectionWithUploads,\n fields,\n },\n ],\n },\n {\n ...collectionWithUploads,\n fields,\n },\n )\n }).rejects.toThrow(ReservedFieldName)\n })\n\n it('should not throw on a custom field', async () => {\n const fields: Field[] = [\n {\n name: 'customField',\n type: 'text',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [\n {\n ...collectionWithUploads,\n fields,\n },\n ],\n },\n {\n ...collectionWithUploads,\n fields,\n },\n )\n }).not.toThrow()\n })\n })\n\n describe('auth -', () => {\n const collectionWithAuth: CollectionConfig = {\n slug: 'collection-with-auth',\n auth: {\n loginWithUsername: true,\n useAPIKey: true,\n verify: true,\n },\n fields: [],\n }\n\n it('should throw on hash', async () => {\n const fields: Field[] = [\n {\n name: 'hash',\n type: 'text',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [\n {\n ...collectionWithAuth,\n fields,\n },\n ],\n },\n {\n ...collectionWithAuth,\n fields,\n },\n )\n }).rejects.toThrow(ReservedFieldName)\n })\n\n it('should throw on salt', async () => {\n const fields: Field[] = [\n {\n name: 'salt',\n type: 'text',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [\n {\n ...collectionWithAuth,\n fields,\n },\n ],\n },\n {\n ...collectionWithAuth,\n fields,\n },\n )\n }).rejects.toThrow(ReservedFieldName)\n })\n\n it('should not throw on a custom field', async () => {\n const fields: Field[] = [\n {\n name: 'customField',\n type: 'text',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [\n {\n ...collectionWithAuth,\n fields,\n },\n ],\n },\n {\n ...collectionWithAuth,\n fields,\n },\n )\n }).not.toThrow()\n })\n })\n})\n"],"names":["ReservedFieldName","sanitizeCollection","describe","it","expect","config","collections","globals","collectionWithUploads","slug","fields","upload","name","type","label","rejects","toThrow","not","collectionWithAuth","auth","loginWithUsername","useAPIKey","verify"],"mappings":"AAGA,SAASA,iBAAiB,QAAQ,wBAAuB;AACzD,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAE7CF,SAAS,sCAAsC;IAC7C,MAAMG,SAAS;QACbC,aAAa,EAAE;QACfC,SAAS,EAAE;IACb;IAEAL,SAAS,aAAa;QACpB,MAAMM,wBAA0C;YAC9CC,MAAM;YACNC,QAAQ,EAAE;YACVC,QAAQ;QACV;QAEAR,GAAG,wBAAwB;YACzB,MAAMO,SAAkB;gBACtB;oBACEE,MAAM;oBACNC,MAAM;oBACNC,OAAO;gBACT;aACD;YAED,MAAMV,OAAO;gBACX,MAAMH,mBACJ,mBAAmB;gBACnB;oBACE,GAAGI,MAAM;oBACTC,aAAa;wBACX;4BACE,GAAGE,qBAAqB;4BACxBE;wBACF;qBACD;gBACH,GACA;oBACE,GAAGF,qBAAqB;oBACxBE;gBACF;YAEJ,GAAGK,OAAO,CAACC,OAAO,CAAChB;QACrB;QAEAG,GAAG,sCAAsC;YACvC,MAAMO,SAAkB;gBACtB;oBACEE,MAAM;oBACNC,MAAM;oBACNC,OAAO;gBACT;aACD;YAED,MAAMV,OAAO;gBACX,MAAMH,mBACJ,mBAAmB;gBACnB;oBACE,GAAGI,MAAM;oBACTC,aAAa;wBACX;4BACE,GAAGE,qBAAqB;4BACxBE;wBACF;qBACD;gBACH,GACA;oBACE,GAAGF,qBAAqB;oBACxBE;gBACF;YAEJ,GAAGO,GAAG,CAACD,OAAO;QAChB;IACF;IAEAd,SAAS,UAAU;QACjB,MAAMgB,qBAAuC;YAC3CT,MAAM;YACNU,MAAM;gBACJC,mBAAmB;gBACnBC,WAAW;gBACXC,QAAQ;YACV;YACAZ,QAAQ,EAAE;QACZ;QAEAP,GAAG,wBAAwB;YACzB,MAAMO,SAAkB;gBACtB;oBACEE,MAAM;oBACNC,MAAM;oBACNC,OAAO;gBACT;aACD;YAED,MAAMV,OAAO;gBACX,MAAMH,mBACJ,mBAAmB;gBACnB;oBACE,GAAGI,MAAM;oBACTC,aAAa;wBACX;4BACE,GAAGY,kBAAkB;4BACrBR;wBACF;qBACD;gBACH,GACA;oBACE,GAAGQ,kBAAkB;oBACrBR;gBACF;YAEJ,GAAGK,OAAO,CAACC,OAAO,CAAChB;QACrB;QAEAG,GAAG,wBAAwB;YACzB,MAAMO,SAAkB;gBACtB;oBACEE,MAAM;oBACNC,MAAM;oBACNC,OAAO;gBACT;aACD;YAED,MAAMV,OAAO;gBACX,MAAMH,mBACJ,mBAAmB;gBACnB;oBACE,GAAGI,MAAM;oBACTC,aAAa;wBACX;4BACE,GAAGY,kBAAkB;4BACrBR;wBACF;qBACD;gBACH,GACA;oBACE,GAAGQ,kBAAkB;oBACrBR;gBACF;YAEJ,GAAGK,OAAO,CAACC,OAAO,CAAChB;QACrB;QAEAG,GAAG,sCAAsC;YACvC,MAAMO,SAAkB;gBACtB;oBACEE,MAAM;oBACNC,MAAM;oBACNC,OAAO;gBACT;aACD;YAED,MAAMV,OAAO;gBACX,MAAMH,mBACJ,mBAAmB;gBACnB;oBACE,GAAGI,MAAM;oBACTC,aAAa;wBACX;4BACE,GAAGY,kBAAkB;4BACrBR;wBACF;qBACD;gBACH,GACA;oBACE,GAAGQ,kBAAkB;oBACrBR;gBACF;YAEJ,GAAGO,GAAG,CAACD,OAAO;QAChB;IACF;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DuplicateFieldName, InvalidFieldName, InvalidFieldRelationship, MissingFieldType } from '../../errors/index.js';
|
|
2
2
|
import { sanitizeFields } from './sanitize.js';
|
|
3
|
+
import { describe, it, expect } from 'vitest';
|
|
3
4
|
describe('sanitizeFields', ()=>{
|
|
4
5
|
const config = {};
|
|
5
6
|
const collectionConfig = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/config/sanitize.spec.ts"],"sourcesContent":["import type { Config } from '../../config/types.js'\nimport type {\n ArrayField,\n Block,\n BlocksField,\n CheckboxField,\n Field,\n NumberField,\n TextField,\n} from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { sanitizeFields } from './sanitize.js'\nimport { CollectionConfig } from '../../index.js'\n\ndescribe('sanitizeFields', () => {\n const config = {} as Config\n const collectionConfig = {} as CollectionConfig\n\n it('should throw on missing type field', async () => {\n const fields: Field[] = [\n // @ts-expect-error\n {\n name: 'Some Collection',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(MissingFieldType)\n })\n\n it('should throw on invalid field name', async () => {\n const fields: Field[] = [\n {\n name: 'some.collection',\n type: 'text',\n label: 'some.collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(InvalidFieldName)\n })\n\n it('should throw on duplicate field name', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: 'someField',\n },\n {\n name: 'someField',\n type: 'text',\n label: 'someField',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(DuplicateFieldName)\n })\n\n it('should throw on duplicate block slug', async () => {\n const fields: Field[] = [\n {\n name: 'blocks',\n type: 'blocks',\n blocks: [\n {\n slug: 'block',\n fields: [\n {\n name: 'blockField',\n type: 'text',\n },\n ],\n },\n {\n slug: 'block',\n fields: [\n {\n name: 'blockField',\n type: 'text',\n },\n ],\n },\n ],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(DuplicateFieldName)\n })\n\n describe('auto-labeling', () => {\n it('should populate label if missing', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual('Some Field')\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n it('should allow auto-label override', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: 'Do not label',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual('Do not label')\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n describe('opt-out', () => {\n it('should allow label opt-out', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n it('should allow label opt-out for arrays', async () => {\n const arrayField: ArrayField = {\n name: 'items',\n type: 'array',\n fields: [\n {\n name: 'itemName',\n type: 'text',\n },\n ],\n label: false,\n }\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields: [arrayField],\n validRelationships: [],\n })\n )[0] as ArrayField\n\n expect(sanitizedField.name).toStrictEqual('items')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('array')\n expect(sanitizedField.labels).toBeUndefined()\n })\n\n it('should allow label opt-out for blocks', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n expect(sanitizedField.name).toStrictEqual('noLabelBlock')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('blocks')\n expect(sanitizedField.labels).toBeUndefined()\n })\n })\n\n it('should label arrays with plural and singular', async () => {\n const fields: Field[] = [\n {\n name: 'items',\n type: 'array',\n fields: [\n {\n name: 'itemName',\n type: 'text',\n },\n ],\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as ArrayField\n\n expect(sanitizedField.name).toStrictEqual('items')\n expect(sanitizedField.label).toStrictEqual('Items')\n expect(sanitizedField.type).toStrictEqual('array')\n expect(sanitizedField.labels).toMatchObject({ plural: 'Items', singular: 'Item' })\n })\n\n it('should label blocks with plural and singular', async () => {\n const fields: Field[] = [\n {\n name: 'specialBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [{ name: 'testNumber', type: 'number' }],\n },\n ],\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n expect(sanitizedField.name).toStrictEqual('specialBlock')\n expect(sanitizedField.label).toStrictEqual('Special Block')\n expect(sanitizedField.type).toStrictEqual('blocks')\n expect(sanitizedField.labels).toMatchObject({\n plural: 'Special Blocks',\n singular: 'Special Block',\n })\n\n expect((sanitizedField.blocks[0].fields[0] as NumberField).label).toStrictEqual('Test Number')\n })\n })\n\n describe('relationships', () => {\n it('should not throw on valid relationship', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should not throw on valid relationship - multiple', async () => {\n const validRelationships = ['some-collection', 'another-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: ['some-collection', 'another-collection'],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should not throw on valid relationship inside blocks', async () => {\n const validRelationships = ['some-collection']\n const relationshipBlock: Block = {\n slug: 'relationshipBlock',\n fields: [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'some-collection',\n },\n ],\n }\n\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [relationshipBlock],\n label: 'Layout Blocks',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should throw on invalid relationship', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'not-valid',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should throw on invalid relationship - multiple', async () => {\n const validRelationships = ['some-collection', 'another-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: ['some-collection', 'not-valid'],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should throw on invalid relationship inside blocks', async () => {\n const validRelationships = ['some-collection']\n const relationshipBlock: Block = {\n slug: 'relationshipBlock',\n fields: [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'not-valid',\n },\n ],\n }\n\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [relationshipBlock],\n label: 'Layout Blocks',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should defaultValue of checkbox to false if required and undefined', async () => {\n const fields: Field[] = [\n {\n name: 'My Checkbox',\n type: 'checkbox',\n required: true,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as CheckboxField\n\n expect(sanitizedField.defaultValue).toStrictEqual(false)\n })\n\n it('should return empty field array if no fields', async () => {\n const sanitizedFields = await sanitizeFields({\n config,\n collectionConfig,\n fields: [],\n validRelationships: [],\n })\n\n expect(sanitizedFields).toStrictEqual([])\n })\n })\n describe('blocks', () => {\n it('should maintain admin.blockName true after sanitization', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n admin: {\n disableBlockName: true,\n },\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n const sanitizedBlock = sanitizedField.blocks[0]\n\n expect(sanitizedBlock.admin?.disableBlockName).toStrictEqual(true)\n })\n it('should default admin.disableBlockName to true after sanitization', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n const sanitizedBlock = sanitizedField.blocks[0]\n\n expect(sanitizedBlock.admin?.disableBlockName).toStrictEqual(undefined)\n })\n })\n})\n"],"names":["DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingFieldType","sanitizeFields","describe","config","collectionConfig","it","fields","name","label","expect","validRelationships","rejects","toThrow","type","blocks","slug","sanitizedField","toStrictEqual","arrayField","labels","toBeUndefined","toMatchObject","plural","singular","relationTo","not","relationshipBlock","required","defaultValue","sanitizedFields","admin","disableBlockName","sanitizedBlock","undefined"],"mappings":"AAWA,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,wBAAwB,EACxBC,gBAAgB,QACX,wBAAuB;AAC9B,SAASC,cAAc,QAAQ,gBAAe;AAG9CC,SAAS,kBAAkB;IACzB,MAAMC,SAAS,CAAC;IAChB,MAAMC,mBAAmB,CAAC;IAE1BC,GAAG,sCAAsC;QACvC,MAAMC,SAAkB;YACtB,mBAAmB;YACnB;gBACEC,MAAM;gBACNC,OAAO;YACT;SACD;QAED,MAAMC,OAAO;YACX,MAAMR,eAAe;gBACnBE;gBACAC;gBACAE;gBACAI,oBAAoB,EAAE;YACxB;QACF,GAAGC,OAAO,CAACC,OAAO,CAACZ;IACrB;IAEAK,GAAG,sCAAsC;QACvC,MAAMC,SAAkB;YACtB;gBACEC,MAAM;gBACNM,MAAM;gBACNL,OAAO;YACT;SACD;QAED,MAAMC,OAAO;YACX,MAAMR,eAAe;gBACnBE;gBACAC;gBACAE;gBACAI,oBAAoB,EAAE;YACxB;QACF,GAAGC,OAAO,CAACC,OAAO,CAACd;IACrB;IAEAO,GAAG,wCAAwC;QACzC,MAAMC,SAAkB;YACtB;gBACEC,MAAM;gBACNM,MAAM;gBACNL,OAAO;YACT;YACA;gBACED,MAAM;gBACNM,MAAM;gBACNL,OAAO;YACT;SACD;QAED,MAAMC,OAAO;YACX,MAAMR,eAAe;gBACnBE;gBACAC;gBACAE;gBACAI,oBAAoB,EAAE;YACxB;QACF,GAAGC,OAAO,CAACC,OAAO,CAACf;IACrB;IAEAQ,GAAG,wCAAwC;QACzC,MAAMC,SAAkB;YAC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E;QAC1C;IACF;IACAf,SAAS,UAAU;QACjBG,GAAG,2DAA2D;YAC5D,MAAMC,SAAkB;gBACtB;oBACEC,MAAM;oBACNM,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNe,OAAO;gCACLC,kBAAkB;4BACpB;4BACAzB,QAAQ;gCACN;oCACEC,MAAM;oCACNM,MAAM;gCACR;6BACD;wBACH;qBACD;oBACDL,OAAO;gBACT;aACD;YAED,MAAMQ,iBAAiB,AACrB,CAAA,MAAMf,eAAe;gBACnBE;gBACAC;gBACAE;gBACAI,oBAAoB,EAAE;YACxB,EAAC,CACF,CAAC,EAAE;YAEJ,MAAMsB,iBAAiBhB,eAAeF,MAAM,CAAC,EAAE;YAE/CL,OAAOuB,eAAeF,KAAK,EAAEC,kBAAkBd,aAAa,CAAC;QAC/D;QACAZ,GAAG,oEAAoE;YACrE,MAAMC,SAAkB;gBACtB;oBACEC,MAAM;oBACNM,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNT,QAAQ;gCACN;oCACEC,MAAM;oCACNM,MAAM;gCACR;6BACD;wBACH;qBACD;oBACDL,OAAO;gBACT;aACD;YAED,MAAMQ,iBAAiB,AACrB,CAAA,MAAMf,eAAe;gBACnBE;gBACAC;gBACAE;gBACAI,oBAAoB,EAAE;YACxB,EAAC,CACF,CAAC,EAAE;YAEJ,MAAMsB,iBAAiBhB,eAAeF,MAAM,CAAC,EAAE;YAE/CL,OAAOuB,eAAeF,KAAK,EAAEC,kBAAkBd,aAAa,CAACgB;QAC/D;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/config/sanitize.spec.ts"],"sourcesContent":["import type { Config } from '../../config/types.js'\nimport type {\n ArrayField,\n Block,\n BlocksField,\n CheckboxField,\n Field,\n NumberField,\n TextField,\n} from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { sanitizeFields } from './sanitize.js'\nimport { CollectionConfig } from '../../index.js'\nimport { describe, it, expect } from 'vitest'\n\ndescribe('sanitizeFields', () => {\n const config = {} as Config\n const collectionConfig = {} as CollectionConfig\n\n it('should throw on missing type field', async () => {\n const fields: Field[] = [\n // @ts-expect-error\n {\n name: 'Some Collection',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(MissingFieldType)\n })\n\n it('should throw on invalid field name', async () => {\n const fields: Field[] = [\n {\n name: 'some.collection',\n type: 'text',\n label: 'some.collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(InvalidFieldName)\n })\n\n it('should throw on duplicate field name', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: 'someField',\n },\n {\n name: 'someField',\n type: 'text',\n label: 'someField',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(DuplicateFieldName)\n })\n\n it('should throw on duplicate block slug', async () => {\n const fields: Field[] = [\n {\n name: 'blocks',\n type: 'blocks',\n blocks: [\n {\n slug: 'block',\n fields: [\n {\n name: 'blockField',\n type: 'text',\n },\n ],\n },\n {\n slug: 'block',\n fields: [\n {\n name: 'blockField',\n type: 'text',\n },\n ],\n },\n ],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(DuplicateFieldName)\n })\n\n describe('auto-labeling', () => {\n it('should populate label if missing', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual('Some Field')\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n it('should allow auto-label override', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: 'Do not label',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual('Do not label')\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n describe('opt-out', () => {\n it('should allow label opt-out', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n it('should allow label opt-out for arrays', async () => {\n const arrayField: ArrayField = {\n name: 'items',\n type: 'array',\n fields: [\n {\n name: 'itemName',\n type: 'text',\n },\n ],\n label: false,\n }\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields: [arrayField],\n validRelationships: [],\n })\n )[0] as ArrayField\n\n expect(sanitizedField.name).toStrictEqual('items')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('array')\n expect(sanitizedField.labels).toBeUndefined()\n })\n\n it('should allow label opt-out for blocks', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n expect(sanitizedField.name).toStrictEqual('noLabelBlock')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('blocks')\n expect(sanitizedField.labels).toBeUndefined()\n })\n })\n\n it('should label arrays with plural and singular', async () => {\n const fields: Field[] = [\n {\n name: 'items',\n type: 'array',\n fields: [\n {\n name: 'itemName',\n type: 'text',\n },\n ],\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as ArrayField\n\n expect(sanitizedField.name).toStrictEqual('items')\n expect(sanitizedField.label).toStrictEqual('Items')\n expect(sanitizedField.type).toStrictEqual('array')\n expect(sanitizedField.labels).toMatchObject({ plural: 'Items', singular: 'Item' })\n })\n\n it('should label blocks with plural and singular', async () => {\n const fields: Field[] = [\n {\n name: 'specialBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [{ name: 'testNumber', type: 'number' }],\n },\n ],\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n expect(sanitizedField.name).toStrictEqual('specialBlock')\n expect(sanitizedField.label).toStrictEqual('Special Block')\n expect(sanitizedField.type).toStrictEqual('blocks')\n expect(sanitizedField.labels).toMatchObject({\n plural: 'Special Blocks',\n singular: 'Special Block',\n })\n\n expect((sanitizedField.blocks[0].fields[0] as NumberField).label).toStrictEqual('Test Number')\n })\n })\n\n describe('relationships', () => {\n it('should not throw on valid relationship', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should not throw on valid relationship - multiple', async () => {\n const validRelationships = ['some-collection', 'another-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: ['some-collection', 'another-collection'],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should not throw on valid relationship inside blocks', async () => {\n const validRelationships = ['some-collection']\n const relationshipBlock: Block = {\n slug: 'relationshipBlock',\n fields: [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'some-collection',\n },\n ],\n }\n\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [relationshipBlock],\n label: 'Layout Blocks',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should throw on invalid relationship', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'not-valid',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should throw on invalid relationship - multiple', async () => {\n const validRelationships = ['some-collection', 'another-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: ['some-collection', 'not-valid'],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should throw on invalid relationship inside blocks', async () => {\n const validRelationships = ['some-collection']\n const relationshipBlock: Block = {\n slug: 'relationshipBlock',\n fields: [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'not-valid',\n },\n ],\n }\n\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [relationshipBlock],\n label: 'Layout Blocks',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should defaultValue of checkbox to false if required and undefined', async () => {\n const fields: Field[] = [\n {\n name: 'My Checkbox',\n type: 'checkbox',\n required: true,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as CheckboxField\n\n expect(sanitizedField.defaultValue).toStrictEqual(false)\n })\n\n it('should return empty field array if no fields', async () => {\n const sanitizedFields = await sanitizeFields({\n config,\n collectionConfig,\n fields: [],\n validRelationships: [],\n })\n\n expect(sanitizedFields).toStrictEqual([])\n })\n })\n describe('blocks', () => {\n it('should maintain admin.blockName true after sanitization', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n admin: {\n disableBlockName: true,\n },\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n const sanitizedBlock = sanitizedField.blocks[0]\n\n expect(sanitizedBlock.admin?.disableBlockName).toStrictEqual(true)\n })\n it('should default admin.disableBlockName to true after sanitization', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n const sanitizedBlock = sanitizedField.blocks[0]\n\n expect(sanitizedBlock.admin?.disableBlockName).toStrictEqual(undefined)\n })\n })\n})\n"],"names":["DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingFieldType","sanitizeFields","describe","it","expect","config","collectionConfig","fields","name","label","validRelationships","rejects","toThrow","type","blocks","slug","sanitizedField","toStrictEqual","arrayField","labels","toBeUndefined","toMatchObject","plural","singular","relationTo","not","relationshipBlock","required","defaultValue","sanitizedFields","admin","disableBlockName","sanitizedBlock","undefined"],"mappings":"AAWA,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,wBAAwB,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ACR;6BACD;wBACH;qBACD;oBACDJ,OAAO;gBACT;aACD;YAED,MAAMO,iBAAiB,AACrB,CAAA,MAAMf,eAAe;gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB,EAAC,CACF,CAAC,EAAE;YAEJ,MAAMsB,iBAAiBhB,eAAeF,MAAM,CAAC,EAAE;YAE/CV,OAAO4B,eAAeF,KAAK,EAAEC,kBAAkBd,aAAa,CAAC;QAC/D;QACAd,GAAG,oEAAoE;YACrE,MAAMI,SAAkB;gBACtB;oBACEC,MAAM;oBACNK,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNR,QAAQ;gCACN;oCACEC,MAAM;oCACNK,MAAM;gCACR;6BACD;wBACH;qBACD;oBACDJ,OAAO;gBACT;aACD;YAED,MAAMO,iBAAiB,AACrB,CAAA,MAAMf,eAAe;gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB,EAAC,CACF,CAAC,EAAE;YAEJ,MAAMsB,iBAAiBhB,eAAeF,MAAM,CAAC,EAAE;YAE/CV,OAAO4B,eAAeF,KAAK,EAAEC,kBAAkBd,aAAa,CAACgB;QAC/D;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jest } from '@jest/globals';
|
|
2
1
|
import { blocks, number, password, point, relationship, select, text, textarea } from './validations.js';
|
|
3
|
-
|
|
2
|
+
import { describe, expect, it, vitest } from 'vitest';
|
|
3
|
+
const t = vitest.fn((string)=>string);
|
|
4
4
|
let options = {
|
|
5
5
|
data: undefined,
|
|
6
6
|
operation: 'create',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/validations.spec.ts"],"sourcesContent":["import { jest } from '@jest/globals'\n\nimport type { SelectField, ValidateOptions } from './config/types.js'\n\nimport {\n blocks,\n number,\n password,\n point,\n relationship,\n select,\n text,\n textarea,\n type BlocksFieldValidation,\n type PointFieldValidation,\n type SelectFieldValidation,\n} from './validations.js'\n\nconst t = jest.fn((string) => string)\n\nlet options: ValidateOptions<any, any, any, any> = {\n data: undefined,\n operation: 'create',\n req: {\n context: {},\n payload: {\n config: {\n db: {\n defaultIDType: 'text',\n init: () => null,\n },\n },\n },\n t,\n },\n siblingData: undefined,\n}\n\ndescribe('Field Validations', () => {\n describe('text', () => {\n it('should validate', () => {\n const val = 'test'\n const result = text(val, options)\n expect(result).toBe(true)\n })\n it('should show required message', () => {\n const val = undefined\n const result = text(val, { ...options, required: true })\n expect(result).toBe('validation:required')\n })\n it('should handle undefined', () => {\n const val = undefined\n const result = text(val, options)\n expect(result).toBe(true)\n })\n it('should validate maxLength', () => {\n const val = 'toolong'\n const result = text(val, { ...options, maxLength: 5 })\n expect(result).toBe('validation:shorterThanMax')\n })\n it('should validate minLength', () => {\n const val = 'short'\n const result = text(val, { ...options, minLength: 10 })\n expect(result).toBe('validation:longerThanMin')\n })\n it('should validate maxLength with no value', () => {\n const val = undefined\n const result = text(val, { ...options, maxLength: 5 })\n expect(result).toBe(true)\n })\n it('should validate minLength with no value', () => {\n const val = undefined\n const result = text(val, { ...options, minLength: 10 })\n expect(result).toBe(true)\n })\n it('should validate minLength with empty string', () => {\n const val = ''\n const result = text(val, { ...options, required: false, minLength: 1 })\n expect(result).toBe('validation:longerThanMin')\n })\n it('should validate an array of texts', async () => {\n const val = ['test']\n const result = text(val, { ...options, hasMany: true })\n expect(result).toBe(true)\n })\n it('should handle required array of texts', async () => {\n const val = ['test']\n const result = text(val, { ...options, hasMany: true, required: true })\n expect(result).toBe(true)\n })\n })\n\n describe('textarea', () => {\n options = { ...options, field: { name: 'test', type: 'textarea' } }\n it('should validate', () => {\n const val = 'test'\n const result = textarea(val, options)\n expect(result).toBe(true)\n })\n it('should show required message', () => {\n const val = undefined\n const result = textarea(val, { ...options, required: true })\n expect(result).toBe('validation:required')\n })\n\n it('should handle undefined', () => {\n const val = undefined\n const result = textarea(val, options)\n expect(result).toBe(true)\n })\n it('should validate maxLength', () => {\n const val = 'toolong'\n const result = textarea(val, { ...options, maxLength: 5 })\n expect(result).toBe('validation:shorterThanMax')\n })\n\n it('should validate minLength', () => {\n const val = 'short'\n const result = textarea(val, { ...options, minLength: 10 })\n expect(result).toBe('validation:longerThanMin')\n })\n it('should validate maxLength with no value', () => {\n const val = undefined\n const result = textarea(val, { ...options, maxLength: 5 })\n expect(result).toBe(true)\n })\n it('should validate minLength with no value', () => {\n const val = undefined\n const result = textarea(val, { ...options, minLength: 10 })\n expect(result).toBe(true)\n })\n })\n\n describe('password', () => {\n const passwordOptions = {\n ...options,\n name: 'test',\n type: 'password',\n }\n it('should validate', () => {\n const val = 'test'\n const result = password(val, passwordOptions)\n expect(result).toBe(true)\n })\n it('should show required message', () => {\n const val = undefined\n const result = password(val, { ...passwordOptions, required: true })\n expect(result).toBe('validation:required')\n })\n it('should handle undefined', () => {\n const val = undefined\n const result = password(val, passwordOptions)\n expect(result).toBe(true)\n })\n it('should validate maxLength', () => {\n const val = 'toolong'\n const result = password(val, { ...passwordOptions, maxLength: 5 })\n expect(result).toBe('validation:shorterThanMax')\n })\n it('should validate minLength', () => {\n const val = 'short'\n const result = password(val, { ...passwordOptions, minLength: 10 })\n expect(result).toBe('validation:longerThanMin')\n })\n it('should validate maxLength with no value', () => {\n const val = undefined\n const result = password(val, { ...passwordOptions, maxLength: 5 })\n expect(result).toBe(true)\n })\n it('should validate minLength with no value', () => {\n const val = undefined\n const result = password(val, { ...passwordOptions, minLength: 10 })\n expect(result).toBe(true)\n })\n })\n\n describe('point', () => {\n const pointOptions: Parameters<PointFieldValidation>[1] = {\n ...options,\n name: 'point',\n type: 'point',\n }\n type PointFieldValue = [number | string, number | string]\n it('should validate numbers', () => {\n const val: PointFieldValue = ['0.1', '0.2']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should validate strings that could be numbers', () => {\n const val: PointFieldValue = ['0.1', '0.2']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should show required message when undefined', () => {\n const val = undefined\n const result = point(val, { ...pointOptions, required: true })\n expect(result).not.toBe(true)\n })\n it('should show required message when array', () => {\n const val = []\n const result = point(val, { ...pointOptions, required: true })\n expect(result).not.toBe(true)\n })\n it('should show required message when array of undefined', () => {\n const val = [undefined, undefined]\n const result = point(val, { ...pointOptions, required: true })\n expect(result).not.toBe(true)\n })\n it('should handle undefined not required', () => {\n const val = undefined\n const result = password(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should handle empty array not required', () => {\n const val = []\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should handle array of undefined not required', () => {\n const val = [undefined, undefined]\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should prevent text input', () => {\n const val = ['bad', 'input']\n const result = point(val, pointOptions)\n expect(result).not.toBe(true)\n })\n it('should prevent missing value', () => {\n const val = [0.1]\n const result = point(val, pointOptions)\n expect(result).not.toBe(true)\n })\n it('should validate longitude within bounds', () => {\n const val: PointFieldValue = ['180', '0']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should validate longitude at lower bound', () => {\n const val: PointFieldValue = ['-180', '0']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should prevent longitude below lower bound', () => {\n const val: PointFieldValue = ['-181', '0']\n const result = point(val, pointOptions)\n expect(result).toBe('validation:longitudeOutOfBounds')\n })\n it('should prevent longitude above upper bound', () => {\n const val: PointFieldValue = ['181', '0']\n const result = point(val, pointOptions)\n expect(result).toBe('validation:longitudeOutOfBounds')\n })\n it('should validate latitude within bounds', () => {\n const val: PointFieldValue = ['0', '90']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should validate latitude at lower bound', () => {\n const val: PointFieldValue = ['0', '-90']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should prevent latitude below lower bound', () => {\n const val: PointFieldValue = ['0', '-91']\n const result = point(val, pointOptions)\n expect(result).toBe('validation:latitudeOutOfBounds')\n })\n it('should prevent latitude above upper bound', () => {\n const val: PointFieldValue = ['0', '91']\n const result = point(val, pointOptions)\n expect(result).toBe('validation:latitudeOutOfBounds')\n })\n })\n\n describe('relationship', () => {\n const relationCollection = {\n slug: 'relation',\n fields: [\n {\n name: 'id',\n type: 'text',\n },\n ],\n }\n\n const relationshipOptions = {\n ...options,\n relationTo: 'relation',\n req: {\n ...options.req,\n payload: {\n ...options.req.payload,\n collections: {\n relation: {\n config: relationCollection,\n },\n },\n config: {\n collections: [relationCollection],\n },\n },\n },\n }\n it('should handle required', async () => {\n const val = undefined\n const result = await relationship(val, { ...relationshipOptions, required: true })\n expect(result).not.toBe(true)\n })\n it('should handle required with hasMany', async () => {\n const val = []\n const result = await relationship(val, {\n ...relationshipOptions,\n hasMany: true,\n required: true,\n })\n expect(result).not.toBe(true)\n })\n it('should enforce hasMany min', async () => {\n const minOptions = {\n ...relationshipOptions,\n hasMany: true,\n minRows: 2,\n }\n\n const val = ['a']\n\n const result = await relationship(val, minOptions)\n expect(result).not.toBe(true)\n\n const allowed = await relationship(['a', 'b'], minOptions)\n expect(allowed).toStrictEqual(true)\n })\n it('should enforce hasMany max', async () => {\n const maxOptions = {\n ...relationshipOptions,\n hasMany: true,\n maxRows: 2,\n }\n let val = ['a', 'b', 'c']\n\n const result = await relationship(val, maxOptions)\n expect(result).not.toBe(true)\n\n val = ['a']\n const allowed = await relationship(val, maxOptions)\n expect(allowed).toStrictEqual(true)\n })\n })\n\n describe('select', () => {\n const selectOptions: Parameters<SelectFieldValidation>[1] = {\n ...options,\n type: 'select',\n options: ['one', 'two', 'three'],\n }\n const optionsRequired: Parameters<SelectFieldValidation>[1] = {\n ...selectOptions,\n options: [\n {\n label: 'One',\n value: 'one',\n },\n {\n label: 'two',\n value: 'two',\n },\n {\n label: 'three',\n value: 'three',\n },\n ],\n required: true,\n }\n const optionsWithEmptyString: Parameters<SelectFieldValidation>[1] = {\n ...selectOptions,\n options: [\n {\n label: 'None',\n value: '',\n },\n {\n label: 'Option',\n value: 'option',\n },\n ],\n }\n it('should allow valid input', async () => {\n const val = 'one'\n const result = select(val, selectOptions)\n expect(result).toStrictEqual(true)\n })\n it('should prevent invalid input', () => {\n const val = 'bad'\n const result = select(val, selectOptions)\n expect(result).not.toStrictEqual(true)\n })\n it('should allow null input', () => {\n const val = null\n const result = select(val, selectOptions)\n expect(result).toStrictEqual(true)\n })\n it('should allow undefined input', () => {\n let val\n const result = select(val, selectOptions)\n expect(result).toStrictEqual(true)\n })\n it('should prevent empty string input', () => {\n const val = ''\n const result = select(val, selectOptions)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent undefined input with required', () => {\n let val\n const result = select(val, optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent empty string input with required', () => {\n const result = select('', optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent undefined input with required and hasMany', () => {\n let val\n options.hasMany = true\n const result = select(val, optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent empty array input with required and hasMany', () => {\n optionsRequired.hasMany = true\n const result = select([], optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent empty string array input with required and hasMany', () => {\n options.hasMany = true\n const result = select([''], optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent null input with required and hasMany', () => {\n const val = null\n options.hasMany = true\n const result = select(val, optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should allow valid input with option objects', () => {\n const val = 'one'\n options.hasMany = false\n const result = select(val, optionsRequired)\n expect(result).toStrictEqual(true)\n })\n it('should prevent invalid input with option objects', () => {\n const val = 'bad'\n options.hasMany = false\n const result = select(val, optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should allow empty string input with option object', () => {\n const val = ''\n const result = select(val, optionsWithEmptyString)\n expect(result).toStrictEqual(true)\n })\n it('should allow empty string input with option object and required', () => {\n const val = ''\n optionsWithEmptyString.required = true\n const result = select(val, optionsWithEmptyString)\n expect(result).toStrictEqual(true)\n })\n it('should allow valid input with hasMany', () => {\n const val = ['one', 'two']\n const result = select(val, selectOptions)\n expect(result).toStrictEqual(true)\n })\n it('should prevent invalid input with hasMany', () => {\n const val = ['one', 'bad']\n const result = select(val, selectOptions)\n expect(result).not.toStrictEqual(true)\n })\n it('should allow valid input with hasMany option objects', () => {\n const val = ['one', 'three']\n optionsRequired.hasMany = true\n const result = select(val, optionsRequired)\n expect(result).toStrictEqual(true)\n })\n it('should prevent invalid input with hasMany option objects', () => {\n const val = ['three', 'bad']\n optionsRequired.hasMany = true\n const result = select(val, optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n })\n\n describe('blocks', () => {\n const blocksOptions: Parameters<BlocksFieldValidation>[1] = {\n ...options,\n }\n it('basic blocks should pass validation', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n const result = await blocks(val, blocksOptions)\n expect(result).toStrictEqual(true)\n })\n\n it('should respect required validation', async () => {\n const result1 = await blocks(\n [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n ],\n { ...blocksOptions, required: true },\n )\n expect(result1).toStrictEqual(true)\n\n const result2 = await blocks([], { ...blocksOptions, required: true })\n expect(result2).not.toStrictEqual(true)\n\n const result3 = await blocks(undefined, { ...blocksOptions, required: true })\n expect(result3).not.toStrictEqual(true)\n\n const result4 = await blocks(null, { ...blocksOptions, required: true })\n expect(result4).not.toStrictEqual(true)\n })\n\n it('should respect minRows validation', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n const result1 = await blocks(val, { ...blocksOptions, minRows: 0 })\n expect(result1).toStrictEqual(true)\n const result2 = await blocks(val, { ...blocksOptions, minRows: 2 })\n expect(result2).toStrictEqual(true)\n\n const result3 = await blocks(val, { ...blocksOptions, minRows: 3 })\n expect(result3).not.toStrictEqual(true)\n })\n\n it('should respect maxRows validation', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n\n const result1 = await blocks(val, { ...blocksOptions, maxRows: 2 })\n expect(result1).toStrictEqual(true)\n const result2 = await blocks(val, { ...blocksOptions, maxRows: 3 })\n expect(result2).toStrictEqual(true)\n\n const result3 = await blocks(val, { ...blocksOptions, maxRows: 1 })\n expect(result3).not.toStrictEqual(true)\n })\n\n it('should respect both minRows and maxRows validation', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n const result1 = await blocks(val, { ...blocksOptions, maxRows: 2, minRows: 2 })\n expect(result1).toStrictEqual(true)\n\n const result2 = await blocks(val, { ...blocksOptions, maxRows: 1, minRows: 4 })\n expect(result2).not.toStrictEqual(true)\n\n const result3 = await blocks(val, { ...blocksOptions, maxRows: 1, minRows: 0 })\n expect(result3).not.toStrictEqual(true)\n\n const result4 = await blocks(val, { ...blocksOptions, maxRows: 5, minRows: 3 })\n expect(result4).not.toStrictEqual(true)\n })\n\n it('should validate static filterOptions', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n const result1 = await blocks(val, { ...blocksOptions, filterOptions: ['block1', 'block2'] })\n expect(result1).toStrictEqual(true)\n\n const result2 = await blocks(val, {\n ...blocksOptions,\n filterOptions: ['block1', 'block2', 'block3'],\n })\n expect(result2).toStrictEqual(true)\n\n const result3 = await blocks(val, { ...blocksOptions, filterOptions: ['block1', 'block3'] })\n expect(result3).not.toStrictEqual(true)\n\n const result4 = await blocks(val, { ...blocksOptions, filterOptions: [] })\n expect(result4).not.toStrictEqual(true)\n })\n\n it('should validate dynamic filterOptions 1', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n const result1 = await blocks(val, { ...blocksOptions, filterOptions: () => true })\n expect(result1).toStrictEqual(true)\n\n const result2 = await blocks(val, {\n ...blocksOptions,\n filterOptions: () => ['block1', 'block2'],\n })\n expect(result2).toStrictEqual(true)\n\n const result3 = await blocks(val, {\n ...blocksOptions,\n filterOptions: () => ['block1', 'block2', 'block3'],\n })\n expect(result3).toStrictEqual(true)\n\n const result4 = await blocks(val, { ...blocksOptions, filterOptions: () => [] })\n expect(result4).not.toStrictEqual(true)\n\n const result5 = await blocks(val, { ...blocksOptions, filterOptions: () => ['block1'] })\n expect(result5).not.toStrictEqual(true)\n\n const result6 = await blocks(val, {\n ...blocksOptions,\n filterOptions: () => ['block1', 'block3'],\n })\n expect(result6).not.toStrictEqual(true)\n })\n })\n\n describe('number', () => {\n const numberOptions = {\n ...options,\n name: 'test',\n type: 'number',\n }\n it('should validate', () => {\n const val = 1\n const result = number(val, numberOptions)\n expect(result).toBe(true)\n })\n it('should validate 0', () => {\n const val = 0\n const result = number(val, { ...numberOptions, required: true })\n expect(result).toBe(true)\n })\n it('should validate 2', () => {\n const val = 1.5\n const result = number(val, numberOptions)\n expect(result).toBe(true)\n })\n it('should show invalid number message', () => {\n const val = 'test'\n const result = number(val, { ...numberOptions })\n expect(result).toBe('validation:enterNumber')\n })\n it('should handle empty value', () => {\n const val = ''\n const result = number(val, { ...numberOptions })\n expect(result).toBe(true)\n })\n it('should handle required value', () => {\n const val = ''\n const result = number(val, { ...numberOptions, required: true })\n expect(result).toBe('validation:required')\n })\n it('should validate minValue', () => {\n const val = 2.4\n const result = number(val, { ...numberOptions, min: 2.5 })\n expect(result).toBe('validation:lessThanMin')\n })\n it('should validate maxValue', () => {\n const val = 1.25\n const result = number(val, { ...numberOptions, max: 1 })\n expect(result).toBe('validation:greaterThanMax')\n })\n it('should validate an array of numbers', async () => {\n const val = [1.25, 2.5]\n const result = number(val, { ...numberOptions, hasMany: true })\n expect(result).toBe(true)\n })\n it('should validate an array of numbers using min', async () => {\n const val = [1.25, 2.5]\n const result = number(val, { ...numberOptions, hasMany: true, min: 3 })\n expect(result).toBe('validation:lessThanMin')\n })\n it('should validate an array of numbers using max', async () => {\n const val = [1.25, 2.5]\n const result = number(val, { ...numberOptions, hasMany: true, max: 1 })\n expect(result).toBe('validation:greaterThanMax')\n })\n it('should validate an array of numbers using minRows', async () => {\n const val = [1.25, 2.5]\n const result = number(val, { ...numberOptions, hasMany: true, minRows: 4 })\n expect(result).toBe('validation:requiresAtLeast')\n })\n it('should validate an array of numbers using maxRows', async () => {\n const val = [1.25, 2.5, 3.5]\n const result = number(val, { ...numberOptions, hasMany: true, maxRows: 2 })\n expect(result).toBe('validation:requiresNoMoreThan')\n })\n })\n})\n"],"names":["jest","blocks","number","password","point","relationship","select","text","textarea","t","fn","string","options","data","undefined","operation","req","context","payload","config","db","defaultIDType","init","siblingData","describe","it","val","result","expect","toBe","required","maxLength","minLength","hasMany","field","name","type","passwordOptions","pointOptions","not","relationCollection","slug","fields","relationshipOptions","relationTo","collections","relation","minOptions","minRows","allowed","toStrictEqual","maxOptions","maxRows","selectOptions","optionsRequired","label","value","optionsWithEmptyString","blocksOptions","blockType","someField","result1","result2","result3","result4","filterOptions","result5","result6","numberOptions","min","max"],"mappings":"AAAA,SAASA,IAAI,QAAQ,gBAAe;AAIpC,SACEC,MAAM,EACNC,MAAM,EACNC,QAAQ,EACRC,KAAK,EACLC,YAAY,EACZC,MAAM,EACNC,IAAI,EACJC,QAAQ,QAIH,mBAAkB;AAEzB,MAAMC,IAAIT,KAAKU,EAAE,CAAC,CAACC,SAAWA;AAE9B,IAAIC,UAA+C;IACjDC,MAAMC;IACNC,WAAW;IACXC,KAAK;QACHC,SAAS,CAAC;QACVC,SAAS;YACPC,QAAQ;gBACNC,IAAI;oBACFC,eAAe;oBACfC,MAAM,IAAM;gBACd;YACF;QACF;QACAb;IACF;IACAc,aAAaT;AACf;AAEAU,SAAS,qBAAqB;IAC5BA,SAAS,QAAQ;QACfC,GAAG,mBAAmB;YACpB,MAAMC,MAAM;YACZ,MAAMC,SAASpB,KAAKmB,KAAKd;YACzB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C,aAAa;gBAAEnC,SAAS;gBAAMqC,KAAK;YAAE;YACrE1C,OAAOD,QAAQE,IAAI,CAAC;QACtB;QACAJ,GAAG,qDAAqD;YACtD,MAAMC,MAAM;gBAAC;gBAAM;aAAI;YACvB,MAAMC,SAASzB,OAAOwB,KAAK;gBAAE,GAAG0C,aAAa;gBAAEnC,SAAS;gBAAMe,SAAS;YAAE;YACzEpB,OAAOD,QAAQE,IAAI,CAAC;QACtB;QACAJ,GAAG,qDAAqD;YACtD,MAAMC,MAAM;gBAAC;gBAAM;gBAAK;aAAI;YAC5B,MAAMC,SAASzB,OAAOwB,KAAK;gBAAE,GAAG0C,aAAa;gBAAEnC,SAAS;gBAAMmB,SAAS;YAAE;YACzExB,OAAOD,QAAQE,IAAI,CAAC;QACtB;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/fields/validations.spec.ts"],"sourcesContent":["import type { SelectField, ValidateOptions } from './config/types.js'\n\nimport {\n blocks,\n number,\n password,\n point,\n relationship,\n select,\n text,\n textarea,\n type BlocksFieldValidation,\n type PointFieldValidation,\n type SelectFieldValidation,\n} from './validations.js'\nimport { describe, expect, it, vitest } from 'vitest'\n\nconst t = vitest.fn((string) => string)\n\nlet options: ValidateOptions<any, any, any, any> = {\n data: undefined,\n operation: 'create',\n req: {\n context: {},\n payload: {\n config: {\n db: {\n defaultIDType: 'text',\n init: () => null,\n },\n },\n },\n t,\n },\n siblingData: undefined,\n}\n\ndescribe('Field Validations', () => {\n describe('text', () => {\n it('should validate', () => {\n const val = 'test'\n const result = text(val, options)\n expect(result).toBe(true)\n })\n it('should show required message', () => {\n const val = undefined\n const result = text(val, { ...options, required: true })\n expect(result).toBe('validation:required')\n })\n it('should handle undefined', () => {\n const val = undefined\n const result = text(val, options)\n expect(result).toBe(true)\n })\n it('should validate maxLength', () => {\n const val = 'toolong'\n const result = text(val, { ...options, maxLength: 5 })\n expect(result).toBe('validation:shorterThanMax')\n })\n it('should validate minLength', () => {\n const val = 'short'\n const result = text(val, { ...options, minLength: 10 })\n expect(result).toBe('validation:longerThanMin')\n })\n it('should validate maxLength with no value', () => {\n const val = undefined\n const result = text(val, { ...options, maxLength: 5 })\n expect(result).toBe(true)\n })\n it('should validate minLength with no value', () => {\n const val = undefined\n const result = text(val, { ...options, minLength: 10 })\n expect(result).toBe(true)\n })\n it('should validate minLength with empty string', () => {\n const val = ''\n const result = text(val, { ...options, required: false, minLength: 1 })\n expect(result).toBe('validation:longerThanMin')\n })\n it('should validate an array of texts', async () => {\n const val = ['test']\n const result = text(val, { ...options, hasMany: true })\n expect(result).toBe(true)\n })\n it('should handle required array of texts', async () => {\n const val = ['test']\n const result = text(val, { ...options, hasMany: true, required: true })\n expect(result).toBe(true)\n })\n })\n\n describe('textarea', () => {\n options = { ...options, field: { name: 'test', type: 'textarea' } }\n it('should validate', () => {\n const val = 'test'\n const result = textarea(val, options)\n expect(result).toBe(true)\n })\n it('should show required message', () => {\n const val = undefined\n const result = textarea(val, { ...options, required: true })\n expect(result).toBe('validation:required')\n })\n\n it('should handle undefined', () => {\n const val = undefined\n const result = textarea(val, options)\n expect(result).toBe(true)\n })\n it('should validate maxLength', () => {\n const val = 'toolong'\n const result = textarea(val, { ...options, maxLength: 5 })\n expect(result).toBe('validation:shorterThanMax')\n })\n\n it('should validate minLength', () => {\n const val = 'short'\n const result = textarea(val, { ...options, minLength: 10 })\n expect(result).toBe('validation:longerThanMin')\n })\n it('should validate maxLength with no value', () => {\n const val = undefined\n const result = textarea(val, { ...options, maxLength: 5 })\n expect(result).toBe(true)\n })\n it('should validate minLength with no value', () => {\n const val = undefined\n const result = textarea(val, { ...options, minLength: 10 })\n expect(result).toBe(true)\n })\n })\n\n describe('password', () => {\n const passwordOptions = {\n ...options,\n name: 'test',\n type: 'password',\n }\n it('should validate', () => {\n const val = 'test'\n const result = password(val, passwordOptions)\n expect(result).toBe(true)\n })\n it('should show required message', () => {\n const val = undefined\n const result = password(val, { ...passwordOptions, required: true })\n expect(result).toBe('validation:required')\n })\n it('should handle undefined', () => {\n const val = undefined\n const result = password(val, passwordOptions)\n expect(result).toBe(true)\n })\n it('should validate maxLength', () => {\n const val = 'toolong'\n const result = password(val, { ...passwordOptions, maxLength: 5 })\n expect(result).toBe('validation:shorterThanMax')\n })\n it('should validate minLength', () => {\n const val = 'short'\n const result = password(val, { ...passwordOptions, minLength: 10 })\n expect(result).toBe('validation:longerThanMin')\n })\n it('should validate maxLength with no value', () => {\n const val = undefined\n const result = password(val, { ...passwordOptions, maxLength: 5 })\n expect(result).toBe(true)\n })\n it('should validate minLength with no value', () => {\n const val = undefined\n const result = password(val, { ...passwordOptions, minLength: 10 })\n expect(result).toBe(true)\n })\n })\n\n describe('point', () => {\n const pointOptions: Parameters<PointFieldValidation>[1] = {\n ...options,\n name: 'point',\n type: 'point',\n }\n type PointFieldValue = [number | string, number | string]\n it('should validate numbers', () => {\n const val: PointFieldValue = ['0.1', '0.2']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should validate strings that could be numbers', () => {\n const val: PointFieldValue = ['0.1', '0.2']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should show required message when undefined', () => {\n const val = undefined\n const result = point(val, { ...pointOptions, required: true })\n expect(result).not.toBe(true)\n })\n it('should show required message when array', () => {\n const val = []\n const result = point(val, { ...pointOptions, required: true })\n expect(result).not.toBe(true)\n })\n it('should show required message when array of undefined', () => {\n const val = [undefined, undefined]\n const result = point(val, { ...pointOptions, required: true })\n expect(result).not.toBe(true)\n })\n it('should handle undefined not required', () => {\n const val = undefined\n const result = password(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should handle empty array not required', () => {\n const val = []\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should handle array of undefined not required', () => {\n const val = [undefined, undefined]\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should prevent text input', () => {\n const val = ['bad', 'input']\n const result = point(val, pointOptions)\n expect(result).not.toBe(true)\n })\n it('should prevent missing value', () => {\n const val = [0.1]\n const result = point(val, pointOptions)\n expect(result).not.toBe(true)\n })\n it('should validate longitude within bounds', () => {\n const val: PointFieldValue = ['180', '0']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should validate longitude at lower bound', () => {\n const val: PointFieldValue = ['-180', '0']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should prevent longitude below lower bound', () => {\n const val: PointFieldValue = ['-181', '0']\n const result = point(val, pointOptions)\n expect(result).toBe('validation:longitudeOutOfBounds')\n })\n it('should prevent longitude above upper bound', () => {\n const val: PointFieldValue = ['181', '0']\n const result = point(val, pointOptions)\n expect(result).toBe('validation:longitudeOutOfBounds')\n })\n it('should validate latitude within bounds', () => {\n const val: PointFieldValue = ['0', '90']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should validate latitude at lower bound', () => {\n const val: PointFieldValue = ['0', '-90']\n const result = point(val, pointOptions)\n expect(result).toBe(true)\n })\n it('should prevent latitude below lower bound', () => {\n const val: PointFieldValue = ['0', '-91']\n const result = point(val, pointOptions)\n expect(result).toBe('validation:latitudeOutOfBounds')\n })\n it('should prevent latitude above upper bound', () => {\n const val: PointFieldValue = ['0', '91']\n const result = point(val, pointOptions)\n expect(result).toBe('validation:latitudeOutOfBounds')\n })\n })\n\n describe('relationship', () => {\n const relationCollection = {\n slug: 'relation',\n fields: [\n {\n name: 'id',\n type: 'text',\n },\n ],\n }\n\n const relationshipOptions = {\n ...options,\n relationTo: 'relation',\n req: {\n ...options.req,\n payload: {\n ...options.req.payload,\n collections: {\n relation: {\n config: relationCollection,\n },\n },\n config: {\n collections: [relationCollection],\n },\n },\n },\n }\n it('should handle required', async () => {\n const val = undefined\n const result = await relationship(val, { ...relationshipOptions, required: true })\n expect(result).not.toBe(true)\n })\n it('should handle required with hasMany', async () => {\n const val = []\n const result = await relationship(val, {\n ...relationshipOptions,\n hasMany: true,\n required: true,\n })\n expect(result).not.toBe(true)\n })\n it('should enforce hasMany min', async () => {\n const minOptions = {\n ...relationshipOptions,\n hasMany: true,\n minRows: 2,\n }\n\n const val = ['a']\n\n const result = await relationship(val, minOptions)\n expect(result).not.toBe(true)\n\n const allowed = await relationship(['a', 'b'], minOptions)\n expect(allowed).toStrictEqual(true)\n })\n it('should enforce hasMany max', async () => {\n const maxOptions = {\n ...relationshipOptions,\n hasMany: true,\n maxRows: 2,\n }\n let val = ['a', 'b', 'c']\n\n const result = await relationship(val, maxOptions)\n expect(result).not.toBe(true)\n\n val = ['a']\n const allowed = await relationship(val, maxOptions)\n expect(allowed).toStrictEqual(true)\n })\n })\n\n describe('select', () => {\n const selectOptions: Parameters<SelectFieldValidation>[1] = {\n ...options,\n type: 'select',\n options: ['one', 'two', 'three'],\n }\n const optionsRequired: Parameters<SelectFieldValidation>[1] = {\n ...selectOptions,\n options: [\n {\n label: 'One',\n value: 'one',\n },\n {\n label: 'two',\n value: 'two',\n },\n {\n label: 'three',\n value: 'three',\n },\n ],\n required: true,\n }\n const optionsWithEmptyString: Parameters<SelectFieldValidation>[1] = {\n ...selectOptions,\n options: [\n {\n label: 'None',\n value: '',\n },\n {\n label: 'Option',\n value: 'option',\n },\n ],\n }\n it('should allow valid input', async () => {\n const val = 'one'\n const result = select(val, selectOptions)\n expect(result).toStrictEqual(true)\n })\n it('should prevent invalid input', () => {\n const val = 'bad'\n const result = select(val, selectOptions)\n expect(result).not.toStrictEqual(true)\n })\n it('should allow null input', () => {\n const val = null\n const result = select(val, selectOptions)\n expect(result).toStrictEqual(true)\n })\n it('should allow undefined input', () => {\n let val\n const result = select(val, selectOptions)\n expect(result).toStrictEqual(true)\n })\n it('should prevent empty string input', () => {\n const val = ''\n const result = select(val, selectOptions)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent undefined input with required', () => {\n let val\n const result = select(val, optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent empty string input with required', () => {\n const result = select('', optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent undefined input with required and hasMany', () => {\n let val\n options.hasMany = true\n const result = select(val, optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent empty array input with required and hasMany', () => {\n optionsRequired.hasMany = true\n const result = select([], optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent empty string array input with required and hasMany', () => {\n options.hasMany = true\n const result = select([''], optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should prevent null input with required and hasMany', () => {\n const val = null\n options.hasMany = true\n const result = select(val, optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should allow valid input with option objects', () => {\n const val = 'one'\n options.hasMany = false\n const result = select(val, optionsRequired)\n expect(result).toStrictEqual(true)\n })\n it('should prevent invalid input with option objects', () => {\n const val = 'bad'\n options.hasMany = false\n const result = select(val, optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n it('should allow empty string input with option object', () => {\n const val = ''\n const result = select(val, optionsWithEmptyString)\n expect(result).toStrictEqual(true)\n })\n it('should allow empty string input with option object and required', () => {\n const val = ''\n optionsWithEmptyString.required = true\n const result = select(val, optionsWithEmptyString)\n expect(result).toStrictEqual(true)\n })\n it('should allow valid input with hasMany', () => {\n const val = ['one', 'two']\n const result = select(val, selectOptions)\n expect(result).toStrictEqual(true)\n })\n it('should prevent invalid input with hasMany', () => {\n const val = ['one', 'bad']\n const result = select(val, selectOptions)\n expect(result).not.toStrictEqual(true)\n })\n it('should allow valid input with hasMany option objects', () => {\n const val = ['one', 'three']\n optionsRequired.hasMany = true\n const result = select(val, optionsRequired)\n expect(result).toStrictEqual(true)\n })\n it('should prevent invalid input with hasMany option objects', () => {\n const val = ['three', 'bad']\n optionsRequired.hasMany = true\n const result = select(val, optionsRequired)\n expect(result).not.toStrictEqual(true)\n })\n })\n\n describe('blocks', () => {\n const blocksOptions: Parameters<BlocksFieldValidation>[1] = {\n ...options,\n }\n it('basic blocks should pass validation', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n const result = await blocks(val, blocksOptions)\n expect(result).toStrictEqual(true)\n })\n\n it('should respect required validation', async () => {\n const result1 = await blocks(\n [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n ],\n { ...blocksOptions, required: true },\n )\n expect(result1).toStrictEqual(true)\n\n const result2 = await blocks([], { ...blocksOptions, required: true })\n expect(result2).not.toStrictEqual(true)\n\n const result3 = await blocks(undefined, { ...blocksOptions, required: true })\n expect(result3).not.toStrictEqual(true)\n\n const result4 = await blocks(null, { ...blocksOptions, required: true })\n expect(result4).not.toStrictEqual(true)\n })\n\n it('should respect minRows validation', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n const result1 = await blocks(val, { ...blocksOptions, minRows: 0 })\n expect(result1).toStrictEqual(true)\n const result2 = await blocks(val, { ...blocksOptions, minRows: 2 })\n expect(result2).toStrictEqual(true)\n\n const result3 = await blocks(val, { ...blocksOptions, minRows: 3 })\n expect(result3).not.toStrictEqual(true)\n })\n\n it('should respect maxRows validation', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n\n const result1 = await blocks(val, { ...blocksOptions, maxRows: 2 })\n expect(result1).toStrictEqual(true)\n const result2 = await blocks(val, { ...blocksOptions, maxRows: 3 })\n expect(result2).toStrictEqual(true)\n\n const result3 = await blocks(val, { ...blocksOptions, maxRows: 1 })\n expect(result3).not.toStrictEqual(true)\n })\n\n it('should respect both minRows and maxRows validation', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n const result1 = await blocks(val, { ...blocksOptions, maxRows: 2, minRows: 2 })\n expect(result1).toStrictEqual(true)\n\n const result2 = await blocks(val, { ...blocksOptions, maxRows: 1, minRows: 4 })\n expect(result2).not.toStrictEqual(true)\n\n const result3 = await blocks(val, { ...blocksOptions, maxRows: 1, minRows: 0 })\n expect(result3).not.toStrictEqual(true)\n\n const result4 = await blocks(val, { ...blocksOptions, maxRows: 5, minRows: 3 })\n expect(result4).not.toStrictEqual(true)\n })\n\n it('should validate static filterOptions', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n const result1 = await blocks(val, { ...blocksOptions, filterOptions: ['block1', 'block2'] })\n expect(result1).toStrictEqual(true)\n\n const result2 = await blocks(val, {\n ...blocksOptions,\n filterOptions: ['block1', 'block2', 'block3'],\n })\n expect(result2).toStrictEqual(true)\n\n const result3 = await blocks(val, { ...blocksOptions, filterOptions: ['block1', 'block3'] })\n expect(result3).not.toStrictEqual(true)\n\n const result4 = await blocks(val, { ...blocksOptions, filterOptions: [] })\n expect(result4).not.toStrictEqual(true)\n })\n\n it('should validate dynamic filterOptions 1', async () => {\n const val: any[] = [\n {\n blockType: 'block1',\n someField: 'some data',\n },\n {\n blockType: 'block2',\n someField: 'some data',\n },\n ]\n const result1 = await blocks(val, { ...blocksOptions, filterOptions: () => true })\n expect(result1).toStrictEqual(true)\n\n const result2 = await blocks(val, {\n ...blocksOptions,\n filterOptions: () => ['block1', 'block2'],\n })\n expect(result2).toStrictEqual(true)\n\n const result3 = await blocks(val, {\n ...blocksOptions,\n filterOptions: () => ['block1', 'block2', 'block3'],\n })\n expect(result3).toStrictEqual(true)\n\n const result4 = await blocks(val, { ...blocksOptions, filterOptions: () => [] })\n expect(result4).not.toStrictEqual(true)\n\n const result5 = await blocks(val, { ...blocksOptions, filterOptions: () => ['block1'] })\n expect(result5).not.toStrictEqual(true)\n\n const result6 = await blocks(val, {\n ...blocksOptions,\n filterOptions: () => ['block1', 'block3'],\n })\n expect(result6).not.toStrictEqual(true)\n })\n })\n\n describe('number', () => {\n const numberOptions = {\n ...options,\n name: 'test',\n type: 'number',\n }\n it('should validate', () => {\n const val = 1\n const result = number(val, numberOptions)\n expect(result).toBe(true)\n })\n it('should validate 0', () => {\n const val = 0\n const result = number(val, { ...numberOptions, required: true })\n expect(result).toBe(true)\n })\n it('should validate 2', () => {\n const val = 1.5\n const result = number(val, numberOptions)\n expect(result).toBe(true)\n })\n it('should show invalid number message', () => {\n const val = 'test'\n const result = number(val, { ...numberOptions })\n expect(result).toBe('validation:enterNumber')\n })\n it('should handle empty value', () => {\n const val = ''\n const result = number(val, { ...numberOptions })\n expect(result).toBe(true)\n })\n it('should handle required value', () => {\n const val = ''\n const result = number(val, { ...numberOptions, required: true })\n expect(result).toBe('validation:required')\n })\n it('should validate minValue', () => {\n const val = 2.4\n const result = number(val, { ...numberOptions, min: 2.5 })\n expect(result).toBe('validation:lessThanMin')\n })\n it('should validate maxValue', () => {\n const val = 1.25\n const result = number(val, { ...numberOptions, max: 1 })\n expect(result).toBe('validation:greaterThanMax')\n })\n it('should validate an array of numbers', async () => {\n const val = [1.25, 2.5]\n const result = number(val, { ...numberOptions, hasMany: true })\n expect(result).toBe(true)\n })\n it('should validate an array of numbers using min', async () => {\n const val = [1.25, 2.5]\n const result = number(val, { ...numberOptions, hasMany: true, min: 3 })\n expect(result).toBe('validation:lessThanMin')\n })\n it('should validate an array of numbers using max', async () => {\n const val = [1.25, 2.5]\n const result = number(val, { ...numberOptions, hasMany: true, max: 1 })\n expect(result).toBe('validation:greaterThanMax')\n })\n it('should validate an array of numbers using minRows', async () => {\n const val = [1.25, 2.5]\n const result = number(val, { ...numberOptions, hasMany: true, minRows: 4 })\n expect(result).toBe('validation:requiresAtLeast')\n })\n it('should validate an array of numbers using maxRows', async () => {\n const val = [1.25, 2.5, 3.5]\n const result = number(val, { ...numberOptions, hasMany: true, maxRows: 2 })\n expect(result).toBe('validation:requiresNoMoreThan')\n })\n })\n})\n"],"names":["blocks","number","password","point","relationship","select","text","textarea","describe","expect","it","vitest","t","fn","string","options","data","undefined","operation","req","context","payload","config","db","defaultIDType","init","siblingData","val","result","toBe","required","maxLength","minLength","hasMany","field","name","type","passwordOptions","pointOptions","not","relationCollection","slug","fields","relationshipOptions","relationTo","collections","relation","minOptions","minRows","allowed","toStrictEqual","maxOptions","maxRows","selectOptions","optionsRequired","label","value","optionsWithEmptyString","blocksOptions","blockType","someField","result1","result2","result3","result4","filterOptions","result5","result6","numberOptions","min","max"],"mappings":"AAEA,SACEA,MAAM,EACNC,MAAM,EACNC,QAAQ,EACRC,KAAK,EACLC,YAAY,EACZC,MAAM,EACNC,IAAI,EACJC,QAAQ,QAIH,mBAAkB;AACzB,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAErD,MAAMC,IAAID,OAAOE,EAAE,CAAC,CAACC,SAAWA;AAEhC,IAAIC,UAA+C;IACjDC,MAAMC;IACNC,WAAW;IACXC,KAAK;QACHC,SAAS,CAAC;QACVC,SAAS;YACPC,QAAQ;gBACNC,IAAI;oBACFC,eAAe;oBACfC,MAAM,IAAM;gBACd;YACF;QACF;QACAb;IACF;IACAc,aAAaT;AACf;AAEAT,SAAS,qBAAqB;IAC5BA,SAAS,QAAQ;QACfE,GAAG,mBAAmB;YACpB,MAAMiB,MAAM;YACZ,MAAMC,SAAStB,KAAKqB,KAAKZ;YACzBN,OAAOmB,QAAQC,IAAI,CAAC;QACtB;QACAnB,GAAG,gCAAgC;YACjC,MAAMiB,MAAMV;YACZ,MAAMW,SAAStB,KAAKqB,KAAK;gBAAE,GAAGZ,OAAO;gBAAEe,UAAU;YAAK;YACtDrB,OAAOmB,QAAQC,IAAI,CAAC;QACtB;QACAnB,GAAG,2BAA2B;YAC5B,MAAMiB,MAAMV;YACZ,MAAMW,SAAStB,KAAKqB,KAAKZ;YACzBN,OAAOmB,QAAQC,IAAI,CAAC;QACtB;QACAnB,GAAG,6BAA6B;YAC9B,MAAMiB,MAAM;YACZ,MAAMC,SAAStB,KAAKqB,KAAK;gBAAE,GAAGZ,OAAO;gBAAEgB,WAAW;YAAE;YACpDtB,OAAOmB,QAAQC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AAS;gBAAMe,SAAS;YAAE;YACzEvC,OAAOmB,QAAQC,IAAI,CAAC;QACtB;QACAnB,GAAG,qDAAqD;YACtD,MAAMiB,MAAM;gBAAC;gBAAM;gBAAK;aAAI;YAC5B,MAAMC,SAAS3B,OAAO0B,KAAK;gBAAE,GAAGyC,aAAa;gBAAEnC,SAAS;gBAAMmB,SAAS;YAAE;YACzE3C,OAAOmB,QAAQC,IAAI,CAAC;QACtB;IACF;AACF"}
|
package/dist/index.bundled.d.ts
CHANGED
|
@@ -4817,6 +4817,7 @@ type JobsConfig = {
|
|
|
4817
4817
|
* queries will be used.
|
|
4818
4818
|
*
|
|
4819
4819
|
* @default 0
|
|
4820
|
+
* @deprecated - this will be removed in 4.0
|
|
4820
4821
|
*/
|
|
4821
4822
|
depth?: number;
|
|
4822
4823
|
/**
|
|
@@ -5745,6 +5746,11 @@ type Config = {
|
|
|
5745
5746
|
* @default 5
|
|
5746
5747
|
*/
|
|
5747
5748
|
limit?: number;
|
|
5749
|
+
/**
|
|
5750
|
+
* The position of the toast on the screen.
|
|
5751
|
+
* @default 'bottom-right'
|
|
5752
|
+
*/
|
|
5753
|
+
position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';
|
|
5748
5754
|
};
|
|
5749
5755
|
/** The slug of a Collection that you want to be used to log in to the Admin dashboard. */
|
|
5750
5756
|
user?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/queues/config/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,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,CAAA;AAE1B,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;;;;;;;;;;;OAkBG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE;QACN;;;;WAIG;QACH,aAAa,CAAC,EAAE,eAAe,CAAA;QAC/B;;;;;;;;;WASG;QACH,cAAc,CAAC,EAAE,gBAAgB,CAAA;KAClC,CAAA;IACD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queues/config/types/index.ts"],"sourcesContent":["import type { CollectionConfig, Job } from '../../../index.js'\nimport type { Payload, PayloadRequest, Sort } from '../../../types/index.js'\nimport type { RunJobsSilent } from '../../localAPI.js'\nimport type { RunJobsArgs } from '../../operations/runJobs/index.js'\nimport type { JobStats } from '../global.js'\nimport type { TaskConfig } from './taskTypes.js'\nimport type { WorkflowConfig } from './workflowTypes.js'\n\nexport type AutorunCronConfig = {\n /**\n * If you want to autoRUn jobs from all queues, set this to true.\n * If you set this to true, the `queue` property will be ignored.\n *\n * @default false\n */\n allQueues?: boolean\n /**\n * The cron schedule for the job.\n * @default '* * * * *' (every minute).\n *\n * @example\n * ┌───────────── (optional) second (0 - 59)\n * │ ┌───────────── minute (0 - 59)\n * │ │ ┌───────────── hour (0 - 23)\n * │ │ │ ┌───────────── day of the month (1 - 31)\n * │ │ │ │ ┌───────────── month (1 - 12)\n * │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)\n * │ │ │ │ │ │\n * │ │ │ │ │ │\n * - '* 0 * * * *' every hour at minute 0\n * - '* 0 0 * * *' daily at midnight\n * - '* 0 0 * * 0' weekly at midnight on Sundays\n * - '* 0 0 1 * *' monthly at midnight on the 1st day of the month\n * - '* 0/5 * * * *' every 5 minutes\n * - '* * * * * *' every second\n */\n cron?: string\n /**\n * By default, the autorun will attempt to schedule jobs for tasks and workflows that have a `schedule` property, given\n * the queue name is the same.\n *\n * Set this to `true` to disable the scheduling of jobs automatically.\n *\n * @default false\n */\n disableScheduling?: boolean\n /**\n * The limit for the job. This can be overridden by the user. Defaults to 10.\n */\n limit?: number\n /**\n * The queue name for the job.\n *\n * @default 'default'\n */\n queue?: string\n /**\n * If set to true, the job system will not log any output to the console (for both info and error logs).\n * Can be an option for more granular control over logging.\n *\n * This will not automatically affect user-configured logs (e.g. if you call `console.log` or `payload.logger.info` in your job code).\n *\n * @default false\n */\n silent?: RunJobsSilent\n}\n\nexport type RunJobAccessArgs = {\n req: PayloadRequest\n}\n\nexport type RunJobAccess = (args: RunJobAccessArgs) => boolean | Promise<boolean>\n\nexport type SanitizedJobsConfig = {\n /**\n * If set to `true`, the job system is enabled and a payload-jobs collection exists.\n * This property is automatically set during sanitization.\n */\n enabled?: boolean\n /**\n * If set to `true`, at least one task or workflow has scheduling enabled.\n * This property is automatically set during sanitization.\n */\n scheduling?: boolean\n /**\n * If set to `true`, a payload-job-stats global exists.\n * This property is automatically set during sanitization.\n */\n stats?: boolean\n} & JobsConfig\nexport type JobsConfig = {\n /**\n * Specify access control to determine who can interact with jobs.\n */\n access?: {\n /**\n * By default, all logged-in users can trigger jobs.\n */\n run?: RunJobAccess\n }\n /** Adds information about the parent job to the task log. This is useful for debugging and tracking the flow of tasks.\n *\n * In 4.0, this will default to `true`.\n *\n * @default false\n */\n addParentToTaskLog?: boolean\n /**\n * Allows you to configure cron jobs that automatically run queued jobs\n * at specified intervals. Note that this does not _queue_ new jobs - only\n * _runs_ jobs that are already in the specified queue.\n *\n * @remark this property should not be used on serverless platforms like Vercel\n */\n autoRun?:\n | ((payload: Payload) => AutorunCronConfig[] | Promise<AutorunCronConfig[]>)\n | AutorunCronConfig[]\n /**\n * Determine whether or not to delete a job after it has successfully completed.\n */\n deleteJobOnComplete?: boolean\n /**\n * Specify depth for retrieving jobs from the queue.\n * This should be as low as possible in order for job retrieval\n * to be as efficient as possible. Setting it to anything higher than\n * 0 will drastically affect performance, as less efficient database\n * queries will be used.\n *\n * @default 0\n */\n depth?: number\n /**\n * Override any settings on the default Jobs collection. Accepts the default collection and allows you to return\n * a new collection.\n */\n jobsCollectionOverrides?: (args: { defaultJobsCollection: CollectionConfig }) => CollectionConfig\n /**\n * Adjust the job processing order using a Payload sort string. This can be set globally or per queue.\n *\n * FIFO would equal `createdAt` and LIFO would equal `-createdAt`.\n *\n * @default all jobs for all queues will be executed in FIFO order.\n */\n processingOrder?:\n | ((args: RunJobsArgs) => Promise<Sort> | Sort)\n | {\n default?: Sort\n queues: {\n [queue: string]: Sort\n }\n }\n | Sort\n /**\n * By default, the job system uses direct database calls for optimal performance.\n * If you added custom hooks to your jobs collection, you can set this to true to\n * use the standard Payload API for all job operations. This is discouraged, as it will\n * drastically affect performance.\n *\n * @default false\n * @deprecated - this will be removed in 4.0\n */\n runHooks?: boolean\n /**\n * A function that will be executed before Payload picks up jobs which are configured by the `jobs.autorun` function.\n * If this function returns true, jobs will be queried and picked up. If it returns false, jobs will not be run.\n * @default undefined - if this function is not defined, jobs will be run - as if () => true was passed.\n * @param payload\n * @returns boolean\n */\n shouldAutoRun?: (payload: Payload) => boolean | Promise<boolean>\n /**\n * Define all possible tasks here\n */\n tasks?: TaskConfig<any>[]\n /**\n * Define all the workflows here. Workflows orchestrate the flow of multiple tasks.\n */\n workflows?: WorkflowConfig<any>[]\n}\n\nexport type Queueable = {\n scheduleConfig: ScheduleConfig\n taskConfig?: TaskConfig\n // If not set, queue it immediately\n waitUntil?: Date\n workflowConfig?: WorkflowConfig\n}\n\ntype OptionalPromise<T> = Promise<T> | T\n\nexport type BeforeScheduleFn = (args: {\n defaultBeforeSchedule: BeforeScheduleFn\n /**\n * payload-job-stats global data\n */\n jobStats: JobStats\n queueable: Queueable\n req: PayloadRequest\n}) => OptionalPromise<{\n input?: object\n shouldSchedule: boolean\n waitUntil?: Date\n}>\n\nexport type AfterScheduleFn = (\n args: {\n defaultAfterSchedule: AfterScheduleFn\n /**\n * payload-job-stats global data. If the global does not exist, it will be null.\n */\n jobStats: JobStats | null\n queueable: Queueable\n req: PayloadRequest\n } & (\n | {\n error: Error\n job?: never\n status: 'error'\n }\n | {\n error?: never\n job: Job\n status: 'success'\n }\n | {\n error?: never\n job?: never\n /**\n * If the beforeSchedule hook returned `shouldSchedule: false`, this will be called with status `skipped`.\n */\n status: 'skipped'\n }\n ),\n) => OptionalPromise<void>\n\nexport type ScheduleConfig = {\n /**\n * The cron for scheduling the job.\n *\n * @example\n * ┌───────────── (optional) second (0 - 59)\n * │ ┌───────────── minute (0 - 59)\n * │ │ ┌───────────── hour (0 - 23)\n * │ │ │ ┌───────────── day of the month (1 - 31)\n * │ │ │ │ ┌───────────── month (1 - 12)\n * │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)\n * │ │ │ │ │ │\n * │ │ │ │ │ │\n * - '* 0 * * * *' every hour at minute 0\n * - '* 0 0 * * *' daily at midnight\n * - '* 0 0 * * 0' weekly at midnight on Sundays\n * - '* 0 0 1 * *' monthly at midnight on the 1st day of the month\n * - '* 0/5 * * * *' every 5 minutes\n * - '* * * * * *' every second\n */\n cron: string\n hooks?: {\n /**\n * Functions that will be executed after the job has been successfully scheduled.\n *\n * @default By default, global update?? Unless global update should happen before\n */\n afterSchedule?: AfterScheduleFn\n /**\n * Functions that will be executed before the job is scheduled.\n * You can use this to control whether or not the job should be scheduled, or what input\n * data should be passed to the job.\n *\n * @default By default, this has one function that returns { shouldSchedule: true } if the following conditions are met:\n * - There currently is no job of the same type in the specified queue that is currently running\n * - There currently is no job of the same type in the specified queue that is scheduled to run in the future\n * - There currently is no job of the same type in the specified queue that failed previously but can be retried\n */\n beforeSchedule?: BeforeScheduleFn\n }\n /**\n * Queue to which the scheduled job will be added.\n */\n queue: string\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/queues/config/types/index.ts"],"sourcesContent":["import type { CollectionConfig, Job } from '../../../index.js'\nimport type { Payload, PayloadRequest, Sort } from '../../../types/index.js'\nimport type { RunJobsSilent } from '../../localAPI.js'\nimport type { RunJobsArgs } from '../../operations/runJobs/index.js'\nimport type { JobStats } from '../global.js'\nimport type { TaskConfig } from './taskTypes.js'\nimport type { WorkflowConfig } from './workflowTypes.js'\n\nexport type AutorunCronConfig = {\n /**\n * If you want to autoRUn jobs from all queues, set this to true.\n * If you set this to true, the `queue` property will be ignored.\n *\n * @default false\n */\n allQueues?: boolean\n /**\n * The cron schedule for the job.\n * @default '* * * * *' (every minute).\n *\n * @example\n * ┌───────────── (optional) second (0 - 59)\n * │ ┌───────────── minute (0 - 59)\n * │ │ ┌───────────── hour (0 - 23)\n * │ │ │ ┌───────────── day of the month (1 - 31)\n * │ │ │ │ ┌───────────── month (1 - 12)\n * │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)\n * │ │ │ │ │ │\n * │ │ │ │ │ │\n * - '* 0 * * * *' every hour at minute 0\n * - '* 0 0 * * *' daily at midnight\n * - '* 0 0 * * 0' weekly at midnight on Sundays\n * - '* 0 0 1 * *' monthly at midnight on the 1st day of the month\n * - '* 0/5 * * * *' every 5 minutes\n * - '* * * * * *' every second\n */\n cron?: string\n /**\n * By default, the autorun will attempt to schedule jobs for tasks and workflows that have a `schedule` property, given\n * the queue name is the same.\n *\n * Set this to `true` to disable the scheduling of jobs automatically.\n *\n * @default false\n */\n disableScheduling?: boolean\n /**\n * The limit for the job. This can be overridden by the user. Defaults to 10.\n */\n limit?: number\n /**\n * The queue name for the job.\n *\n * @default 'default'\n */\n queue?: string\n /**\n * If set to true, the job system will not log any output to the console (for both info and error logs).\n * Can be an option for more granular control over logging.\n *\n * This will not automatically affect user-configured logs (e.g. if you call `console.log` or `payload.logger.info` in your job code).\n *\n * @default false\n */\n silent?: RunJobsSilent\n}\n\nexport type RunJobAccessArgs = {\n req: PayloadRequest\n}\n\nexport type RunJobAccess = (args: RunJobAccessArgs) => boolean | Promise<boolean>\n\nexport type SanitizedJobsConfig = {\n /**\n * If set to `true`, the job system is enabled and a payload-jobs collection exists.\n * This property is automatically set during sanitization.\n */\n enabled?: boolean\n /**\n * If set to `true`, at least one task or workflow has scheduling enabled.\n * This property is automatically set during sanitization.\n */\n scheduling?: boolean\n /**\n * If set to `true`, a payload-job-stats global exists.\n * This property is automatically set during sanitization.\n */\n stats?: boolean\n} & JobsConfig\nexport type JobsConfig = {\n /**\n * Specify access control to determine who can interact with jobs.\n */\n access?: {\n /**\n * By default, all logged-in users can trigger jobs.\n */\n run?: RunJobAccess\n }\n /** Adds information about the parent job to the task log. This is useful for debugging and tracking the flow of tasks.\n *\n * In 4.0, this will default to `true`.\n *\n * @default false\n */\n addParentToTaskLog?: boolean\n /**\n * Allows you to configure cron jobs that automatically run queued jobs\n * at specified intervals. Note that this does not _queue_ new jobs - only\n * _runs_ jobs that are already in the specified queue.\n *\n * @remark this property should not be used on serverless platforms like Vercel\n */\n autoRun?:\n | ((payload: Payload) => AutorunCronConfig[] | Promise<AutorunCronConfig[]>)\n | AutorunCronConfig[]\n /**\n * Determine whether or not to delete a job after it has successfully completed.\n */\n deleteJobOnComplete?: boolean\n /**\n * Specify depth for retrieving jobs from the queue.\n * This should be as low as possible in order for job retrieval\n * to be as efficient as possible. Setting it to anything higher than\n * 0 will drastically affect performance, as less efficient database\n * queries will be used.\n *\n * @default 0\n * @deprecated - this will be removed in 4.0\n */\n depth?: number\n /**\n * Override any settings on the default Jobs collection. Accepts the default collection and allows you to return\n * a new collection.\n */\n jobsCollectionOverrides?: (args: { defaultJobsCollection: CollectionConfig }) => CollectionConfig\n /**\n * Adjust the job processing order using a Payload sort string. This can be set globally or per queue.\n *\n * FIFO would equal `createdAt` and LIFO would equal `-createdAt`.\n *\n * @default all jobs for all queues will be executed in FIFO order.\n */\n processingOrder?:\n | ((args: RunJobsArgs) => Promise<Sort> | Sort)\n | {\n default?: Sort\n queues: {\n [queue: string]: Sort\n }\n }\n | Sort\n /**\n * By default, the job system uses direct database calls for optimal performance.\n * If you added custom hooks to your jobs collection, you can set this to true to\n * use the standard Payload API for all job operations. This is discouraged, as it will\n * drastically affect performance.\n *\n * @default false\n * @deprecated - this will be removed in 4.0\n */\n runHooks?: boolean\n /**\n * A function that will be executed before Payload picks up jobs which are configured by the `jobs.autorun` function.\n * If this function returns true, jobs will be queried and picked up. If it returns false, jobs will not be run.\n * @default undefined - if this function is not defined, jobs will be run - as if () => true was passed.\n * @param payload\n * @returns boolean\n */\n shouldAutoRun?: (payload: Payload) => boolean | Promise<boolean>\n /**\n * Define all possible tasks here\n */\n tasks?: TaskConfig<any>[]\n /**\n * Define all the workflows here. Workflows orchestrate the flow of multiple tasks.\n */\n workflows?: WorkflowConfig<any>[]\n}\n\nexport type Queueable = {\n scheduleConfig: ScheduleConfig\n taskConfig?: TaskConfig\n // If not set, queue it immediately\n waitUntil?: Date\n workflowConfig?: WorkflowConfig\n}\n\ntype OptionalPromise<T> = Promise<T> | T\n\nexport type BeforeScheduleFn = (args: {\n defaultBeforeSchedule: BeforeScheduleFn\n /**\n * payload-job-stats global data\n */\n jobStats: JobStats\n queueable: Queueable\n req: PayloadRequest\n}) => OptionalPromise<{\n input?: object\n shouldSchedule: boolean\n waitUntil?: Date\n}>\n\nexport type AfterScheduleFn = (\n args: {\n defaultAfterSchedule: AfterScheduleFn\n /**\n * payload-job-stats global data. If the global does not exist, it will be null.\n */\n jobStats: JobStats | null\n queueable: Queueable\n req: PayloadRequest\n } & (\n | {\n error: Error\n job?: never\n status: 'error'\n }\n | {\n error?: never\n job: Job\n status: 'success'\n }\n | {\n error?: never\n job?: never\n /**\n * If the beforeSchedule hook returned `shouldSchedule: false`, this will be called with status `skipped`.\n */\n status: 'skipped'\n }\n ),\n) => OptionalPromise<void>\n\nexport type ScheduleConfig = {\n /**\n * The cron for scheduling the job.\n *\n * @example\n * ┌───────────── (optional) second (0 - 59)\n * │ ┌───────────── minute (0 - 59)\n * │ │ ┌───────────── hour (0 - 23)\n * │ │ │ ┌───────────── day of the month (1 - 31)\n * │ │ │ │ ┌───────────── month (1 - 12)\n * │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)\n * │ │ │ │ │ │\n * │ │ │ │ │ │\n * - '* 0 * * * *' every hour at minute 0\n * - '* 0 0 * * *' daily at midnight\n * - '* 0 0 * * 0' weekly at midnight on Sundays\n * - '* 0 0 1 * *' monthly at midnight on the 1st day of the month\n * - '* 0/5 * * * *' every 5 minutes\n * - '* * * * * *' every second\n */\n cron: string\n hooks?: {\n /**\n * Functions that will be executed after the job has been successfully scheduled.\n *\n * @default By default, global update?? Unless global update should happen before\n */\n afterSchedule?: AfterScheduleFn\n /**\n * Functions that will be executed before the job is scheduled.\n * You can use this to control whether or not the job should be scheduled, or what input\n * data should be passed to the job.\n *\n * @default By default, this has one function that returns { shouldSchedule: true } if the following conditions are met:\n * - There currently is no job of the same type in the specified queue that is currently running\n * - There currently is no job of the same type in the specified queue that is scheduled to run in the future\n * - There currently is no job of the same type in the specified queue that failed previously but can be retried\n */\n beforeSchedule?: BeforeScheduleFn\n }\n /**\n * Queue to which the scheduled job will be added.\n */\n queue: string\n}\n"],"names":[],"mappings":"AA4OA,WA4CC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/uploads/mimeTypeValidator.spec.ts"],"sourcesContent":["import type { ValidateOptions } from '../fields/config/types'\n\nimport { mimeTypeValidator } from './mimeTypeValidator'\n\nconst options = { siblingData: { filename: 'file.xyz' } } as ValidateOptions<\n undefined,\n undefined,\n undefined\n>\n\ndescribe('mimeTypeValidator', () => {\n it('should validate single mimeType', () => {\n const mimeTypes = ['image/png']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('image/png', options)).toBe(true)\n })\n\n it('should validate multiple mimeTypes', () => {\n const mimeTypes = ['image/png', 'application/pdf']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('image/png', options)).toBe(true)\n expect(validate('application/pdf', options)).toBe(true)\n })\n\n it('should validate using wildcard', () => {\n const mimeTypes = ['image/*']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('image/png', options)).toBe(true)\n expect(validate('image/gif', options)).toBe(true)\n })\n\n it('should validate multiple wildcards', () => {\n const mimeTypes = ['image/*', 'audio/*']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('image/png', options)).toBe(true)\n expect(validate('audio/mpeg', options)).toBe(true)\n })\n\n it('should not validate when unmatched', () => {\n const mimeTypes = ['image/png']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('audio/mpeg', options)).toBe(\"Invalid file type: 'audio/mpeg'\")\n })\n\n it('should not validate when unmatched - multiple mimeTypes', () => {\n const mimeTypes = ['image/png', 'application/pdf']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('audio/mpeg', options)).toBe(\"Invalid file type: 'audio/mpeg'\")\n })\n\n it('should not validate using wildcard - unmatched', () => {\n const mimeTypes = ['image/*']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('audio/mpeg', options)).toBe(\"Invalid file type: 'audio/mpeg'\")\n })\n\n it('should not validate multiple wildcards - unmatched', () => {\n const mimeTypes = ['image/*', 'audio/*']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('video/mp4', options)).toBe(\"Invalid file type: 'video/mp4'\")\n expect(validate('application/pdf', options)).toBe(\"Invalid file type: 'application/pdf'\")\n })\n\n it('should not error when mimeType is missing', () => {\n const mimeTypes = ['image/*', 'application/pdf']\n const validate = mimeTypeValidator(mimeTypes)\n let value\n expect(validate(value, options)).toBe('Invalid file type')\n })\n})\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../src/uploads/mimeTypeValidator.spec.ts"],"sourcesContent":["import { describe, it, expect } from 'vitest'\nimport type { ValidateOptions } from '../fields/config/types'\n\nimport { mimeTypeValidator } from './mimeTypeValidator'\n\nconst options = { siblingData: { filename: 'file.xyz' } } as ValidateOptions<\n undefined,\n undefined,\n undefined\n>\n\ndescribe('mimeTypeValidator', () => {\n it('should validate single mimeType', () => {\n const mimeTypes = ['image/png']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('image/png', options)).toBe(true)\n })\n\n it('should validate multiple mimeTypes', () => {\n const mimeTypes = ['image/png', 'application/pdf']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('image/png', options)).toBe(true)\n expect(validate('application/pdf', options)).toBe(true)\n })\n\n it('should validate using wildcard', () => {\n const mimeTypes = ['image/*']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('image/png', options)).toBe(true)\n expect(validate('image/gif', options)).toBe(true)\n })\n\n it('should validate multiple wildcards', () => {\n const mimeTypes = ['image/*', 'audio/*']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('image/png', options)).toBe(true)\n expect(validate('audio/mpeg', options)).toBe(true)\n })\n\n it('should not validate when unmatched', () => {\n const mimeTypes = ['image/png']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('audio/mpeg', options)).toBe(\"Invalid file type: 'audio/mpeg'\")\n })\n\n it('should not validate when unmatched - multiple mimeTypes', () => {\n const mimeTypes = ['image/png', 'application/pdf']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('audio/mpeg', options)).toBe(\"Invalid file type: 'audio/mpeg'\")\n })\n\n it('should not validate using wildcard - unmatched', () => {\n const mimeTypes = ['image/*']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('audio/mpeg', options)).toBe(\"Invalid file type: 'audio/mpeg'\")\n })\n\n it('should not validate multiple wildcards - unmatched', () => {\n const mimeTypes = ['image/*', 'audio/*']\n const validate = mimeTypeValidator(mimeTypes)\n expect(validate('video/mp4', options)).toBe(\"Invalid file type: 'video/mp4'\")\n expect(validate('application/pdf', options)).toBe(\"Invalid file type: 'application/pdf'\")\n })\n\n it('should not error when mimeType is missing', () => {\n const mimeTypes = ['image/*', 'application/pdf']\n const validate = mimeTypeValidator(mimeTypes)\n let value\n expect(validate(value, options)).toBe('Invalid file type')\n })\n})\n"],"names":["describe","it","expect","mimeTypeValidator","options","siblingData","filename","mimeTypes","validate","toBe","value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AY;YAAC;SAAU;QAC7B,MAAMC,WAAWL,kBAAkBI;QACnCL,OAAOM,SAAS,cAAcJ,UAAUK,IAAI,CAAC;IAC/C;IAEAR,GAAG,sDAAsD;QACvD,MAAMM,YAAY;YAAC;YAAW;SAAU;QACxC,MAAMC,WAAWL,kBAAkBI;QACnCL,OAAOM,SAAS,aAAaJ,UAAUK,IAAI,CAAC;QAC5CP,OAAOM,SAAS,mBAAmBJ,UAAUK,IAAI,CAAC;IACpD;IAEAR,GAAG,6CAA6C;QAC9C,MAAMM,YAAY;YAAC;YAAW;SAAkB;QAChD,MAAMC,WAAWL,kBAAkBI;QACnC,IAAIG;QACJR,OAAOM,SAASE,OAAON,UAAUK,IAAI,CAAC;IACxC;AACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
1
2
|
import { addSelectGenericsToGeneratedTypes } from './addSelectGenericsToGeneretedTypes.js';
|
|
2
3
|
const INPUT_AND_OUTPUT = [
|
|
3
4
|
{
|
|
@@ -271,7 +272,7 @@ export interface Auth {
|
|
|
271
272
|
|
|
272
273
|
|
|
273
274
|
declare module 'payload' {
|
|
274
|
-
// @ts-ignore
|
|
275
|
+
// @ts-ignore
|
|
275
276
|
export interface GeneratedTypes extends Config {}
|
|
276
277
|
}
|
|
277
278
|
`,
|
|
@@ -545,7 +546,7 @@ export interface Auth {
|
|
|
545
546
|
|
|
546
547
|
|
|
547
548
|
declare module 'payload' {
|
|
548
|
-
// @ts-ignore
|
|
549
|
+
// @ts-ignore
|
|
549
550
|
export interface GeneratedTypes extends Config {}
|
|
550
551
|
}
|
|
551
552
|
`
|