@cedarjs/cli 6.0.0-canary.2864 → 6.0.0-canary.2866
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.
|
@@ -22,6 +22,21 @@ const builder = createBuilder({
|
|
|
22
22
|
default: "",
|
|
23
23
|
description: "Use to enforce a specific query name within the generated cell - must be unique.",
|
|
24
24
|
type: "string"
|
|
25
|
+
},
|
|
26
|
+
beforeQuery: {
|
|
27
|
+
default: false,
|
|
28
|
+
description: "Include a typed `beforeQuery` stub for configuring the query (e.g. variables, fetch policy).",
|
|
29
|
+
type: "boolean"
|
|
30
|
+
},
|
|
31
|
+
afterQuery: {
|
|
32
|
+
default: false,
|
|
33
|
+
description: "Include a typed `afterQuery` stub for sanitizing data returned from the query.",
|
|
34
|
+
type: "boolean"
|
|
35
|
+
},
|
|
36
|
+
isEmpty: {
|
|
37
|
+
default: false,
|
|
38
|
+
description: "Include a typed `isEmpty` stub for overriding the default check for the Empty component.",
|
|
39
|
+
type: "boolean"
|
|
25
40
|
}
|
|
26
41
|
};
|
|
27
42
|
}
|
|
@@ -26,7 +26,10 @@ const files = async ({
|
|
|
26
26
|
list = false,
|
|
27
27
|
query,
|
|
28
28
|
stories,
|
|
29
|
-
tests
|
|
29
|
+
tests,
|
|
30
|
+
beforeQuery = false,
|
|
31
|
+
afterQuery = false,
|
|
32
|
+
isEmpty = false
|
|
30
33
|
}) => {
|
|
31
34
|
let cellName = removeGeneratorName(name, "cell");
|
|
32
35
|
let idName = "id";
|
|
@@ -71,7 +74,10 @@ const files = async ({
|
|
|
71
74
|
templateVars: {
|
|
72
75
|
operationName,
|
|
73
76
|
idName,
|
|
74
|
-
idType
|
|
77
|
+
idType,
|
|
78
|
+
beforeQuery,
|
|
79
|
+
afterQuery,
|
|
80
|
+
isEmpty
|
|
75
81
|
}
|
|
76
82
|
});
|
|
77
83
|
const testFile = await templateForComponentFile({
|
|
@@ -6,7 +6,9 @@ import type {
|
|
|
6
6
|
import type {
|
|
7
7
|
CellSuccessProps,
|
|
8
8
|
CellFailureProps,
|
|
9
|
-
TypedDocumentNode
|
|
9
|
+
TypedDocumentNode,<% if (beforeQuery) { %>
|
|
10
|
+
CellBeforeQueryResult,<% } %><% if (afterQuery || isEmpty) { %>
|
|
11
|
+
DataObject,<% } %>
|
|
10
12
|
} from '@cedarjs/web'
|
|
11
13
|
|
|
12
14
|
export const QUERY: TypedDocumentNode<
|
|
@@ -19,7 +21,24 @@ export const QUERY: TypedDocumentNode<
|
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
`
|
|
22
|
-
|
|
24
|
+
<% if (beforeQuery) { %>
|
|
25
|
+
export const beforeQuery = (
|
|
26
|
+
props: ${operationName}Variables,
|
|
27
|
+
): CellBeforeQueryResult<${operationName}Variables> => {
|
|
28
|
+
return { variables: props, fetchPolicy: 'cache-and-network' }
|
|
29
|
+
}
|
|
30
|
+
<% } %><% if (isEmpty) { %>
|
|
31
|
+
export const isEmpty = (
|
|
32
|
+
data: DataObject,
|
|
33
|
+
{ isDataEmpty }: { isDataEmpty: (data: DataObject) => boolean },
|
|
34
|
+
) => {
|
|
35
|
+
return isDataEmpty(data)
|
|
36
|
+
}
|
|
37
|
+
<% } %><% if (afterQuery) { %>
|
|
38
|
+
export const afterQuery = (data: DataObject): DataObject => {
|
|
39
|
+
return data
|
|
40
|
+
}
|
|
41
|
+
<% } %>
|
|
23
42
|
export const Loading = () => <div>Loading...</div>
|
|
24
43
|
|
|
25
44
|
export const Empty = () => <div>Empty</div>
|
|
@@ -3,7 +3,9 @@ import type { ${operationName}, ${operationName}Variables } from 'types/graphql
|
|
|
3
3
|
import type {
|
|
4
4
|
CellSuccessProps,
|
|
5
5
|
CellFailureProps,
|
|
6
|
-
TypedDocumentNode
|
|
6
|
+
TypedDocumentNode,<% if (beforeQuery) { %>
|
|
7
|
+
CellBeforeQueryResult,<% } %><% if (afterQuery || isEmpty) { %>
|
|
8
|
+
DataObject,<% } %>
|
|
7
9
|
} from '@cedarjs/web'
|
|
8
10
|
|
|
9
11
|
export const QUERY: TypedDocumentNode<
|
|
@@ -16,7 +18,24 @@ export const QUERY: TypedDocumentNode<
|
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
`
|
|
19
|
-
|
|
21
|
+
<% if (beforeQuery) { %>
|
|
22
|
+
export const beforeQuery = (
|
|
23
|
+
props: ${operationName}Variables,
|
|
24
|
+
): CellBeforeQueryResult<${operationName}Variables> => {
|
|
25
|
+
return { variables: props, fetchPolicy: 'cache-and-network' }
|
|
26
|
+
}
|
|
27
|
+
<% } %><% if (isEmpty) { %>
|
|
28
|
+
export const isEmpty = (
|
|
29
|
+
data: DataObject,
|
|
30
|
+
{ isDataEmpty }: { isDataEmpty: (data: DataObject) => boolean },
|
|
31
|
+
) => {
|
|
32
|
+
return isDataEmpty(data)
|
|
33
|
+
}
|
|
34
|
+
<% } %><% if (afterQuery) { %>
|
|
35
|
+
export const afterQuery = (data: DataObject): DataObject => {
|
|
36
|
+
return data
|
|
37
|
+
}
|
|
38
|
+
<% } %>
|
|
20
39
|
export const Loading = () => <div>Loading...</div>
|
|
21
40
|
|
|
22
41
|
export const Empty = () => <div>Empty</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2866",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"@babel/preset-typescript": "7.29.7",
|
|
37
37
|
"@babel/traverse": "7.29.7",
|
|
38
38
|
"@babel/types": "7.29.7",
|
|
39
|
-
"@cedarjs/api-server": "6.0.0-canary.
|
|
40
|
-
"@cedarjs/babel-config": "6.0.0-canary.
|
|
41
|
-
"@cedarjs/cli-helpers": "6.0.0-canary.
|
|
42
|
-
"@cedarjs/internal": "6.0.0-canary.
|
|
43
|
-
"@cedarjs/prerender": "6.0.0-canary.
|
|
44
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
45
|
-
"@cedarjs/structure": "6.0.0-canary.
|
|
46
|
-
"@cedarjs/telemetry": "6.0.0-canary.
|
|
47
|
-
"@cedarjs/utils": "6.0.0-canary.
|
|
48
|
-
"@cedarjs/vite": "6.0.0-canary.
|
|
49
|
-
"@cedarjs/web-server": "6.0.0-canary.
|
|
39
|
+
"@cedarjs/api-server": "6.0.0-canary.2866",
|
|
40
|
+
"@cedarjs/babel-config": "6.0.0-canary.2866",
|
|
41
|
+
"@cedarjs/cli-helpers": "6.0.0-canary.2866",
|
|
42
|
+
"@cedarjs/internal": "6.0.0-canary.2866",
|
|
43
|
+
"@cedarjs/prerender": "6.0.0-canary.2866",
|
|
44
|
+
"@cedarjs/project-config": "6.0.0-canary.2866",
|
|
45
|
+
"@cedarjs/structure": "6.0.0-canary.2866",
|
|
46
|
+
"@cedarjs/telemetry": "6.0.0-canary.2866",
|
|
47
|
+
"@cedarjs/utils": "6.0.0-canary.2866",
|
|
48
|
+
"@cedarjs/vite": "6.0.0-canary.2866",
|
|
49
|
+
"@cedarjs/web-server": "6.0.0-canary.2866",
|
|
50
50
|
"@listr2/prompt-adapter-enquirer": "4.3.0",
|
|
51
51
|
"@opentelemetry/api": "1.9.1",
|
|
52
52
|
"@opentelemetry/core": "1.30.1",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"yargs": "17.7.3"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
97
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2866",
|
|
98
98
|
"@prisma/dmmf": "7.8.0",
|
|
99
99
|
"@types/archiver": "^7.0.0",
|
|
100
100
|
"memfs": "4.64.0",
|