@sitecore-content-sdk/core 2.0.0-canary.9 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +202 -202
- package/dist/cjs/constants.js +36 -1
- package/dist/cjs/debug.js +11 -0
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/initialization/helpers.js +65 -0
- package/dist/cjs/initialization/index.js +6 -0
- package/dist/cjs/initialization/init-content-sdk.js +46 -0
- package/dist/cjs/initialization/types.js +2 -0
- package/dist/cjs/tools/auth/flow.js +1 -1
- package/dist/cjs/tools/timeout-promise.js +4 -1
- package/dist/esm/constants.js +35 -0
- package/dist/esm/debug.js +10 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/initialization/helpers.js +57 -0
- package/dist/esm/initialization/index.js +1 -0
- package/dist/esm/initialization/init-content-sdk.js +39 -0
- package/dist/esm/initialization/types.js +1 -0
- package/dist/esm/tools/auth/flow.js +2 -2
- package/dist/esm/tools/timeout-promise.js +4 -1
- package/package.json +4 -2
- package/types/constants.d.ts +34 -0
- package/types/constants.d.ts.map +1 -1
- package/types/debug.d.ts +8 -0
- package/types/debug.d.ts.map +1 -1
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/initialization/helpers.d.ts +23 -0
- package/types/initialization/helpers.d.ts.map +1 -0
- package/types/initialization/index.d.ts +3 -0
- package/types/initialization/index.d.ts.map +1 -0
- package/types/initialization/init-content-sdk.d.ts +15 -0
- package/types/initialization/init-content-sdk.d.ts.map +1 -0
- package/types/initialization/types.d.ts +89 -0
- package/types/initialization/types.d.ts.map +1 -0
- package/types/tools/auth/flow.d.ts.map +1 -1
- package/types/tools/timeout-promise.d.ts.map +1 -1
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/dist/cjs/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable jsdoc/require-param */
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_SITECORE_AUTH_BASE_URL = exports.DEFAULT_SITECORE_AUTH_AUDIENCE = exports.DEFAULT_SITECORE_AUTH_DOMAIN = exports.CLAIMS = exports.SITECORE_EXPERIENCE_EDGE_URL_DEFAULT = exports.SITECORE_EDGE_PLATFORM_URL_DEFAULT = void 0;
|
|
4
|
+
exports.ERROR_MESSAGES = exports.DEFAULT_SITECORE_AUTH_BASE_URL = exports.DEFAULT_SITECORE_AUTH_AUDIENCE = exports.DEFAULT_SITECORE_AUTH_DOMAIN = exports.CLAIMS = exports.SITECORE_EXPERIENCE_EDGE_URL_DEFAULT = exports.SITECORE_EDGE_PLATFORM_URL_DEFAULT = void 0;
|
|
4
5
|
/**
|
|
5
6
|
* Default Edge Platform URL (edge-platform.sitecorecloud.io). Used for service endpoints
|
|
6
7
|
* (GraphQL, content API, forms, layout, static files) when no custom hostname is configured.
|
|
@@ -33,3 +34,37 @@ exports.DEFAULT_SITECORE_AUTH_AUDIENCE = 'https://api.sitecorecloud.io';
|
|
|
33
34
|
* @internal
|
|
34
35
|
*/
|
|
35
36
|
exports.DEFAULT_SITECORE_AUTH_BASE_URL = 'https://edge-platform.sitecorecloud.io/cs/api';
|
|
37
|
+
/**
|
|
38
|
+
* The error messages. Includes errors for all packages.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
exports.ERROR_MESSAGES = {
|
|
42
|
+
/** IV errors are related to incorrect values, wrongly formatted objects, etc. */
|
|
43
|
+
IV_001: '[IV-001] Incorrect value for "edgeUrl". Set the value to a valid URL.',
|
|
44
|
+
IV_002: '[IV-002] Incorrect value for "timeout". Set the value to an integer greater than or equal to 0.',
|
|
45
|
+
IV_003: '[IV-003] Incorrect value for "dob". Format the value according to ISO 8601.',
|
|
46
|
+
IV_004: '[IV-004] Incorrect value for "email". Set the value to a valid email address.',
|
|
47
|
+
IV_005: '[IV-005] Incorrect value for "expiryDate". Format the value according to ISO 8601.',
|
|
48
|
+
IV_006: (maxAttributes) => `[IV-006] "extensionData" supports maximum ${maxAttributes} attributes. Reduce the number of attributes.`,
|
|
49
|
+
IV_007: (siteName) => `[IV-007] Site "${siteName}" does not exist or site item tree is missing.`,
|
|
50
|
+
/** IE errors are related to incorrect execution */
|
|
51
|
+
IE_001: (pluginName, dependency) => `[IE-001] "${pluginName}" also requires "${dependency}". Add the missing dependency.`,
|
|
52
|
+
IE_002: '[IE-002] SDK not initialized. You must first initialize the SDK using "initContentSdk()".',
|
|
53
|
+
IE_003: '[IE-003] Timeout exceeded. The server did not respond within the allotted time.',
|
|
54
|
+
IE_004: (pluginName) => `[IE-004] Plugin not registered. You must first add "${pluginName}" to the "initContentSdk()" "plugins" array.`,
|
|
55
|
+
IE_005: '[IE-005] Unable to set the "sc_cid" cookie because the client ID could not be retrieved from the server. Make sure to set the correct values for "contextId" and "siteName". If the issue persists, try again later or use try-catch blocks to handle this error.',
|
|
56
|
+
IE_006: '[IE-006] Unable to set the "sc_cid_personalize" cookie because the visitor ID could not be retrieved from the server. Make sure to set the correct values for "contextId" and "siteName". If the issue persists, try again later or use try-catch blocks to handle this error.',
|
|
57
|
+
IE_007: (hostName) => `[IE-007] Could not resolve site for host "${hostName}".`,
|
|
58
|
+
/** MV errors are related to missing values */
|
|
59
|
+
MV_001: '[MV-001] "contextId" is required.',
|
|
60
|
+
MV_002: '[MV-002] "siteName" is required.',
|
|
61
|
+
MV_003: '[MV-003] "identifiers" is required.',
|
|
62
|
+
MV_004: '[MV-004] "friendlyId" is required.',
|
|
63
|
+
MV_005: (property) => `[MV-005] The "sitecore.cli.config" file is missing a "${property}". Please add it to use this command.`,
|
|
64
|
+
MV_006: '[MV-006] "clientContextId" is missing. Client-side functionalities may be limited.',
|
|
65
|
+
MV_007: '[MV-007] Provide either "contextId" or both "apiHost" and "apiKey".',
|
|
66
|
+
MV_008: '[MV-008] Verify that sitecore.config is properly imported and correctly referenced.',
|
|
67
|
+
MV_009: '[MV-009] "language" is required.',
|
|
68
|
+
/** Generic follow-up when the user should contact support */
|
|
69
|
+
CONTACT_SUPPORT: 'If the issue persists, please contact Sitecore Support.',
|
|
70
|
+
};
|
package/dist/cjs/debug.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.enableDebug = exports.debugNamespace = exports.debugModule = void 0;
|
|
8
|
+
exports.isNamespaceEnabled = isNamespaceEnabled;
|
|
8
9
|
/* eslint-disable import/no-anonymous-default-export */
|
|
9
10
|
const debug_1 = __importDefault(require("debug"));
|
|
10
11
|
const is_server_1 = __importDefault(require("./tools/is-server"));
|
|
@@ -34,6 +35,15 @@ if ((0, is_server_1.default)() &&
|
|
|
34
35
|
*/
|
|
35
36
|
const enableDebug = (namespaces) => debug_1.default.enable(namespaces);
|
|
36
37
|
exports.enableDebug = enableDebug;
|
|
38
|
+
/**
|
|
39
|
+
* Check if a debug namespace is enabled
|
|
40
|
+
* @param {string} namespace the namespace to check
|
|
41
|
+
* @returns {boolean} whether the namespace is enabled
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
function isNamespaceEnabled(namespace) {
|
|
45
|
+
return debug_1.default.enabled(namespace);
|
|
46
|
+
}
|
|
37
47
|
/**
|
|
38
48
|
* Default Sitecore Content SDK 'debug' module debuggers. Uses namespace prefix 'content-sdk:'.
|
|
39
49
|
* See {@link https://www.npmjs.com/package/debug} for details.
|
|
@@ -41,4 +51,5 @@ exports.enableDebug = enableDebug;
|
|
|
41
51
|
exports.default = {
|
|
42
52
|
common: (0, debug_1.default)(`${exports.debugNamespace}:common`),
|
|
43
53
|
http: (0, debug_1.default)(`${exports.debugNamespace}:http`),
|
|
54
|
+
init: (0, debug_1.default)(`${exports.debugNamespace}:init`),
|
|
44
55
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -32,11 +32,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
35
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
40
|
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.constants = exports.NativeDataFetcher = exports.ClientError = exports.MemoryCacheClient = exports.DefaultRetryStrategy = exports.GraphQLRequestClient = exports.debugModule = exports.debugNamespace = exports.enableDebug = exports.debug = void 0;
|
|
42
|
+
exports.constants = exports.NativeDataFetcher = exports.ClientError = exports.MemoryCacheClient = exports.DefaultRetryStrategy = exports.GraphQLRequestClient = exports.isNamespaceEnabled = exports.debugModule = exports.debugNamespace = exports.enableDebug = exports.debug = void 0;
|
|
40
43
|
const constants = __importStar(require("./constants"));
|
|
41
44
|
exports.constants = constants;
|
|
42
45
|
var debug_1 = require("./debug");
|
|
@@ -44,6 +47,7 @@ Object.defineProperty(exports, "debug", { enumerable: true, get: function () { r
|
|
|
44
47
|
Object.defineProperty(exports, "enableDebug", { enumerable: true, get: function () { return debug_1.enableDebug; } });
|
|
45
48
|
Object.defineProperty(exports, "debugNamespace", { enumerable: true, get: function () { return debug_1.debugNamespace; } });
|
|
46
49
|
Object.defineProperty(exports, "debugModule", { enumerable: true, get: function () { return debug_1.debugModule; } });
|
|
50
|
+
Object.defineProperty(exports, "isNamespaceEnabled", { enumerable: true, get: function () { return debug_1.isNamespaceEnabled; } });
|
|
47
51
|
var graphql_request_client_1 = require("./graphql-request-client");
|
|
48
52
|
Object.defineProperty(exports, "GraphQLRequestClient", { enumerable: true, get: function () { return graphql_request_client_1.GraphQLRequestClient; } });
|
|
49
53
|
var retries_1 = require("./retries");
|
|
@@ -54,3 +58,4 @@ var graphql_request_1 = require("graphql-request");
|
|
|
54
58
|
Object.defineProperty(exports, "ClientError", { enumerable: true, get: function () { return graphql_request_1.ClientError; } });
|
|
55
59
|
var native_fetcher_1 = require("./native-fetcher");
|
|
56
60
|
Object.defineProperty(exports, "NativeDataFetcher", { enumerable: true, get: function () { return native_fetcher_1.NativeDataFetcher; } });
|
|
61
|
+
__exportStar(require("./initialization"), exports);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkPluginDependencies = checkPluginDependencies;
|
|
7
|
+
exports.initPlugins = initPlugins;
|
|
8
|
+
exports.resolveCoreContextConfig = resolveCoreContextConfig;
|
|
9
|
+
const debug_1 = __importDefault(require("../debug"));
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
const constants_2 = require("../constants");
|
|
12
|
+
const debugInit = debug_1.default.init;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the plugin's dependencies are present in the state.
|
|
15
|
+
* @param {Plugin} plugin - The plugin to check dependencies for.
|
|
16
|
+
* @param {Map<string, Plugin>} plugins - The map of available plugins.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
function checkPluginDependencies(plugin, plugins) {
|
|
20
|
+
if (!plugin.dependencies)
|
|
21
|
+
return;
|
|
22
|
+
for (const dependency of plugin.dependencies) {
|
|
23
|
+
if (!plugins.has(dependency))
|
|
24
|
+
throw new Error(constants_1.ERROR_MESSAGES.IE_001(plugin.name, dependency));
|
|
25
|
+
}
|
|
26
|
+
debugInit(`All required dependencies for "${plugin.name}" are present`);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Initializes all registered plugins by calling their `init` function.
|
|
30
|
+
* @param {Map<string, Plugin>} plugins - The array of plugins to initialize.
|
|
31
|
+
* @returns A promise that resolves when all plugins have been initialized.
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
async function initPlugins(plugins) {
|
|
35
|
+
var _a;
|
|
36
|
+
debugInit(`Initializing ${plugins.size} plugins`);
|
|
37
|
+
for (const plugin of plugins.values()) {
|
|
38
|
+
checkPluginDependencies(plugin, plugins);
|
|
39
|
+
await ((_a = plugin.init) === null || _a === void 0 ? void 0 : _a.call(plugin));
|
|
40
|
+
debugInit(`Successfully initialized "${plugin.name}"`);
|
|
41
|
+
}
|
|
42
|
+
debugInit(`Successfully initialized ${plugins.size} plugins`);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Validates and constructs the core context settings.
|
|
46
|
+
* @param {InitContentSdkParams['config']} config - The core context settings object.
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
function resolveCoreContextConfig(config) {
|
|
50
|
+
var _a;
|
|
51
|
+
const { contextId, siteName, edgeUrl } = config;
|
|
52
|
+
if (!contextId || contextId.trim().length === 0)
|
|
53
|
+
throw new Error(constants_1.ERROR_MESSAGES.MV_001);
|
|
54
|
+
if (!siteName || siteName.trim().length === 0)
|
|
55
|
+
throw new Error(constants_1.ERROR_MESSAGES.MV_002);
|
|
56
|
+
if (edgeUrl !== undefined)
|
|
57
|
+
try {
|
|
58
|
+
new URL(edgeUrl);
|
|
59
|
+
}
|
|
60
|
+
catch (_b) {
|
|
61
|
+
throw new Error(constants_1.ERROR_MESSAGES.IV_001);
|
|
62
|
+
}
|
|
63
|
+
debugInit('Configuration is valid');
|
|
64
|
+
return Object.assign(Object.assign({}, config), { edgeUrl: (_a = edgeUrl === null || edgeUrl === void 0 ? void 0 : edgeUrl.trim()) !== null && _a !== void 0 ? _a : constants_2.SITECORE_EDGE_PLATFORM_URL_DEFAULT });
|
|
65
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCoreContext = exports.initContentSdk = void 0;
|
|
4
|
+
var init_content_sdk_1 = require("./init-content-sdk");
|
|
5
|
+
Object.defineProperty(exports, "initContentSdk", { enumerable: true, get: function () { return init_content_sdk_1.initContentSdk; } });
|
|
6
|
+
Object.defineProperty(exports, "getCoreContext", { enumerable: true, get: function () { return init_content_sdk_1.getCoreContext; } });
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getCoreContext = getCoreContext;
|
|
7
|
+
exports.initContentSdk = initContentSdk;
|
|
8
|
+
const debug_1 = __importDefault(require("../debug"));
|
|
9
|
+
const helpers_1 = require("./helpers");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
let coreContext;
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the current core context.
|
|
14
|
+
* @returns {CoreContext} The current core context object.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
function getCoreContext() {
|
|
18
|
+
if (!coreContext)
|
|
19
|
+
throw new Error(constants_1.ERROR_MESSAGES.IE_002);
|
|
20
|
+
return coreContext;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Initializes the Content SDK with the provided params.
|
|
24
|
+
* @param {InitContentSdkParams} params - The initialization params including config and plugins.
|
|
25
|
+
* @returns A promise that resolves when initialization is complete.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
async function initContentSdk(params) {
|
|
29
|
+
debug_1.default.init('Initializing Content SDK with params:', params);
|
|
30
|
+
const { config, plugins } = params;
|
|
31
|
+
const resolvedConfig = (0, helpers_1.resolveCoreContextConfig)(config);
|
|
32
|
+
if (plugins.length === 0)
|
|
33
|
+
debug_1.default.init('No plugins provided to the plugins array');
|
|
34
|
+
coreContext = {
|
|
35
|
+
config: resolvedConfig,
|
|
36
|
+
plugins: new Map(),
|
|
37
|
+
readyPromise: null,
|
|
38
|
+
};
|
|
39
|
+
for (const plugin of plugins) {
|
|
40
|
+
coreContext.plugins.set(plugin.name, plugin);
|
|
41
|
+
}
|
|
42
|
+
debug_1.default.init(`Registered ${coreContext.plugins.size} plugins`);
|
|
43
|
+
coreContext.readyPromise = (0, helpers_1.initPlugins)(coreContext.plugins);
|
|
44
|
+
await coreContext.readyPromise;
|
|
45
|
+
debug_1.default.init('Content SDK initialization complete');
|
|
46
|
+
}
|
|
@@ -48,7 +48,7 @@ async function _clientCredentialsFlow({ clientId, clientSecret, organizationId,
|
|
|
48
48
|
});
|
|
49
49
|
const data = await response.json();
|
|
50
50
|
if (!response.ok) {
|
|
51
|
-
throw new Error(data.error_description || data.error ||
|
|
51
|
+
throw new Error(data.error_description || data.error || `Error during client credentials flow. ${constants_1.ERROR_MESSAGES.CONTACT_SUPPORT}`);
|
|
52
52
|
}
|
|
53
53
|
const decodedPayload = (0, tenant_store_1.decodeJwtPayload)(data.access_token) || {};
|
|
54
54
|
if (!(decodedPayload === null || decodedPayload === void 0 ? void 0 : decodedPayload.tokenTenantId) || !decodedPayload.tokenOrgId) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
3
4
|
/**
|
|
4
5
|
* A helper to assign timeouts to fetch or other promises
|
|
5
6
|
* Useful in nextjs middleware until fetch.signal is fully supported by Vercel edge functions
|
|
@@ -14,8 +15,10 @@ class TimeoutPromise {
|
|
|
14
15
|
*/
|
|
15
16
|
get start() {
|
|
16
17
|
return new Promise((_, reject) => {
|
|
18
|
+
if (!Number.isInteger(this.timeout) || this.timeout < 0)
|
|
19
|
+
throw new Error(constants_1.ERROR_MESSAGES.IV_002);
|
|
17
20
|
this.timeoutId = setTimeout(() => {
|
|
18
|
-
const abortError = new Error(
|
|
21
|
+
const abortError = new Error(constants_1.ERROR_MESSAGES.IE_003);
|
|
19
22
|
abortError.name = 'AbortError';
|
|
20
23
|
reject(abortError);
|
|
21
24
|
}, this.timeout);
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable jsdoc/require-param */
|
|
1
2
|
/**
|
|
2
3
|
* Default Edge Platform URL (edge-platform.sitecorecloud.io). Used for service endpoints
|
|
3
4
|
* (GraphQL, content API, forms, layout, static files) when no custom hostname is configured.
|
|
@@ -30,3 +31,37 @@ export const DEFAULT_SITECORE_AUTH_AUDIENCE = 'https://api.sitecorecloud.io';
|
|
|
30
31
|
* @internal
|
|
31
32
|
*/
|
|
32
33
|
export const DEFAULT_SITECORE_AUTH_BASE_URL = 'https://edge-platform.sitecorecloud.io/cs/api';
|
|
34
|
+
/**
|
|
35
|
+
* The error messages. Includes errors for all packages.
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export const ERROR_MESSAGES = {
|
|
39
|
+
/** IV errors are related to incorrect values, wrongly formatted objects, etc. */
|
|
40
|
+
IV_001: '[IV-001] Incorrect value for "edgeUrl". Set the value to a valid URL.',
|
|
41
|
+
IV_002: '[IV-002] Incorrect value for "timeout". Set the value to an integer greater than or equal to 0.',
|
|
42
|
+
IV_003: '[IV-003] Incorrect value for "dob". Format the value according to ISO 8601.',
|
|
43
|
+
IV_004: '[IV-004] Incorrect value for "email". Set the value to a valid email address.',
|
|
44
|
+
IV_005: '[IV-005] Incorrect value for "expiryDate". Format the value according to ISO 8601.',
|
|
45
|
+
IV_006: (maxAttributes) => `[IV-006] "extensionData" supports maximum ${maxAttributes} attributes. Reduce the number of attributes.`,
|
|
46
|
+
IV_007: (siteName) => `[IV-007] Site "${siteName}" does not exist or site item tree is missing.`,
|
|
47
|
+
/** IE errors are related to incorrect execution */
|
|
48
|
+
IE_001: (pluginName, dependency) => `[IE-001] "${pluginName}" also requires "${dependency}". Add the missing dependency.`,
|
|
49
|
+
IE_002: '[IE-002] SDK not initialized. You must first initialize the SDK using "initContentSdk()".',
|
|
50
|
+
IE_003: '[IE-003] Timeout exceeded. The server did not respond within the allotted time.',
|
|
51
|
+
IE_004: (pluginName) => `[IE-004] Plugin not registered. You must first add "${pluginName}" to the "initContentSdk()" "plugins" array.`,
|
|
52
|
+
IE_005: '[IE-005] Unable to set the "sc_cid" cookie because the client ID could not be retrieved from the server. Make sure to set the correct values for "contextId" and "siteName". If the issue persists, try again later or use try-catch blocks to handle this error.',
|
|
53
|
+
IE_006: '[IE-006] Unable to set the "sc_cid_personalize" cookie because the visitor ID could not be retrieved from the server. Make sure to set the correct values for "contextId" and "siteName". If the issue persists, try again later or use try-catch blocks to handle this error.',
|
|
54
|
+
IE_007: (hostName) => `[IE-007] Could not resolve site for host "${hostName}".`,
|
|
55
|
+
/** MV errors are related to missing values */
|
|
56
|
+
MV_001: '[MV-001] "contextId" is required.',
|
|
57
|
+
MV_002: '[MV-002] "siteName" is required.',
|
|
58
|
+
MV_003: '[MV-003] "identifiers" is required.',
|
|
59
|
+
MV_004: '[MV-004] "friendlyId" is required.',
|
|
60
|
+
MV_005: (property) => `[MV-005] The "sitecore.cli.config" file is missing a "${property}". Please add it to use this command.`,
|
|
61
|
+
MV_006: '[MV-006] "clientContextId" is missing. Client-side functionalities may be limited.',
|
|
62
|
+
MV_007: '[MV-007] Provide either "contextId" or both "apiHost" and "apiKey".',
|
|
63
|
+
MV_008: '[MV-008] Verify that sitecore.config is properly imported and correctly referenced.',
|
|
64
|
+
MV_009: '[MV-009] "language" is required.',
|
|
65
|
+
/** Generic follow-up when the user should contact support */
|
|
66
|
+
CONTACT_SUPPORT: 'If the issue persists, please contact Sitecore Support.',
|
|
67
|
+
};
|
package/dist/esm/debug.js
CHANGED
|
@@ -27,6 +27,15 @@ if (isServer() &&
|
|
|
27
27
|
* @public
|
|
28
28
|
*/
|
|
29
29
|
export const enableDebug = (namespaces) => debug.enable(namespaces);
|
|
30
|
+
/**
|
|
31
|
+
* Check if a debug namespace is enabled
|
|
32
|
+
* @param {string} namespace the namespace to check
|
|
33
|
+
* @returns {boolean} whether the namespace is enabled
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export function isNamespaceEnabled(namespace) {
|
|
37
|
+
return debug.enabled(namespace);
|
|
38
|
+
}
|
|
30
39
|
/**
|
|
31
40
|
* Default Sitecore Content SDK 'debug' module debuggers. Uses namespace prefix 'content-sdk:'.
|
|
32
41
|
* See {@link https://www.npmjs.com/package/debug} for details.
|
|
@@ -34,4 +43,5 @@ export const enableDebug = (namespaces) => debug.enable(namespaces);
|
|
|
34
43
|
export default {
|
|
35
44
|
common: debug(`${debugNamespace}:common`),
|
|
36
45
|
http: debug(`${debugNamespace}:http`),
|
|
46
|
+
init: debug(`${debugNamespace}:init`),
|
|
37
47
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as constants from './constants';
|
|
2
|
-
export { default as debug, enableDebug, debugNamespace, debugModule } from './debug';
|
|
2
|
+
export { default as debug, enableDebug, debugNamespace, debugModule, isNamespaceEnabled, } from './debug';
|
|
3
3
|
export { GraphQLRequestClient, } from './graphql-request-client';
|
|
4
4
|
export { DefaultRetryStrategy } from './retries';
|
|
5
5
|
export { MemoryCacheClient } from './cache-client';
|
|
6
6
|
export { ClientError } from 'graphql-request';
|
|
7
7
|
export { NativeDataFetcher, } from './native-fetcher';
|
|
8
8
|
export { constants };
|
|
9
|
+
export * from './initialization';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import debug from '../debug';
|
|
2
|
+
import { ERROR_MESSAGES } from '../constants';
|
|
3
|
+
import { SITECORE_EDGE_PLATFORM_URL_DEFAULT } from '../constants';
|
|
4
|
+
const debugInit = debug.init;
|
|
5
|
+
/**
|
|
6
|
+
* Checks if the plugin's dependencies are present in the state.
|
|
7
|
+
* @param {Plugin} plugin - The plugin to check dependencies for.
|
|
8
|
+
* @param {Map<string, Plugin>} plugins - The map of available plugins.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export function checkPluginDependencies(plugin, plugins) {
|
|
12
|
+
if (!plugin.dependencies)
|
|
13
|
+
return;
|
|
14
|
+
for (const dependency of plugin.dependencies) {
|
|
15
|
+
if (!plugins.has(dependency))
|
|
16
|
+
throw new Error(ERROR_MESSAGES.IE_001(plugin.name, dependency));
|
|
17
|
+
}
|
|
18
|
+
debugInit(`All required dependencies for "${plugin.name}" are present`);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Initializes all registered plugins by calling their `init` function.
|
|
22
|
+
* @param {Map<string, Plugin>} plugins - The array of plugins to initialize.
|
|
23
|
+
* @returns A promise that resolves when all plugins have been initialized.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export async function initPlugins(plugins) {
|
|
27
|
+
var _a;
|
|
28
|
+
debugInit(`Initializing ${plugins.size} plugins`);
|
|
29
|
+
for (const plugin of plugins.values()) {
|
|
30
|
+
checkPluginDependencies(plugin, plugins);
|
|
31
|
+
await ((_a = plugin.init) === null || _a === void 0 ? void 0 : _a.call(plugin));
|
|
32
|
+
debugInit(`Successfully initialized "${plugin.name}"`);
|
|
33
|
+
}
|
|
34
|
+
debugInit(`Successfully initialized ${plugins.size} plugins`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Validates and constructs the core context settings.
|
|
38
|
+
* @param {InitContentSdkParams['config']} config - The core context settings object.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export function resolveCoreContextConfig(config) {
|
|
42
|
+
var _a;
|
|
43
|
+
const { contextId, siteName, edgeUrl } = config;
|
|
44
|
+
if (!contextId || contextId.trim().length === 0)
|
|
45
|
+
throw new Error(ERROR_MESSAGES.MV_001);
|
|
46
|
+
if (!siteName || siteName.trim().length === 0)
|
|
47
|
+
throw new Error(ERROR_MESSAGES.MV_002);
|
|
48
|
+
if (edgeUrl !== undefined)
|
|
49
|
+
try {
|
|
50
|
+
new URL(edgeUrl);
|
|
51
|
+
}
|
|
52
|
+
catch (_b) {
|
|
53
|
+
throw new Error(ERROR_MESSAGES.IV_001);
|
|
54
|
+
}
|
|
55
|
+
debugInit('Configuration is valid');
|
|
56
|
+
return Object.assign(Object.assign({}, config), { edgeUrl: (_a = edgeUrl === null || edgeUrl === void 0 ? void 0 : edgeUrl.trim()) !== null && _a !== void 0 ? _a : SITECORE_EDGE_PLATFORM_URL_DEFAULT });
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { initContentSdk, getCoreContext } from './init-content-sdk';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import debug from '../debug';
|
|
2
|
+
import { initPlugins, resolveCoreContextConfig } from './helpers';
|
|
3
|
+
import { ERROR_MESSAGES } from '../constants';
|
|
4
|
+
let coreContext;
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves the current core context.
|
|
7
|
+
* @returns {CoreContext} The current core context object.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export function getCoreContext() {
|
|
11
|
+
if (!coreContext)
|
|
12
|
+
throw new Error(ERROR_MESSAGES.IE_002);
|
|
13
|
+
return coreContext;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Initializes the Content SDK with the provided params.
|
|
17
|
+
* @param {InitContentSdkParams} params - The initialization params including config and plugins.
|
|
18
|
+
* @returns A promise that resolves when initialization is complete.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export async function initContentSdk(params) {
|
|
22
|
+
debug.init('Initializing Content SDK with params:', params);
|
|
23
|
+
const { config, plugins } = params;
|
|
24
|
+
const resolvedConfig = resolveCoreContextConfig(config);
|
|
25
|
+
if (plugins.length === 0)
|
|
26
|
+
debug.init('No plugins provided to the plugins array');
|
|
27
|
+
coreContext = {
|
|
28
|
+
config: resolvedConfig,
|
|
29
|
+
plugins: new Map(),
|
|
30
|
+
readyPromise: null,
|
|
31
|
+
};
|
|
32
|
+
for (const plugin of plugins) {
|
|
33
|
+
coreContext.plugins.set(plugin.name, plugin);
|
|
34
|
+
}
|
|
35
|
+
debug.init(`Registered ${coreContext.plugins.size} plugins`);
|
|
36
|
+
coreContext.readyPromise = initPlugins(coreContext.plugins);
|
|
37
|
+
await coreContext.readyPromise;
|
|
38
|
+
debug.init('Content SDK initialization complete');
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decodeJwtPayload } from './tenant-store';
|
|
2
|
-
import { DEFAULT_SITECORE_AUTH_DOMAIN, DEFAULT_SITECORE_AUTH_AUDIENCE, DEFAULT_SITECORE_AUTH_BASE_URL, } from '../../constants';
|
|
2
|
+
import { DEFAULT_SITECORE_AUTH_DOMAIN, DEFAULT_SITECORE_AUTH_AUDIENCE, DEFAULT_SITECORE_AUTH_BASE_URL, ERROR_MESSAGES, } from '../../constants';
|
|
3
3
|
const GRANT_TYPE = 'client_credentials';
|
|
4
4
|
/**
|
|
5
5
|
* Performs the OAuth 2.0 client credentials flow to obtain a JWT access token
|
|
@@ -45,7 +45,7 @@ async function _clientCredentialsFlow({ clientId, clientSecret, organizationId,
|
|
|
45
45
|
});
|
|
46
46
|
const data = await response.json();
|
|
47
47
|
if (!response.ok) {
|
|
48
|
-
throw new Error(data.error_description || data.error ||
|
|
48
|
+
throw new Error(data.error_description || data.error || `Error during client credentials flow. ${ERROR_MESSAGES.CONTACT_SUPPORT}`);
|
|
49
49
|
}
|
|
50
50
|
const decodedPayload = decodeJwtPayload(data.access_token) || {};
|
|
51
51
|
if (!(decodedPayload === null || decodedPayload === void 0 ? void 0 : decodedPayload.tokenTenantId) || !decodedPayload.tokenOrgId) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ERROR_MESSAGES } from '../constants';
|
|
1
2
|
/**
|
|
2
3
|
* A helper to assign timeouts to fetch or other promises
|
|
3
4
|
* Useful in nextjs middleware until fetch.signal is fully supported by Vercel edge functions
|
|
@@ -12,8 +13,10 @@ export default class TimeoutPromise {
|
|
|
12
13
|
*/
|
|
13
14
|
get start() {
|
|
14
15
|
return new Promise((_, reject) => {
|
|
16
|
+
if (!Number.isInteger(this.timeout) || this.timeout < 0)
|
|
17
|
+
throw new Error(ERROR_MESSAGES.IV_002);
|
|
15
18
|
this.timeoutId = setTimeout(() => {
|
|
16
|
-
const abortError = new Error(
|
|
19
|
+
const abortError = new Error(ERROR_MESSAGES.IE_003);
|
|
17
20
|
abortError.name = 'AbortError';
|
|
18
21
|
reject(abortError);
|
|
19
22
|
}, this.timeout);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@types/memory-cache": "^0.2.6",
|
|
44
44
|
"@types/mocha": "^10.0.10",
|
|
45
45
|
"@types/node": "^24.10.4",
|
|
46
|
+
"@types/proxyquire": "^1.3.31",
|
|
46
47
|
"@types/sinon": "^17.0.4",
|
|
47
48
|
"@types/url-parse": "1.4.11",
|
|
48
49
|
"@typescript-eslint/eslint-plugin": "8.39.0",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"nock": "14.0.0-beta.7",
|
|
60
61
|
"nyc": "^17.1.0",
|
|
61
62
|
"prettier": "^2.8.0",
|
|
63
|
+
"proxyquire": "^2.1.3",
|
|
62
64
|
"sinon": "^20.0.0",
|
|
63
65
|
"tsx": "^4.19.4",
|
|
64
66
|
"typescript": "~5.8.3"
|
|
@@ -72,7 +74,7 @@
|
|
|
72
74
|
},
|
|
73
75
|
"description": "",
|
|
74
76
|
"types": "types/index.d.ts",
|
|
75
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "fc12774027a7aa86b870d5da278426b9cdfbfffb",
|
|
76
78
|
"files": [
|
|
77
79
|
"dist",
|
|
78
80
|
"types",
|
package/types/constants.d.ts
CHANGED
|
@@ -30,4 +30,38 @@ export declare const DEFAULT_SITECORE_AUTH_AUDIENCE = "https://api.sitecorecloud
|
|
|
30
30
|
* @internal
|
|
31
31
|
*/
|
|
32
32
|
export declare const DEFAULT_SITECORE_AUTH_BASE_URL = "https://edge-platform.sitecorecloud.io/cs/api";
|
|
33
|
+
/**
|
|
34
|
+
* The error messages. Includes errors for all packages.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export declare const ERROR_MESSAGES: {
|
|
38
|
+
/** IV errors are related to incorrect values, wrongly formatted objects, etc. */
|
|
39
|
+
readonly IV_001: "[IV-001] Incorrect value for \"edgeUrl\". Set the value to a valid URL.";
|
|
40
|
+
readonly IV_002: "[IV-002] Incorrect value for \"timeout\". Set the value to an integer greater than or equal to 0.";
|
|
41
|
+
readonly IV_003: "[IV-003] Incorrect value for \"dob\". Format the value according to ISO 8601.";
|
|
42
|
+
readonly IV_004: "[IV-004] Incorrect value for \"email\". Set the value to a valid email address.";
|
|
43
|
+
readonly IV_005: "[IV-005] Incorrect value for \"expiryDate\". Format the value according to ISO 8601.";
|
|
44
|
+
readonly IV_006: (maxAttributes: number) => string;
|
|
45
|
+
readonly IV_007: (siteName: string) => string;
|
|
46
|
+
/** IE errors are related to incorrect execution */
|
|
47
|
+
readonly IE_001: (pluginName: string, dependency: string) => string;
|
|
48
|
+
readonly IE_002: "[IE-002] SDK not initialized. You must first initialize the SDK using \"initContentSdk()\".";
|
|
49
|
+
readonly IE_003: "[IE-003] Timeout exceeded. The server did not respond within the allotted time.";
|
|
50
|
+
readonly IE_004: (pluginName: string) => string;
|
|
51
|
+
readonly IE_005: "[IE-005] Unable to set the \"sc_cid\" cookie because the client ID could not be retrieved from the server. Make sure to set the correct values for \"contextId\" and \"siteName\". If the issue persists, try again later or use try-catch blocks to handle this error.";
|
|
52
|
+
readonly IE_006: "[IE-006] Unable to set the \"sc_cid_personalize\" cookie because the visitor ID could not be retrieved from the server. Make sure to set the correct values for \"contextId\" and \"siteName\". If the issue persists, try again later or use try-catch blocks to handle this error.";
|
|
53
|
+
readonly IE_007: (hostName: string) => string;
|
|
54
|
+
/** MV errors are related to missing values */
|
|
55
|
+
readonly MV_001: "[MV-001] \"contextId\" is required.";
|
|
56
|
+
readonly MV_002: "[MV-002] \"siteName\" is required.";
|
|
57
|
+
readonly MV_003: "[MV-003] \"identifiers\" is required.";
|
|
58
|
+
readonly MV_004: "[MV-004] \"friendlyId\" is required.";
|
|
59
|
+
readonly MV_005: (property: string) => string;
|
|
60
|
+
readonly MV_006: "[MV-006] \"clientContextId\" is missing. Client-side functionalities may be limited.";
|
|
61
|
+
readonly MV_007: "[MV-007] Provide either \"contextId\" or both \"apiHost\" and \"apiKey\".";
|
|
62
|
+
readonly MV_008: "[MV-008] Verify that sitecore.config is properly imported and correctly referenced.";
|
|
63
|
+
readonly MV_009: "[MV-009] \"language\" is required.";
|
|
64
|
+
/** Generic follow-up when the user should contact support */
|
|
65
|
+
readonly CONTACT_SUPPORT: "If the issue persists, please contact Sitecore Support.";
|
|
66
|
+
};
|
|
33
67
|
//# sourceMappingURL=constants.d.ts.map
|
package/types/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,2CAA2C,CAAC;AAE3F;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,kCAAkC,CAAC;AAEpF;;;GAGG;AACH,eAAO,MAAM,MAAM,yCAAyC,CAAC;AAC7D;;;GAGG;AACH,eAAO,MAAM,4BAA4B,kCAAkC,CAAC;AAC5E;;;GAGG;AACH,eAAO,MAAM,8BAA8B,iCAAiC,CAAC;AAC7E;;;GAGG;AACH,eAAO,MAAM,8BAA8B,kDAAkD,CAAC;AAE9F;;;GAGG;AACH,eAAO,MAAM,cAAc;IACzB,iFAAiF;;;;;;qCAOzD,MAAM;gCAEX,MAAM;IAGzB,mDAAmD;kCAC9B,MAAM,cAAc,MAAM;;;kCAK1B,MAAM;;;gCAMR,MAAM;IAEzB,8CAA8C;;;;;gCAK3B,MAAM;;;;;IAOzB,6DAA6D;;CAErD,CAAC"}
|
package/types/debug.d.ts
CHANGED
|
@@ -23,6 +23,13 @@ export type Debugger = debug.Debugger;
|
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
export declare const enableDebug: (namespaces: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a debug namespace is enabled
|
|
28
|
+
* @param {string} namespace the namespace to check
|
|
29
|
+
* @returns {boolean} whether the namespace is enabled
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare function isNamespaceEnabled(namespace: string): boolean;
|
|
26
33
|
/**
|
|
27
34
|
* Default Sitecore Content SDK 'debug' module debuggers. Uses namespace prefix 'content-sdk:'.
|
|
28
35
|
* See {@link https://www.npmjs.com/package/debug} for details.
|
|
@@ -30,6 +37,7 @@ export declare const enableDebug: (namespaces: string) => void;
|
|
|
30
37
|
declare const _default: {
|
|
31
38
|
common: debug.Debugger;
|
|
32
39
|
http: debug.Debugger;
|
|
40
|
+
init: debug.Debugger;
|
|
33
41
|
};
|
|
34
42
|
export default _default;
|
|
35
43
|
//# sourceMappingURL=debug.d.ts.map
|
package/types/debug.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;;GAGG;AACH,eAAO,MAAM,WAAW;;;CAAQ,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;AActC;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,YAAY,MAAM,SAA6B,CAAC;AAE5E;;;GAGG
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;;GAGG;AACH,eAAO,MAAM,WAAW;;;CAAQ,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;AActC;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,YAAY,MAAM,SAA6B,CAAC;AAE5E;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;;GAGG;;;;;;AACH,wBAIE"}
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as constants from './constants';
|
|
2
|
-
export { default as debug, Debugger, enableDebug, debugNamespace, debugModule } from './debug';
|
|
2
|
+
export { default as debug, Debugger, enableDebug, debugNamespace, debugModule, isNamespaceEnabled, } from './debug';
|
|
3
3
|
export { GraphQLClient, GraphQLRequestClient, GraphQLClientError, GraphQLRequestClientConfig, GraphQLRequestClientFactory, GraphQLRequestClientFactoryConfig, } from './graphql-request-client';
|
|
4
4
|
export { DefaultRetryStrategy } from './retries';
|
|
5
5
|
export { CacheClient, CacheOptions, MemoryCacheClient } from './cache-client';
|
|
@@ -7,4 +7,5 @@ export { ClientError } from 'graphql-request';
|
|
|
7
7
|
export { NativeDataFetcher, NativeDataFetcherConfig, NativeDataFetcherError, NativeDataFetcherResponse, } from './native-fetcher';
|
|
8
8
|
export { RetryStrategy, GenericGraphQLClientError, FetchOptions } from './models';
|
|
9
9
|
export { constants };
|
|
10
|
+
export * from './initialization';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,OAAO,IAAI,KAAK,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,WAAW,EACX,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC3B,iCAAiC,GAClC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CoreContext, InitContentSdkParams } from './types';
|
|
2
|
+
import { Plugin } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the plugin's dependencies are present in the state.
|
|
5
|
+
* @param {Plugin} plugin - The plugin to check dependencies for.
|
|
6
|
+
* @param {Map<string, Plugin>} plugins - The map of available plugins.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function checkPluginDependencies(plugin: Plugin, plugins: Map<string, Plugin>): void;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes all registered plugins by calling their `init` function.
|
|
12
|
+
* @param {Map<string, Plugin>} plugins - The array of plugins to initialize.
|
|
13
|
+
* @returns A promise that resolves when all plugins have been initialized.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function initPlugins(plugins: Map<string, Plugin>): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Validates and constructs the core context settings.
|
|
19
|
+
* @param {InitContentSdkParams['config']} config - The core context settings object.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveCoreContextConfig(config: InitContentSdkParams['config']): CoreContext['config'];
|
|
23
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/initialization/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAMjC;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAQ1F;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAW7E;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GACrC,WAAW,CAAC,QAAQ,CAAC,CAmBvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initialization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpE,YAAY,EACV,MAAM,EACN,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CoreContext, InitContentSdkParams } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the current core context.
|
|
4
|
+
* @returns {CoreContext} The current core context object.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function getCoreContext(): CoreContext;
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the Content SDK with the provided params.
|
|
10
|
+
* @param {InitContentSdkParams} params - The initialization params including config and plugins.
|
|
11
|
+
* @returns A promise that resolves when initialization is complete.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare function initContentSdk(params: InitContentSdkParams): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=init-content-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-content-sdk.d.ts","sourceRoot":"","sources":["../../src/initialization/init-content-sdk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAOjE;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAI5C;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBhF"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameters for initContentSdk
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export interface InitContentSdkParams {
|
|
6
|
+
/** Initialization config */
|
|
7
|
+
config: {
|
|
8
|
+
/**
|
|
9
|
+
* The context ID.
|
|
10
|
+
*/
|
|
11
|
+
contextId: string;
|
|
12
|
+
/**
|
|
13
|
+
* Sitecore edge URL
|
|
14
|
+
*/
|
|
15
|
+
edgeUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The site name.
|
|
18
|
+
*/
|
|
19
|
+
siteName: string;
|
|
20
|
+
};
|
|
21
|
+
/** Array of plugins to initialize */
|
|
22
|
+
plugins: Plugin[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Internal config of the SDK initialization
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export interface CoreContext {
|
|
29
|
+
/**
|
|
30
|
+
* The SDK initialization config
|
|
31
|
+
*/
|
|
32
|
+
config: {
|
|
33
|
+
contextId: string;
|
|
34
|
+
edgeUrl: string;
|
|
35
|
+
siteName: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Map of enabled plugins by name
|
|
39
|
+
*/
|
|
40
|
+
plugins: Map<string, Plugin>;
|
|
41
|
+
/**
|
|
42
|
+
* Promise that resolves when initialization is complete
|
|
43
|
+
*/
|
|
44
|
+
readyPromise: Promise<void> | null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Dependency definition for a plugin.
|
|
48
|
+
* Used to declare that a plugin requires another plugin to be present.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export type PluginDependency = string;
|
|
52
|
+
/**
|
|
53
|
+
* Plugin interface for extending SDK functionality.
|
|
54
|
+
* Plugins are the standard way to add capabilities to the SDK.
|
|
55
|
+
* @template Options - Plugin-specific options type
|
|
56
|
+
* @template Adapter - Plugin-specific adapter type
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export interface Plugin<Options = unknown, Adapter = unknown> {
|
|
60
|
+
/**
|
|
61
|
+
* Unique identifier for the plugin (e.g., 'EventsPlugin')
|
|
62
|
+
*/
|
|
63
|
+
name: string;
|
|
64
|
+
/**
|
|
65
|
+
* Optional plugin-specific options
|
|
66
|
+
*/
|
|
67
|
+
options?: Options;
|
|
68
|
+
/**
|
|
69
|
+
* List of plugins this plugin depends on
|
|
70
|
+
*/
|
|
71
|
+
dependencies?: PluginDependency[];
|
|
72
|
+
/**
|
|
73
|
+
* Initialization function run once when init is called for the first time.
|
|
74
|
+
* Can be async for plugins that need to perform async setup.
|
|
75
|
+
*/
|
|
76
|
+
init?: () => void | Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Optional adapter requirements for the plugin.
|
|
79
|
+
*/
|
|
80
|
+
adapter?: Adapter;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Adapter definition for plugins.
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
export interface PluginAdapter {
|
|
87
|
+
type: 'browser' | (string & {});
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/initialization/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,4BAA4B;IAC5B,MAAM,EAAE;QACN;;WAEG;QACH,SAAS,EAAE,MAAM,CAAC;QAClB;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB;;WAEG;QACH,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,qCAAqC;IACrC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,WAAW,MAAM,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAC1D;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAClC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;CACjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../../src/tools/auth/flow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../../src/tools/auth/flow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAWtC;;;;;;;;;;;;;;GAcG;AACH,eAAO,IAAI,qBAAqB,+BAAyB,CAAC;AAK1D,eAAO,MAAM,SAAS;;CAOrB,CAAC;AAEF,iBAAe,sBAAsB,CAAC,EACpC,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,QAAyC,EACzC,SAAwC,EACxC,OAAwC,GACzC,EAAE,UAAU;;;;;;GAwCZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeout-promise.d.ts","sourceRoot":"","sources":["../../src/tools/timeout-promise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timeout-promise.d.ts","sourceRoot":"","sources":["../../src/tools/timeout-promise.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc;IAGrB,OAAO,CAAC,OAAO;IAF3B,SAAS,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;gBAElB,OAAO,EAAE,MAAM;IAInC;;OAEG;IACH,IAAI,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAW5B;IAED;;OAEG;IACH,KAAK;CAGN"}
|