@sitecore-marketplace-sdk/client 0.1.0
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.MD +202 -0
- package/README.md +138 -0
- package/dist/client.d.ts +126 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/logger.d.ts +17 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/sdk-types.d.ts +195 -0
- package/dist/sdk-types.d.ts.map +1 -0
- package/dist/state.d.ts +46 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/types.d.ts +69 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +73 -0
package/LICENSE.MD
ADDED
|
@@ -0,0 +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.
|
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# SITECORE MARKETPLACE CLIENT SDK
|
|
2
|
+
|
|
3
|
+
The Marketplace Client SDK provides a secure, bidirectional communication between a client
|
|
4
|
+
application (running inside an iframe) and the host application. Inspired by React Query, the SDK implements a query/mutation API where:
|
|
5
|
+
|
|
6
|
+
- **Queries** support one-off data requests as well as subscriptions for live updates.
|
|
7
|
+
- **Mutations** trigger state changes or HTTP requests on the host side (with user tokens attached by the Host SDK).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @sitecore-marketplace-sdk/client
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Initialization
|
|
16
|
+
|
|
17
|
+
Before you use queries or mutations, you must initialize the Client SDK.
|
|
18
|
+
|
|
19
|
+
Example initialization code:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { ClientSDK } from '@sitecore-marketplace-sdk/client';
|
|
23
|
+
|
|
24
|
+
// Create a configuration object.
|
|
25
|
+
const config = {
|
|
26
|
+
origin: 'https://pages.sitecorecloud.io',
|
|
27
|
+
target: window.parent,
|
|
28
|
+
modules: []
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Create a Client SDK instance using the configuration.
|
|
32
|
+
// The returned SDK provides a type-safe API based on your resource schema.
|
|
33
|
+
const client = await ClientSDK.init(config);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### Query Example
|
|
39
|
+
|
|
40
|
+
The `query` method supports one-off data requests and live subscriptions. The keys follow a dot-notated format derived from your
|
|
41
|
+
static JSON schema (for example, `"application.context"`).
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
(async () => {
|
|
45
|
+
// One-off query example: Request host state once.
|
|
46
|
+
const queryResult = await client.query('host.state');
|
|
47
|
+
|
|
48
|
+
console.log(queryResult.data); // Displays the host state data
|
|
49
|
+
console.log(queryResult.isLoading); // false once the request is complete
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Mutation Example
|
|
53
|
+
|
|
54
|
+
Use the `mutate` method to trigger changes on the host side. The Host SDK (integrated via the internal Core SDK) will attach the required
|
|
55
|
+
user token and perform the HTTP request on behalf of the client application.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
(async () => {
|
|
59
|
+
try {
|
|
60
|
+
const mutationResponse = await client.mutate(
|
|
61
|
+
'host.state',
|
|
62
|
+
{ params: {
|
|
63
|
+
newState: 'active'
|
|
64
|
+
}}
|
|
65
|
+
);
|
|
66
|
+
console.log('Mutation response:', mutationResponse);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error('Error during mutation:', error);
|
|
69
|
+
}
|
|
70
|
+
})();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Application Context
|
|
74
|
+
|
|
75
|
+
This application context provides information about the application, such as its ID, URL, name, type, icon URL, installation ID, and associated resources.
|
|
76
|
+
|
|
77
|
+
Here is the ApplicationContext data example:
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
{
|
|
81
|
+
id: 'my-app-id',
|
|
82
|
+
name: 'My App',
|
|
83
|
+
type: 'portal',
|
|
84
|
+
url: 'https://my-app.com/app',
|
|
85
|
+
iconUrl: 'https://my-app.com/assets/icon.png',
|
|
86
|
+
installationId: 'abc1234567890',
|
|
87
|
+
resources: [
|
|
88
|
+
{
|
|
89
|
+
resourceId: 'resource-1',
|
|
90
|
+
tenantId: 'tenant-1',
|
|
91
|
+
tenantName: 'Example Tenant',
|
|
92
|
+
context: {
|
|
93
|
+
live: '1234567890',
|
|
94
|
+
preview: '0987654321'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
To request the application context, you can use the query method with the key 'application.context'. This will return data of type ApplicationContext.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
(async () => {
|
|
105
|
+
const queryResult = await client.query('application.context');
|
|
106
|
+
console.log(queryResult.data); // Displays the application context data
|
|
107
|
+
})();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Generated Types & Namespace Mapping
|
|
111
|
+
|
|
112
|
+
The Client SDK heavily relies on a generated static contract (based on a JSON schema such as `resources.schema.json`) that defines
|
|
113
|
+
available resource namespaces and methods. For example, with a schema structured like:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"resources": {
|
|
118
|
+
"xmc": {
|
|
119
|
+
"publishing": {
|
|
120
|
+
"status": { "type": "query", ... },
|
|
121
|
+
"publish": { "type": "mutation", ... }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The generated client types provide a type-safe interface:
|
|
129
|
+
|
|
130
|
+
- `xmc.publishing.status(params)` returns a `Promise<QueryResult<...>>`
|
|
131
|
+
- `xmc.publishing.publish(params)` returns a `Promise<MutationResult<...>>`
|
|
132
|
+
|
|
133
|
+
The keys passed to `query` and `mutate` are dot-notated (e.g., `"xmc.publishing.status"`), ensuring that they map directly
|
|
134
|
+
to the generated methods and resource definitions.
|
|
135
|
+
|
|
136
|
+
## Additional Information
|
|
137
|
+
|
|
138
|
+
For more details, please refer to the full documentation in the `/docs` folder or the project documentation.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client SDK provides high-level abstractions for interacting with the host application
|
|
3
|
+
* via the Core SDK. It exposes a query/mutation API similar to React Query.
|
|
4
|
+
*
|
|
5
|
+
* - Queries support one-off data requests and (optionally) subscriptions for live updates.
|
|
6
|
+
* - Mutations trigger host-side state changes or HTTP requests.
|
|
7
|
+
*
|
|
8
|
+
* Usage example:
|
|
9
|
+
* const client = await ClientSDK.init({
|
|
10
|
+
* origin: 'https://host.app',
|
|
11
|
+
* target: window.parent,
|
|
12
|
+
* timeout: 5000
|
|
13
|
+
* });
|
|
14
|
+
* const { data } = await client.query('host.user');
|
|
15
|
+
*/
|
|
16
|
+
import { ClientSDKConfig, MutationOptions, QueryOptions, QueryResult } from './types';
|
|
17
|
+
import type { QueryKey, MutationKey, MutationMap, NavbarItemsProps, SDKModule } from './sdk-types';
|
|
18
|
+
export declare class ClientSDK {
|
|
19
|
+
private config;
|
|
20
|
+
private stateManager;
|
|
21
|
+
private coreSdk;
|
|
22
|
+
private modules;
|
|
23
|
+
constructor(config: ClientSDKConfig);
|
|
24
|
+
/**
|
|
25
|
+
* Creates and initializes a ClientSDK instance.
|
|
26
|
+
*
|
|
27
|
+
* This static method encapsulates the logic that was formerly in create-client.ts.
|
|
28
|
+
* It builds the necessary configuration, instantiates the ClientSDK, performs the handshake,
|
|
29
|
+
* and returns an instance that is ready to execute requests.
|
|
30
|
+
*
|
|
31
|
+
* @param config - The configuration for the client SDK.
|
|
32
|
+
* Includes the host origin, the target window (typically window.parent),
|
|
33
|
+
* and an optional timeout.
|
|
34
|
+
* @returns A Promise that resolves with an initialized and ready-to-use ClientSDK instance.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const client = await ClientSDK.init({
|
|
39
|
+
* origin: 'https://host.app',
|
|
40
|
+
* target: window.parent,
|
|
41
|
+
* timeout: 5000
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
static init(config: {
|
|
46
|
+
origin: string;
|
|
47
|
+
target: Window;
|
|
48
|
+
timeout?: number;
|
|
49
|
+
modules?: SDKModule[];
|
|
50
|
+
events?: ClientSDKConfig['events'];
|
|
51
|
+
navbarItems?: NavbarItemsProps;
|
|
52
|
+
}): Promise<ClientSDK>;
|
|
53
|
+
/**
|
|
54
|
+
* Initializes the client SDK by performing a handshake with the host application.
|
|
55
|
+
* Must be called after the client script loads (when running inside an iframe).
|
|
56
|
+
* @returns A Promise that resolves once the handshake is successfully completed.
|
|
57
|
+
*/
|
|
58
|
+
initialize(): Promise<void>;
|
|
59
|
+
private registerModule;
|
|
60
|
+
private hasModule;
|
|
61
|
+
private availableModules;
|
|
62
|
+
private resolveOperation;
|
|
63
|
+
private registerHandlers;
|
|
64
|
+
/**
|
|
65
|
+
* Executes a query against the host application. Queries can be one-off requests
|
|
66
|
+
* or subscriptions that receive live updates.
|
|
67
|
+
*
|
|
68
|
+
* @param key - The query key identifying the resource (e.g. 'host.state', 'host.user')
|
|
69
|
+
* @param options - Configuration for the query
|
|
70
|
+
* @param options.params - Request parameters (headers, query, body)
|
|
71
|
+
* @param options.subscribe - Whether to subscribe to live updates
|
|
72
|
+
* @param options.timeoutMs - Custom timeout in milliseconds
|
|
73
|
+
* @param options.onSuccess - Callback when query succeeds
|
|
74
|
+
* @param options.onError - Callback when query fails
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* // One-off query
|
|
79
|
+
* const { data } = await client.query('host.user');
|
|
80
|
+
*
|
|
81
|
+
* // Query with subscription
|
|
82
|
+
* const { data, unsubscribe } = await client.query('host.state', {
|
|
83
|
+
* subscribe: true,
|
|
84
|
+
* onSuccess: (newState) => console.log('State updated:', newState)
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* // Later: cleanup subscription
|
|
88
|
+
* unsubscribe?.();
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
query<K extends QueryKey>(key: K, queryOptions?: QueryOptions<K>): Promise<QueryResult<K>>;
|
|
92
|
+
private generateKeyWithHash;
|
|
93
|
+
/**
|
|
94
|
+
* Executes a mutation against the host application. Mutations trigger host-side state changes or HTTP requests.
|
|
95
|
+
*
|
|
96
|
+
* @param key - The mutation key identifying the resource (e.g. 'host.update', 'host.delete')
|
|
97
|
+
* @param options - Configuration for the mutation
|
|
98
|
+
* @param options.params - Request parameters (headers, query, body)
|
|
99
|
+
* @param options.timeoutMs - Custom timeout in milliseconds
|
|
100
|
+
* @param options.onSuccess - Callback when mutation succeeds
|
|
101
|
+
* @param options.onError - Callback when mutation fails
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* // Mutation with key
|
|
106
|
+
* const response = await client.mutate('host.update', {
|
|
107
|
+
* params: { id: 1, name: 'New Name' },
|
|
108
|
+
* onSuccess: (data) => console.log('Update successful:', data),
|
|
109
|
+
* onError: (error) => console.error('Update failed:', error),
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
mutate<K extends MutationKey>(key: K, mutationOptions?: MutationOptions<K>): Promise<MutationMap[K]['response']>;
|
|
114
|
+
private _fetch;
|
|
115
|
+
logout(): Promise<void>;
|
|
116
|
+
openProfile(): Promise<void>;
|
|
117
|
+
navigateToExternalUrl(url: string, newTab?: boolean): Promise<void>;
|
|
118
|
+
private setNavbarItems;
|
|
119
|
+
private unsubscribe;
|
|
120
|
+
/**
|
|
121
|
+
* Cleans up all active subscriptions and resources.
|
|
122
|
+
* Call this when the SDK instance is no longer needed.
|
|
123
|
+
*/
|
|
124
|
+
destroy(): void;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtF,OAAO,KAAK,EACV,QAAQ,EAER,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,SAAS,EACV,MAAM,aAAa,CAAC;AAErB,qBAAa,SAAS;IAKR,OAAO,CAAC,MAAM;IAJ1B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,OAAO,CAAqC;gBAEhC,MAAM,EAAE,eAAe;IAM3C;;;;;;;;;;;;;;;;;;;;OAoBG;WACU,IAAI,CAAC,MAAM,EAAE;QACxB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;QACtB,MAAM,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;QACnC,WAAW,CAAC,EAAE,gBAAgB,CAAC;KAChC,GAAG,OAAO,CAAC,SAAS,CAAC;IAoCtB;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBjC,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,gBAAgB;IAsBxB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEG,KAAK,CAAC,CAAC,SAAS,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YA0ElF,mBAAmB;IAYjC;;;;;;;;;;;;;;;;;;;OAmBG;IACG,MAAM,CAAC,CAAC,SAAS,WAAW,EAChC,GAAG,EAAE,CAAC,EACN,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GACnC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;YAiBxB,MAAM;IA8Bd,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC;YASjE,cAAc;IAM5B,OAAO,CAAC,WAAW;IASnB;;;OAGG;IACH,OAAO,IAAI,IAAI;CAOhB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e,t=require("@sitecore-marketplace-sdk/core");class s{queryStates=new Map;listeners=new Map;getQueryState(e){return this.queryStates.has(e)||this.queryStates.set(e,{status:"idle",subscriptionCount:0}),this.queryStates.get(e)}getQueryKeys(){return Array.from(this.queryStates.keys())}updateQueryState(e,t){const s={...this.getQueryState(e),...t};this.queryStates.set(e,s);const r={data:s.data,error:s.error,status:s.status,isLoading:"loading"===s.status,isError:"error"===s.status,isSuccess:"success"===s.status,refetch:async()=>{throw new Error("Refetch not implemented")},unsubscribe:s.unsubscribe};this.listeners.get(e)?.forEach((e=>e(r)))}subscribe(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{const s=this.listeners.get(e);s&&(s.delete(t),0===s.size&&this.listeners.delete(e))}}removeQuery(e){this.queryStates.delete(e),this.listeners.delete(e)}getSubscriptionCount(e){return this.getQueryState(e).subscriptionCount}incrementSubscriptionCount(e){const t=this.getQueryState(e);t.subscriptionCount++,this.queryStates.set(e,t)}decrementSubscriptionCount(e){const t=this.getQueryState(e);t.subscriptionCount--,this.queryStates.set(e,t)}}!function(e){e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR"}(e||(e={}));const r=new class{level;constructor(t=e.INFO){this.level=t}debug(t,...s){this.level<=e.DEBUG&&console.debug(`DEBUG: ${t}`,...s)}info(t,...s){this.level<=e.INFO&&console.info(`INFO: ${t}`,...s)}warn(t,...s){this.level<=e.WARN&&console.warn(`WARN: ${t}`,...s)}error(t,...s){this.level<=e.ERROR&&console.error(`ERROR: ${t}`,...s)}setLevel(e){this.level=e}}(e.DEBUG);class i{config;stateManager;coreSdk;modules=new Map;constructor(e){this.config=e,this.stateManager=new s,this.coreSdk=new t.CoreSDK(this.config)}static async init(e){const t={target:e.target,targetOrigin:e.origin,selfOrigin:window.location.origin,timeout:e.timeout,events:e.events,navbarItems:e.navbarItems},s=new i(t);if(await s.initialize(),await s.setNavbarItems(e.navbarItems),e.modules)for(const t of e.modules)s.registerModule(t);return window?(r.info("window is available. Assigning client to window"),window.sitecore_marketplace__clientSdk=s):r.info("window is not available. Not assigning client to window"),e.events&&s.registerHandlers(),s}async initialize(){try{this.coreSdk.initialize({type:"client",targetOrigin:this.config.targetOrigin,selfOrigin:this.config.selfOrigin||window.location.origin,version:"1"}),r.info("Client SDK initialized, performing handshake..."),await this.coreSdk.connect(),r.info("Client handshake successful.")}catch(e){throw r.error("Client handshake failed:",e),e}}registerModule(e){this.modules.set(e.namespace,e)}hasModule(e){return this.modules.has(e)}availableModules(){return Array.from(this.modules.keys())}resolveOperation(e){let t=this.coreSdk.request.bind(this.coreSdk),s=e;if(e.includes(".")){const r=e.indexOf("."),i=e.substring(0,r),n=e.substring(r+1),a=this.modules.get(i);a&&(t=a.invokeOperation.bind(a),s=n)}return{request:t,operation:s}}registerHandlers(){if(!this.coreSdk)return;const e=this.config.events||{};this.coreSdk.on("pages.context",(async t=>{r.debug("Received pages.context request:",t),e.onPageContextUpdate?(e.onPageContextUpdate(t),r.debug("Processed pages.context request.")):r.debug("onPageContextUpdate event listener is not set.")})),this.coreSdk.on("host.route",(e=>{this.config.events?.onRouteUpdate&&this.config.events.onRouteUpdate(e.route)}))}async query(e,t){const{request:s,operation:i}=this.resolveOperation(e),{subscribe:n,onSuccess:a,onError:o,params:u,timeoutMs:c}=t||{},h=await this.generateKeyWithHash(e,t);r.debug(`Query (${e}) initiated with params:`,u,`timeoutMs: ${c}`),this.stateManager.updateQueryState(h,{status:"loading"});try{const c=await s(i,u);if(r.info(`Query (${e}) success:`,c),this.stateManager.updateQueryState(h,{status:"success",data:c}),n&&(this.stateManager.subscribe(e,(e=>{e.data&&a?.(e.data),e.error&&o?.(e.error)})),this.stateManager.incrementSubscriptionCount(h),1===this.stateManager.getSubscriptionCount(h))){const t=this.coreSdk.on(e,(e=>{this.stateManager.updateQueryState(h,{status:"success",data:e})}));this.stateManager.updateQueryState(h,{unsubscribe:t})}a?.(c);const d=this.stateManager.getQueryState(h);return{data:d.data,error:void 0,status:d.status,isLoading:"loading"===d.status,isError:!1,isSuccess:!0,refetch:()=>this.query(e,t),unsubscribe:n?()=>this.unsubscribe(h):void 0}}catch(s){return r.error(`Query (${e}) error:`,s),this.stateManager.updateQueryState(h,{status:"error",error:s}),o?.(s),{data:void 0,error:s,status:"error",isLoading:!1,isError:!0,isSuccess:!1,refetch:()=>this.query(e,t),unsubscribe:n?()=>this.unsubscribe(h):void 0}}}async generateKeyWithHash(e,t){const s=(new TextEncoder).encode(JSON.stringify(t||{})),r=await crypto.subtle.digest("SHA-256",s);return`${e}_${Array.from(new Uint8Array(r)).map((e=>e.toString(16).padStart(2,"0"))).join("")}`}async mutate(e,t){const{request:s,operation:i}=this.resolveOperation(e),{onSuccess:n,onError:a,params:o,timeoutMs:u}=t||{};r.debug(`Mutation (${e}) initiated with params:`,o,`timeoutMs: ${u}`);try{const t=await s(i,o);return r.info(`Mutation (${e}) success:`,t),n?.(t),t}catch(t){throw r.error(`Mutation (${e}) error:`,t),a?.(t),t}}async _fetch(e){const t=new URL(e.url),s=t.pathname+t.search+t.hash,r=e.method||"GET",i=e?.headers?Object.fromEntries(new Headers(e.headers)):void 0,n=await e.arrayBuffer(),a={body:n.byteLength>0?n:void 0,headers:i,method:r,path:s,requiresAuth:!0};return this.coreSdk.request("host.request",a).then((e=>{const t={headers:e.headers||{},status:e.status||200,statusText:e.statusText||""};return new Response(e.body,t)}))}async logout(){await this.coreSdk.request("host.logout")}async openProfile(){await this.coreSdk.request("host.openProfile")}async navigateToExternalUrl(e,t=!0){if(!e)throw new Error("URL is required for navigateToExternalUrl");const s={url:e,newTab:t};await this.coreSdk.request("host.navigateTo.externalUrl",s)}async setNavbarItems(e){e&&await this.coreSdk.request("host.setNavbarItems",e)}unsubscribe(e){const t=this.stateManager.getQueryState(e);this.stateManager.decrementSubscriptionCount(e),0===this.stateManager.getSubscriptionCount(e)&&(t.unsubscribe?.(),this.stateManager.removeQuery(e))}destroy(){const e=this.stateManager.getQueryKeys();for(const t of e)this.unsubscribe(t)}}exports.ClientSDK=i,exports.objectToJsonArrayBuffer=function(e){const t=JSON.stringify(e);return new Uint8Array((new TextEncoder).encode(t)).buffer};
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/logger.ts","../src/state.ts","../src/client.ts","../src/utils.ts"],"sourcesContent":[null,null,null,null],"names":["LogLevel","StateManager","queryStates","Map","listeners","getQueryState","key","this","has","set","status","subscriptionCount","get","getQueryKeys","Array","from","keys","updateQueryState","updates","newState","queryResult","data","error","isLoading","isError","isSuccess","refetch","async","Error","unsubscribe","forEach","listener","subscribe","Set","add","delete","size","removeQuery","getSubscriptionCount","incrementSubscriptionCount","state","decrementSubscriptionCount","logger","level","constructor","INFO","debug","message","args","DEBUG","console","info","warn","WARN","ERROR","setLevel","ClientSDK","config","stateManager","coreSdk","modules","CoreSDK","init","coreConfig","target","targetOrigin","origin","selfOrigin","window","location","timeout","events","navbarItems","client","initialize","setNavbarItems","module","registerModule","sitecore_marketplace__clientSdk","registerHandlers","type","version","connect","namespace","hasModule","availableModules","resolveOperation","keyOrOperationKey","request","bind","operation","includes","firstDotIndex","indexOf","substring","operationName","invokeOperation","on","payload","onPageContextUpdate","onRouteUpdate","route","query","queryOptions","onSuccess","onError","params","timeoutMs","hashedKey","generateKeyWithHash","updatedData","undefined","options","TextEncoder","encode","JSON","stringify","hashBuffer","crypto","subtle","digest","Uint8Array","map","byte","toString","padStart","join","mutate","mutationOptions","_fetch","input","url","URL","path","pathname","search","hash","method","headers","Object","fromEntries","Headers","body","arrayBuffer","genericRequest","byteLength","requiresAuth","then","response","statusText","Response","logout","openProfile","navigateToExternalUrl","newTab","destroy","jsonString","buffer"],"mappings":"iBAAYA,oDCUCC,EACHC,YAAuC,IAAIC,IAC3CC,UAAkE,IAAID,IAK9E,aAAAE,CACEC,GAQA,OANKC,KAAKL,YAAYM,IAAIF,IACxBC,KAAKL,YAAYO,IAAIH,EAAK,CACxBI,OAAQ,OACRC,kBAAmB,IAGhBJ,KAAKL,YAAYU,IAAIN,GAM9B,YAAAO,GACE,OAAOC,MAAMC,KAAKR,KAAKL,YAAYc,QAMrC,gBAAAC,CACEX,EACAY,GAEA,MACMC,EAAW,IADHZ,KAAKF,cAA6BC,MAChBY,GAChCX,KAAKL,Y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}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{CoreSDK as e}from"@sitecore-marketplace-sdk/core";class t{queryStates=new Map;listeners=new Map;getQueryState(e){return this.queryStates.has(e)||this.queryStates.set(e,{status:"idle",subscriptionCount:0}),this.queryStates.get(e)}getQueryKeys(){return Array.from(this.queryStates.keys())}updateQueryState(e,t){const s={...this.getQueryState(e),...t};this.queryStates.set(e,s);const r={data:s.data,error:s.error,status:s.status,isLoading:"loading"===s.status,isError:"error"===s.status,isSuccess:"success"===s.status,refetch:async()=>{throw new Error("Refetch not implemented")},unsubscribe:s.unsubscribe};this.listeners.get(e)?.forEach((e=>e(r)))}subscribe(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{const s=this.listeners.get(e);s&&(s.delete(t),0===s.size&&this.listeners.delete(e))}}removeQuery(e){this.queryStates.delete(e),this.listeners.delete(e)}getSubscriptionCount(e){return this.getQueryState(e).subscriptionCount}incrementSubscriptionCount(e){const t=this.getQueryState(e);t.subscriptionCount++,this.queryStates.set(e,t)}decrementSubscriptionCount(e){const t=this.getQueryState(e);t.subscriptionCount--,this.queryStates.set(e,t)}}var s;!function(e){e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR"}(s||(s={}));const r=new class{level;constructor(e=s.INFO){this.level=e}debug(e,...t){this.level<=s.DEBUG&&console.debug(`DEBUG: ${e}`,...t)}info(e,...t){this.level<=s.INFO&&console.info(`INFO: ${e}`,...t)}warn(e,...t){this.level<=s.WARN&&console.warn(`WARN: ${e}`,...t)}error(e,...t){this.level<=s.ERROR&&console.error(`ERROR: ${e}`,...t)}setLevel(e){this.level=e}}(s.DEBUG);class i{config;stateManager;coreSdk;modules=new Map;constructor(s){this.config=s,this.stateManager=new t,this.coreSdk=new e(this.config)}static async init(e){const t={target:e.target,targetOrigin:e.origin,selfOrigin:window.location.origin,timeout:e.timeout,events:e.events,navbarItems:e.navbarItems},s=new i(t);if(await s.initialize(),await s.setNavbarItems(e.navbarItems),e.modules)for(const t of e.modules)s.registerModule(t);return window?(r.info("window is available. Assigning client to window"),window.sitecore_marketplace__clientSdk=s):r.info("window is not available. Not assigning client to window"),e.events&&s.registerHandlers(),s}async initialize(){try{this.coreSdk.initialize({type:"client",targetOrigin:this.config.targetOrigin,selfOrigin:this.config.selfOrigin||window.location.origin,version:"1"}),r.info("Client SDK initialized, performing handshake..."),await this.coreSdk.connect(),r.info("Client handshake successful.")}catch(e){throw r.error("Client handshake failed:",e),e}}registerModule(e){this.modules.set(e.namespace,e)}hasModule(e){return this.modules.has(e)}availableModules(){return Array.from(this.modules.keys())}resolveOperation(e){let t=this.coreSdk.request.bind(this.coreSdk),s=e;if(e.includes(".")){const r=e.indexOf("."),i=e.substring(0,r),a=e.substring(r+1),n=this.modules.get(i);n&&(t=n.invokeOperation.bind(n),s=a)}return{request:t,operation:s}}registerHandlers(){if(!this.coreSdk)return;const e=this.config.events||{};this.coreSdk.on("pages.context",(async t=>{r.debug("Received pages.context request:",t),e.onPageContextUpdate?(e.onPageContextUpdate(t),r.debug("Processed pages.context request.")):r.debug("onPageContextUpdate event listener is not set.")})),this.coreSdk.on("host.route",(e=>{this.config.events?.onRouteUpdate&&this.config.events.onRouteUpdate(e.route)}))}async query(e,t){const{request:s,operation:i}=this.resolveOperation(e),{subscribe:a,onSuccess:n,onError:o,params:u,timeoutMs:c}=t||{},h=await this.generateKeyWithHash(e,t);r.debug(`Query (${e}) initiated with params:`,u,`timeoutMs: ${c}`),this.stateManager.updateQueryState(h,{status:"loading"});try{const c=await s(i,u);if(r.info(`Query (${e}) success:`,c),this.stateManager.updateQueryState(h,{status:"success",data:c}),a&&(this.stateManager.subscribe(e,(e=>{e.data&&n?.(e.data),e.error&&o?.(e.error)})),this.stateManager.incrementSubscriptionCount(h),1===this.stateManager.getSubscriptionCount(h))){const t=this.coreSdk.on(e,(e=>{this.stateManager.updateQueryState(h,{status:"success",data:e})}));this.stateManager.updateQueryState(h,{unsubscribe:t})}n?.(c);const d=this.stateManager.getQueryState(h);return{data:d.data,error:void 0,status:d.status,isLoading:"loading"===d.status,isError:!1,isSuccess:!0,refetch:()=>this.query(e,t),unsubscribe:a?()=>this.unsubscribe(h):void 0}}catch(s){return r.error(`Query (${e}) error:`,s),this.stateManager.updateQueryState(h,{status:"error",error:s}),o?.(s),{data:void 0,error:s,status:"error",isLoading:!1,isError:!0,isSuccess:!1,refetch:()=>this.query(e,t),unsubscribe:a?()=>this.unsubscribe(h):void 0}}}async generateKeyWithHash(e,t){const s=(new TextEncoder).encode(JSON.stringify(t||{})),r=await crypto.subtle.digest("SHA-256",s);return`${e}_${Array.from(new Uint8Array(r)).map((e=>e.toString(16).padStart(2,"0"))).join("")}`}async mutate(e,t){const{request:s,operation:i}=this.resolveOperation(e),{onSuccess:a,onError:n,params:o,timeoutMs:u}=t||{};r.debug(`Mutation (${e}) initiated with params:`,o,`timeoutMs: ${u}`);try{const t=await s(i,o);return r.info(`Mutation (${e}) success:`,t),a?.(t),t}catch(t){throw r.error(`Mutation (${e}) error:`,t),n?.(t),t}}async _fetch(e){const t=new URL(e.url),s=t.pathname+t.search+t.hash,r=e.method||"GET",i=e?.headers?Object.fromEntries(new Headers(e.headers)):void 0,a=await e.arrayBuffer(),n={body:a.byteLength>0?a:void 0,headers:i,method:r,path:s,requiresAuth:!0};return this.coreSdk.request("host.request",n).then((e=>{const t={headers:e.headers||{},status:e.status||200,statusText:e.statusText||""};return new Response(e.body,t)}))}async logout(){await this.coreSdk.request("host.logout")}async openProfile(){await this.coreSdk.request("host.openProfile")}async navigateToExternalUrl(e,t=!0){if(!e)throw new Error("URL is required for navigateToExternalUrl");const s={url:e,newTab:t};await this.coreSdk.request("host.navigateTo.externalUrl",s)}async setNavbarItems(e){e&&await this.coreSdk.request("host.setNavbarItems",e)}unsubscribe(e){const t=this.stateManager.getQueryState(e);this.stateManager.decrementSubscriptionCount(e),0===this.stateManager.getSubscriptionCount(e)&&(t.unsubscribe?.(),this.stateManager.removeQuery(e))}destroy(){const e=this.stateManager.getQueryKeys();for(const t of e)this.unsubscribe(t)}}function a(e){const t=JSON.stringify(e);return new Uint8Array((new TextEncoder).encode(t)).buffer}export{i as ClientSDK,a as objectToJsonArrayBuffer};
|
|
2
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/state.ts","../src/logger.ts","../src/client.ts","../src/utils.ts"],"sourcesContent":[null,null,null,null],"names":["StateManager","queryStates","Map","listeners","getQueryState","key","this","has","set","status","subscriptionCount","get","getQueryKeys","Array","from","keys","updateQueryState","updates","newState","queryResult","data","error","isLoading","isError","isSuccess","refetch","async","Error","unsubscribe","forEach","listener","subscribe","Set","add","delete","size","removeQuery","getSubscriptionCount","incrementSubscriptionCount","state","decrementSubscriptionCount","LogLevel","logger","level","constructor","INFO","debug","message","args","DEBUG","console","info","warn","WARN","ERROR","setLevel","ClientSDK","config","stateManager","coreSdk","modules","CoreSDK","init","coreConfig","target","targetOrigin","origin","selfOrigin","window","location","timeout","events","navbarItems","client","initialize","setNavbarItems","module","registerModule","sitecore_marketplace__clientSdk","registerHandlers","type","version","connect","namespace","hasModule","availableModules","resolveOperation","keyOrOperationKey","request","bind","operation","includes","firstDotIndex","indexOf","substring","operationName","invokeOperation","on","payload","onPageContextUpdate","onRouteUpdate","route","query","queryOptions","onSuccess","onError","params","timeoutMs","hashedKey","generateKeyWithHash","updatedData","undefined","options","TextEncoder","encode","JSON","stringify","hashBuffer","crypto","subtle","digest","Uint8Array","map","byte","toString","padStart","join","mutate","mutationOptions","_fetch","input","url","URL","path","pathname","search","hash","method","headers","Object","fromEntries","Headers","body","arrayBuffer","genericRequest","byteLength","requiresAuth","then","response","statusText","Response","logout","openProfile","navigateToExternalUrl","newTab","destroy","objectToJsonArrayBuffer","jsonString","buffer"],"mappings":"+DAUaA,EACHC,YAAuC,IAAIC,IAC3CC,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,KAAKC,UAAUhG,GAClC,OAAO,IAAIqG,YAAW,IAAIR,aAAcC,OAAO2C,IAAaC,MAC9D"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
DEBUG = 0,
|
|
3
|
+
INFO = 1,
|
|
4
|
+
WARN = 2,
|
|
5
|
+
ERROR = 3
|
|
6
|
+
}
|
|
7
|
+
export declare class Logger {
|
|
8
|
+
private level;
|
|
9
|
+
constructor(level?: LogLevel);
|
|
10
|
+
debug(message: string, ...args: any[]): void;
|
|
11
|
+
info(message: string, ...args: any[]): void;
|
|
12
|
+
warn(message: string, ...args: any[]): void;
|
|
13
|
+
error(message: string, ...args: any[]): void;
|
|
14
|
+
setLevel(level: LogLevel): void;
|
|
15
|
+
}
|
|
16
|
+
export declare const logger: Logger;
|
|
17
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,IAAI,IAAA;IACJ,KAAK,IAAA;CACN;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAW;gBAEZ,KAAK,GAAE,QAAwB;IAI3C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAMrC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAMpC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAMpC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAMrC,QAAQ,CAAC,KAAK,EAAE,QAAQ;CAGzB;AAED,eAAO,MAAM,MAAM,QAA6B,CAAC"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { ApplicationContext, UserInfo } from '@sitecore-marketplace-sdk/core';
|
|
2
|
+
export type AppType = 'portal' | 'xmc:xmapps' | 'xmc:pages-contextview';
|
|
3
|
+
export type HostState<T extends AppType = AppType> = T extends 'portal' ? null : T extends 'xmc:xmapps' ? XmcXmAppsHostState : T extends 'xmc:pages-contextview' ? XmcPagesContextViewHostState : never;
|
|
4
|
+
export interface XmcXmAppsHostState {
|
|
5
|
+
environment: string;
|
|
6
|
+
language: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export interface XmcPagesContextViewHostState {
|
|
10
|
+
organizationId?: string;
|
|
11
|
+
xmCloudTenantInfo?: XmcPagesContextViewTenantInfo;
|
|
12
|
+
userInfo?: XmcPagesContextViewUserInfo;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
export interface XmcPagesContextViewTenantInfo {
|
|
16
|
+
url?: string;
|
|
17
|
+
gqlEndpointUrl?: string;
|
|
18
|
+
cdpEmbeddedTenantId?: string;
|
|
19
|
+
aiEmbeddedTenantID?: string;
|
|
20
|
+
customerEnvironmentType?: string;
|
|
21
|
+
environmentId?: string;
|
|
22
|
+
environmentName?: string;
|
|
23
|
+
projectId?: string;
|
|
24
|
+
projectName?: string;
|
|
25
|
+
regionCode?: string;
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}
|
|
28
|
+
export interface XmcPagesContextViewUserInfo {
|
|
29
|
+
name?: string;
|
|
30
|
+
given_name?: string;
|
|
31
|
+
family_name?: string;
|
|
32
|
+
middle_name?: string;
|
|
33
|
+
nickname?: string;
|
|
34
|
+
preferred_username?: string;
|
|
35
|
+
profile?: string;
|
|
36
|
+
picture?: string;
|
|
37
|
+
website?: string;
|
|
38
|
+
email?: string;
|
|
39
|
+
email_verified?: boolean;
|
|
40
|
+
gender?: string;
|
|
41
|
+
birthdate?: string;
|
|
42
|
+
zoneinfo?: string;
|
|
43
|
+
locale?: string;
|
|
44
|
+
phone_number?: string;
|
|
45
|
+
phone_number_verified?: boolean;
|
|
46
|
+
address?: string;
|
|
47
|
+
updated_at?: string;
|
|
48
|
+
sub?: string;
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
}
|
|
51
|
+
export interface ApplicationMetadata {
|
|
52
|
+
resources: Array<{
|
|
53
|
+
contextId: string;
|
|
54
|
+
tenantName: string;
|
|
55
|
+
tenantId: string;
|
|
56
|
+
}>;
|
|
57
|
+
appId: string;
|
|
58
|
+
appType: AppType;
|
|
59
|
+
}
|
|
60
|
+
interface NavBarItem {
|
|
61
|
+
label: string;
|
|
62
|
+
link?: string;
|
|
63
|
+
icon?: Element;
|
|
64
|
+
subMenu?: NavBarItem[];
|
|
65
|
+
}
|
|
66
|
+
export interface NavbarItemsProps {
|
|
67
|
+
appLogo: string;
|
|
68
|
+
appName: string;
|
|
69
|
+
menu: NavBarItem[];
|
|
70
|
+
helpLinks: NavBarItem[];
|
|
71
|
+
}
|
|
72
|
+
export interface PagesContext {
|
|
73
|
+
siteInfo?: PagesContextSiteInfo;
|
|
74
|
+
pageInfo?: PagesContextPageInfo;
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
}
|
|
77
|
+
export interface PagesContextSiteInfo {
|
|
78
|
+
id?: string;
|
|
79
|
+
name?: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
displayName?: string;
|
|
82
|
+
thumbnail?: {
|
|
83
|
+
url?: string;
|
|
84
|
+
rootPath?: string;
|
|
85
|
+
autogenerated?: boolean;
|
|
86
|
+
[key: string]: any;
|
|
87
|
+
};
|
|
88
|
+
collectionId?: string;
|
|
89
|
+
created?: string;
|
|
90
|
+
createdBy?: string;
|
|
91
|
+
sortOrder?: number;
|
|
92
|
+
brandKitId?: string;
|
|
93
|
+
permissions?: {
|
|
94
|
+
canAdmin?: boolean;
|
|
95
|
+
canWrite?: boolean;
|
|
96
|
+
canCreate?: boolean;
|
|
97
|
+
canDelete?: boolean;
|
|
98
|
+
canRename?: boolean;
|
|
99
|
+
canRead?: boolean;
|
|
100
|
+
canPublish?: boolean;
|
|
101
|
+
canDuplicate?: boolean;
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
};
|
|
104
|
+
languages?: string[];
|
|
105
|
+
hosts?: any;
|
|
106
|
+
supportedLanguages?: string[];
|
|
107
|
+
errorPagesConfiguration?: any;
|
|
108
|
+
settings?: {
|
|
109
|
+
thumbnailsRootPath?: string;
|
|
110
|
+
generateThumbnails?: string;
|
|
111
|
+
[key: string]: any;
|
|
112
|
+
};
|
|
113
|
+
properties?: any;
|
|
114
|
+
[key: string]: any;
|
|
115
|
+
}
|
|
116
|
+
interface PagesContextPageInfo {
|
|
117
|
+
name?: string;
|
|
118
|
+
id?: string;
|
|
119
|
+
version?: number;
|
|
120
|
+
versionName?: string;
|
|
121
|
+
versions?: any;
|
|
122
|
+
hasVersions?: boolean;
|
|
123
|
+
revision?: string;
|
|
124
|
+
updatedBy?: string;
|
|
125
|
+
updatedDate?: string;
|
|
126
|
+
displayName?: string;
|
|
127
|
+
icon?: string;
|
|
128
|
+
url?: string;
|
|
129
|
+
path?: string;
|
|
130
|
+
hasChildren?: boolean;
|
|
131
|
+
children?: any;
|
|
132
|
+
language?: string;
|
|
133
|
+
template?: any;
|
|
134
|
+
parent?: any;
|
|
135
|
+
fields?: any;
|
|
136
|
+
isFolder?: boolean;
|
|
137
|
+
ancestors?: any;
|
|
138
|
+
workflow?: any | null;
|
|
139
|
+
isLatestPublishableVersion?: boolean;
|
|
140
|
+
creationDate?: string;
|
|
141
|
+
createdBy?: string;
|
|
142
|
+
insertOptions?: any;
|
|
143
|
+
permissions?: {
|
|
144
|
+
canWrite?: boolean;
|
|
145
|
+
canDelete?: boolean;
|
|
146
|
+
canRename?: boolean;
|
|
147
|
+
canCreate?: boolean;
|
|
148
|
+
canPublish?: boolean;
|
|
149
|
+
canWriteLanguage?: boolean;
|
|
150
|
+
[key: string]: any;
|
|
151
|
+
};
|
|
152
|
+
locking?: any;
|
|
153
|
+
publishing?: any;
|
|
154
|
+
presentationDetails?: string;
|
|
155
|
+
layoutEditingKind?: any;
|
|
156
|
+
route?: string;
|
|
157
|
+
[key: string]: any;
|
|
158
|
+
}
|
|
159
|
+
export interface QueryMap {
|
|
160
|
+
'host.user': {
|
|
161
|
+
params: void;
|
|
162
|
+
response: UserInfo;
|
|
163
|
+
subscribe: false;
|
|
164
|
+
};
|
|
165
|
+
'host.state': {
|
|
166
|
+
params: void;
|
|
167
|
+
response: HostState;
|
|
168
|
+
subscribe: true;
|
|
169
|
+
};
|
|
170
|
+
'pages.context': {
|
|
171
|
+
params: void;
|
|
172
|
+
response: PagesContext;
|
|
173
|
+
subscribe: true;
|
|
174
|
+
};
|
|
175
|
+
'application.context': {
|
|
176
|
+
params: void;
|
|
177
|
+
response: ApplicationContext;
|
|
178
|
+
subscribe: false;
|
|
179
|
+
};
|
|
180
|
+
'host.route': {
|
|
181
|
+
params: void;
|
|
182
|
+
response: string;
|
|
183
|
+
subscribe: false;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
export interface MutationMap {
|
|
187
|
+
}
|
|
188
|
+
export type QueryKey = keyof QueryMap;
|
|
189
|
+
export type MutationKey = keyof MutationMap;
|
|
190
|
+
export interface SDKModule {
|
|
191
|
+
namespace: string;
|
|
192
|
+
invokeOperation: (operationName: string, ...args: any[]) => any;
|
|
193
|
+
}
|
|
194
|
+
export {};
|
|
195
|
+
//# sourceMappingURL=sdk-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../src/sdk-types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAGlB,QAAQ,EACT,MAAM,gCAAgC,CAAC;AAKxC,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,YAAY,GAAG,uBAAuB,CAAC;AAIxE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC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AAE,GAAG,EAAE,KAAK,GAAG,CAAC;CACjE"}
|
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { StateQueryResult, QueryStatus } from './types';
|
|
2
|
+
interface QueryState<TData = unknown, TError extends Error = Error> {
|
|
3
|
+
data?: TData;
|
|
4
|
+
error?: TError;
|
|
5
|
+
status: QueryStatus;
|
|
6
|
+
subscriptionCount: number;
|
|
7
|
+
unsubscribe?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare class StateManager {
|
|
10
|
+
private queryStates;
|
|
11
|
+
private listeners;
|
|
12
|
+
/**
|
|
13
|
+
* Get or create a query state
|
|
14
|
+
*/
|
|
15
|
+
getQueryState<TData = unknown, TError extends Error = Error>(key: string): QueryState<TData, TError>;
|
|
16
|
+
/**
|
|
17
|
+
* Get all active query keys
|
|
18
|
+
*/
|
|
19
|
+
getQueryKeys(): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Update a query's state and notify listeners
|
|
22
|
+
*/
|
|
23
|
+
updateQueryState<TData = unknown, TError extends Error = Error>(key: string, updates: Partial<QueryState<TData, TError>>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Subscribe to state changes for a query
|
|
26
|
+
*/
|
|
27
|
+
subscribe(key: string, listener: (result: StateQueryResult) => void): () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Remove all state and listeners for a query
|
|
30
|
+
*/
|
|
31
|
+
removeQuery(key: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get current number of subscribers for a query
|
|
34
|
+
*/
|
|
35
|
+
getSubscriptionCount(key: string): number;
|
|
36
|
+
/**
|
|
37
|
+
* Increment subscription count for a query
|
|
38
|
+
*/
|
|
39
|
+
incrementSubscriptionCount(key: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Decrement subscription count for a query
|
|
42
|
+
*/
|
|
43
|
+
decrementSubscriptionCount(key: string): void;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL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;IACH,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAK9C"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { CoreSDKConfig } from '@sitecore-marketplace-sdk/core';
|
|
2
|
+
import { MutationKey, MutationMap, NavbarItemsProps, QueryKey, QueryMap } from './sdk-types';
|
|
3
|
+
export type QueryStatus = 'idle' | 'loading' | 'error' | 'success';
|
|
4
|
+
export interface BaseQueryOptions<TData = unknown, TError extends Error = Error, TParams = {}> {
|
|
5
|
+
/** Whether to subscribe to updates for this query */
|
|
6
|
+
subscribe?: boolean;
|
|
7
|
+
/** Called when the query successfully completes */
|
|
8
|
+
onSuccess?: (data: TData) => void;
|
|
9
|
+
/** Called when the query encounters an error */
|
|
10
|
+
onError?: (error: TError) => void;
|
|
11
|
+
/** Additional parameters for the query; always includes headers, query and body */
|
|
12
|
+
params?: TParams;
|
|
13
|
+
/** Custom timeout in milliseconds */
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface QueryOptions<K extends QueryKey> extends BaseQueryOptions<QueryMap[K]['response'], Error, QueryMap[K]['params']> {
|
|
17
|
+
}
|
|
18
|
+
export interface BaseQueryResult<TData = unknown, TError extends Error = Error> {
|
|
19
|
+
/** The current data value */
|
|
20
|
+
data: TData | undefined;
|
|
21
|
+
/** The current error if any */
|
|
22
|
+
error: TError | undefined;
|
|
23
|
+
/** The current status of the query */
|
|
24
|
+
status: QueryStatus;
|
|
25
|
+
/** Whether the query is currently loading */
|
|
26
|
+
isLoading: boolean;
|
|
27
|
+
/** Whether the query has errored */
|
|
28
|
+
isError: boolean;
|
|
29
|
+
/** Whether the query was successful */
|
|
30
|
+
isSuccess: boolean;
|
|
31
|
+
/** Function to manually trigger a refetch */
|
|
32
|
+
refetch: () => Promise<BaseQueryResult<TData, TError>>;
|
|
33
|
+
/** Function to unsubscribe if subscribed */
|
|
34
|
+
unsubscribe?: () => void;
|
|
35
|
+
}
|
|
36
|
+
export interface QueryResult<K extends QueryKey> extends BaseQueryResult<QueryMap[K]['response'], Error> {
|
|
37
|
+
}
|
|
38
|
+
export interface StateQueryResult<TData = unknown, TError extends Error = Error> extends BaseQueryResult<TData, TError> {
|
|
39
|
+
}
|
|
40
|
+
export interface BaseMutationOptions<TData = unknown, TError extends Error = Error, TParams = {}> {
|
|
41
|
+
/** Called when the mutation successfully completes */
|
|
42
|
+
onSuccess?: (data: TData) => void;
|
|
43
|
+
/** Called when the mutation encounters an error */
|
|
44
|
+
onError?: (error: TError) => void;
|
|
45
|
+
/** Additional parameters for the mutation */
|
|
46
|
+
params?: TParams;
|
|
47
|
+
/** Custom timeout in milliseconds */
|
|
48
|
+
timeoutMs?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface MutationOptions<K extends MutationKey> extends BaseMutationOptions<MutationMap[K]['response'], Error, MutationMap[K]['params']> {
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* ClientSDKConfig is the configuration used by the Client SDK.
|
|
54
|
+
* Instead of exposing a CoreSDK instance, users should provide the
|
|
55
|
+
* configuration needed to initialize CoreSDK internally.
|
|
56
|
+
*/
|
|
57
|
+
export interface ClientSDKConfig extends CoreSDKConfig {
|
|
58
|
+
/** The origin of the remote endpoint (e.g. client for the host, or host for the client) */
|
|
59
|
+
targetOrigin: string;
|
|
60
|
+
/** Our own origin – this defaults to the value of window.location.origin */
|
|
61
|
+
selfOrigin: string;
|
|
62
|
+
/** Events that the SDK can listen for */
|
|
63
|
+
events?: {
|
|
64
|
+
onRouteUpdate?: (route: string) => void;
|
|
65
|
+
onPageContextUpdate?: (data: any) => void;
|
|
66
|
+
};
|
|
67
|
+
navbarItems?: NavbarItemsProps;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,E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,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QACxC,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;KAC3C,CAAC;IACF,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a JavaScript object into a JSON ArrayBuffer.
|
|
3
|
+
* @param data The object to serialize and convert.
|
|
4
|
+
* @returns {ArrayBuffer} The serialized JSON as an ArrayBuffer.
|
|
5
|
+
*/
|
|
6
|
+
export declare function objectToJsonArrayBuffer(data: object): ArrayBuffer;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAGjE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sitecore-marketplace-sdk/client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs.js",
|
|
7
|
+
"module": "./dist/index.esm.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=16"
|
|
17
|
+
},
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/Sitecore/sitecore-marketplace-sdk"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"sitecore",
|
|
25
|
+
"marketplace",
|
|
26
|
+
"sdk",
|
|
27
|
+
"client"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@sitecore-marketplace-sdk/core": "0.1.0",
|
|
31
|
+
"tslib": "^2.8.1",
|
|
32
|
+
"uuid": "^11.1.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
36
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
37
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
38
|
+
"@types/node": "^20.17.19",
|
|
39
|
+
"@vitest/coverage-v8": "^3.0.6",
|
|
40
|
+
"@vitest/expect": "^3.0.5",
|
|
41
|
+
"ajv": "^8.17.1",
|
|
42
|
+
"commander": "^11.0.0",
|
|
43
|
+
"esbuild": "^0.20.0",
|
|
44
|
+
"esbuild-node-externals": "^1.12.0",
|
|
45
|
+
"handlebars": "^4.7.7",
|
|
46
|
+
"jsdom": "^26.0.0",
|
|
47
|
+
"prettier": "^3.5.1",
|
|
48
|
+
"rimraf": "^6.0.1",
|
|
49
|
+
"rollup": "^4.34.8",
|
|
50
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
51
|
+
"ts-node": "^10.9.1",
|
|
52
|
+
"tsx": "^4.19.3",
|
|
53
|
+
"typescript": "^5.7.3",
|
|
54
|
+
"vitest": "^3.0.6"
|
|
55
|
+
},
|
|
56
|
+
"exports": {
|
|
57
|
+
".": {
|
|
58
|
+
"import": "./dist/index.esm.js",
|
|
59
|
+
"require": "./dist/index.cjs.js",
|
|
60
|
+
"types": "./dist/index.d.ts"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "pnpm run clean && rollup -c",
|
|
65
|
+
"build:js": "node scripts/build.js",
|
|
66
|
+
"build:types": "tsc --emitDeclarationOnly",
|
|
67
|
+
"build:watch": "node scripts/build.js --watch",
|
|
68
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
69
|
+
"lint": "eslint src --ext .ts",
|
|
70
|
+
"test": "vitest",
|
|
71
|
+
"coverage": "vitest run --coverage"
|
|
72
|
+
}
|
|
73
|
+
}
|