@latte-macchiat-io/latte-payload 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +9 -0
- package/.env.example +29 -0
- package/.github/workflows/ci.yml +160 -0
- package/.github/workflows/publish.yml +126 -0
- package/.nvmrc +1 -0
- package/.prettierignore +2 -0
- package/.prettierrc +11 -0
- package/CHANGELOG.md +87 -0
- package/README.md +364 -0
- package/TESTING_AND_DOCUMENTATION_SETUP.md +348 -0
- package/dist/access/adminAccessOnly.d.ts +25 -0
- package/dist/access/adminAccessOnly.d.ts.map +1 -0
- package/dist/access/adminAccessOnly.js +11 -0
- package/dist/access/adminAccessOnly.js.map +1 -0
- package/dist/access/admins.d.ts +72 -0
- package/dist/access/admins.d.ts.map +1 -0
- package/dist/access/admins.js +76 -0
- package/dist/access/admins.js.map +1 -0
- package/dist/access/anyone.d.ts +35 -0
- package/dist/access/anyone.d.ts.map +1 -0
- package/dist/access/anyone.js +34 -0
- package/dist/access/anyone.js.map +1 -0
- package/dist/access/authenticated.d.ts +63 -0
- package/dist/access/authenticated.d.ts.map +1 -0
- package/dist/access/authenticated.js +68 -0
- package/dist/access/authenticated.js.map +1 -0
- package/dist/access/authenticatedAccessOnly.d.ts +13 -0
- package/dist/access/authenticatedAccessOnly.d.ts.map +1 -0
- package/dist/access/authenticatedAccessOnly.js +11 -0
- package/dist/access/authenticatedAccessOnly.js.map +1 -0
- package/dist/access/index.d.ts +7 -0
- package/dist/access/index.d.ts.map +1 -0
- package/dist/access/index.js +7 -0
- package/dist/access/index.js.map +1 -0
- package/dist/access/publicReadAuthenticatedAccess.d.ts +13 -0
- package/dist/access/publicReadAuthenticatedAccess.d.ts.map +1 -0
- package/dist/access/publicReadAuthenticatedAccess.js +12 -0
- package/dist/access/publicReadAuthenticatedAccess.js.map +1 -0
- package/dist/collections/ContactMessages/hooks/sendEmailNotification.d.ts +31 -0
- package/dist/collections/ContactMessages/hooks/sendEmailNotification.d.ts.map +1 -0
- package/dist/collections/ContactMessages/hooks/sendEmailNotification.js +29 -0
- package/dist/collections/ContactMessages/hooks/sendEmailNotification.js.map +1 -0
- package/dist/collections/ContactMessages/index.d.ts +27 -0
- package/dist/collections/ContactMessages/index.d.ts.map +1 -0
- package/dist/collections/ContactMessages/index.js +81 -0
- package/dist/collections/ContactMessages/index.js.map +1 -0
- package/dist/collections/EmailTemplates/index.d.ts +26 -0
- package/dist/collections/EmailTemplates/index.d.ts.map +1 -0
- package/dist/collections/EmailTemplates/index.js +74 -0
- package/dist/collections/EmailTemplates/index.js.map +1 -0
- package/dist/collections/Media/index.d.ts +3 -0
- package/dist/collections/Media/index.d.ts.map +1 -0
- package/dist/collections/Media/index.js +22 -0
- package/dist/collections/Media/index.js.map +1 -0
- package/dist/collections/QueuedEmails/components/HtmlViewer.d.ts +3 -0
- package/dist/collections/QueuedEmails/components/HtmlViewer.d.ts.map +1 -0
- package/dist/collections/QueuedEmails/components/HtmlViewer.js +11 -0
- package/dist/collections/QueuedEmails/components/HtmlViewer.js.map +1 -0
- package/dist/collections/QueuedEmails/components/RetryEmailButtons.d.ts +2 -0
- package/dist/collections/QueuedEmails/components/RetryEmailButtons.d.ts.map +1 -0
- package/dist/collections/QueuedEmails/components/RetryEmailButtons.js +79 -0
- package/dist/collections/QueuedEmails/components/RetryEmailButtons.js.map +1 -0
- package/dist/collections/QueuedEmails/index.d.ts +3 -0
- package/dist/collections/QueuedEmails/index.d.ts.map +1 -0
- package/dist/collections/QueuedEmails/index.js +245 -0
- package/dist/collections/QueuedEmails/index.js.map +1 -0
- package/dist/collections/Users/auth-emails/forgot-password-email.d.ts +51 -0
- package/dist/collections/Users/auth-emails/forgot-password-email.d.ts.map +1 -0
- package/dist/collections/Users/auth-emails/forgot-password-email.js +90 -0
- package/dist/collections/Users/auth-emails/forgot-password-email.js.map +1 -0
- package/dist/collections/Users/auth-emails/verify-email.d.ts +51 -0
- package/dist/collections/Users/auth-emails/verify-email.d.ts.map +1 -0
- package/dist/collections/Users/auth-emails/verify-email.js +80 -0
- package/dist/collections/Users/auth-emails/verify-email.js.map +1 -0
- package/dist/collections/Users/hooks/ensureFirstUserIsAdmin.d.ts +3 -0
- package/dist/collections/Users/hooks/ensureFirstUserIsAdmin.d.ts.map +1 -0
- package/dist/collections/Users/hooks/ensureFirstUserIsAdmin.js +19 -0
- package/dist/collections/Users/hooks/ensureFirstUserIsAdmin.js.map +1 -0
- package/dist/collections/Users/index.d.ts +76 -0
- package/dist/collections/Users/index.d.ts.map +1 -0
- package/dist/collections/Users/index.js +116 -0
- package/dist/collections/Users/index.js.map +1 -0
- package/dist/collections/index.d.ts +10 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/index.js +14 -0
- package/dist/collections/index.js.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -0
- package/dist/forms/states.d.ts +8 -0
- package/dist/forms/states.d.ts.map +1 -0
- package/dist/forms/states.js +16 -0
- package/dist/forms/states.js.map +1 -0
- package/dist/forms/translate-errors.d.ts +8 -0
- package/dist/forms/translate-errors.d.ts.map +1 -0
- package/dist/forms/translate-errors.js +11 -0
- package/dist/forms/translate-errors.js.map +1 -0
- package/dist/forms/validators.d.ts +10 -0
- package/dist/forms/validators.d.ts.map +1 -0
- package/dist/forms/validators.js +23 -0
- package/dist/forms/validators.js.map +1 -0
- package/dist/globals/PrivacyPolicy/hooks/revalidate-cache.d.ts +2 -0
- package/dist/globals/PrivacyPolicy/hooks/revalidate-cache.d.ts.map +1 -0
- package/dist/globals/PrivacyPolicy/hooks/revalidate-cache.js +5 -0
- package/dist/globals/PrivacyPolicy/hooks/revalidate-cache.js.map +1 -0
- package/dist/globals/PrivacyPolicy/index.d.ts +3 -0
- package/dist/globals/PrivacyPolicy/index.d.ts.map +1 -0
- package/dist/globals/PrivacyPolicy/index.js +31 -0
- package/dist/globals/PrivacyPolicy/index.js.map +1 -0
- package/dist/globals/TermsOfUse/hooks/revalidate-cache.d.ts +2 -0
- package/dist/globals/TermsOfUse/hooks/revalidate-cache.d.ts.map +1 -0
- package/dist/globals/TermsOfUse/hooks/revalidate-cache.js +5 -0
- package/dist/globals/TermsOfUse/hooks/revalidate-cache.js.map +1 -0
- package/dist/globals/TermsOfUse/index.d.ts +3 -0
- package/dist/globals/TermsOfUse/index.d.ts.map +1 -0
- package/dist/globals/TermsOfUse/index.js +31 -0
- package/dist/globals/TermsOfUse/index.js.map +1 -0
- package/dist/globals/index.d.ts +3 -0
- package/dist/globals/index.d.ts.map +1 -0
- package/dist/globals/index.js +3 -0
- package/dist/globals/index.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/tasks/index.d.ts +2 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +2 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/tasks/process-email-queue.d.ts +46 -0
- package/dist/tasks/process-email-queue.d.ts.map +1 -0
- package/dist/tasks/process-email-queue.js +199 -0
- package/dist/tasks/process-email-queue.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/slug.d.ts +2 -0
- package/dist/types/slug.d.ts.map +1 -0
- package/dist/types/slug.js +11 -0
- package/dist/types/slug.js.map +1 -0
- package/dist/utils/database-dates.d.ts +3 -0
- package/dist/utils/database-dates.d.ts.map +1 -0
- package/dist/utils/database-dates.js +6 -0
- package/dist/utils/database-dates.js.map +1 -0
- package/dist/utils/email/generate-email-html.d.ts +23 -0
- package/dist/utils/email/generate-email-html.d.ts.map +1 -0
- package/dist/utils/email/generate-email-html.js +42 -0
- package/dist/utils/email/generate-email-html.js.map +1 -0
- package/dist/utils/email/get-email-template.d.ts +8 -0
- package/dist/utils/email/get-email-template.d.ts.map +1 -0
- package/dist/utils/email/get-email-template.js +14 -0
- package/dist/utils/email/get-email-template.js.map +1 -0
- package/dist/utils/email/index.d.ts +4 -0
- package/dist/utils/email/index.d.ts.map +1 -0
- package/dist/utils/email/index.js +4 -0
- package/dist/utils/email/index.js.map +1 -0
- package/dist/utils/email/queue-email.d.ts +29 -0
- package/dist/utils/email/queue-email.d.ts.map +1 -0
- package/dist/utils/email/queue-email.js +79 -0
- package/dist/utils/email/queue-email.js.map +1 -0
- package/dist/utils/get-global.d.ts +6 -0
- package/dist/utils/get-global.d.ts.map +1 -0
- package/dist/utils/get-global.js +20 -0
- package/dist/utils/get-global.js.map +1 -0
- package/dist/utils/id-from-payload.d.ts +4 -0
- package/dist/utils/id-from-payload.d.ts.map +1 -0
- package/dist/utils/id-from-payload.js +10 -0
- package/dist/utils/id-from-payload.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/migrations.d.ts +2 -0
- package/dist/utils/migrations.d.ts.map +1 -0
- package/dist/utils/migrations.js +18 -0
- package/dist/utils/migrations.js.map +1 -0
- package/dist/utils/payload-client.d.ts +10 -0
- package/dist/utils/payload-client.d.ts.map +1 -0
- package/dist/utils/payload-client.js +14 -0
- package/dist/utils/payload-client.js.map +1 -0
- package/dist/utils/slugify.d.ts +8 -0
- package/dist/utils/slugify.d.ts.map +1 -0
- package/dist/utils/slugify.js +15 -0
- package/dist/utils/slugify.js.map +1 -0
- package/eslint.config.mjs +90 -0
- package/package.json +139 -0
- package/pnpm-workspace.yaml +4 -0
- package/src/access/adminAccessOnly.ts +13 -0
- package/src/access/admins.ts +78 -0
- package/src/access/anyone.ts +35 -0
- package/src/access/authenticated.ts +70 -0
- package/src/access/authenticatedAccessOnly.ts +13 -0
- package/src/access/index.ts +6 -0
- package/src/access/publicReadAuthenticatedAccess.ts +14 -0
- package/src/collections/ContactMessages/hooks/sendEmailNotification.ts +58 -0
- package/src/collections/ContactMessages/index.ts +100 -0
- package/src/collections/EmailTemplates/index.ts +89 -0
- package/src/collections/Media/index.ts +24 -0
- package/src/collections/QueuedEmails/components/HtmlViewer.tsx +16 -0
- package/src/collections/QueuedEmails/components/RetryEmailButtons.tsx +115 -0
- package/src/collections/QueuedEmails/index.ts +246 -0
- package/src/collections/Users/auth-emails/forgot-password-email.ts +135 -0
- package/src/collections/Users/auth-emails/verify-email.ts +123 -0
- package/src/collections/Users/hooks/ensureFirstUserIsAdmin.ts +22 -0
- package/src/collections/Users/index.ts +201 -0
- package/src/collections/index.ts +23 -0
- package/src/components/index.ts +3 -0
- package/src/forms/states.ts +23 -0
- package/src/forms/translate-errors.ts +13 -0
- package/src/forms/validators.ts +33 -0
- package/src/globals/PrivacyPolicy/hooks/revalidate-cache.ts +5 -0
- package/src/globals/PrivacyPolicy/index.ts +33 -0
- package/src/globals/TermsOfUse/hooks/revalidate-cache.ts +5 -0
- package/src/globals/TermsOfUse/index.ts +33 -0
- package/src/globals/index.ts +2 -0
- package/src/index.ts +26 -0
- package/src/tasks/index.ts +7 -0
- package/src/tasks/process-email-queue.ts +261 -0
- package/src/types/index.ts +15 -0
- package/src/types/slug.ts +11 -0
- package/src/utils/database-dates.ts +6 -0
- package/src/utils/email/generate-email-html.ts +63 -0
- package/src/utils/email/get-email-template.ts +18 -0
- package/src/utils/email/index.ts +3 -0
- package/src/utils/email/queue-email.ts +109 -0
- package/src/utils/get-global.ts +25 -0
- package/src/utils/id-from-payload.ts +11 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/migrations.ts +18 -0
- package/src/utils/payload-client.ts +16 -0
- package/src/utils/slugify.ts +21 -0
- package/tests/fixtures/email-template.html +58 -0
- package/tests/fixtures/sample-data.ts +56 -0
- package/tests/helpers/create-test-user.ts +37 -0
- package/tests/helpers/init-payload.ts +59 -0
- package/tests/setup.integration.ts +9 -0
- package/tests/setup.ts +4 -0
- package/tests/unit/access/adminAccessOnly.spec.ts +117 -0
- package/tests/unit/access/admins.spec.ts +68 -0
- package/tests/unit/access/anyone.spec.ts +28 -0
- package/tests/unit/access/authenticated.spec.ts +53 -0
- package/tests/unit/access/authenticatedAccessOnly.spec.ts +112 -0
- package/tests/unit/access/publicReadAuthenticatedAccess.spec.ts +112 -0
- package/tests/unit/forms/validators.spec.ts +348 -0
- package/tests/unit/utils/database-dates.spec.ts +97 -0
- package/tests/unit/utils/id-from-payload.spec.ts +142 -0
- package/tests/unit/utils/slugify.spec.ts +185 -0
- package/tsconfig.json +31 -0
- package/typedoc.json +40 -0
- package/vitest.config.ts +31 -0
- package/vitest.integration.config.ts +27 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { slugify } from '@/utils/slugify';
|
|
3
|
+
|
|
4
|
+
describe('slugify utility', () => {
|
|
5
|
+
describe('basic functionality', () => {
|
|
6
|
+
it('should convert string to lowercase slug', () => {
|
|
7
|
+
expect(slugify('Hello World')).toBe('hello-world');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should handle empty strings', () => {
|
|
11
|
+
expect(slugify('')).toBe('');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should handle undefined (uses default empty string)', () => {
|
|
15
|
+
expect(slugify(undefined as any)).toBe('');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should trim whitespace by default', () => {
|
|
19
|
+
expect(slugify(' hello ')).toBe('hello');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should replace spaces with hyphens', () => {
|
|
23
|
+
expect(slugify('hello world test')).toBe('hello-world-test');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should handle multiple consecutive spaces', () => {
|
|
27
|
+
expect(slugify('hello world')).toBe('hello-world');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('special character removal', () => {
|
|
32
|
+
it('should remove question marks', () => {
|
|
33
|
+
expect(slugify('Hello?')).toBe('hello');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should remove exclamation marks', () => {
|
|
37
|
+
expect(slugify('Hello!')).toBe('hello');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should remove parentheses', () => {
|
|
41
|
+
expect(slugify('Hello (World)')).toBe('hello-world');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should remove quotes', () => {
|
|
45
|
+
expect(slugify('Hello \'World\' "Test"')).toBe('hello-world-test');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should remove or replace special characters', () => {
|
|
49
|
+
expect(slugify('a*b+c~d.e(f)g\'h"i!j:k@l')).toBe('abcdefghijkl');
|
|
50
|
+
// Note: slugify converts some chars to words (< = less, > = greater, & = and, | = or, % = percent, $ = dollar)
|
|
51
|
+
const result = slugify('a<b>c&d|e%f$g');
|
|
52
|
+
expect(result).toContain('a');
|
|
53
|
+
expect(result).toContain('g');
|
|
54
|
+
// Just verify it's a valid slug
|
|
55
|
+
expect(result).toMatch(/^[a-z0-9-]+$/);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should keep alphanumeric characters', () => {
|
|
59
|
+
expect(slugify('abc123xyz')).toBe('abc123xyz');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should handle accented characters', () => {
|
|
63
|
+
expect(slugify('Café')).toBe('cafe');
|
|
64
|
+
expect(slugify('naïve')).toBe('naive');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('options: trim', () => {
|
|
69
|
+
it('should trim when trim is true', () => {
|
|
70
|
+
expect(slugify(' hello ', { trim: true })).toBe('hello');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should not trim when trim is false', () => {
|
|
74
|
+
const result = slugify(' hello ', { trim: false });
|
|
75
|
+
expect(result).not.toBe('hello');
|
|
76
|
+
expect(result).toMatch(/hello/);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should trim by default', () => {
|
|
80
|
+
expect(slugify(' hello ')).toBe('hello');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('options: lower', () => {
|
|
85
|
+
it('should convert to lowercase when lower is true', () => {
|
|
86
|
+
expect(slugify('HELLO WORLD', { lower: true })).toBe('hello-world');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should preserve case when lower is false', () => {
|
|
90
|
+
expect(slugify('HELLO WORLD', { lower: false })).toBe('HELLO-WORLD');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should convert to lowercase by default', () => {
|
|
94
|
+
expect(slugify('HELLO WORLD')).toBe('hello-world');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('options: locale', () => {
|
|
99
|
+
it('should handle French locale', () => {
|
|
100
|
+
expect(slugify('Café', { locale: 'fr' })).toBe('cafe');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should handle German locale with umlauts', () => {
|
|
104
|
+
// Note: slugify may transliterate differently depending on locale
|
|
105
|
+
const result = slugify('Über', { locale: 'de' });
|
|
106
|
+
expect(result).toMatch(/^(uber|ueber)$/); // Can be either depending on transliteration
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should work without locale option', () => {
|
|
110
|
+
expect(slugify('Café')).toBe('cafe');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('options: remove (custom removal pattern)', () => {
|
|
115
|
+
it('should use custom remove pattern', () => {
|
|
116
|
+
// The remove option removes characters before slugification
|
|
117
|
+
const result = slugify('a@b#c', { remove: /@/g });
|
|
118
|
+
expect(result).toContain('b');
|
|
119
|
+
expect(result).not.toContain('@');
|
|
120
|
+
// Note: custom remove doesn't override default behavior, it adds to it
|
|
121
|
+
// The # may or may not be present depending on how the library processes it
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should remove multiple custom characters', () => {
|
|
125
|
+
const result = slugify('a@b@c', { remove: /@/g });
|
|
126
|
+
expect(result).not.toContain('@');
|
|
127
|
+
expect(result).toMatch(/^[a-z0-9-]+$/);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should remove specified pattern', () => {
|
|
131
|
+
// Custom remove pattern removes the specified characters
|
|
132
|
+
const result = slugify('a@b#c', { remove: /@/g });
|
|
133
|
+
expect(result).not.toContain('@');
|
|
134
|
+
// # is handled by default remove pattern
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('combined options', () => {
|
|
139
|
+
it('should handle multiple options together', () => {
|
|
140
|
+
expect(
|
|
141
|
+
slugify(' Café WORLD! ', {
|
|
142
|
+
trim: true,
|
|
143
|
+
lower: true,
|
|
144
|
+
locale: 'fr',
|
|
145
|
+
})
|
|
146
|
+
).toBe('cafe-world');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should handle trim=false and lower=false', () => {
|
|
150
|
+
const result = slugify(' HELLO ', { trim: false, lower: false });
|
|
151
|
+
expect(result).toMatch(/HELLO/);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe('edge cases', () => {
|
|
156
|
+
it('should handle single character', () => {
|
|
157
|
+
expect(slugify('a')).toBe('a');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('should handle numbers only', () => {
|
|
161
|
+
expect(slugify('123')).toBe('123');
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('should handle hyphenated strings', () => {
|
|
165
|
+
expect(slugify('hello-world')).toBe('hello-world');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('should handle underscores', () => {
|
|
169
|
+
expect(slugify('hello_world')).toBe('hello_world');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('should handle mixed case with numbers', () => {
|
|
173
|
+
expect(slugify('Test123ABC')).toBe('test123abc');
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('should handle strings with only special characters', () => {
|
|
177
|
+
expect(slugify('!!!')).toBe('');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('should handle long strings', () => {
|
|
181
|
+
const long = 'a'.repeat(100);
|
|
182
|
+
expect(slugify(long)).toBe(long);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"checkJs": false,
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"rootDir": "./src",
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"strict": true,
|
|
16
|
+
"noUnusedLocals": true,
|
|
17
|
+
"noUnusedParameters": true,
|
|
18
|
+
"noFallthroughCasesInSwitch": true,
|
|
19
|
+
"esModuleInterop": true,
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
"forceConsistentCasingInFileNames": true,
|
|
22
|
+
"jsx": "react-jsx",
|
|
23
|
+
"types": ["node"],
|
|
24
|
+
"baseUrl": ".",
|
|
25
|
+
"paths": {
|
|
26
|
+
"@/*": ["./src/*"]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"include": ["src/**/*"],
|
|
30
|
+
"exclude": ["node_modules", "dist"]
|
|
31
|
+
}
|
package/typedoc.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://typedoc.org/schema.json",
|
|
3
|
+
"name": "@latte-macchiat-io/latte-payload",
|
|
4
|
+
"entryPoints": ["src/index.ts"],
|
|
5
|
+
"out": "docs",
|
|
6
|
+
"readme": "README.md",
|
|
7
|
+
"tsconfig": "tsconfig.json",
|
|
8
|
+
"exclude": [
|
|
9
|
+
"**/*.spec.ts",
|
|
10
|
+
"**/*.test.ts",
|
|
11
|
+
"**/node_modules/**",
|
|
12
|
+
"**/dist/**",
|
|
13
|
+
"**/tests/**"
|
|
14
|
+
],
|
|
15
|
+
"excludePrivate": true,
|
|
16
|
+
"excludeProtected": false,
|
|
17
|
+
"excludeInternal": true,
|
|
18
|
+
"includeVersion": true,
|
|
19
|
+
"sort": ["source-order"],
|
|
20
|
+
"categorizeByGroup": true,
|
|
21
|
+
"categoryOrder": [
|
|
22
|
+
"Collections",
|
|
23
|
+
"Globals",
|
|
24
|
+
"Access Control",
|
|
25
|
+
"Utilities",
|
|
26
|
+
"Components",
|
|
27
|
+
"Tasks",
|
|
28
|
+
"Types",
|
|
29
|
+
"*"
|
|
30
|
+
],
|
|
31
|
+
"navigation": {
|
|
32
|
+
"includeCategories": true,
|
|
33
|
+
"includeGroups": true
|
|
34
|
+
},
|
|
35
|
+
"theme": "default",
|
|
36
|
+
"githubPages": false,
|
|
37
|
+
"hideGenerator": false,
|
|
38
|
+
"searchInComments": true,
|
|
39
|
+
"searchInDocuments": true
|
|
40
|
+
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
name: 'latte-payload-unit',
|
|
7
|
+
globals: true,
|
|
8
|
+
environment: 'node',
|
|
9
|
+
setupFiles: ['./tests/setup.ts'],
|
|
10
|
+
include: ['tests/unit/**/*.spec.ts'],
|
|
11
|
+
exclude: ['**/node_modules/**', '**/dist/**'],
|
|
12
|
+
coverage: {
|
|
13
|
+
provider: 'v8',
|
|
14
|
+
reporter: ['text', 'json', 'html', 'lcov'],
|
|
15
|
+
reportsDirectory: './coverage',
|
|
16
|
+
include: ['src/**/*.ts', 'src/**/*.tsx'],
|
|
17
|
+
exclude: ['src/**/*.d.ts', 'src/**/index.ts', 'src/types/**'],
|
|
18
|
+
thresholds: {
|
|
19
|
+
lines: 60,
|
|
20
|
+
functions: 60,
|
|
21
|
+
branches: 60,
|
|
22
|
+
statements: 60,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
resolve: {
|
|
27
|
+
alias: {
|
|
28
|
+
'@': path.resolve(__dirname, './src'),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
name: 'latte-payload-integration',
|
|
7
|
+
globals: true,
|
|
8
|
+
environment: 'node',
|
|
9
|
+
setupFiles: ['./tests/setup.integration.ts'],
|
|
10
|
+
include: ['tests/integration/**/*.int.spec.ts'],
|
|
11
|
+
exclude: ['**/node_modules/**', '**/dist/**'],
|
|
12
|
+
testTimeout: 90000, // 90 seconds for Payload operations
|
|
13
|
+
hookTimeout: 90000,
|
|
14
|
+
fileParallelism: false, // Sequential execution for database tests
|
|
15
|
+
pool: 'forks',
|
|
16
|
+
poolOptions: {
|
|
17
|
+
forks: {
|
|
18
|
+
singleFork: true, // Single process to avoid database conflicts
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
resolve: {
|
|
23
|
+
alias: {
|
|
24
|
+
'@': path.resolve(__dirname, './src'),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|