@sitecore-jss/sitecore-jss-nextjs 21.5.0 → 21.6.0-canary.10
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/LICENSE.txt +202 -202
- package/README.md +12 -9
- package/dist/cjs/editing/constants.js +6 -0
- package/dist/cjs/editing/editing-data-middleware.js +2 -2
- package/dist/cjs/editing/editing-data-service.js +15 -7
- package/dist/cjs/editing/editing-render-middleware.js +31 -8
- package/dist/esm/editing/constants.js +3 -0
- package/dist/esm/editing/editing-data-middleware.js +1 -1
- package/dist/esm/editing/editing-data-service.js +13 -5
- package/dist/esm/editing/editing-render-middleware.js +31 -8
- package/package.json +5 -5
- package/types/ComponentBuilder.d.ts +1 -0
- package/types/components/ComponentPropsContext.d.ts +1 -0
- package/types/components/Link.d.ts +1 -0
- package/types/components/NextImage.d.ts +1 -0
- package/types/components/Placeholder.d.ts +1 -0
- package/types/editing/constants.d.ts +3 -0
- package/types/editing/editing-data-service.d.ts +12 -4
- package/types/editing/editing-render-middleware.d.ts +10 -0
- package/types/sharedTypes/module-factory.d.ts +1 -0
package/LICENSE.txt
CHANGED
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
Apache License
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
5
|
-
|
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
-
|
|
8
|
-
1. Definitions.
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
-
|
|
181
|
-
To apply the Apache License to your work, attach the following
|
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
-
replaced with your own identifying information. (Don't include
|
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format. We also recommend that a
|
|
186
|
-
file or class name and description of purpose be included on the
|
|
187
|
-
same "printed page" as the copyright notice for easier
|
|
188
|
-
identification within third-party archives.
|
|
189
|
-
|
|
190
|
-
Copyright [yyyy] [name of copyright owner]
|
|
191
|
-
|
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
you may not use this file except in compliance with the License.
|
|
194
|
-
You may obtain a copy of the License at
|
|
195
|
-
|
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
|
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
-
See the License for the specific language governing permissions and
|
|
202
|
-
limitations under the License.
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
# Sitecore JavaScript Rendering SDK for Next.js
|
|
2
|
-
|
|
3
|
-
This module is provided as a part of Sitecore JavaScript Rendering SDK. It contains Next.js components and integration for JSS.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
# Sitecore JavaScript Rendering SDK for Next.js
|
|
2
|
+
|
|
3
|
+
This module is provided as a part of Sitecore JavaScript Rendering SDK. It contains Next.js components and integration for JSS.
|
|
4
|
+
|
|
5
|
+
<!---
|
|
6
|
+
@TODO: Update to next version docs before release
|
|
7
|
+
-->
|
|
8
|
+
[Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
|
|
9
|
+
|
|
10
|
+
[Documentation (XM Cloud)](https://doc.sitecore.com/xmc/en/developers/xm-cloud/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
|
|
11
|
+
|
|
12
|
+
[API reference documentation](/ref-docs/sitecore-jss-nextjs/)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QUERY_PARAM_PROTECTION_BYPASS_VERCEL = exports.QUERY_PARAM_PROTECTION_BYPASS_SITECORE = exports.QUERY_PARAM_EDITING_SECRET = void 0;
|
|
4
|
+
exports.QUERY_PARAM_EDITING_SECRET = 'secret';
|
|
5
|
+
exports.QUERY_PARAM_PROTECTION_BYPASS_SITECORE = 'x-sitecore-protection-bypass';
|
|
6
|
+
exports.QUERY_PARAM_PROTECTION_BYPASS_VERCEL = 'x-vercel-protection-bypass';
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.EditingDataMiddleware = void 0;
|
|
13
13
|
const editing_data_cache_1 = require("./editing-data-cache");
|
|
14
14
|
const editing_data_1 = require("./editing-data");
|
|
15
|
-
const
|
|
15
|
+
const constants_1 = require("./constants");
|
|
16
16
|
const utils_1 = require("../utils/utils");
|
|
17
17
|
/**
|
|
18
18
|
* Middleware / handler for use in the editing data Next.js API dynamic route (e.g. '/api/editing/data/[key]')
|
|
@@ -26,7 +26,7 @@ class EditingDataMiddleware {
|
|
|
26
26
|
var _a, _b;
|
|
27
27
|
this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
28
28
|
const { method, query, body } = req;
|
|
29
|
-
const secret = query[
|
|
29
|
+
const secret = query[constants_1.QUERY_PARAM_EDITING_SECRET];
|
|
30
30
|
const key = query[this.queryParamKey];
|
|
31
31
|
// Validate secret
|
|
32
32
|
if (secret !== (0, utils_1.getJssEditingSecret)()) {
|
|
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.editingDataService = exports.ServerlessEditingDataService = exports.BasicEditingDataService = exports.generateKey =
|
|
12
|
+
exports.editingDataService = exports.ServerlessEditingDataService = exports.BasicEditingDataService = exports.generateKey = void 0;
|
|
13
|
+
const constants_1 = require("./constants");
|
|
13
14
|
const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
14
15
|
const editing_data_cache_1 = require("./editing-data-cache");
|
|
15
16
|
const utils_1 = require("../utils/utils");
|
|
16
|
-
exports.QUERY_PARAM_EDITING_SECRET = 'secret';
|
|
17
17
|
/**
|
|
18
18
|
* Unique key generator.
|
|
19
19
|
* Need more than just the item GUID since requests are made "live" during editing in EE.
|
|
@@ -98,13 +98,14 @@ class ServerlessEditingDataService {
|
|
|
98
98
|
* @param {string} serverUrl The server url to use for subsequent data API requests
|
|
99
99
|
* @returns {Promise} The {@link EditingPreviewData} containing the generated key and serverUrl to use for retrieval
|
|
100
100
|
*/
|
|
101
|
-
setEditingData(data, serverUrl) {
|
|
101
|
+
setEditingData(data, serverUrl, params) {
|
|
102
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
103
|
const key = this.generateKey(data);
|
|
104
|
-
const url = this.getUrl(serverUrl, key);
|
|
104
|
+
const url = this.getUrl(serverUrl, key, params);
|
|
105
105
|
const previewData = {
|
|
106
106
|
key,
|
|
107
107
|
serverUrl,
|
|
108
|
+
params,
|
|
108
109
|
};
|
|
109
110
|
sitecore_jss_1.debug.editing('storing editing data for %o: %o', previewData, data);
|
|
110
111
|
return this.dataFetcher.put(url, data).then(() => {
|
|
@@ -123,20 +124,27 @@ class ServerlessEditingDataService {
|
|
|
123
124
|
if (!(editingPreviewData === null || editingPreviewData === void 0 ? void 0 : editingPreviewData.serverUrl)) {
|
|
124
125
|
return undefined;
|
|
125
126
|
}
|
|
126
|
-
const url = this.getUrl(editingPreviewData.serverUrl, editingPreviewData.key);
|
|
127
|
+
const url = this.getUrl(editingPreviewData.serverUrl, editingPreviewData.key, editingPreviewData.params);
|
|
127
128
|
sitecore_jss_1.debug.editing('retrieving editing data for %o', previewData);
|
|
128
129
|
return this.dataFetcher.get(url).then((response) => {
|
|
129
130
|
return response.data;
|
|
130
131
|
});
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
|
-
getUrl(serverUrl, key) {
|
|
134
|
+
getUrl(serverUrl, key, params) {
|
|
134
135
|
var _a;
|
|
135
136
|
// Example URL format:
|
|
136
137
|
// http://localhost:3000/api/editing/data/52961eea-bafd-5287-a532-a72e36bd8a36-qkb4e3fv5x?secret=1234secret
|
|
137
138
|
const apiRoute = (_a = this.apiRoute) === null || _a === void 0 ? void 0 : _a.replace('[key]', key);
|
|
138
139
|
const url = new URL(apiRoute, serverUrl);
|
|
139
|
-
url.searchParams.append(
|
|
140
|
+
url.searchParams.append(constants_1.QUERY_PARAM_EDITING_SECRET, (0, utils_1.getJssEditingSecret)());
|
|
141
|
+
if (params) {
|
|
142
|
+
for (const key in params) {
|
|
143
|
+
if ({}.hasOwnProperty.call(params, key)) {
|
|
144
|
+
url.searchParams.append(key, params[key]);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
140
148
|
return url.toString();
|
|
141
149
|
}
|
|
142
150
|
}
|
|
@@ -15,6 +15,7 @@ const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
|
15
15
|
const layout_1 = require("@sitecore-jss/sitecore-jss/layout");
|
|
16
16
|
const node_html_parser_1 = require("node-html-parser");
|
|
17
17
|
const editing_data_service_1 = require("./editing-data-service");
|
|
18
|
+
const constants_2 = require("./constants");
|
|
18
19
|
const utils_1 = require("../utils/utils");
|
|
19
20
|
/**
|
|
20
21
|
* Middleware / handler for use in the editing render Next.js API route (e.g. '/api/editing/render')
|
|
@@ -26,6 +27,21 @@ class EditingRenderMiddleware {
|
|
|
26
27
|
*/
|
|
27
28
|
constructor(config) {
|
|
28
29
|
var _a, _b, _c, _d;
|
|
30
|
+
/**
|
|
31
|
+
* Gets query parameters that should be passed along to subsequent requests
|
|
32
|
+
* @param query Object of query parameters from incoming URL
|
|
33
|
+
* @returns Object of approved query parameters
|
|
34
|
+
*/
|
|
35
|
+
this.getQueryParamsForPropagation = (query) => {
|
|
36
|
+
const params = {};
|
|
37
|
+
if (query[constants_2.QUERY_PARAM_PROTECTION_BYPASS_SITECORE]) {
|
|
38
|
+
params[constants_2.QUERY_PARAM_PROTECTION_BYPASS_SITECORE] = query[constants_2.QUERY_PARAM_PROTECTION_BYPASS_SITECORE];
|
|
39
|
+
}
|
|
40
|
+
if (query[constants_2.QUERY_PARAM_PROTECTION_BYPASS_VERCEL]) {
|
|
41
|
+
params[constants_2.QUERY_PARAM_PROTECTION_BYPASS_VERCEL] = query[constants_2.QUERY_PARAM_PROTECTION_BYPASS_VERCEL];
|
|
42
|
+
}
|
|
43
|
+
return params;
|
|
44
|
+
};
|
|
29
45
|
this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
30
46
|
var _e, _f;
|
|
31
47
|
const { method, query, body, headers } = req;
|
|
@@ -44,7 +60,7 @@ class EditingRenderMiddleware {
|
|
|
44
60
|
});
|
|
45
61
|
}
|
|
46
62
|
// Validate secret
|
|
47
|
-
const secret = (_e = query[
|
|
63
|
+
const secret = (_e = query[constants_2.QUERY_PARAM_EDITING_SECRET]) !== null && _e !== void 0 ? _e : body === null || body === void 0 ? void 0 : body.jssEditingSecret;
|
|
48
64
|
if (secret !== (0, utils_1.getJssEditingSecret)()) {
|
|
49
65
|
sitecore_jss_1.debug.editing('invalid editing secret - sent "%s" expected "%s"', secret, (0, utils_1.getJssEditingSecret)());
|
|
50
66
|
return res.status(401).json({
|
|
@@ -56,21 +72,28 @@ class EditingRenderMiddleware {
|
|
|
56
72
|
const editingData = extractEditingData(req);
|
|
57
73
|
// Resolve server URL
|
|
58
74
|
const serverUrl = this.resolveServerUrl(req);
|
|
75
|
+
// Get query string parameters to propagate on subsequent requests (e.g. for deployment protection bypass)
|
|
76
|
+
const params = this.getQueryParamsForPropagation(query);
|
|
59
77
|
// Stash for use later on (i.e. within getStatic/ServerSideProps).
|
|
60
78
|
// Note we can't set this directly in setPreviewData since it's stored as a cookie (2KB limit)
|
|
61
79
|
// https://nextjs.org/docs/advanced-features/preview-mode#previewdata-size-limits)
|
|
62
|
-
const previewData = yield this.editingDataService.setEditingData(editingData, serverUrl);
|
|
80
|
+
const previewData = yield this.editingDataService.setEditingData(editingData, serverUrl, params);
|
|
63
81
|
// Enable Next.js Preview Mode, passing our preview data (i.e. editingData cache key)
|
|
64
82
|
res.setPreviewData(previewData);
|
|
65
83
|
// Grab the Next.js preview cookies to send on to the render request
|
|
66
84
|
const cookies = res.getHeader('Set-Cookie');
|
|
67
|
-
// Make actual render request for page route, passing on preview cookies.
|
|
85
|
+
// Make actual render request for page route, passing on preview cookies as well as any approved query string parameters.
|
|
68
86
|
// Note timestamp effectively disables caching the request in Axios (no amount of cache headers seemed to do it)
|
|
69
|
-
const requestUrl = this.resolvePageUrl(serverUrl, editingData.path);
|
|
70
87
|
sitecore_jss_1.debug.editing('fetching page route for %s', editingData.path);
|
|
71
|
-
const
|
|
88
|
+
const requestUrl = new URL(this.resolvePageUrl(serverUrl, editingData.path));
|
|
89
|
+
for (const key in params) {
|
|
90
|
+
if ({}.hasOwnProperty.call(params, key)) {
|
|
91
|
+
requestUrl.searchParams.append(key, params[key]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
requestUrl.searchParams.append('timestamp', Date.now().toString());
|
|
72
95
|
const pageRes = yield this.dataFetcher
|
|
73
|
-
.get(
|
|
96
|
+
.get(requestUrl.toString(), {
|
|
74
97
|
headers: {
|
|
75
98
|
Cookie: cookies.join(';'),
|
|
76
99
|
},
|
|
@@ -85,7 +108,7 @@ class EditingRenderMiddleware {
|
|
|
85
108
|
});
|
|
86
109
|
let html = pageRes.data;
|
|
87
110
|
if (!html || html.length === 0) {
|
|
88
|
-
throw new Error(`Failed to render html for ${
|
|
111
|
+
throw new Error(`Failed to render html for ${editingData.path}`);
|
|
89
112
|
}
|
|
90
113
|
// replace phkey attribute with key attribute so that newly added renderings
|
|
91
114
|
// show correct placeholders, so save and refresh won't be needed after adding each rendering
|
|
@@ -101,7 +124,7 @@ class EditingRenderMiddleware {
|
|
|
101
124
|
// Handle component rendering. Extract component markup only
|
|
102
125
|
html = (_f = (0, node_html_parser_1.parse)(html).getElementById(layout_1.EDITING_COMPONENT_ID)) === null || _f === void 0 ? void 0 : _f.innerHTML;
|
|
103
126
|
if (!html)
|
|
104
|
-
throw new Error(`Failed to render component for ${
|
|
127
|
+
throw new Error(`Failed to render component for ${editingData.path}`);
|
|
105
128
|
}
|
|
106
129
|
const body = { html };
|
|
107
130
|
// Return expected JSON result
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { editingDataDiskCache } from './editing-data-cache';
|
|
11
11
|
import { isEditingData } from './editing-data';
|
|
12
|
-
import { QUERY_PARAM_EDITING_SECRET } from './
|
|
12
|
+
import { QUERY_PARAM_EDITING_SECRET } from './constants';
|
|
13
13
|
import { getJssEditingSecret } from '../utils/utils';
|
|
14
14
|
/**
|
|
15
15
|
* Middleware / handler for use in the editing data Next.js API dynamic route (e.g. '/api/editing/data/[key]')
|
|
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { QUERY_PARAM_EDITING_SECRET } from './constants';
|
|
10
11
|
import { AxiosDataFetcher, debug } from '@sitecore-jss/sitecore-jss';
|
|
11
12
|
import { editingDataDiskCache } from './editing-data-cache';
|
|
12
13
|
import { getJssEditingSecret } from '../utils/utils';
|
|
13
|
-
export const QUERY_PARAM_EDITING_SECRET = 'secret';
|
|
14
14
|
/**
|
|
15
15
|
* Unique key generator.
|
|
16
16
|
* Need more than just the item GUID since requests are made "live" during editing in EE.
|
|
@@ -93,13 +93,14 @@ export class ServerlessEditingDataService {
|
|
|
93
93
|
* @param {string} serverUrl The server url to use for subsequent data API requests
|
|
94
94
|
* @returns {Promise} The {@link EditingPreviewData} containing the generated key and serverUrl to use for retrieval
|
|
95
95
|
*/
|
|
96
|
-
setEditingData(data, serverUrl) {
|
|
96
|
+
setEditingData(data, serverUrl, params) {
|
|
97
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
98
|
const key = this.generateKey(data);
|
|
99
|
-
const url = this.getUrl(serverUrl, key);
|
|
99
|
+
const url = this.getUrl(serverUrl, key, params);
|
|
100
100
|
const previewData = {
|
|
101
101
|
key,
|
|
102
102
|
serverUrl,
|
|
103
|
+
params,
|
|
103
104
|
};
|
|
104
105
|
debug.editing('storing editing data for %o: %o', previewData, data);
|
|
105
106
|
return this.dataFetcher.put(url, data).then(() => {
|
|
@@ -118,20 +119,27 @@ export class ServerlessEditingDataService {
|
|
|
118
119
|
if (!(editingPreviewData === null || editingPreviewData === void 0 ? void 0 : editingPreviewData.serverUrl)) {
|
|
119
120
|
return undefined;
|
|
120
121
|
}
|
|
121
|
-
const url = this.getUrl(editingPreviewData.serverUrl, editingPreviewData.key);
|
|
122
|
+
const url = this.getUrl(editingPreviewData.serverUrl, editingPreviewData.key, editingPreviewData.params);
|
|
122
123
|
debug.editing('retrieving editing data for %o', previewData);
|
|
123
124
|
return this.dataFetcher.get(url).then((response) => {
|
|
124
125
|
return response.data;
|
|
125
126
|
});
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
|
-
getUrl(serverUrl, key) {
|
|
129
|
+
getUrl(serverUrl, key, params) {
|
|
129
130
|
var _a;
|
|
130
131
|
// Example URL format:
|
|
131
132
|
// http://localhost:3000/api/editing/data/52961eea-bafd-5287-a532-a72e36bd8a36-qkb4e3fv5x?secret=1234secret
|
|
132
133
|
const apiRoute = (_a = this.apiRoute) === null || _a === void 0 ? void 0 : _a.replace('[key]', key);
|
|
133
134
|
const url = new URL(apiRoute, serverUrl);
|
|
134
135
|
url.searchParams.append(QUERY_PARAM_EDITING_SECRET, getJssEditingSecret());
|
|
136
|
+
if (params) {
|
|
137
|
+
for (const key in params) {
|
|
138
|
+
if ({}.hasOwnProperty.call(params, key)) {
|
|
139
|
+
url.searchParams.append(key, params[key]);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
135
143
|
return url.toString();
|
|
136
144
|
}
|
|
137
145
|
}
|
|
@@ -11,7 +11,8 @@ import { STATIC_PROPS_ID, SERVER_PROPS_ID } from 'next/constants';
|
|
|
11
11
|
import { AxiosDataFetcher, debug } from '@sitecore-jss/sitecore-jss';
|
|
12
12
|
import { EDITING_COMPONENT_ID, RenderingType } from '@sitecore-jss/sitecore-jss/layout';
|
|
13
13
|
import { parse } from 'node-html-parser';
|
|
14
|
-
import { editingDataService
|
|
14
|
+
import { editingDataService } from './editing-data-service';
|
|
15
|
+
import { QUERY_PARAM_EDITING_SECRET, QUERY_PARAM_PROTECTION_BYPASS_SITECORE, QUERY_PARAM_PROTECTION_BYPASS_VERCEL, } from './constants';
|
|
15
16
|
import { getJssEditingSecret } from '../utils/utils';
|
|
16
17
|
/**
|
|
17
18
|
* Middleware / handler for use in the editing render Next.js API route (e.g. '/api/editing/render')
|
|
@@ -23,6 +24,21 @@ export class EditingRenderMiddleware {
|
|
|
23
24
|
*/
|
|
24
25
|
constructor(config) {
|
|
25
26
|
var _a, _b, _c, _d;
|
|
27
|
+
/**
|
|
28
|
+
* Gets query parameters that should be passed along to subsequent requests
|
|
29
|
+
* @param query Object of query parameters from incoming URL
|
|
30
|
+
* @returns Object of approved query parameters
|
|
31
|
+
*/
|
|
32
|
+
this.getQueryParamsForPropagation = (query) => {
|
|
33
|
+
const params = {};
|
|
34
|
+
if (query[QUERY_PARAM_PROTECTION_BYPASS_SITECORE]) {
|
|
35
|
+
params[QUERY_PARAM_PROTECTION_BYPASS_SITECORE] = query[QUERY_PARAM_PROTECTION_BYPASS_SITECORE];
|
|
36
|
+
}
|
|
37
|
+
if (query[QUERY_PARAM_PROTECTION_BYPASS_VERCEL]) {
|
|
38
|
+
params[QUERY_PARAM_PROTECTION_BYPASS_VERCEL] = query[QUERY_PARAM_PROTECTION_BYPASS_VERCEL];
|
|
39
|
+
}
|
|
40
|
+
return params;
|
|
41
|
+
};
|
|
26
42
|
this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
27
43
|
var _e, _f;
|
|
28
44
|
const { method, query, body, headers } = req;
|
|
@@ -53,21 +69,28 @@ export class EditingRenderMiddleware {
|
|
|
53
69
|
const editingData = extractEditingData(req);
|
|
54
70
|
// Resolve server URL
|
|
55
71
|
const serverUrl = this.resolveServerUrl(req);
|
|
72
|
+
// Get query string parameters to propagate on subsequent requests (e.g. for deployment protection bypass)
|
|
73
|
+
const params = this.getQueryParamsForPropagation(query);
|
|
56
74
|
// Stash for use later on (i.e. within getStatic/ServerSideProps).
|
|
57
75
|
// Note we can't set this directly in setPreviewData since it's stored as a cookie (2KB limit)
|
|
58
76
|
// https://nextjs.org/docs/advanced-features/preview-mode#previewdata-size-limits)
|
|
59
|
-
const previewData = yield this.editingDataService.setEditingData(editingData, serverUrl);
|
|
77
|
+
const previewData = yield this.editingDataService.setEditingData(editingData, serverUrl, params);
|
|
60
78
|
// Enable Next.js Preview Mode, passing our preview data (i.e. editingData cache key)
|
|
61
79
|
res.setPreviewData(previewData);
|
|
62
80
|
// Grab the Next.js preview cookies to send on to the render request
|
|
63
81
|
const cookies = res.getHeader('Set-Cookie');
|
|
64
|
-
// Make actual render request for page route, passing on preview cookies.
|
|
82
|
+
// Make actual render request for page route, passing on preview cookies as well as any approved query string parameters.
|
|
65
83
|
// Note timestamp effectively disables caching the request in Axios (no amount of cache headers seemed to do it)
|
|
66
|
-
const requestUrl = this.resolvePageUrl(serverUrl, editingData.path);
|
|
67
84
|
debug.editing('fetching page route for %s', editingData.path);
|
|
68
|
-
const
|
|
85
|
+
const requestUrl = new URL(this.resolvePageUrl(serverUrl, editingData.path));
|
|
86
|
+
for (const key in params) {
|
|
87
|
+
if ({}.hasOwnProperty.call(params, key)) {
|
|
88
|
+
requestUrl.searchParams.append(key, params[key]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
requestUrl.searchParams.append('timestamp', Date.now().toString());
|
|
69
92
|
const pageRes = yield this.dataFetcher
|
|
70
|
-
.get(
|
|
93
|
+
.get(requestUrl.toString(), {
|
|
71
94
|
headers: {
|
|
72
95
|
Cookie: cookies.join(';'),
|
|
73
96
|
},
|
|
@@ -82,7 +105,7 @@ export class EditingRenderMiddleware {
|
|
|
82
105
|
});
|
|
83
106
|
let html = pageRes.data;
|
|
84
107
|
if (!html || html.length === 0) {
|
|
85
|
-
throw new Error(`Failed to render html for ${
|
|
108
|
+
throw new Error(`Failed to render html for ${editingData.path}`);
|
|
86
109
|
}
|
|
87
110
|
// replace phkey attribute with key attribute so that newly added renderings
|
|
88
111
|
// show correct placeholders, so save and refresh won't be needed after adding each rendering
|
|
@@ -98,7 +121,7 @@ export class EditingRenderMiddleware {
|
|
|
98
121
|
// Handle component rendering. Extract component markup only
|
|
99
122
|
html = (_f = parse(html).getElementById(EDITING_COMPONENT_ID)) === null || _f === void 0 ? void 0 : _f.innerHTML;
|
|
100
123
|
if (!html)
|
|
101
|
-
throw new Error(`Failed to render component for ${
|
|
124
|
+
throw new Error(`Failed to render component for ${editingData.path}`);
|
|
102
125
|
}
|
|
103
126
|
const body = { html };
|
|
104
127
|
// Return expected JSON result
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.6.0-canary.10",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"react-dom": "^18.2.0"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@sitecore-jss/sitecore-jss": "21.
|
|
76
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "21.
|
|
77
|
-
"@sitecore-jss/sitecore-jss-react": "21.
|
|
75
|
+
"@sitecore-jss/sitecore-jss": "^21.6.0-canary.10",
|
|
76
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^21.6.0-canary.10",
|
|
77
|
+
"@sitecore-jss/sitecore-jss-react": "^21.6.0-canary.10",
|
|
78
78
|
"@vercel/kv": "^0.2.1",
|
|
79
79
|
"node-html-parser": "^6.1.4",
|
|
80
80
|
"prop-types": "^15.8.1",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"description": "",
|
|
85
85
|
"types": "types/index.d.ts",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "e817e8c5acc83bda2e6d8cb16fc656eb0ce8e19f",
|
|
87
87
|
"files": [
|
|
88
88
|
"dist",
|
|
89
89
|
"types",
|
|
@@ -2,13 +2,15 @@ import { AxiosDataFetcher } from '@sitecore-jss/sitecore-jss';
|
|
|
2
2
|
import { EditingData } from './editing-data';
|
|
3
3
|
import { EditingDataCache } from './editing-data-cache';
|
|
4
4
|
import { PreviewData } from 'next';
|
|
5
|
-
export declare const QUERY_PARAM_EDITING_SECRET = "secret";
|
|
6
5
|
/**
|
|
7
6
|
* Data for Next.js Preview (Editing) mode
|
|
8
7
|
*/
|
|
9
8
|
export interface EditingPreviewData {
|
|
10
9
|
key: string;
|
|
11
10
|
serverUrl?: string;
|
|
11
|
+
params?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* Defines an editing data service implementation
|
|
@@ -20,7 +22,9 @@ export interface EditingDataService {
|
|
|
20
22
|
* @param {string} serverUrl The server url e.g. which can be used for further API requests
|
|
21
23
|
* @returns The {@link EditingPreviewData} containing the information to use for retrieval
|
|
22
24
|
*/
|
|
23
|
-
setEditingData(data: EditingData, serverUrl: string
|
|
25
|
+
setEditingData(data: EditingData, serverUrl: string, params?: {
|
|
26
|
+
[key: string]: string;
|
|
27
|
+
}): Promise<EditingPreviewData>;
|
|
24
28
|
/**
|
|
25
29
|
* Retrieves Sitecore editor payload data
|
|
26
30
|
* @param {PreviewData} previewData Editing preview data containing the information to use for retrieval
|
|
@@ -107,14 +111,18 @@ export declare class ServerlessEditingDataService implements EditingDataService
|
|
|
107
111
|
* @param {string} serverUrl The server url to use for subsequent data API requests
|
|
108
112
|
* @returns {Promise} The {@link EditingPreviewData} containing the generated key and serverUrl to use for retrieval
|
|
109
113
|
*/
|
|
110
|
-
setEditingData(data: EditingData, serverUrl: string
|
|
114
|
+
setEditingData(data: EditingData, serverUrl: string, params?: {
|
|
115
|
+
[key: string]: string;
|
|
116
|
+
}): Promise<EditingPreviewData>;
|
|
111
117
|
/**
|
|
112
118
|
* Retrieves Sitecore editor payload data by key
|
|
113
119
|
* @param {PreviewData} previewData Editing preview data containing the key and serverUrl to use for retrieval
|
|
114
120
|
* @returns {Promise} The {@link EditingData}
|
|
115
121
|
*/
|
|
116
122
|
getEditingData(previewData: PreviewData): Promise<EditingData | undefined>;
|
|
117
|
-
protected getUrl(serverUrl: string, key: string
|
|
123
|
+
protected getUrl(serverUrl: string, key: string, params?: {
|
|
124
|
+
[key: string]: string;
|
|
125
|
+
}): string;
|
|
118
126
|
}
|
|
119
127
|
/**
|
|
120
128
|
* The `EditingDataService` default instance.
|
|
@@ -55,6 +55,16 @@ export declare class EditingRenderMiddleware {
|
|
|
55
55
|
* @returns route handler
|
|
56
56
|
*/
|
|
57
57
|
getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Gets query parameters that should be passed along to subsequent requests
|
|
60
|
+
* @param query Object of query parameters from incoming URL
|
|
61
|
+
* @returns Object of approved query parameters
|
|
62
|
+
*/
|
|
63
|
+
protected getQueryParamsForPropagation: (query: Partial<{
|
|
64
|
+
[key: string]: string | string[];
|
|
65
|
+
}>) => {
|
|
66
|
+
[key: string]: string;
|
|
67
|
+
};
|
|
58
68
|
private handler;
|
|
59
69
|
/**
|
|
60
70
|
* Default page URL resolution.
|