@viglet/shio-client 2026.3.2 → 2026.3.3
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 +201 -201
- package/README.md +31 -6
- package/dist/client.d.ts +23 -4
- package/dist/index.d.ts +2 -1
- package/dist/shio-client.js +35 -12
- package/dist/shio-client.umd.cjs +2 -2
- package/dist/types.d.ts +135 -0
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,201 +1,201 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@viglet/shio-client)
|
|
4
4
|
[](https://github.com/openviglet/shio/blob/HEAD/LICENSE)
|
|
5
|
-
[](https://openviglet.github.io/shio/)
|
|
6
6
|
|
|
7
7
|
Framework-agnostic **TypeScript client** for the Content Delivery API (CDA) of
|
|
8
|
-
**[Viglet Shio](https://
|
|
8
|
+
**[Viglet Shio](https://openviglet.github.io/shio/)**, the open source, **agent-ready CMS
|
|
9
9
|
for coding agents**.
|
|
10
10
|
|
|
11
11
|
- **Zero runtime dependencies** — just `fetch`.
|
|
@@ -41,16 +41,41 @@ console.log(post?.attrs.title);
|
|
|
41
41
|
|---|---|---|
|
|
42
42
|
| `getSites()` | `GET /site` | `ShioSite[]` |
|
|
43
43
|
| `getSite(siteId)` | `GET /site/{id}` | `ShioSite \| null` |
|
|
44
|
-
| `listChildren(folderId, {page,size})` | `GET /object/{id}/list` | `ShioListing \| null` |
|
|
44
|
+
| `listChildren(folderId, {page,size,locale})` | `GET /object/{id}/list` | `ShioListing \| null` |
|
|
45
45
|
| `getPath(objectId)` | `GET /object/{id}/path` | `ShioPath \| null` |
|
|
46
46
|
| `getPost(postId)` | `GET /post/{id}` | `ShioPost \| null` |
|
|
47
|
-
| `getPostByUrl(siteId, url)` | `GET /post/by-url` | `ShioPost \| null` |
|
|
48
|
-
| `query({siteId,folderId,postType,page,size})` | `GET /query` | `ShioListing` |
|
|
47
|
+
| `getPostByUrl(siteId, url, locale?)` | `GET /post/by-url` | `ShioPost \| null` |
|
|
48
|
+
| `query({siteId,folderId,postType,page,size,locale})` | `GET /query` | `ShioListing` |
|
|
49
49
|
|
|
50
50
|
- Single-resource getters return `null` on `404`.
|
|
51
51
|
- Any other non-OK status throws `ShioHttpError` (`{ status, url, body }`).
|
|
52
52
|
- Every method accepts a final `{ signal }` option for cancellation.
|
|
53
53
|
|
|
54
|
+
## A language switcher
|
|
55
|
+
|
|
56
|
+
A site's `locales` says which languages it offers; a post's `availableLocales` says which of
|
|
57
|
+
them this page exists in. Together they are a switcher, with no call beyond the two you
|
|
58
|
+
already make:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const site = await shio.getSite(siteId);
|
|
62
|
+
// null when the post at `url` is in another language; its availableLocales say which exist
|
|
63
|
+
const post = await shio.getPostByUrl(siteId, url, locale) ?? await shio.getPostByUrl(siteId, url);
|
|
64
|
+
|
|
65
|
+
const offered = site?.locales?.enabled ?? [];
|
|
66
|
+
const links = offered.map((tag) => ({
|
|
67
|
+
tag,
|
|
68
|
+
// a language this page is missing in shows the site's fallback for it, else its default
|
|
69
|
+
target: post?.availableLocales.includes(tag)
|
|
70
|
+
? tag
|
|
71
|
+
: site?.locales?.fallback[tag] ?? site?.locales?.defaultLocale,
|
|
72
|
+
}));
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`locales.declared` is `false` when nobody has chosen the site's languages yet. The list is
|
|
76
|
+
then the languages its published pages are already written in, which is a description of the
|
|
77
|
+
content so far rather than a promise about it.
|
|
78
|
+
|
|
54
79
|
## Next.js App Router — catch-all page
|
|
55
80
|
|
|
56
81
|
The `getPostByUrl` call is built for `[...slug]` routing:
|
|
@@ -115,7 +140,7 @@ npm test # node:test, no network (injected fetch)
|
|
|
115
140
|
|
|
116
141
|
## License
|
|
117
142
|
|
|
118
|
-
Apache-2.0 — [Viglet Shio](https://
|
|
143
|
+
Apache-2.0 — [Viglet Shio](https://openviglet.github.io/shio/) ·
|
|
119
144
|
[github.com/openviglet/shio](https://github.com/openviglet/shio) ·
|
|
120
145
|
[docs.viglet.org/shio](https://docs.viglet.org/shio/) ·
|
|
121
146
|
part of the [Viglet](https://www.viglet.org) open source family.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ShioClientConfig, ShioListing, ShioPageParams, ShioPath, ShioPost, ShioPostTypeSchema, ShioQueryParams, ShioRequestOptions, ShioSite } from "./types";
|
|
1
|
+
import type { ShioClientConfig, ShioListing, ShioPageParams, ShioPath, ShioPost, ShioPostTypeSchema, ShioQueryParams, ShioReadOptions, ShioRedirect, ShioRequestOptions, ShioSite } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Framework-agnostic client for the Shio Content Delivery API (CDA, SH1).
|
|
4
4
|
*
|
|
@@ -22,17 +22,36 @@ export declare class ShioClient {
|
|
|
22
22
|
getSites(opts?: ShioRequestOptions): Promise<ShioSite[]>;
|
|
23
23
|
/** Get one site (with its root folder id), or `null` if not found. */
|
|
24
24
|
getSite(siteId: string, opts?: ShioRequestOptions): Promise<ShioSite | null>;
|
|
25
|
+
/**
|
|
26
|
+
* A site's redirect table (SH1133), ordered by `from`, or `null` if the site is unknown.
|
|
27
|
+
*
|
|
28
|
+
* Small and site-scoped, so a front end can hold it and consult it before a 404 rather than
|
|
29
|
+
* asking per request. A production token sees published redirects only.
|
|
30
|
+
*/
|
|
31
|
+
getRedirects(siteId: string, opts?: ShioRequestOptions): Promise<ShioRedirect[] | null>;
|
|
25
32
|
/** List a folder's children (subfolders + published posts), or `null` if the folder is unknown. */
|
|
26
33
|
listChildren(folderId: string, params?: ShioPageParams, opts?: ShioRequestOptions): Promise<ShioListing | null>;
|
|
27
34
|
/** Get the breadcrumb path for a folder or post, or `null` if unknown. */
|
|
28
35
|
getPath(objectId: string, opts?: ShioRequestOptions): Promise<ShioPath | null>;
|
|
29
|
-
/**
|
|
30
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Get a published post by id (attributes expanded), or `null` if not found / not published.
|
|
38
|
+
*
|
|
39
|
+
* SH1081 — `opts.state` asks for another version: `"draft"` or `"rev:<n>"` with a preview token.
|
|
40
|
+
*/
|
|
41
|
+
getPost(postId: string, opts?: ShioReadOptions): Promise<ShioPost | null>;
|
|
31
42
|
/**
|
|
32
43
|
* Resolve a published post by site + friendly URL — the call behind catch-all
|
|
33
44
|
* routing (e.g. Next.js `[...slug]`). Returns `null` if unresolved.
|
|
45
|
+
*
|
|
46
|
+
* SH1057 — pass a `locale` as the third argument to resolve only the translation
|
|
47
|
+
* in that language: `getPostByUrl(siteId, "/about", "pt-br")` is `null` when the
|
|
48
|
+
* post at `/about` is in another language, and its `availableLocales` says which.
|
|
49
|
+
*
|
|
50
|
+
* SH1081 — `opts.state` asks for another version, as on {@link getPost}: a draft preview of
|
|
51
|
+
* one page is `getPostByUrl(siteId, "/about", { state: "draft" })` with a preview token.
|
|
34
52
|
*/
|
|
35
|
-
getPostByUrl(siteId: string, url: string, opts?:
|
|
53
|
+
getPostByUrl(siteId: string, url: string, opts?: ShioReadOptions): Promise<ShioPost | null>;
|
|
54
|
+
getPostByUrl(siteId: string, url: string, locale: string, opts?: ShioReadOptions): Promise<ShioPost | null>;
|
|
36
55
|
/**
|
|
37
56
|
* List every post-type's content-model schema — the input to
|
|
38
57
|
* {@link generateShioTypes}. The schema is global (not site-scoped), so a
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { ShioClient, createShioClient } from "./client";
|
|
|
2
2
|
export { ShioHttpError } from "./errors";
|
|
3
3
|
export { generateShioTypes } from "./codegen";
|
|
4
4
|
export type { GenerateTypesOptions } from "./codegen";
|
|
5
|
-
export type { ShioClientConfig, ShioRequestOptions, ShioSite, ShioFolder, ShioPostSummary, ShioPost, ShioListing, ShioPath, ShioQueryParams, ShioPageParams, ShioFieldSchema, ShioPostTypeSchema, } from "./types";
|
|
5
|
+
export type { ShioClientConfig, ShioRequestOptions, ShioContentState, ShioReadOptions, ShioSite, ShioSiteLocales, ShioRedirect, ShioFolder, ShioPostSummary, ShioPost, ShioListing, ShioPath, ShioQueryParams, ShioPageParams, ShioFieldSchema, ShioPostTypeSchema, ShioBlock, ShioBlockMark, } from "./types";
|
|
6
|
+
export { SHIO_BLOCK_TYPES, shioBlocks } from "./types";
|
package/dist/shio-client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/errors.ts
|
|
2
2
|
var e = class e extends Error {
|
|
3
3
|
constructor(t, n, r) {
|
|
4
4
|
super(`Shio CDA ${t} for ${n}`), this.name = "ShioHttpError", this.status = t, this.url = n, this.body = r, Object.setPrototypeOf(this, e.prototype);
|
|
@@ -20,10 +20,15 @@ var e = class e extends Error {
|
|
|
20
20
|
getSite(e, t) {
|
|
21
21
|
return this.requestOrNull(`/site/${i(e)}`, t);
|
|
22
22
|
}
|
|
23
|
+
getRedirects(e, t) {
|
|
24
|
+
return this.requestOrNull(`/site/${i(e)}/redirects`, t);
|
|
25
|
+
}
|
|
23
26
|
listChildren(e, t, n) {
|
|
24
27
|
let r = a({
|
|
25
28
|
page: t?.page,
|
|
26
|
-
size: t?.size
|
|
29
|
+
size: t?.size,
|
|
30
|
+
locale: t?.locale,
|
|
31
|
+
state: t?.state
|
|
27
32
|
});
|
|
28
33
|
return this.requestOrNull(`/object/${i(e)}/list${r}`, n);
|
|
29
34
|
}
|
|
@@ -31,14 +36,17 @@ var e = class e extends Error {
|
|
|
31
36
|
return this.requestOrNull(`/object/${i(e)}/path`, t);
|
|
32
37
|
}
|
|
33
38
|
getPost(e, t) {
|
|
34
|
-
|
|
39
|
+
let n = a({ state: t?.state });
|
|
40
|
+
return this.requestOrNull(`/post/${i(e)}${n}`, t);
|
|
35
41
|
}
|
|
36
|
-
getPostByUrl(e, t, n) {
|
|
37
|
-
let r = a({
|
|
42
|
+
getPostByUrl(e, t, n, r) {
|
|
43
|
+
let i = typeof n == "string" ? n : void 0, o = typeof n == "string" ? r : n, s = a({
|
|
38
44
|
siteId: e,
|
|
39
|
-
url: t
|
|
45
|
+
url: t,
|
|
46
|
+
locale: i,
|
|
47
|
+
state: o?.state
|
|
40
48
|
});
|
|
41
|
-
return this.requestOrNull(`/post/by-url${
|
|
49
|
+
return this.requestOrNull(`/post/by-url${s}`, o);
|
|
42
50
|
}
|
|
43
51
|
getPostTypes(e) {
|
|
44
52
|
return this.request("/post-type", e);
|
|
@@ -52,7 +60,9 @@ var e = class e extends Error {
|
|
|
52
60
|
folderId: e?.folderId,
|
|
53
61
|
postType: e?.postType,
|
|
54
62
|
page: e?.page,
|
|
55
|
-
size: e?.size
|
|
63
|
+
size: e?.size,
|
|
64
|
+
locale: e?.locale,
|
|
65
|
+
state: e?.state
|
|
56
66
|
});
|
|
57
67
|
return this.request(`/query${n}`, t);
|
|
58
68
|
}
|
|
@@ -95,8 +105,7 @@ async function o(e) {
|
|
|
95
105
|
return;
|
|
96
106
|
}
|
|
97
107
|
}
|
|
98
|
-
|
|
99
|
-
//#region src/codegen.ts
|
|
108
|
+
// src/codegen.ts
|
|
100
109
|
var s = "@viglet/shio-client", c = "// AUTO-GENERATED by @viglet/shio-client (shio-types). DO NOT EDIT BY HAND.\n// Re-run `shio-types` after changing a post-type.";
|
|
101
110
|
function l(e, t = {}) {
|
|
102
111
|
let n = t.importFrom ?? s, r = t.banner ?? c, i = [...e].sort((e, t) => e.name.localeCompare(t.name)), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set();
|
|
@@ -135,5 +144,19 @@ function m(e) {
|
|
|
135
144
|
let t = (e ?? "").split(/[^A-Za-z0-9]+/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("");
|
|
136
145
|
return /^[0-9]/.test(t) && (t = `T${t}`), t;
|
|
137
146
|
}
|
|
138
|
-
|
|
139
|
-
|
|
147
|
+
// src/types.ts
|
|
148
|
+
var h = [
|
|
149
|
+
"heading",
|
|
150
|
+
"paragraph",
|
|
151
|
+
"quote",
|
|
152
|
+
"list",
|
|
153
|
+
"code",
|
|
154
|
+
"image",
|
|
155
|
+
"embed",
|
|
156
|
+
"reference"
|
|
157
|
+
];
|
|
158
|
+
function g(e, t) {
|
|
159
|
+
let n = e.attrs?.[t];
|
|
160
|
+
return Array.isArray(n) ? n : null;
|
|
161
|
+
}
|
|
162
|
+
export { h as SHIO_BLOCK_TYPES, n as ShioClient, e as ShioHttpError, r as createShioClient, l as generateShioTypes, g as shioBlocks };
|
package/dist/shio-client.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ShioClient={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class e extends Error{constructor(t,n,r){super(`Shio CDA ${t} for ${n}`),this.name=`ShioHttpError`,this.status=t,this.url=n,this.body=r,Object.setPrototypeOf(this,e.prototype)}},n=`/api/v2/cda`,r=class{constructor(e){if(!e?.baseUrl)throw Error("ShioClient: `baseUrl` is required");this.baseUrl=e.baseUrl.replace(/\/+$/,``),this.headers={Accept:`application/json`,...e.headers??{}},e.apiToken&&(this.headers.Key=e.apiToken);let t=e.fetch??globalThis.fetch;if(typeof t!=`function`)throw Error("ShioClient: no global `fetch` available — pass `fetch` in the config");this.fetchFn=t.bind(globalThis),this.credentials=e.credentials}getSites(e){return this.request(`/site`,e)}getSite(e,t){return this.requestOrNull(`/site/${a(e)}`,t)}listChildren(e,t,n){let r=o({page:t?.page,size:t?.size});return this.requestOrNull(`/object/${a(e)}/list${r}`,n)}getPath(e,t){return this.requestOrNull(`/object/${a(e)}/path`,t)}getPost(e,t){return this.requestOrNull(`/post/${a(e)}`,t)}getPostByUrl(e,t,n){let r=o({siteId:e,url:t});return this.requestOrNull(`/post/by-url${
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ShioClient={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class e extends Error{constructor(t,n,r){super(`Shio CDA ${t} for ${n}`),this.name=`ShioHttpError`,this.status=t,this.url=n,this.body=r,Object.setPrototypeOf(this,e.prototype)}},n=`/api/v2/cda`,r=class{constructor(e){if(!e?.baseUrl)throw Error("ShioClient: `baseUrl` is required");this.baseUrl=e.baseUrl.replace(/\/+$/,``),this.headers={Accept:`application/json`,...e.headers??{}},e.apiToken&&(this.headers.Key=e.apiToken);let t=e.fetch??globalThis.fetch;if(typeof t!=`function`)throw Error("ShioClient: no global `fetch` available — pass `fetch` in the config");this.fetchFn=t.bind(globalThis),this.credentials=e.credentials}getSites(e){return this.request(`/site`,e)}getSite(e,t){return this.requestOrNull(`/site/${a(e)}`,t)}getRedirects(e,t){return this.requestOrNull(`/site/${a(e)}/redirects`,t)}listChildren(e,t,n){let r=o({page:t?.page,size:t?.size,locale:t?.locale,state:t?.state});return this.requestOrNull(`/object/${a(e)}/list${r}`,n)}getPath(e,t){return this.requestOrNull(`/object/${a(e)}/path`,t)}getPost(e,t){let n=o({state:t?.state});return this.requestOrNull(`/post/${a(e)}${n}`,t)}getPostByUrl(e,t,n,r){let i=typeof n==`string`?n:void 0,a=typeof n==`string`?r:n,s=o({siteId:e,url:t,locale:i,state:a?.state});return this.requestOrNull(`/post/by-url${s}`,a)}getPostTypes(e){return this.request(`/post-type`,e)}getPostType(e,t){return this.requestOrNull(`/post-type/${a(e)}`,t)}query(e,t){let n=o({siteId:e?.siteId,folderId:e?.folderId,postType:e?.postType,page:e?.page,size:e?.size,locale:e?.locale,state:e?.state});return this.request(`/query${n}`,t)}async send(e,t){return this.fetchFn(`${this.baseUrl}${n}${e}`,{method:`GET`,headers:this.headers,signal:t?.signal,...this.credentials?{credentials:this.credentials}:{}})}async request(e,n){let r=await this.send(e,n);if(!r.ok)throw new t(r.status,e,await s(r));return await r.json()}async requestOrNull(e,n){let r=await this.send(e,n);if(r.status===404)return null;if(!r.ok)throw new t(r.status,e,await s(r));return await r.json()}};function i(e){return new r(e)}function a(e){return encodeURIComponent(e)}function o(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!=null&&r!==``&&t.append(n,String(r));let n=t.toString();return n?`?${n}`:``}async function s(e){try{return await e.text()}catch{return}}var c=`@viglet/shio-client`,l="// AUTO-GENERATED by @viglet/shio-client (shio-types). DO NOT EDIT BY HAND.\n// Re-run `shio-types` after changing a post-type.";function u(e,t={}){let n=t.importFrom??c,r=t.banner??l,i=[...e].sort((e,t)=>e.name.localeCompare(t.name)),a=new Map,o=new Set;for(let e of i){let t=h(e.name)||`PostType`,n=t,r=2;for(;o.has(n);)n=`${t}${r++}`;o.add(n),a.set(e.name,n)}let s=[];for(let e of i){let t=a.get(e.name),n=p(e.title??e.description,0);s.push(`${n}export interface ${t}Attrs {\n${d(e.fields,1)}}\n\n/** A \`${e.name}\` post with typed attributes. */\nexport type ${t}Post = ShioPost & {\n postType: ${JSON.stringify(e.name)};\n attrs: ${t}Attrs;\n};`)}let u=`/** Maps each post-type's API name to its typed post interface. */
|
|
2
2
|
export interface ShioPostTypes {\n${i.map(e=>` ${m(e.name)}: ${a.get(e.name)}Post;`).join(`
|
|
3
3
|
`)||``}\n}\n\n/** Union of all known post-type API names. */
|
|
4
4
|
export type ShioPostTypeName = keyof ShioPostTypes;`;return`${r}\n\nimport type { ShioPost } from ${JSON.stringify(n)};\n\n`+(s.length?`${s.join(`
|
|
5
5
|
|
|
6
|
-
`)}\n\n`:``)+`${u}\n`}function d(e,t){let n=` `.repeat(t);return[...e].sort((e,t)=>e.ordinal-t.ordinal).map(e=>{let r=p(e.label??e.description,t),i=e.required?``:`?`;return`${r}${n}${m(e.name)}${i}: ${f(e,t)};\n`}).join(``)}function f(e,t){return e.fields&&e.fields.length>0?`Array<{\n${d(e.fields,t+1)}${` `.repeat(t)}}>`:e.multiple?`string[]`:`string`}function p(e,t){return!e||!e.trim()?``:`${` `.repeat(t)}/** ${e.trim().replace(/\*\//g,`*\\/`)} */\n`}function m(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)?e:JSON.stringify(e)}function h(e){let t=(e??``).split(/[^A-Za-z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return/^[0-9]/.test(t)&&(t=`T${t}`),t}e.ShioClient=r,e.ShioHttpError=t,e.createShioClient=i,e.generateShioTypes=u});
|
|
6
|
+
`)}\n\n`:``)+`${u}\n`}function d(e,t){let n=` `.repeat(t);return[...e].sort((e,t)=>e.ordinal-t.ordinal).map(e=>{let r=p(e.label??e.description,t),i=e.required?``:`?`;return`${r}${n}${m(e.name)}${i}: ${f(e,t)};\n`}).join(``)}function f(e,t){return e.fields&&e.fields.length>0?`Array<{\n${d(e.fields,t+1)}${` `.repeat(t)}}>`:e.multiple?`string[]`:`string`}function p(e,t){return!e||!e.trim()?``:`${` `.repeat(t)}/** ${e.trim().replace(/\*\//g,`*\\/`)} */\n`}function m(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)?e:JSON.stringify(e)}function h(e){let t=(e??``).split(/[^A-Za-z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return/^[0-9]/.test(t)&&(t=`T${t}`),t}var g=[`heading`,`paragraph`,`quote`,`list`,`code`,`image`,`embed`,`reference`];function _(e,t){let n=e.attrs?.[t];return Array.isArray(n)?n:null}e.SHIO_BLOCK_TYPES=g,e.ShioClient=r,e.ShioHttpError=t,e.createShioClient=i,e.generateShioTypes=u,e.shioBlocks=_});
|
package/dist/types.d.ts
CHANGED
|
@@ -39,6 +39,20 @@ export interface ShioRequestOptions {
|
|
|
39
39
|
/** Abort signal for cancellation (e.g. React effect cleanup). */
|
|
40
40
|
signal?: AbortSignal;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* The version of content a CDA read asks for (SH1081, over SH990's parameter).
|
|
44
|
+
*
|
|
45
|
+
* `"published"` is the default and any token may read it. `"draft"` and `"rev:<n>"` need a
|
|
46
|
+
* preview token, and without one the read throws {@link ShioHttpError} with status 403 and the
|
|
47
|
+
* problem slug `state-needs-preview-token`. A string rather than a union, so the server stays the
|
|
48
|
+
* one place that says which values exist.
|
|
49
|
+
*/
|
|
50
|
+
export type ShioContentState = string;
|
|
51
|
+
/** Per-request options for a single-post read: {@link ShioRequestOptions} plus a state. */
|
|
52
|
+
export interface ShioReadOptions extends ShioRequestOptions {
|
|
53
|
+
/** See {@link ShioContentState}; omitted, the published version. */
|
|
54
|
+
state?: ShioContentState;
|
|
55
|
+
}
|
|
42
56
|
/** A published site. */
|
|
43
57
|
export interface ShioSite {
|
|
44
58
|
id: string;
|
|
@@ -46,6 +60,47 @@ export interface ShioSite {
|
|
|
46
60
|
description?: string;
|
|
47
61
|
url?: string;
|
|
48
62
|
rootFolderId?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The languages this site is in (SH1123) — what a language switcher is built from.
|
|
65
|
+
* Present on {@link ShioClient.getSite} and {@link ShioClient.getSites}; absent on the
|
|
66
|
+
* `site` a {@link ShioPath} carries.
|
|
67
|
+
*/
|
|
68
|
+
locales?: ShioSiteLocales;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A site's locale policy (SH1123). Pair it with {@link ShioPost.availableLocales}: the
|
|
72
|
+
* site says which languages it offers, the post says which of them this page exists in.
|
|
73
|
+
*/
|
|
74
|
+
export interface ShioSiteLocales {
|
|
75
|
+
/** The locale the site is written in — always one of {@link enabled}. */
|
|
76
|
+
defaultLocale: string;
|
|
77
|
+
/** Every locale the site offers, in the order a switcher lists them. */
|
|
78
|
+
enabled: string[];
|
|
79
|
+
/**
|
|
80
|
+
* Locale to show instead when a page is missing in the one asked for, e.g.
|
|
81
|
+
* `{ "pt-br": "pt" }`. A locale with no entry falls back to {@link defaultLocale}.
|
|
82
|
+
*/
|
|
83
|
+
fallback: Record<string, string>;
|
|
84
|
+
/**
|
|
85
|
+
* `true` when somebody chose this policy. `false` when it was read off the published
|
|
86
|
+
* content, in which case {@link enabled} lists what has been translated so far rather
|
|
87
|
+
* than what the site promises.
|
|
88
|
+
*/
|
|
89
|
+
declared: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* One row of a site's redirect table (SH1133), from {@link ShioClient.getRedirects}.
|
|
93
|
+
*
|
|
94
|
+
* A front end that serves the site's URLs itself consults this before answering 404: the
|
|
95
|
+
* instance's own renderer honours these, and a headless site never reaches it.
|
|
96
|
+
*/
|
|
97
|
+
export interface ShioRedirect {
|
|
98
|
+
/** The site-relative path that moved, e.g. `/pricing`. */
|
|
99
|
+
from: string;
|
|
100
|
+
/** Where it moved: a site-relative path, or an absolute URL as written. */
|
|
101
|
+
to: string;
|
|
102
|
+
/** `true` for a 301, `false` for a 302 — the default, because a wrong 301 is cached for ever. */
|
|
103
|
+
permanent: boolean;
|
|
49
104
|
}
|
|
50
105
|
/** A folder (listing item / breadcrumb node). */
|
|
51
106
|
export interface ShioFolder {
|
|
@@ -88,7 +143,78 @@ export interface ShioPost {
|
|
|
88
143
|
availableLocales: string[];
|
|
89
144
|
/** Post-type attributes as a JSON object, keyed by attribute name. */
|
|
90
145
|
attrs: Record<string, unknown>;
|
|
146
|
+
/**
|
|
147
|
+
* SH1016 — field name to rendered HTML, for this post's `Blocks` fields.
|
|
148
|
+
*
|
|
149
|
+
* Beside {@link attrs}, never instead of it: a site that maps block types to its own
|
|
150
|
+
* components reads the array out of `attrs`, and one that has been dropping a body into a
|
|
151
|
+
* div reads this. Absent for a post with no block field, which is every post written
|
|
152
|
+
* before the widget existed.
|
|
153
|
+
*/
|
|
154
|
+
rendered?: Record<string, string>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* SH1016 — one block of a `Blocks` field, discriminated by {@link ShioBlock.type}.
|
|
158
|
+
*
|
|
159
|
+
* TypeScript narrows on `type`, so `switch (block.type)` gives each case its own fields with
|
|
160
|
+
* no cast — which is the whole reason the body is an array of these rather than a string.
|
|
161
|
+
* A `key` is the block's identity across a reorder, not its position.
|
|
162
|
+
*
|
|
163
|
+
* Marks are ranges over the block's own `text`, not nested spans: `<b><i>x</i></b>` and
|
|
164
|
+
* `<i><b>x</b></i>` are one content with two spellings, and a range has one.
|
|
165
|
+
*/
|
|
166
|
+
export interface ShioBlockMark {
|
|
167
|
+
from: number;
|
|
168
|
+
to: number;
|
|
169
|
+
type: "strong" | "em" | "code" | "link" | "strike";
|
|
170
|
+
/** Present on a `link` mark. */
|
|
171
|
+
href?: string;
|
|
91
172
|
}
|
|
173
|
+
interface ShioBlockBase {
|
|
174
|
+
key: string;
|
|
175
|
+
}
|
|
176
|
+
export type ShioBlock = (ShioBlockBase & {
|
|
177
|
+
type: "heading";
|
|
178
|
+
level: number;
|
|
179
|
+
text?: string;
|
|
180
|
+
marks?: ShioBlockMark[];
|
|
181
|
+
}) | (ShioBlockBase & {
|
|
182
|
+
type: "paragraph";
|
|
183
|
+
text?: string;
|
|
184
|
+
marks?: ShioBlockMark[];
|
|
185
|
+
}) | (ShioBlockBase & {
|
|
186
|
+
type: "quote";
|
|
187
|
+
text?: string;
|
|
188
|
+
marks?: ShioBlockMark[];
|
|
189
|
+
}) | (ShioBlockBase & {
|
|
190
|
+
type: "list";
|
|
191
|
+
ordered?: boolean;
|
|
192
|
+
items?: string[];
|
|
193
|
+
}) | (ShioBlockBase & {
|
|
194
|
+
type: "code";
|
|
195
|
+
language?: string;
|
|
196
|
+
text?: string;
|
|
197
|
+
}) | (ShioBlockBase & {
|
|
198
|
+
type: "image";
|
|
199
|
+
src?: string;
|
|
200
|
+
alt?: string;
|
|
201
|
+
}) | (ShioBlockBase & {
|
|
202
|
+
type: "embed";
|
|
203
|
+
url?: string;
|
|
204
|
+
}) | (ShioBlockBase & {
|
|
205
|
+
type: "reference";
|
|
206
|
+
address?: string;
|
|
207
|
+
});
|
|
208
|
+
/** The registered block types, as the server refuses anything outside them. */
|
|
209
|
+
export declare const SHIO_BLOCK_TYPES: readonly ["heading", "paragraph", "quote", "list", "code", "image", "embed", "reference"];
|
|
210
|
+
/**
|
|
211
|
+
* Reads a post's block field as blocks, or `null` when it is not one.
|
|
212
|
+
*
|
|
213
|
+
* A helper rather than a cast, because the honest answer for a field that holds a string is
|
|
214
|
+
* "this is not a blocks field" — and a consumer that casts finds that out by rendering
|
|
215
|
+
* nothing.
|
|
216
|
+
*/
|
|
217
|
+
export declare function shioBlocks(post: ShioPost, field: string): ShioBlock[] | null;
|
|
92
218
|
/** Folder children: subfolders plus a paged slice of published posts. */
|
|
93
219
|
export interface ShioListing {
|
|
94
220
|
folderId?: string;
|
|
@@ -148,9 +274,18 @@ export interface ShioQueryParams {
|
|
|
148
274
|
postType?: string;
|
|
149
275
|
page?: number;
|
|
150
276
|
size?: number;
|
|
277
|
+
/** Only posts written in this locale (SH1057), e.g. `"pt-br"`; omitted, every locale. */
|
|
278
|
+
locale?: string;
|
|
279
|
+
/** SH1081 — which version of each post; see {@link ShioContentState}. */
|
|
280
|
+
state?: ShioContentState;
|
|
151
281
|
}
|
|
152
282
|
/** Paging parameters for listings. */
|
|
153
283
|
export interface ShioPageParams {
|
|
154
284
|
page?: number;
|
|
155
285
|
size?: number;
|
|
286
|
+
/** Only posts written in this locale (SH1057); a folder's subfolders are listed whatever it is. */
|
|
287
|
+
locale?: string;
|
|
288
|
+
/** SH1081 — which version of each post; see {@link ShioContentState}. */
|
|
289
|
+
state?: ShioContentState;
|
|
156
290
|
}
|
|
291
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viglet/shio-client",
|
|
3
|
-
"version": "2026.3.
|
|
4
|
-
"description": "Framework-agnostic TypeScript client for the Shio
|
|
5
|
-
"homepage": "https://
|
|
3
|
+
"version": "2026.3.3",
|
|
4
|
+
"description": "Framework-agnostic TypeScript client for the Viglet Shio Content Delivery API (CDA). Zero runtime dependencies — works in Node, the browser, edge runtimes, Next.js server components, Astro, Vue, Svelte and plain scripts.",
|
|
5
|
+
"homepage": "https://openviglet.github.io/shio/",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/openviglet/shio.git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"sideEffects": false,
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typescript": "^5.8.3",
|
|
36
|
-
"vite": "^8.
|
|
36
|
+
"vite": "^8.3.5"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|
|
39
39
|
"shio",
|
|
@@ -65,6 +65,6 @@
|
|
|
65
65
|
"dev": "vite build --watch",
|
|
66
66
|
"build": "vite build && tsc --emitDeclarationOnly",
|
|
67
67
|
"typecheck": "tsc --noEmit",
|
|
68
|
-
"test": "node --test \"test/*.test.mjs\""
|
|
68
|
+
"test": "node --import ../scripts/test-watchdog.mjs --test \"test/*.test.mjs\""
|
|
69
69
|
}
|
|
70
70
|
}
|