@payloadcms/tanstack-start 4.0.0-canary.34 → 4.0.0-canary.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/tanstack-start",
3
- "version": "4.0.0-canary.34",
3
+ "version": "4.0.0-canary.36",
4
4
  "description": "TanStack Start framework adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -58,8 +58,8 @@
58
58
  ],
59
59
  "dependencies": {
60
60
  "qs-esm": "^7.0.2",
61
- "@payloadcms/translations": "4.0.0-canary.34",
62
- "@payloadcms/ui": "4.0.0-canary.34"
61
+ "@payloadcms/ui": "4.0.0-canary.36",
62
+ "@payloadcms/translations": "4.0.0-canary.36"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@tanstack/react-router": "^1.120.0",
@@ -68,10 +68,10 @@
68
68
  "@types/react-dom": "^19.0.0",
69
69
  "@vitejs/plugin-react": "^6.0.0",
70
70
  "@vitejs/plugin-rsc": "^0.5.21",
71
- "react": "^19.0.0",
72
- "react-dom": "^19.0.0",
71
+ "react": "19.2.6",
72
+ "react-dom": "19.2.6",
73
73
  "vite": ">=8.0.0",
74
- "payload": "4.0.0-canary.34"
74
+ "payload": "4.0.0-canary.36"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "@tanstack/react-router": "^1.120.0",
@@ -81,7 +81,7 @@
81
81
  "react": "^19.0.0",
82
82
  "react-dom": "^19.0.0",
83
83
  "vite": ">=8.0.0",
84
- "payload": "4.0.0-canary.34"
84
+ "payload": "4.0.0-canary.36"
85
85
  },
86
86
  "peerDependenciesMeta": {
87
87
  "@vitejs/plugin-react": {
@@ -1,144 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from 'vitest';
2
- const mocks = vi.hoisted(()=>({
3
- accessUser: null,
4
- applyUserReadAccess: vi.fn(async ({ user })=>({
5
- collection: user.collection,
6
- id: user.id
7
- })),
8
- user: {
9
- collection: 'users',
10
- id: 'user-id',
11
- role: 'admin'
12
- }
13
- }));
14
- vi.mock('@payloadcms/translations', ()=>({
15
- initI18n: vi.fn(async ()=>({
16
- fallbackLanguage: 'en',
17
- language: 'en',
18
- t: (key)=>key,
19
- translations: {}
20
- }))
21
- }));
22
- vi.mock('@tanstack/react-start/server', ()=>({
23
- getRequest: ()=>new Request('http://localhost/admin')
24
- }));
25
- vi.mock('payload', ()=>({
26
- createLocalReq: vi.fn(async (options, payload)=>{
27
- const user = options.user ?? options.req.user ?? null;
28
- return {
29
- context: options.context ?? {},
30
- headers: options.req.headers,
31
- locale: 'en',
32
- payload,
33
- query: {},
34
- responseHeaders: options.req.responseHeaders,
35
- user: user && !user.collection ? {
36
- ...user,
37
- collection: payload.config.admin.user
38
- } : user
39
- };
40
- }),
41
- executeAuthStrategies: vi.fn(async ()=>({
42
- user: mocks.user
43
- })),
44
- getAccessResults: vi.fn(async ({ req })=>{
45
- mocks.accessUser = req.user;
46
- return {};
47
- }),
48
- getPayload: vi.fn(async ()=>({
49
- collections: {
50
- users: {
51
- config: {
52
- auth: {
53
- depth: 1
54
- },
55
- slug: 'users'
56
- }
57
- }
58
- },
59
- config: {
60
- admin: {
61
- user: 'users'
62
- },
63
- i18n: {
64
- fallbackLanguage: 'en',
65
- supportedLanguages: {
66
- en: {}
67
- },
68
- translations: {}
69
- }
70
- },
71
- logger: {
72
- error: vi.fn()
73
- }
74
- })),
75
- getRequestLanguage: vi.fn(()=>'en'),
76
- parseCookies: vi.fn(()=>new Map())
77
- }));
78
- vi.mock('payload/internal', ()=>({
79
- applyUserReadAccess: mocks.applyUserReadAccess
80
- }));
81
- vi.mock('./devConfigReload.server.js', ()=>({}));
82
- vi.mock('./getRequestLocale.js', ()=>({
83
- getRequestLocale: vi.fn(async ()=>({
84
- code: 'en'
85
- }))
86
- }));
87
- import { initReq } from './initReq.server.js';
88
- describe('initReq', ()=>{
89
- beforeEach(()=>{
90
- mocks.accessUser = null;
91
- mocks.applyUserReadAccess.mockClear();
92
- });
93
- it('should keep the complete req.user and return the user with read access', async ()=>{
94
- const result = await initReq({
95
- configPromise: {},
96
- importMap: {},
97
- serverAdapter: {
98
- getHeaders: async ()=>new Headers()
99
- }
100
- });
101
- expect(result.req.user).toHaveProperty('role', 'admin');
102
- expect(result.user).not.toHaveProperty('role');
103
- expect(mocks.accessUser).toHaveProperty('role', 'admin');
104
- });
105
- it('should preserve an explicit null user override', async ()=>{
106
- const result = await initReq({
107
- configPromise: {},
108
- importMap: {},
109
- overrides: {
110
- user: null
111
- },
112
- serverAdapter: {
113
- getHeaders: async ()=>new Headers()
114
- }
115
- });
116
- expect(result.req.user).toBeNull();
117
- expect(result.user).toBeNull();
118
- expect(mocks.accessUser).toBeNull();
119
- expect(mocks.applyUserReadAccess).not.toHaveBeenCalled();
120
- });
121
- it('should preserve a normalized explicit user override', async ()=>{
122
- const result = await initReq({
123
- configPromise: {},
124
- importMap: {},
125
- overrides: {
126
- user: {
127
- id: 'override-user'
128
- }
129
- },
130
- serverAdapter: {
131
- getHeaders: async ()=>new Headers()
132
- }
133
- });
134
- expect(result.req.user).toMatchObject({
135
- collection: 'users',
136
- id: 'override-user'
137
- });
138
- expect(result.user).toBe(result.req.user);
139
- expect(mocks.accessUser).toBe(result.req.user);
140
- expect(mocks.applyUserReadAccess).not.toHaveBeenCalled();
141
- });
142
- });
143
-
144
- //# sourceMappingURL=initReq.server.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/initReq.server.spec.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { beforeEach, describe, expect, it, vi } from 'vitest'\n\nconst mocks = vi.hoisted(() => ({\n accessUser: null as PayloadRequest['user'],\n applyUserReadAccess: vi.fn(async ({ user }: { user: NonNullable<PayloadRequest['user']> }) => ({\n collection: user.collection,\n id: user.id,\n })),\n user: {\n collection: 'users',\n id: 'user-id',\n role: 'admin',\n } as PayloadRequest['user'],\n}))\n\nvi.mock('@payloadcms/translations', () => ({\n initI18n: vi.fn(async () => ({\n fallbackLanguage: 'en',\n language: 'en',\n t: (key: string) => key,\n translations: {},\n })),\n}))\n\nvi.mock('@tanstack/react-start/server', () => ({\n getRequest: () => new Request('http://localhost/admin'),\n}))\n\nvi.mock('payload', () => ({\n createLocalReq: vi.fn(async (options, payload) => {\n const user = options.user ?? options.req.user ?? null\n\n return {\n context: options.context ?? {},\n headers: options.req.headers,\n locale: 'en',\n payload,\n query: {},\n responseHeaders: options.req.responseHeaders,\n user: user && !user.collection ? { ...user, collection: payload.config.admin.user } : user,\n }\n }),\n executeAuthStrategies: vi.fn(async () => ({ user: mocks.user })),\n getAccessResults: vi.fn(async ({ req }: { req: PayloadRequest }) => {\n mocks.accessUser = req.user\n return {}\n }),\n getPayload: vi.fn(async () => ({\n collections: {\n users: {\n config: {\n auth: { depth: 1 },\n slug: 'users',\n },\n },\n },\n config: {\n admin: { user: 'users' },\n i18n: {\n fallbackLanguage: 'en',\n supportedLanguages: { en: {} },\n translations: {},\n },\n },\n logger: { error: vi.fn() },\n })),\n getRequestLanguage: vi.fn(() => 'en'),\n parseCookies: vi.fn(() => new Map()),\n}))\n\nvi.mock('payload/internal', () => ({\n applyUserReadAccess: mocks.applyUserReadAccess,\n}))\n\nvi.mock('./devConfigReload.server.js', () => ({}))\n\nvi.mock('./getRequestLocale.js', () => ({\n getRequestLocale: vi.fn(async () => ({ code: 'en' })),\n}))\n\nimport { initReq } from './initReq.server.js'\n\ndescribe('initReq', () => {\n beforeEach(() => {\n mocks.accessUser = null\n mocks.applyUserReadAccess.mockClear()\n })\n\n it('should keep the complete req.user and return the user with read access', async () => {\n const result = await initReq({\n configPromise: {} as never,\n importMap: {},\n serverAdapter: { getHeaders: async () => new Headers() } as never,\n })\n\n expect(result.req.user).toHaveProperty('role', 'admin')\n expect(result.user).not.toHaveProperty('role')\n expect(mocks.accessUser).toHaveProperty('role', 'admin')\n })\n\n it('should preserve an explicit null user override', async () => {\n const result = await initReq({\n configPromise: {} as never,\n importMap: {},\n overrides: { user: null } as never,\n serverAdapter: { getHeaders: async () => new Headers() } as never,\n })\n\n expect(result.req.user).toBeNull()\n expect(result.user).toBeNull()\n expect(mocks.accessUser).toBeNull()\n expect(mocks.applyUserReadAccess).not.toHaveBeenCalled()\n })\n\n it('should preserve a normalized explicit user override', async () => {\n const result = await initReq({\n configPromise: {} as never,\n importMap: {},\n overrides: { user: { id: 'override-user' } } as never,\n serverAdapter: { getHeaders: async () => new Headers() } as never,\n })\n\n expect(result.req.user).toMatchObject({ collection: 'users', id: 'override-user' })\n expect(result.user).toBe(result.req.user)\n expect(mocks.accessUser).toBe(result.req.user)\n expect(mocks.applyUserReadAccess).not.toHaveBeenCalled()\n })\n})\n"],"names":["beforeEach","describe","expect","it","vi","mocks","hoisted","accessUser","applyUserReadAccess","fn","user","collection","id","role","mock","initI18n","fallbackLanguage","language","t","key","translations","getRequest","Request","createLocalReq","options","payload","req","context","headers","locale","query","responseHeaders","config","admin","executeAuthStrategies","getAccessResults","getPayload","collections","users","auth","depth","slug","i18n","supportedLanguages","en","logger","error","getRequestLanguage","parseCookies","Map","getRequestLocale","code","initReq","mockClear","result","configPromise","importMap","serverAdapter","getHeaders","Headers","toHaveProperty","not","overrides","toBeNull","toHaveBeenCalled","toMatchObject","toBe"],"mappings":"AAEA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,SAAQ;AAE7D,MAAMC,QAAQD,GAAGE,OAAO,CAAC,IAAO,CAAA;QAC9BC,YAAY;QACZC,qBAAqBJ,GAAGK,EAAE,CAAC,OAAO,EAAEC,IAAI,EAAiD,GAAM,CAAA;gBAC7FC,YAAYD,KAAKC,UAAU;gBAC3BC,IAAIF,KAAKE,EAAE;YACb,CAAA;QACAF,MAAM;YACJC,YAAY;YACZC,IAAI;YACJC,MAAM;QACR;IACF,CAAA;AAEAT,GAAGU,IAAI,CAAC,4BAA4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AO5B,GAAG,CAAChB,IAAI,EAAEqD,QAAQ;QAChC7D,OAAOoD,OAAO5C,IAAI,EAAEqD,QAAQ;QAC5B7D,OAAOG,MAAME,UAAU,EAAEwD,QAAQ;QACjC7D,OAAOG,MAAMG,mBAAmB,EAAEqD,GAAG,CAACG,gBAAgB;IACxD;IAEA7D,GAAG,uDAAuD;QACxD,MAAMmD,SAAS,MAAMF,QAAQ;YAC3BG,eAAe,CAAC;YAChBC,WAAW,CAAC;YACZM,WAAW;gBAAEpD,MAAM;oBAAEE,IAAI;gBAAgB;YAAE;YAC3C6C,eAAe;gBAAEC,YAAY,UAAY,IAAIC;YAAU;QACzD;QAEAzD,OAAOoD,OAAO5B,GAAG,CAAChB,IAAI,EAAEuD,aAAa,CAAC;YAAEtD,YAAY;YAASC,IAAI;QAAgB;QACjFV,OAAOoD,OAAO5C,IAAI,EAAEwD,IAAI,CAACZ,OAAO5B,GAAG,CAAChB,IAAI;QACxCR,OAAOG,MAAME,UAAU,EAAE2D,IAAI,CAACZ,OAAO5B,GAAG,CAAChB,IAAI;QAC7CR,OAAOG,MAAMG,mBAAmB,EAAEqD,GAAG,CAACG,gBAAgB;IACxD;AACF"}
@@ -1,24 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { serializeForRsc } from './serializeForRsc.js';
3
- import { stripUnserializable } from './serverFunctionClient.js';
4
- import { toSerializable } from './toSerializable.js';
5
- describe('TanStack serializers', ()=>{
6
- it('should copy special JSON keys as own data', async ()=>{
7
- const input = JSON.parse('{"__proto__":{"label":"value"}}');
8
- const results = [
9
- toSerializable(input),
10
- stripUnserializable(input),
11
- await serializeForRsc(input)
12
- ];
13
- for (const result of results){
14
- expect(Object.getPrototypeOf(result)).toBe(Object.prototype);
15
- expect(Object.hasOwn(result, '__proto__')).toBe(true);
16
- expect(Reflect.get(result, '__proto__')).toEqual({
17
- label: 'value'
18
- });
19
- expect(Reflect.get(result, 'label')).toBeUndefined();
20
- }
21
- });
22
- });
23
-
24
- //# sourceMappingURL=serializers.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/serializers.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { serializeForRsc } from './serializeForRsc.js'\nimport { stripUnserializable } from './serverFunctionClient.js'\nimport { toSerializable } from './toSerializable.js'\n\ndescribe('TanStack serializers', () => {\n it('should copy special JSON keys as own data', async () => {\n const input = JSON.parse('{\"__proto__\":{\"label\":\"value\"}}')\n const results = [\n toSerializable(input),\n stripUnserializable(input),\n await serializeForRsc(input),\n ]\n\n for (const result of results) {\n expect(Object.getPrototypeOf(result)).toBe(Object.prototype)\n expect(Object.hasOwn(result, '__proto__')).toBe(true)\n expect(Reflect.get(result, '__proto__')).toEqual({ label: 'value' })\n expect(Reflect.get(result, 'label')).toBeUndefined()\n }\n })\n})\n"],"names":["describe","expect","it","serializeForRsc","stripUnserializable","toSerializable","input","JSON","parse","results","result","Object","getPrototypeOf","toBe","prototype","hasOwn","Reflect","get","toEqual","label","toBeUndefined"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,mBAAmB,QAAQ,4BAA2B;AAC/D,SAASC,cAAc,QAAQ,sBAAqB;AAEpDL,SAAS,wBAAwB;IAC/BE,GAAG,6CAA6C;QAC9C,MAAMI,QAAQC,KAAKC,KAAK,CAAC;QACzB,MAAMC,UAAU;YACdJ,eAAeC;YACfF,oBAAoBE;YACpB,MAAMH,gBAAgBG;SACvB;QAED,KAAK,MAAMI,UAAUD,QAAS;YAC5BR,OAAOU,OAAOC,cAAc,CAACF,SAASG,IAAI,CAACF,OAAOG,SAAS;YAC3Db,OAAOU,OAAOI,MAAM,CAACL,QAAQ,cAAcG,IAAI,CAAC;YAChDZ,OAAOe,QAAQC,GAAG,CAACP,QAAQ,cAAcQ,OAAO,CAAC;gBAAEC,OAAO;YAAQ;YAClElB,OAAOe,QAAQC,GAAG,CAACP,QAAQ,UAAUU,aAAa;QACpD;IACF;AACF"}