@payloadcms/figma 0.0.1-alpha.44 → 0.0.1-alpha.46
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/api/control-plane.d.ts.map +1 -1
- package/dist/api/control-plane.js +90 -54
- package/dist/api/control-plane.js.map +1 -1
- package/dist/api/figma-api.d.ts +20 -0
- package/dist/api/figma-api.d.ts.map +1 -1
- package/dist/api/figma-api.js +34 -0
- package/dist/api/figma-api.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/debug.d.ts +8 -0
- package/dist/commands/debug.d.ts.map +1 -0
- package/dist/commands/debug.js +156 -0
- package/dist/commands/debug.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +17 -14
- package/dist/commands/init.js.map +1 -1
- package/dist/db-content-api/index.d.ts.map +1 -1
- package/dist/db-content-api/index.js +26 -7
- package/dist/db-content-api/index.js.map +1 -1
- package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
- package/dist/db-content-api/temp-utilities/types.d.ts.map +1 -0
- package/dist/db-content-api/temp-utilities/types.js +15 -0
- package/dist/db-content-api/temp-utilities/types.js.map +1 -0
- package/dist/db-content-api/utilities/data/index.d.ts +14 -4
- package/dist/db-content-api/utilities/data/index.d.ts.map +1 -1
- package/dist/db-content-api/utilities/data/index.js +15 -8
- package/dist/db-content-api/utilities/data/index.js.map +1 -1
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts.map +1 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js.map +1 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts.map +1 -1
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js.map +1 -1
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +17 -2
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts.map +1 -1
- package/dist/db-content-api/utilities/meta/buildMeta.js +4 -1
- package/dist/db-content-api/utilities/meta/buildMeta.js.map +1 -1
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +8 -2
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts.map +1 -1
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +41 -11
- package/dist/db-content-api/utilities/meta/buildPathTypes.js.map +1 -1
- package/dist/db-content-api/utilities/where.d.ts +8 -0
- package/dist/db-content-api/utilities/where.d.ts.map +1 -1
- package/dist/db-content-api/utilities/where.js +6 -0
- package/dist/db-content-api/utilities/where.js.map +1 -1
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +2 -0
- package/dist/exports/client.js.map +1 -1
- package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts.map +1 -0
- package/dist/oauth/components/FigmaAvatar/index.js +27 -0
- package/dist/oauth/components/FigmaAvatar/index.js.map +1 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts.map +1 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js.map +1 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts.map +1 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js.map +1 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/defaults.d.ts.map +1 -1
- package/dist/oauth/defaults.js +38 -5
- package/dist/oauth/defaults.js.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +49 -14
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
- package/dist/plugin/build-config.d.ts.map +1 -1
- package/dist/plugin/build-config.js +44 -2
- package/dist/plugin/build-config.js.map +1 -1
- package/dist/templates/README.md +1 -1
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +0 -2
- package/dist/types/config.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/lambda-config.d.ts +1 -1
- package/dist/utils/lambda-config.d.ts.map +1 -1
- package/dist/utils/lambda-config.js +2 -2
- package/dist/utils/lambda-config.js.map +1 -1
- package/dist/utils/messages.d.ts +1 -1
- package/dist/utils/messages.d.ts.map +1 -1
- package/dist/utils/messages.js +1 -0
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.d.ts.map +1 -1
- package/dist/utils/package-manager.js +53 -0
- package/dist/utils/package-manager.js.map +1 -1
- package/dist/utils/payload-config-modifier.d.ts +1 -1
- package/dist/utils/payload-config-modifier.d.ts.map +1 -1
- package/dist/utils/payload-config-modifier.js +4 -3
- package/dist/utils/payload-config-modifier.js.map +1 -1
- package/dist/utils/project.d.ts +3 -2
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +4 -2
- package/dist/utils/project.js.map +1 -1
- package/package.json +1 -1
- package/dist/db-content-api/utilities/meta/index.d.ts +0 -5
- package/dist/db-content-api/utilities/meta/index.d.ts.map +0 -1
- package/dist/db-content-api/utilities/meta/index.js +0 -5
- package/dist/db-content-api/utilities/meta/index.js.map +0 -1
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import type { Payload, Where } from 'payload';
|
|
2
|
+
import type { components } from '../../generated/content-api-types.js';
|
|
3
|
+
import type { PathTypesRecord } from '../../temp-utilities/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Metadata sent to Content API for query processing.
|
|
6
|
+
*
|
|
7
|
+
* TODO: This interface is defined here temporarily so Content API can test the integration.
|
|
8
|
+
* Once Content API implements support for pathTypes with relationship info, this type
|
|
9
|
+
* should be generated from openapi.json and ContentAPIMeta can be removed.
|
|
10
|
+
*/
|
|
2
11
|
export interface ContentAPIMeta {
|
|
3
12
|
localizedPaths?: string[];
|
|
4
|
-
pathTypes?:
|
|
13
|
+
pathTypes?: PathTypesRecord;
|
|
5
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* The type that Content API currently expects (from generated types).
|
|
17
|
+
* This is more restrictive than ContentAPIMeta until Content API is updated.
|
|
18
|
+
*/
|
|
19
|
+
type ContentAPIMetaGenerated = components['schemas']['RequestMeta'];
|
|
6
20
|
export interface BuildMetaOptions {
|
|
7
21
|
collection: string;
|
|
8
22
|
locale: string | undefined;
|
|
@@ -17,6 +31,7 @@ export interface BuildMetaOptions {
|
|
|
17
31
|
* @returns Object with meta property ready to spread into request body, or empty object if no meta needed
|
|
18
32
|
*/
|
|
19
33
|
export declare function buildMeta(payload: Payload, options: BuildMetaOptions): {
|
|
20
|
-
meta?:
|
|
34
|
+
meta?: ContentAPIMetaGenerated;
|
|
21
35
|
};
|
|
36
|
+
export {};
|
|
22
37
|
//# sourceMappingURL=buildMeta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildMeta.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/meta/buildMeta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"buildMeta.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/meta/buildMeta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAA;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAKpE;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;AAED;;;GAGG;AACH,KAAK,uBAAuB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAA;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,gBAAgB,GACxB;IAAE,IAAI,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAuBpC"}
|
|
@@ -22,8 +22,11 @@ import { buildPathTypes } from './buildPathTypes.js';
|
|
|
22
22
|
meta.localizedPaths = localizedPaths;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
// Cast to generated type - Content API will need to be updated to handle
|
|
26
|
+
// the new pathTypes format with relationship info. Until then, it will
|
|
27
|
+
// ignore the extra fields but still receive the data for testing.
|
|
25
28
|
return Object.keys(meta).length > 0 ? {
|
|
26
|
-
meta
|
|
29
|
+
meta: meta
|
|
27
30
|
} : {};
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/db-content-api/utilities/meta/buildMeta.ts"],"sourcesContent":["import type { Payload, Where } from 'payload'\n\nimport { buildLocalizedPaths } from './buildLocalizedPaths.js'\nimport { buildPathTypes } from './buildPathTypes.js'\n\nexport interface ContentAPIMeta {\n localizedPaths?: string[]\n pathTypes?:
|
|
1
|
+
{"version":3,"sources":["../../../../src/db-content-api/utilities/meta/buildMeta.ts"],"sourcesContent":["import type { Payload, Where } from 'payload'\n\nimport type { components } from '../../generated/content-api-types.js'\nimport type { PathTypesRecord } from '../../temp-utilities/types.js'\n\nimport { buildLocalizedPaths } from './buildLocalizedPaths.js'\nimport { buildPathTypes } from './buildPathTypes.js'\n\n/**\n * Metadata sent to Content API for query processing.\n *\n * TODO: This interface is defined here temporarily so Content API can test the integration.\n * Once Content API implements support for pathTypes with relationship info, this type\n * should be generated from openapi.json and ContentAPIMeta can be removed.\n */\nexport interface ContentAPIMeta {\n localizedPaths?: string[]\n pathTypes?: PathTypesRecord\n}\n\n/**\n * The type that Content API currently expects (from generated types).\n * This is more restrictive than ContentAPIMeta until Content API is updated.\n */\ntype ContentAPIMetaGenerated = components['schemas']['RequestMeta']\n\nexport interface BuildMetaOptions {\n collection: string\n locale: string | undefined\n where?: Where\n}\n\n/**\n * Builds the `meta` object for Content API requests.\n * Combines pathTypes (for array field handling) and localizedPaths (for locale queries).\n *\n * @param payload - The Payload instance\n * @param options - Options including collection slug, locale, and where clause\n * @returns Object with meta property ready to spread into request body, or empty object if no meta needed\n */\nexport function buildMeta(\n payload: Payload,\n options: BuildMetaOptions,\n): { meta?: ContentAPIMetaGenerated } {\n const { collection, locale, where } = options\n\n const meta: ContentAPIMeta = {}\n\n // Add pathTypes if there are array fields in the where clause\n const pathTypes = buildPathTypes(payload, collection, where)\n if (Object.keys(pathTypes).length > 0) {\n meta.pathTypes = pathTypes\n }\n\n // Add localizedPaths if locale is specified (but not 'all')\n if (locale && locale !== 'all') {\n const localizedPaths = buildLocalizedPaths(payload, collection)\n if (localizedPaths.length > 0) {\n meta.localizedPaths = localizedPaths\n }\n }\n\n // Cast to generated type - Content API will need to be updated to handle\n // the new pathTypes format with relationship info. Until then, it will\n // ignore the extra fields but still receive the data for testing.\n return Object.keys(meta).length > 0 ? { meta: meta as unknown as ContentAPIMetaGenerated } : {}\n}\n"],"names":["buildLocalizedPaths","buildPathTypes","buildMeta","payload","options","collection","locale","where","meta","pathTypes","Object","keys","length","localizedPaths"],"mappings":"AAKA,SAASA,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,cAAc,QAAQ,sBAAqB;AA0BpD;;;;;;;CAOC,GACD,OAAO,SAASC,UACdC,OAAgB,EAChBC,OAAyB;IAEzB,MAAM,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGH;IAEtC,MAAMI,OAAuB,CAAC;IAE9B,8DAA8D;IAC9D,MAAMC,YAAYR,eAAeE,SAASE,YAAYE;IACtD,IAAIG,OAAOC,IAAI,CAACF,WAAWG,MAAM,GAAG,GAAG;QACrCJ,KAAKC,SAAS,GAAGA;IACnB;IAEA,4DAA4D;IAC5D,IAAIH,UAAUA,WAAW,OAAO;QAC9B,MAAMO,iBAAiBb,oBAAoBG,SAASE;QACpD,IAAIQ,eAAeD,MAAM,GAAG,GAAG;YAC7BJ,KAAKK,cAAc,GAAGA;QACxB;IACF;IAEA,yEAAyE;IACzE,uEAAuE;IACvE,kEAAkE;IAClE,OAAOH,OAAOC,IAAI,CAACH,MAAMI,MAAM,GAAG,IAAI;QAAEJ,MAAMA;IAA2C,IAAI,CAAC;AAChG"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { Payload, Where } from 'payload';
|
|
2
|
+
import type { PathTypesRecord } from '../../temp-utilities/types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Builds pathTypes metadata for Content API request.
|
|
4
|
-
* Returns a record of paths
|
|
5
|
+
* Returns a record of paths with their types for proper query generation.
|
|
6
|
+
*
|
|
7
|
+
* Includes:
|
|
8
|
+
* - Array fields (type: "array")
|
|
9
|
+
* - Relationship fields (type: { type: "relationship", collection, hasMany })
|
|
10
|
+
* - Join fields (type: { type: "join", collection, hasMany, on })
|
|
5
11
|
*/
|
|
6
|
-
export declare function buildPathTypes(payload: Payload, collectionSlug: string, where: undefined | Where):
|
|
12
|
+
export declare function buildPathTypes(payload: Payload, collectionSlug: string, where: undefined | Where): PathTypesRecord;
|
|
7
13
|
//# sourceMappingURL=buildPathTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPathTypes.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/meta/buildPathTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"buildPathTypes.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/meta/buildPathTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,+BAA+B,CAAA;AAuKnF;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,SAAS,GAAG,KAAK,GACvB,eAAe,CAgCjB"}
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
return paths;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* Determines the type of a field based on its configuration
|
|
38
|
+
* Determines the type of a field based on its configuration.
|
|
39
|
+
* Returns PathTypeValue for fields that need special handling in Content API queries.
|
|
39
40
|
*/ function getFieldType(field) {
|
|
40
41
|
// Array field
|
|
41
42
|
if (field.type === 'array') {
|
|
@@ -45,18 +46,38 @@
|
|
|
45
46
|
if (field.type === 'blocks') {
|
|
46
47
|
return 'array';
|
|
47
48
|
}
|
|
48
|
-
// Relationship field
|
|
49
|
-
if (field.type === 'relationship'
|
|
50
|
-
|
|
49
|
+
// Relationship field - always include for JOIN support
|
|
50
|
+
if (field.type === 'relationship') {
|
|
51
|
+
const { hasMany = false, relationTo: collection } = field;
|
|
52
|
+
return {
|
|
53
|
+
type: 'relationship',
|
|
54
|
+
collection,
|
|
55
|
+
hasMany
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// Upload field - treated like relationship
|
|
59
|
+
if (field.type === 'upload') {
|
|
60
|
+
const { hasMany = false, relationTo: collection } = field;
|
|
61
|
+
return {
|
|
62
|
+
type: 'relationship',
|
|
63
|
+
collection,
|
|
64
|
+
hasMany
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Join field - virtual reverse lookup
|
|
68
|
+
if (field.type === 'join') {
|
|
69
|
+
const { collection, on } = field;
|
|
70
|
+
return {
|
|
71
|
+
type: 'join',
|
|
72
|
+
collection,
|
|
73
|
+
hasMany: true,
|
|
74
|
+
on
|
|
75
|
+
};
|
|
51
76
|
}
|
|
52
77
|
// Select field with hasMany (array)
|
|
53
78
|
if (field.type === 'select' && 'hasMany' in field && field.hasMany) {
|
|
54
79
|
return 'array';
|
|
55
80
|
}
|
|
56
|
-
// Upload field with hasMany (array)
|
|
57
|
-
if (field.type === 'upload' && 'hasMany' in field && field.hasMany) {
|
|
58
|
-
return 'array';
|
|
59
|
-
}
|
|
60
81
|
// Objects (group, collapsible, row, tabs) don't need traversal
|
|
61
82
|
return null;
|
|
62
83
|
}
|
|
@@ -124,7 +145,12 @@
|
|
|
124
145
|
}
|
|
125
146
|
/**
|
|
126
147
|
* Builds pathTypes metadata for Content API request.
|
|
127
|
-
* Returns a record of paths
|
|
148
|
+
* Returns a record of paths with their types for proper query generation.
|
|
149
|
+
*
|
|
150
|
+
* Includes:
|
|
151
|
+
* - Array fields (type: "array")
|
|
152
|
+
* - Relationship fields (type: { type: "relationship", collection, hasMany })
|
|
153
|
+
* - Join fields (type: { type: "join", collection, hasMany, on })
|
|
128
154
|
*/ export function buildPathTypes(payload, collectionSlug, where) {
|
|
129
155
|
if (!where) {
|
|
130
156
|
return {};
|
|
@@ -132,14 +158,18 @@
|
|
|
132
158
|
const pathTypes = {};
|
|
133
159
|
const paths = extractPathsFromWhere(where);
|
|
134
160
|
for (const path of paths){
|
|
135
|
-
// For each path, we need to check all segments to see if any intermediate ones are arrays/
|
|
161
|
+
// For each path, we need to check all segments to see if any intermediate ones are arrays/relationships
|
|
136
162
|
const segments = path.split('.');
|
|
137
163
|
for(let i = 0; i < segments.length; i++){
|
|
138
164
|
const partialPath = segments.slice(0, i + 1).join('.');
|
|
165
|
+
// Skip if we already have this path
|
|
166
|
+
if (partialPath in pathTypes) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
139
169
|
const field = findFieldByPath(payload, collectionSlug, partialPath);
|
|
140
170
|
if (field) {
|
|
141
171
|
const fieldType = getFieldType(field);
|
|
142
|
-
if (fieldType
|
|
172
|
+
if (fieldType !== null) {
|
|
143
173
|
pathTypes[partialPath] = fieldType;
|
|
144
174
|
}
|
|
145
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/db-content-api/utilities/meta/buildPathTypes.ts"],"sourcesContent":["import type { Field, Payload, Where } from 'payload'\n\n/**\n * Extracts all field paths from a where clause recursively\n */\nfunction extractPathsFromWhere(where: Where, paths: Set<string> = new Set()): Set<string> {\n if (!where || typeof where !== 'object') {\n return paths\n }\n\n // Handle 'and' operator\n if ('and' in where && Array.isArray(where.and)) {\n for (const clause of where.and) {\n extractPathsFromWhere(clause, paths)\n }\n return paths\n }\n\n // Handle 'or' operator\n if ('or' in where && Array.isArray(where.or)) {\n for (const clause of where.or) {\n extractPathsFromWhere(clause, paths)\n }\n return paths\n }\n\n // Handle regular conditions - keys are field paths\n for (const key in where) {\n if (key === 'and' || key === 'or') {\n continue\n }\n\n // Add the path\n paths.add(key)\n\n // Check if the value is a nested where clause (for relationships)\n const value = where[key]\n if (value && typeof value === 'object' && !('equals' in value) && !('in' in value)) {\n // Might be a nested where, recurse\n extractPathsFromWhere(value as Where, paths)\n }\n }\n\n return paths\n}\n\n/**\n * Determines the type of a field based on its configuration\n */\nfunction getFieldType(field: Field): 'array' | null {\n // Array field\n if (field.type === 'array') {\n return 'array'\n }\n\n // Blocks field (array of objects)\n if (field.type === 'blocks') {\n return 'array'\n }\n\n // Relationship field with hasMany (array)\n if (field.type === 'relationship' && 'hasMany' in field && field.hasMany) {\n return 'array'\n }\n\n // Select field with hasMany (array)\n if (field.type === 'select' && 'hasMany' in field && field.hasMany) {\n return 'array'\n }\n\n // Upload field with hasMany (array)\n if (field.type === 'upload' && 'hasMany' in field && field.hasMany) {\n return 'array'\n }\n\n // Objects (group, collapsible, row, tabs) don't need traversal\n return null\n}\n\n/**\n * Finds a field in the collection schema by its path\n * Supports nested paths like \"access.read.users\"\n */\nfunction findFieldByPath(\n payload: Payload,\n collectionSlug: string,\n path: string,\n): Field | undefined {\n const collectionConfig = payload.config.collections.find((c) => c.slug === collectionSlug)\n if (!collectionConfig) {\n return undefined\n }\n\n const pathSegments = path.split('.')\n\n // Walk through the path segments to find the field\n let currentFields = collectionConfig.fields\n let currentField: Field | undefined = undefined\n\n for (let i = 0; i < pathSegments.length; i++) {\n const segment = pathSegments[i]\n\n // First try to find a direct match\n currentField = currentFields.find((f) => 'name' in f && f.name === segment)\n\n // If not found, check if any unnamed container fields (collapsible, row) contain it\n if (!currentField) {\n for (const field of currentFields) {\n if (!('name' in field) || !field.name) {\n // This is an unnamed field, check its contents\n if (\n ('fields' in field && field.type === 'collapsible') ||\n ('fields' in field && field.type === 'row')\n ) {\n currentField = field.fields.find((f) => 'name' in f && f.name === segment)\n if (currentField) {\n break\n }\n } else if ('tabs' in field && field.type === 'tabs') {\n // Check all tabs\n for (const tab of field.tabs) {\n currentField = tab.fields.find((f) => 'name' in f && f.name === segment)\n if (currentField) {\n break\n }\n }\n if (currentField) {\n break\n }\n }\n }\n }\n }\n\n if (!currentField) {\n return undefined\n }\n\n // If we're not at the end, get nested fields\n if (i < pathSegments.length - 1) {\n if (currentField.type === 'group' && 'fields' in currentField) {\n currentFields = currentField.fields\n } else if (currentField.type === 'array' && 'fields' in currentField) {\n currentFields = currentField.fields\n } else if (currentField.type === 'blocks' && 'blocks' in currentField) {\n // For blocks, we can't determine the exact field without knowing the block type\n // Return the blocks field itself\n return currentField\n } else {\n // Field doesn't have nested fields, can't continue\n return undefined\n }\n }\n }\n\n return currentField\n}\n\n/**\n * Builds pathTypes metadata for Content API request.\n * Returns a record of paths that are arrays for proper query generation.\n */\nexport function buildPathTypes(\n payload: Payload,\n collectionSlug: string,\n where: undefined | Where,\n): Record<string, 'array'> {\n if (!where) {\n return {}\n }\n\n const pathTypes: Record<string, 'array'> = {}\n const paths = extractPathsFromWhere(where)\n\n for (const path of paths) {\n // For each path, we need to check all segments to see if any intermediate ones are arrays/objects\n const segments = path.split('.')\n\n for (let i = 0; i < segments.length; i++) {\n const partialPath = segments.slice(0, i + 1).join('.')\n const field = findFieldByPath(payload, collectionSlug, partialPath)\n\n if (field) {\n const fieldType = getFieldType(field)\n if (fieldType === 'array') {\n pathTypes[partialPath] = fieldType\n }\n }\n }\n }\n\n return pathTypes\n}\n"],"names":["extractPathsFromWhere","where","paths","Set","Array","isArray","and","clause","or","key","add","value","getFieldType","field","type","hasMany","findFieldByPath","payload","collectionSlug","path","collectionConfig","config","collections","find","c","slug","undefined","pathSegments","split","currentFields","fields","currentField","i","length","segment","f","name","tab","tabs","buildPathTypes","pathTypes","segments","partialPath","slice","join","fieldType"],"mappings":"AAEA;;CAEC,GACD,SAASA,sBAAsBC,KAAY,EAAEC,QAAqB,IAAIC,KAAK;IACzE,IAAI,CAACF,SAAS,OAAOA,UAAU,UAAU;QACvC,OAAOC;IACT;IAEA,wBAAwB;IACxB,IAAI,SAASD,SAASG,MAAMC,OAAO,CAACJ,MAAMK,GAAG,GAAG;QAC9C,KAAK,MAAMC,UAAUN,MAAMK,GAAG,CAAE;YAC9BN,sBAAsBO,QAAQL;QAChC;QACA,OAAOA;IACT;IAEA,uBAAuB;IACvB,IAAI,QAAQD,SAASG,MAAMC,OAAO,CAACJ,MAAMO,EAAE,GAAG;QAC5C,KAAK,MAAM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YACrC,OAAO,IAAIC,aAAajB,IAAI,KAAK,YAAY,YAAYiB,cAAc;gBACrE,gFAAgF;gBAChF,iCAAiC;gBACjC,OAAOA;YACT,OAAO;gBACL,mDAAmD;gBACnD,OAAOL;YACT;QACF;IACF;IAEA,OAAOK;AACT;AAEA;;;CAGC,GACD,OAAO,SAASQ,eACdtB,OAAgB,EAChBC,cAAsB,EACtBjB,KAAwB;IAExB,IAAI,CAACA,OAAO;QACV,OAAO,CAAC;IACV;IAEA,MAAMuC,YAAqC,CAAC;IAC5C,MAAMtC,QAAQF,sBAAsBC;IAEpC,KAAK,MAAMkB,QAAQjB,MAAO;QACxB,kGAAkG;QAClG,MAAMuC,WAAWtB,KAAKS,KAAK,CAAC;QAE5B,IAAK,IAAII,IAAI,GAAGA,IAAIS,SAASR,MAAM,EAAED,IAAK;YACxC,MAAMU,cAAcD,SAASE,KAAK,CAAC,GAAGX,IAAI,GAAGY,IAAI,CAAC;YAClD,MAAM/B,QAAQG,gBAAgBC,SAASC,gBAAgBwB;YAEvD,IAAI7B,OAAO;gBACT,MAAMgC,YAAYjC,aAAaC;gBAC/B,IAAIgC,cAAc,SAAS;oBACzBL,SAAS,CAACE,YAAY,GAAGG;gBAC3B;YACF;QACF;IACF;IAEA,OAAOL;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/db-content-api/utilities/meta/buildPathTypes.ts"],"sourcesContent":["import type { Field, Payload, Where } from 'payload'\n\nimport type { PathTypesRecord, PathTypeValue } from '../../temp-utilities/types.js'\n\n/**\n * Extracts all field paths from a where clause recursively\n */\nfunction extractPathsFromWhere(where: Where, paths: Set<string> = new Set()): Set<string> {\n if (!where || typeof where !== 'object') {\n return paths\n }\n\n // Handle 'and' operator\n if ('and' in where && Array.isArray(where.and)) {\n for (const clause of where.and) {\n extractPathsFromWhere(clause, paths)\n }\n return paths\n }\n\n // Handle 'or' operator\n if ('or' in where && Array.isArray(where.or)) {\n for (const clause of where.or) {\n extractPathsFromWhere(clause, paths)\n }\n return paths\n }\n\n // Handle regular conditions - keys are field paths\n for (const key in where) {\n if (key === 'and' || key === 'or') {\n continue\n }\n\n // Add the path\n paths.add(key)\n\n // Check if the value is a nested where clause (for relationships)\n const value = where[key]\n if (value && typeof value === 'object' && !('equals' in value) && !('in' in value)) {\n // Might be a nested where, recurse\n extractPathsFromWhere(value as Where, paths)\n }\n }\n\n return paths\n}\n\n/**\n * Determines the type of a field based on its configuration.\n * Returns PathTypeValue for fields that need special handling in Content API queries.\n */\nfunction getFieldType(field: Field): null | PathTypeValue {\n // Array field\n if (field.type === 'array') {\n return 'array'\n }\n\n // Blocks field (array of objects)\n if (field.type === 'blocks') {\n return 'array'\n }\n\n // Relationship field - always include for JOIN support\n if (field.type === 'relationship') {\n const { hasMany = false, relationTo: collection } = field\n return { type: 'relationship', collection, hasMany }\n }\n\n // Upload field - treated like relationship\n if (field.type === 'upload') {\n const { hasMany = false, relationTo: collection } = field\n return { type: 'relationship', collection, hasMany }\n }\n\n // Join field - virtual reverse lookup\n if (field.type === 'join') {\n const { collection, on } = field\n return { type: 'join', collection, hasMany: true, on }\n }\n\n // Select field with hasMany (array)\n if (field.type === 'select' && 'hasMany' in field && field.hasMany) {\n return 'array'\n }\n\n // Objects (group, collapsible, row, tabs) don't need traversal\n return null\n}\n\n/**\n * Finds a field in the collection schema by its path\n * Supports nested paths like \"access.read.users\"\n */\nfunction findFieldByPath(\n payload: Payload,\n collectionSlug: string,\n path: string,\n): Field | undefined {\n const collectionConfig = payload.config.collections.find((c) => c.slug === collectionSlug)\n if (!collectionConfig) {\n return undefined\n }\n\n const pathSegments = path.split('.')\n\n // Walk through the path segments to find the field\n let currentFields = collectionConfig.fields\n let currentField: Field | undefined = undefined\n\n for (let i = 0; i < pathSegments.length; i++) {\n const segment = pathSegments[i]\n\n // First try to find a direct match\n currentField = currentFields.find((f) => 'name' in f && f.name === segment)\n\n // If not found, check if any unnamed container fields (collapsible, row) contain it\n if (!currentField) {\n for (const field of currentFields) {\n if (!('name' in field) || !field.name) {\n // This is an unnamed field, check its contents\n if (\n ('fields' in field && field.type === 'collapsible') ||\n ('fields' in field && field.type === 'row')\n ) {\n currentField = field.fields.find((f) => 'name' in f && f.name === segment)\n if (currentField) {\n break\n }\n } else if ('tabs' in field && field.type === 'tabs') {\n // Check all tabs\n for (const tab of field.tabs) {\n currentField = tab.fields.find((f) => 'name' in f && f.name === segment)\n if (currentField) {\n break\n }\n }\n if (currentField) {\n break\n }\n }\n }\n }\n }\n\n if (!currentField) {\n return undefined\n }\n\n // If we're not at the end, get nested fields\n if (i < pathSegments.length - 1) {\n if (currentField.type === 'group' && 'fields' in currentField) {\n currentFields = currentField.fields\n } else if (currentField.type === 'array' && 'fields' in currentField) {\n currentFields = currentField.fields\n } else if (currentField.type === 'blocks' && 'blocks' in currentField) {\n // For blocks, we can't determine the exact field without knowing the block type\n // Return the blocks field itself\n return currentField\n } else {\n // Field doesn't have nested fields, can't continue\n return undefined\n }\n }\n }\n\n return currentField\n}\n\n/**\n * Builds pathTypes metadata for Content API request.\n * Returns a record of paths with their types for proper query generation.\n *\n * Includes:\n * - Array fields (type: \"array\")\n * - Relationship fields (type: { type: \"relationship\", collection, hasMany })\n * - Join fields (type: { type: \"join\", collection, hasMany, on })\n */\nexport function buildPathTypes(\n payload: Payload,\n collectionSlug: string,\n where: undefined | Where,\n): PathTypesRecord {\n if (!where) {\n return {}\n }\n\n const pathTypes: PathTypesRecord = {}\n const paths = extractPathsFromWhere(where)\n\n for (const path of paths) {\n // For each path, we need to check all segments to see if any intermediate ones are arrays/relationships\n const segments = path.split('.')\n\n for (let i = 0; i < segments.length; i++) {\n const partialPath = segments.slice(0, i + 1).join('.')\n\n // Skip if we already have this path\n if (partialPath in pathTypes) {\n continue\n }\n\n const field = findFieldByPath(payload, collectionSlug, partialPath)\n\n if (field) {\n const fieldType = getFieldType(field)\n if (fieldType !== null) {\n pathTypes[partialPath] = fieldType\n }\n }\n }\n }\n\n return pathTypes\n}\n"],"names":["extractPathsFromWhere","where","paths","Set","Array","isArray","and","clause","or","key","add","value","getFieldType","field","type","hasMany","relationTo","collection","on","findFieldByPath","payload","collectionSlug","path","collectionConfig","config","collections","find","c","slug","undefined","pathSegments","split","currentFields","fields","currentField","i","length","segment","f","name","tab","tabs","buildPathTypes","pathTypes","segments","partialPath","slice","join","fieldType"],"mappings":"AAIA;;CAEC,GACD,SAASA,sBAAsBC,KAAY,EAAEC,QAAqB,IAAIC,KAAK;IACzE,IAAI,CAACF,SAAS,OAAOA,UAAU,UAAU;QACvC,OAAOC;IACT;IAEA,wBAAwB;IACxB,IAAI,SAASD,SAASG,MAAMC,OAAO,CAACJ,MAAMK,GAAG,GAAG;QAC9C,KAAK,MAAMC,UAAUN,MAAMK,GAAG,CAAE;YAC9BN,sBAAsBO,QAAQL;QAChC;QACA,OAAOA;IACT;IAEA,uBAAuB;IACvB,IAAI,QAAQD,SAASG,MAAMC,OAAO,CAACJ,MAAMO,EAAE,GAAG;QAC5C,KAAK,MAAMD,UAAUN,MAAMO,EAAE,CAAE;YAC7BR,sBAAsBO,QAAQL;QAChC;QACA,OAAOA;IACT;IAEA,mDAAmD;IACnD,IAAK,MAAMO,OAAOR,MAAO;QACvB,IAAIQ,QAAQ,SAASA,QAAQ,MAAM;YACjC;QACF;QAEA,eAAe;QACfP,MAAMQ,GAAG,CAACD;QAEV,kEAAkE;QAClE,MAAME,QAAQV,KAAK,CAACQ,IAAI;QACxB,IAAIE,SAAS,OAAOA,UAAU,YAAY,CAAE,CAAA,YAAYA,KAAI,KAAM,CAAE,CAAA,QAAQA,KAAI,GAAI;YAClF,mCAAmC;YACnCX,sBAAsBW,OAAgBT;QACxC;IACF;IAEA,OAAOA;AACT;AAEA;;;CAGC,GACD,SAASU,aAAaC,KAAY;IAChC,cAAc;IACd,IAAIA,MAAMC,IAAI,KAAK,SAAS;QAC1B,OAAO;IACT;IAEA,kCAAkC;IAClC,IAAID,MAAMC,IAAI,KAAK,UAAU;QAC3B,OAAO;IACT;IAEA,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;IACV;IAEA,MAAM0C,YAA6B,CAAC;IACpC,MAAMzC,QAAQF,sBAAsBC;IAEpC,KAAK,MAAMqB,QAAQpB,MAAO;QACxB,wGAAwG;QACxG,MAAM0C,WAAWtB,KAAKS,KAAK,CAAC;QAE5B,IAAK,IAAII,IAAI,GAAGA,IAAIS,SAASR,MAAM,EAAED,IAAK;YACxC,MAAMU,cAAcD,SAASE,KAAK,CAAC,GAAGX,IAAI,GAAGY,IAAI,CAAC;YAElD,oCAAoC;YACpC,IAAIF,eAAeF,WAAW;gBAC5B;YACF;YAEA,MAAM9B,QAAQM,gBAAgBC,SAASC,gBAAgBwB;YAEvD,IAAIhC,OAAO;gBACT,MAAMmC,YAAYpC,aAAaC;gBAC/B,IAAImC,cAAc,MAAM;oBACtBL,SAAS,CAACE,YAAY,GAAGG;gBAC3B;YACF;QACF;IACF;IAEA,OAAOL;AACT"}
|
|
@@ -6,6 +6,14 @@ type ConvertOptions = {
|
|
|
6
6
|
insideLogicalOperator?: boolean;
|
|
7
7
|
/** If true, transform 'parent' field to 'documentId' (used for version queries) */
|
|
8
8
|
parentToDocumentId?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* If true, strip 'version.' prefix from field paths (used for version queries).
|
|
11
|
+
*
|
|
12
|
+
* Payload queries version content with paths like 'version._status.en', but Content API
|
|
13
|
+
* stores version data directly in the 'data' column (not nested under 'version').
|
|
14
|
+
* The 'version' wrapper is only added in API responses for client compatibility.
|
|
15
|
+
*/
|
|
16
|
+
stripVersionPrefix?: boolean;
|
|
9
17
|
};
|
|
10
18
|
export declare function convertPayloadWhereToContentAPI(where: undefined | Where, options?: ConvertOptions): WhereClause;
|
|
11
19
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"where.d.ts","sourceRoot":"","sources":["../../../src/db-content-api/utilities/where.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,KAAK,WAAW,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAA;AASvD,KAAK,cAAc,GAAG;IACpB,yEAAyE;IACzE,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,SAAS,GAAG,KAAK,EACxB,OAAO,GAAE,cAAmB,GAC3B,WAAW,
|
|
1
|
+
{"version":3,"file":"where.d.ts","sourceRoot":"","sources":["../../../src/db-content-api/utilities/where.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,KAAK,WAAW,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAA;AASvD,KAAK,cAAc,GAAG;IACpB,yEAAyE;IACzE,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,SAAS,GAAG,KAAK,EACxB,OAAO,GAAE,cAAmB,GAC3B,WAAW,CAoIb"}
|
|
@@ -68,6 +68,12 @@ export function convertPayloadWhereToContentAPI(where, options = {}) {
|
|
|
68
68
|
if (options.parentToDocumentId && key === 'parent') {
|
|
69
69
|
fieldPath = 'documentId';
|
|
70
70
|
}
|
|
71
|
+
// Strip 'version.' prefix from field paths for version queries
|
|
72
|
+
// Payload uses paths like 'version._status.en' but Content API stores version data
|
|
73
|
+
// directly in the 'data' column, not nested under 'version'
|
|
74
|
+
if (options.stripVersionPrefix && fieldPath.startsWith('version.')) {
|
|
75
|
+
fieldPath = fieldPath.slice('version.'.length);
|
|
76
|
+
}
|
|
71
77
|
// Convert field conditions: { fieldName: { operator: value } }
|
|
72
78
|
// to: { path: fieldName, operator, value }
|
|
73
79
|
// Handle Payload's shorthand: { fieldName: value } → { fieldName: { equals: value } }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/db-content-api/utilities/where.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport type { components } from '../generated/content-api-types.js'\n\ntype WhereClause = components['schemas']['WhereClause']\n\n// Payload's format: { fieldName: { operator: value }, and: [...], or: [...] }\n// Content API expects: { and: [{ path, operator, value }], or: [{ path, operator, value }] }\n//\n// The format stays different. This allows the Content API to evolve its filter schema,\n// for example to support composite types like Point, which are not lexicographically sortable.\n// Semantics must remain identical to Payload.\n\ntype ConvertOptions = {\n /** Internal flag to track if we're inside a logical operator (and/or) */\n insideLogicalOperator?: boolean\n /** If true, transform 'parent' field to 'documentId' (used for version queries) */\n parentToDocumentId?: boolean\n}\n\nexport function convertPayloadWhereToContentAPI(\n where: undefined | Where,\n options: ConvertOptions = {},\n): WhereClause {\n // Empty where {} should be { and: [] } not undefined\n // Content API requires a where clause structure even for \"no filter\"\n if (!where || Object.keys(where).length === 0) {\n return { and: [] }\n }\n\n // Extract the condition type (the variant with 'path', 'operator', 'value') from WhereClause union\n type WhereCondition = Extract<WhereClause, { path: string }>\n const conditions: WhereClause[] = []\n\n for (const [key, value] of Object.entries(where)) {\n if (key === 'and') {\n // Recursively convert nested 'and' conditions, preserving options\n const nestedConditions = (value as Where[])\n .map((item) =>\n convertPayloadWhereToContentAPI(item, { ...options, insideLogicalOperator: true }),\n )\n // TODO: A better solution would be to make the `where` schema of `zod` in `content-api`\n // more permissive. For now I'll do it this way because I have an idea to simplify\n // everything we're doing with `where` (Post EAP) anyway.\n // Filter out empty conditions { and: [] } that would be invalid\n .filter((condition) => {\n if ('and' in condition) {\n return condition.and.length > 0\n }\n if ('or' in condition) {\n return condition.or.length > 0\n }\n return true // Keep path/operator/value conditions\n })\n\n // If filtering resulted in no conditions, return empty and\n if (nestedConditions.length === 0) {\n return { and: [] }\n }\n\n return { and: nestedConditions }\n } else if (key === 'or') {\n // Recursively convert nested 'or' conditions, preserving options\n const nestedConditions = (value as Where[])\n .map((item) =>\n convertPayloadWhereToContentAPI(item, { ...options, insideLogicalOperator: true }),\n )\n // Filter out empty conditions { and: [] } or { or: [] } that would be invalid\n .filter((condition) => {\n if ('and' in condition) {\n return condition.and.length > 0\n }\n if ('or' in condition) {\n return condition.or.length > 0\n }\n return true // Keep path/operator/value conditions\n })\n\n // If filtering resulted in no conditions, return empty and\n if (nestedConditions.length === 0) {\n return { and: [] }\n }\n\n return { or: nestedConditions }\n } else {\n // TODO: fix this in content api\n // WORKAROUND: Payload uses 'parent' for version queries, but Content API expects 'documentId'\n let fieldPath = key\n if (options.parentToDocumentId && key === 'parent') {\n fieldPath = 'documentId'\n }\n\n // Convert field conditions: { fieldName: { operator: value } }\n // to: { path: fieldName, operator, value }\n\n // Handle Payload's shorthand: { fieldName: value } → { fieldName: { equals: value } }\n // If value is a primitive (string, number, boolean, null) or not a plain object,\n // treat it as an implicit 'equals' operator\n const isPrimitive = value === null || typeof value !== 'object' || Array.isArray(value)\n\n if (isPrimitive) {\n // Shorthand format: { id: \"some-value\" } means { id: { equals: \"some-value\" } }\n conditions.push({\n operator: 'equals',\n path: fieldPath,\n value,\n } as WhereCondition)\n continue\n }\n\n const operators = value as Record<string, unknown>\n\n // Skip empty operator objects { fieldName: {} }\n if (Object.keys(operators).length === 0) {\n continue\n }\n\n for (const [op, operatorValue] of Object.entries(operators)) {\n // Skip operators with undefined values (e.g., { equals: undefined })\n // This can happen when Payload sends incomplete where clauses\n if (operatorValue === undefined) {\n continue\n }\n\n let finalValue = operatorValue\n\n // Convert string booleans to actual booleans for exists operator\n // REST API sends \"true\"/\"false\" as strings, but Content API requires boolean\n if (op === 'exists' && typeof operatorValue === 'string') {\n finalValue = operatorValue === 'true'\n }\n\n conditions.push({\n operator: op as WhereCondition['operator'],\n path: fieldPath,\n value: finalValue,\n } as WhereCondition)\n }\n }\n }\n\n // If inside a logical operator (and/or), return conditions directly\n // Otherwise, wrap in 'and' to match WhereClause type\n if (options.insideLogicalOperator && conditions.length === 1) {\n return conditions[0]\n }\n\n return { and: conditions }\n}\n"],"names":["convertPayloadWhereToContentAPI","where","options","Object","keys","length","and","conditions","key","value","entries","nestedConditions","map","item","insideLogicalOperator","filter","condition","or","fieldPath","parentToDocumentId","isPrimitive","Array","isArray","push","operator","path","operators","op","operatorValue","undefined","finalValue"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/db-content-api/utilities/where.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport type { components } from '../generated/content-api-types.js'\n\ntype WhereClause = components['schemas']['WhereClause']\n\n// Payload's format: { fieldName: { operator: value }, and: [...], or: [...] }\n// Content API expects: { and: [{ path, operator, value }], or: [{ path, operator, value }] }\n//\n// The format stays different. This allows the Content API to evolve its filter schema,\n// for example to support composite types like Point, which are not lexicographically sortable.\n// Semantics must remain identical to Payload.\n\ntype ConvertOptions = {\n /** Internal flag to track if we're inside a logical operator (and/or) */\n insideLogicalOperator?: boolean\n /** If true, transform 'parent' field to 'documentId' (used for version queries) */\n parentToDocumentId?: boolean\n /**\n * If true, strip 'version.' prefix from field paths (used for version queries).\n *\n * Payload queries version content with paths like 'version._status.en', but Content API\n * stores version data directly in the 'data' column (not nested under 'version').\n * The 'version' wrapper is only added in API responses for client compatibility.\n */\n stripVersionPrefix?: boolean\n}\n\nexport function convertPayloadWhereToContentAPI(\n where: undefined | Where,\n options: ConvertOptions = {},\n): WhereClause {\n // Empty where {} should be { and: [] } not undefined\n // Content API requires a where clause structure even for \"no filter\"\n if (!where || Object.keys(where).length === 0) {\n return { and: [] }\n }\n\n // Extract the condition type (the variant with 'path', 'operator', 'value') from WhereClause union\n type WhereCondition = Extract<WhereClause, { path: string }>\n const conditions: WhereClause[] = []\n\n for (const [key, value] of Object.entries(where)) {\n if (key === 'and') {\n // Recursively convert nested 'and' conditions, preserving options\n const nestedConditions = (value as Where[])\n .map((item) =>\n convertPayloadWhereToContentAPI(item, { ...options, insideLogicalOperator: true }),\n )\n // TODO: A better solution would be to make the `where` schema of `zod` in `content-api`\n // more permissive. For now I'll do it this way because I have an idea to simplify\n // everything we're doing with `where` (Post EAP) anyway.\n // Filter out empty conditions { and: [] } that would be invalid\n .filter((condition) => {\n if ('and' in condition) {\n return condition.and.length > 0\n }\n if ('or' in condition) {\n return condition.or.length > 0\n }\n return true // Keep path/operator/value conditions\n })\n\n // If filtering resulted in no conditions, return empty and\n if (nestedConditions.length === 0) {\n return { and: [] }\n }\n\n return { and: nestedConditions }\n } else if (key === 'or') {\n // Recursively convert nested 'or' conditions, preserving options\n const nestedConditions = (value as Where[])\n .map((item) =>\n convertPayloadWhereToContentAPI(item, { ...options, insideLogicalOperator: true }),\n )\n // Filter out empty conditions { and: [] } or { or: [] } that would be invalid\n .filter((condition) => {\n if ('and' in condition) {\n return condition.and.length > 0\n }\n if ('or' in condition) {\n return condition.or.length > 0\n }\n return true // Keep path/operator/value conditions\n })\n\n // If filtering resulted in no conditions, return empty and\n if (nestedConditions.length === 0) {\n return { and: [] }\n }\n\n return { or: nestedConditions }\n } else {\n // TODO: fix this in content api\n // WORKAROUND: Payload uses 'parent' for version queries, but Content API expects 'documentId'\n let fieldPath = key\n if (options.parentToDocumentId && key === 'parent') {\n fieldPath = 'documentId'\n }\n\n // Strip 'version.' prefix from field paths for version queries\n // Payload uses paths like 'version._status.en' but Content API stores version data\n // directly in the 'data' column, not nested under 'version'\n if (options.stripVersionPrefix && fieldPath.startsWith('version.')) {\n fieldPath = fieldPath.slice('version.'.length)\n }\n\n // Convert field conditions: { fieldName: { operator: value } }\n // to: { path: fieldName, operator, value }\n\n // Handle Payload's shorthand: { fieldName: value } → { fieldName: { equals: value } }\n // If value is a primitive (string, number, boolean, null) or not a plain object,\n // treat it as an implicit 'equals' operator\n const isPrimitive = value === null || typeof value !== 'object' || Array.isArray(value)\n\n if (isPrimitive) {\n // Shorthand format: { id: \"some-value\" } means { id: { equals: \"some-value\" } }\n conditions.push({\n operator: 'equals',\n path: fieldPath,\n value,\n } as WhereCondition)\n continue\n }\n\n const operators = value as Record<string, unknown>\n\n // Skip empty operator objects { fieldName: {} }\n if (Object.keys(operators).length === 0) {\n continue\n }\n\n for (const [op, operatorValue] of Object.entries(operators)) {\n // Skip operators with undefined values (e.g., { equals: undefined })\n // This can happen when Payload sends incomplete where clauses\n if (operatorValue === undefined) {\n continue\n }\n\n let finalValue = operatorValue\n\n // Convert string booleans to actual booleans for exists operator\n // REST API sends \"true\"/\"false\" as strings, but Content API requires boolean\n if (op === 'exists' && typeof operatorValue === 'string') {\n finalValue = operatorValue === 'true'\n }\n\n conditions.push({\n operator: op as WhereCondition['operator'],\n path: fieldPath,\n value: finalValue,\n } as WhereCondition)\n }\n }\n }\n\n // If inside a logical operator (and/or), return conditions directly\n // Otherwise, wrap in 'and' to match WhereClause type\n if (options.insideLogicalOperator && conditions.length === 1) {\n return conditions[0]\n }\n\n return { and: conditions }\n}\n"],"names":["convertPayloadWhereToContentAPI","where","options","Object","keys","length","and","conditions","key","value","entries","nestedConditions","map","item","insideLogicalOperator","filter","condition","or","fieldPath","parentToDocumentId","stripVersionPrefix","startsWith","slice","isPrimitive","Array","isArray","push","operator","path","operators","op","operatorValue","undefined","finalValue"],"mappings":"AA4BA,OAAO,SAASA,gCACdC,KAAwB,EACxBC,UAA0B,CAAC,CAAC;IAE5B,qDAAqD;IACrD,qEAAqE;IACrE,IAAI,CAACD,SAASE,OAAOC,IAAI,CAACH,OAAOI,MAAM,KAAK,GAAG;QAC7C,OAAO;YAAEC,KAAK,EAAE;QAAC;IACnB;IAIA,MAAMC,aAA4B,EAAE;IAEpC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIN,OAAOO,OAAO,CAACT,OAAQ;QAChD,IAAIO,Q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,+DAA+D;YAC/D,mFAAmF;YACnF,4DAA4D;YAC5D,IAAIhB,QAAQkB,kBAAkB,IAAIF,UAAUG,UAAU,CAAC,aAAa;gBAClEH,YAAYA,UAAUI,KAAK,CAAC,WAAWjB,MAAM;YAC/C;YAEA,+DAA+D;YAC/D,2CAA2C;YAE3C,sFAAsF;YACtF,iFAAiF;YACjF,4CAA4C;YAC5C,MAAMkB,cAAcd,UAAU,QAAQ,OAAOA,UAAU,YAAYe,MAAMC,OAAO,CAAChB;YAEjF,IAAIc,aAAa;gBACf,gFAAgF;gBAChFhB,WAAWmB,IAAI,CAAC;oBACdC,UAAU;oBACVC,MAAMV;oBACNT;gBACF;gBACA;YACF;YAEA,MAAMoB,YAAYpB;YAElB,gDAAgD;YAChD,IAAIN,OAAOC,IAAI,CAACyB,WAAWxB,MAAM,KAAK,GAAG;gBACvC;YACF;YAEA,KAAK,MAAM,CAACyB,IAAIC,cAAc,IAAI5B,OAAOO,OAAO,CAACmB,WAAY;gBAC3D,qEAAqE;gBACrE,8DAA8D;gBAC9D,IAAIE,kBAAkBC,WAAW;oBAC/B;gBACF;gBAEA,IAAIC,aAAaF;gBAEjB,iEAAiE;gBACjE,6EAA6E;gBAC7E,IAAID,OAAO,YAAY,OAAOC,kBAAkB,UAAU;oBACxDE,aAAaF,kBAAkB;gBACjC;gBAEAxB,WAAWmB,IAAI,CAAC;oBACdC,UAAUG;oBACVF,MAAMV;oBACNT,OAAOwB;gBACT;YACF;QACF;IACF;IAEA,oEAAoE;IACpE,qDAAqD;IACrD,IAAI/B,QAAQY,qBAAqB,IAAIP,WAAWF,MAAM,KAAK,GAAG;QAC5D,OAAOE,UAAU,CAAC,EAAE;IACtB;IAEA,OAAO;QAAED,KAAKC;IAAW;AAC3B"}
|
package/dist/exports/client.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { FigmaAvatar } from '../oauth/components/FigmaAvatar/index.js';
|
|
2
|
+
export { FigmaAvatarCell } from '../oauth/components/FigmaAvatarCell/index.js';
|
|
1
3
|
export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
|
|
2
4
|
export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
|
|
3
5
|
export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAA;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAA"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAA;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAA;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAA"}
|
package/dist/exports/client.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { FigmaAvatar } from '../oauth/components/FigmaAvatar/index.js';
|
|
2
|
+
export { FigmaAvatarCell } from '../oauth/components/FigmaAvatarCell/index.js';
|
|
1
3
|
export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
|
|
2
4
|
export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
|
|
3
5
|
export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js'\nexport { LogoutButton } from '../oauth/components/LogoutButton/index.js'\nexport { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js'\n"],"names":["DefaultLoginButton","LogoutButton","ContentApiClientUploadHandler"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,YAAY,QAAQ,4CAA2C;AACxE,SAASC,6BAA6B,QAAQ,+DAA8D"}
|
|
1
|
+
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { FigmaAvatar } from '../oauth/components/FigmaAvatar/index.js'\nexport { FigmaAvatarCell } from '../oauth/components/FigmaAvatarCell/index.js'\nexport { DefaultLoginButton } from '../oauth/components/LoginButton/index.js'\nexport { LogoutButton } from '../oauth/components/LogoutButton/index.js'\nexport { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js'\n"],"names":["FigmaAvatar","FigmaAvatarCell","DefaultLoginButton","LogoutButton","ContentApiClientUploadHandler"],"mappings":"AAAA,SAASA,WAAW,QAAQ,2CAA0C;AACtE,SAASC,eAAe,QAAQ,+CAA8C;AAC9E,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,YAAY,QAAQ,4CAA2C;AACxE,SAASC,6BAA6B,QAAQ,+DAA8D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/FigmaAvatar/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,cAAc,CAAA;AAQrB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAoB/B,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useAuth } from '@payloadcms/ui';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { FigmaAvatarPlaceholder, isValidImageUrl } from '../FigmaAvatarPlaceholder/index.js';
|
|
6
|
+
import './index.scss';
|
|
7
|
+
const baseClass = 'figma-avatar';
|
|
8
|
+
export const FigmaAvatar = ()=>{
|
|
9
|
+
const { user } = useAuth();
|
|
10
|
+
const [hasError, setHasError] = useState(false);
|
|
11
|
+
const figmaImageUrl = user?.figmaImageUrl;
|
|
12
|
+
if (!figmaImageUrl || hasError || !isValidImageUrl(figmaImageUrl)) {
|
|
13
|
+
return /*#__PURE__*/ _jsx(FigmaAvatarPlaceholder, {
|
|
14
|
+
size: 25
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return /*#__PURE__*/ _jsx("img", {
|
|
18
|
+
alt: "Profile",
|
|
19
|
+
className: `${baseClass}__image`,
|
|
20
|
+
height: 25,
|
|
21
|
+
onError: ()=>setHasError(true),
|
|
22
|
+
src: figmaImageUrl,
|
|
23
|
+
width: 25
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/oauth/components/FigmaAvatar/index.tsx"],"sourcesContent":["'use client'\nimport type React from 'react'\n\nimport { useAuth } from '@payloadcms/ui'\nimport { useState } from 'react'\n\nimport { FigmaAvatarPlaceholder, isValidImageUrl } from '../FigmaAvatarPlaceholder/index.js'\nimport './index.scss'\n\nconst baseClass = 'figma-avatar'\n\ntype UserWithFigmaFields = {\n figmaImageUrl?: string\n}\n\nexport const FigmaAvatar: React.FC = () => {\n const { user } = useAuth()\n const [hasError, setHasError] = useState(false)\n\n const figmaImageUrl = (user as UserWithFigmaFields)?.figmaImageUrl\n\n if (!figmaImageUrl || hasError || !isValidImageUrl(figmaImageUrl)) {\n return <FigmaAvatarPlaceholder size={25} />\n }\n\n return (\n <img\n alt=\"Profile\"\n className={`${baseClass}__image`}\n height={25}\n onError={() => setHasError(true)}\n src={figmaImageUrl}\n width={25}\n />\n )\n}\n"],"names":["useAuth","useState","FigmaAvatarPlaceholder","isValidImageUrl","baseClass","FigmaAvatar","user","hasError","setHasError","figmaImageUrl","size","img","alt","className","height","onError","src","width"],"mappings":"AAAA;;AAGA,SAASA,OAAO,QAAQ,iBAAgB;AACxC,SAASC,QAAQ,QAAQ,QAAO;AAEhC,SAASC,sBAAsB,EAAEC,eAAe,QAAQ,qCAAoC;AAC5F,OAAO,eAAc;AAErB,MAAMC,YAAY;AAMlB,OAAO,MAAMC,cAAwB;IACnC,MAAM,EAAEC,IAAI,EAAE,GAAGN;IACjB,MAAM,CAACO,UAAUC,YAAY,GAAGP,SAAS;IAEzC,MAAMQ,gBAAiBH,MAA8BG;IAErD,IAAI,CAACA,iBAAiBF,YAAY,CAACJ,gBAAgBM,gBAAgB;QACjE,qBAAO,KAACP;YAAuBQ,MAAM;;IACvC;IAEA,qBACE,KAACC;QACCC,KAAI;QACJC,WAAW,GAAGT,UAAU,OAAO,CAAC;QAChCU,QAAQ;QACRC,SAAS,IAAMP,YAAY;QAC3BQ,KAAKP;QACLQ,OAAO;;AAGb,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/FigmaAvatarCell/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAkB/D,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { FigmaAvatarPlaceholder, isValidImageUrl } from '../FigmaAvatarPlaceholder/index.js';
|
|
5
|
+
import './index.scss';
|
|
6
|
+
const baseClass = 'figma-avatar-cell';
|
|
7
|
+
export const FigmaAvatarCell = ({ cellData })=>{
|
|
8
|
+
const [hasError, setHasError] = useState(false);
|
|
9
|
+
const figmaImageUrl = cellData;
|
|
10
|
+
if (!figmaImageUrl || hasError || !isValidImageUrl(figmaImageUrl)) {
|
|
11
|
+
return /*#__PURE__*/ _jsx(FigmaAvatarPlaceholder, {
|
|
12
|
+
size: 20
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return /*#__PURE__*/ _jsx("img", {
|
|
16
|
+
alt: "Avatar",
|
|
17
|
+
className: `${baseClass}__image`,
|
|
18
|
+
height: 20,
|
|
19
|
+
onError: ()=>setHasError(true),
|
|
20
|
+
src: figmaImageUrl,
|
|
21
|
+
width: 20
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/oauth/components/FigmaAvatarCell/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultCellComponentProps } from 'payload'\nimport type React from 'react'\n\nimport { useState } from 'react'\n\nimport { FigmaAvatarPlaceholder, isValidImageUrl } from '../FigmaAvatarPlaceholder/index.js'\nimport './index.scss'\n\nconst baseClass = 'figma-avatar-cell'\n\nexport const FigmaAvatarCell: React.FC<DefaultCellComponentProps> = ({ cellData }) => {\n const [hasError, setHasError] = useState(false)\n const figmaImageUrl = cellData as string | undefined\n\n if (!figmaImageUrl || hasError || !isValidImageUrl(figmaImageUrl)) {\n return <FigmaAvatarPlaceholder size={20} />\n }\n\n return (\n <img\n alt=\"Avatar\"\n className={`${baseClass}__image`}\n height={20}\n onError={() => setHasError(true)}\n src={figmaImageUrl}\n width={20}\n />\n )\n}\n"],"names":["useState","FigmaAvatarPlaceholder","isValidImageUrl","baseClass","FigmaAvatarCell","cellData","hasError","setHasError","figmaImageUrl","size","img","alt","className","height","onError","src","width"],"mappings":"AAAA;;AAIA,SAASA,QAAQ,QAAQ,QAAO;AAEhC,SAASC,sBAAsB,EAAEC,eAAe,QAAQ,qCAAoC;AAC5F,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,OAAO,MAAMC,kBAAuD,CAAC,EAAEC,QAAQ,EAAE;IAC/E,MAAM,CAACC,UAAUC,YAAY,GAAGP,SAAS;IACzC,MAAMQ,gBAAgBH;IAEtB,IAAI,CAACG,iBAAiBF,YAAY,CAACJ,gBAAgBM,gBAAgB;QACjE,qBAAO,KAACP;YAAuBQ,MAAM;;IACvC;IAEA,qBACE,KAACC;QACCC,KAAI;QACJC,WAAW,GAAGT,UAAU,OAAO,CAAC;QAChCU,QAAQ;QACRC,SAAS,IAAMP,YAAY;QAC3BQ,KAAKP;QACLQ,OAAO;;AAGb,EAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
type FigmaAvatarPlaceholderProps = {
|
|
4
|
+
size?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const FigmaAvatarPlaceholder: React.FC<FigmaAvatarPlaceholderProps>;
|
|
7
|
+
export declare function isValidImageUrl(url: string): boolean;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/FigmaAvatarPlaceholder/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,cAAc,CAAA;AAIrB,KAAK,2BAA2B,GAAG;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAMxE,CAAA;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOpD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './index.scss';
|
|
3
|
+
const baseClass = 'figma-avatar-placeholder';
|
|
4
|
+
export const FigmaAvatarPlaceholder = ({ size = 25 })=>/*#__PURE__*/ _jsxs("svg", {
|
|
5
|
+
className: baseClass,
|
|
6
|
+
height: size,
|
|
7
|
+
viewBox: "0 0 25 25",
|
|
8
|
+
width: size,
|
|
9
|
+
children: [
|
|
10
|
+
/*#__PURE__*/ _jsx("circle", {
|
|
11
|
+
className: `${baseClass}__bg`,
|
|
12
|
+
cx: "12.5",
|
|
13
|
+
cy: "12.5",
|
|
14
|
+
r: "11.5"
|
|
15
|
+
}),
|
|
16
|
+
/*#__PURE__*/ _jsx("circle", {
|
|
17
|
+
className: `${baseClass}__head`,
|
|
18
|
+
cx: "12.5",
|
|
19
|
+
cy: "10",
|
|
20
|
+
r: "4"
|
|
21
|
+
}),
|
|
22
|
+
/*#__PURE__*/ _jsx("path", {
|
|
23
|
+
className: `${baseClass}__body`,
|
|
24
|
+
d: "M12.5 15c-4 0-7 2-7 4.5v1h14v-1c0-2.5-3-4.5-7-4.5z"
|
|
25
|
+
})
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
export function isValidImageUrl(url) {
|
|
29
|
+
try {
|
|
30
|
+
const parsed = new URL(url);
|
|
31
|
+
return parsed.protocol === 'https:' || parsed.protocol === 'http:';
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/oauth/components/FigmaAvatarPlaceholder/index.tsx"],"sourcesContent":["import type React from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'figma-avatar-placeholder'\n\ntype FigmaAvatarPlaceholderProps = {\n size?: number\n}\n\nexport const FigmaAvatarPlaceholder: React.FC<FigmaAvatarPlaceholderProps> = ({ size = 25 }) => (\n <svg className={baseClass} height={size} viewBox=\"0 0 25 25\" width={size}>\n <circle className={`${baseClass}__bg`} cx=\"12.5\" cy=\"12.5\" r=\"11.5\" />\n <circle className={`${baseClass}__head`} cx=\"12.5\" cy=\"10\" r=\"4\" />\n <path className={`${baseClass}__body`} d=\"M12.5 15c-4 0-7 2-7 4.5v1h14v-1c0-2.5-3-4.5-7-4.5z\" />\n </svg>\n)\n\nexport function isValidImageUrl(url: string): boolean {\n try {\n const parsed = new URL(url)\n return parsed.protocol === 'https:' || parsed.protocol === 'http:'\n } catch {\n return false\n }\n}\n"],"names":["baseClass","FigmaAvatarPlaceholder","size","svg","className","height","viewBox","width","circle","cx","cy","r","path","d","isValidImageUrl","url","parsed","URL","protocol"],"mappings":";AAEA,OAAO,eAAc;AAErB,MAAMA,YAAY;AAMlB,OAAO,MAAMC,yBAAgE,CAAC,EAAEC,OAAO,EAAE,EAAE,iBACzF,MAACC;QAAIC,WAAWJ;QAAWK,QAAQH;QAAMI,SAAQ;QAAYC,OAAOL;;0BAClE,KAACM;gBAAOJ,WAAW,GAAGJ,UAAU,IAAI,CAAC;gBAAES,IAAG;gBAAOC,IAAG;gBAAOC,GAAE;;0BAC7D,KAACH;gBAAOJ,WAAW,GAAGJ,UAAU,MAAM,CAAC;gBAAES,IAAG;gBAAOC,IAAG;gBAAKC,GAAE;;0BAC7D,KAACC;gBAAKR,WAAW,GAAGJ,UAAU,MAAM,CAAC;gBAAEa,GAAE;;;OAE5C;AAED,OAAO,SAASC,gBAAgBC,GAAW;IACzC,IAAI;QACF,MAAMC,SAAS,IAAIC,IAAIF;QACvB,OAAOC,OAAOE,QAAQ,KAAK,YAAYF,OAAOE,QAAQ,KAAK;IAC7D,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.figma-avatar-placeholder {
|
|
3
|
+
&__bg {
|
|
4
|
+
fill: var(--theme-elevation-50);
|
|
5
|
+
stroke: var(--theme-elevation-200);
|
|
6
|
+
stroke-width: 1px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&__head,
|
|
10
|
+
&__body {
|
|
11
|
+
fill: var(--theme-elevation-200);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&:hover {
|
|
15
|
+
.figma-avatar-placeholder {
|
|
16
|
+
&__bg {
|
|
17
|
+
fill: var(--theme-elevation-200);
|
|
18
|
+
stroke: var(--theme-elevation-600);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&__head,
|
|
22
|
+
&__body {
|
|
23
|
+
fill: var(--theme-elevation-600);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/oauth/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/oauth/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAa,MAAM,SAAS,CAAA;AAKjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AA4BhD,eAAO,MAAM,YAAY,UAAiC,CAAA;AAE1D,eAAO,MAAM,oBAAoB,EAAE,SAQlC,CAAA;AAED,eAAO,MAAM,aAAa,iDAKrB;IACD,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,UAAU,GAAG,SAAS,CAAA;CACtC,KAAG,cAkIH,CAAA"}
|