@salesforce/b2c-tooling-sdk 0.0.0-nightly.20260122024142 → 0.0.0-nightly.20260122144746
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/dist/cjs/cli/mrt-command.d.ts +2 -1
- package/dist/cjs/cli/mrt-command.js +3 -2
- package/dist/cjs/cli/mrt-command.js.map +1 -1
- package/dist/cjs/clients/cdn-zones.d.ts +154 -0
- package/dist/cjs/clients/cdn-zones.generated.d.ts +8330 -0
- package/dist/cjs/clients/cdn-zones.generated.js +6 -0
- package/dist/cjs/clients/cdn-zones.generated.js.map +1 -0
- package/dist/cjs/clients/cdn-zones.js +100 -0
- package/dist/cjs/clients/cdn-zones.js.map +1 -0
- package/dist/cjs/clients/error-utils.d.ts +35 -0
- package/dist/cjs/clients/error-utils.js +69 -0
- package/dist/cjs/clients/error-utils.js.map +1 -0
- package/dist/cjs/clients/index.d.ts +5 -0
- package/dist/cjs/clients/index.js +3 -0
- package/dist/cjs/clients/index.js.map +1 -1
- package/dist/cjs/clients/middleware-registry.d.ts +1 -1
- package/dist/cjs/clients/middleware-registry.js.map +1 -1
- package/dist/cjs/clients/mrt-b2c.d.ts +114 -0
- package/dist/cjs/clients/mrt-b2c.generated.d.ts +176 -0
- package/dist/cjs/clients/mrt-b2c.generated.js +6 -0
- package/dist/cjs/clients/mrt-b2c.generated.js.map +1 -0
- package/dist/cjs/clients/mrt-b2c.js +86 -0
- package/dist/cjs/clients/mrt-b2c.js.map +1 -0
- package/dist/cjs/config/dw-json.d.ts +4 -0
- package/dist/cjs/config/dw-json.js.map +1 -1
- package/dist/cjs/config/mapping.js +1 -0
- package/dist/cjs/config/mapping.js.map +1 -1
- package/dist/cjs/config/resolver.js +3 -0
- package/dist/cjs/config/resolver.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/operations/code/deploy.js +9 -3
- package/dist/cjs/operations/code/deploy.js.map +1 -1
- package/dist/cjs/operations/mrt/access-control.d.ts +192 -0
- package/dist/cjs/operations/mrt/access-control.js +152 -0
- package/dist/cjs/operations/mrt/access-control.js.map +1 -0
- package/dist/cjs/operations/mrt/b2c-config.d.ts +201 -0
- package/dist/cjs/operations/mrt/b2c-config.js +195 -0
- package/dist/cjs/operations/mrt/b2c-config.js.map +1 -0
- package/dist/cjs/operations/mrt/cache.d.ts +80 -0
- package/dist/cjs/operations/mrt/cache.js +65 -0
- package/dist/cjs/operations/mrt/cache.js.map +1 -0
- package/dist/cjs/operations/mrt/deployment.d.ts +157 -0
- package/dist/cjs/operations/mrt/deployment.js +109 -0
- package/dist/cjs/operations/mrt/deployment.js.map +1 -0
- package/dist/cjs/operations/mrt/env.d.ts +141 -0
- package/dist/cjs/operations/mrt/env.js +119 -0
- package/dist/cjs/operations/mrt/env.js.map +1 -1
- package/dist/cjs/operations/mrt/index.d.ts +24 -4
- package/dist/cjs/operations/mrt/index.js +23 -3
- package/dist/cjs/operations/mrt/index.js.map +1 -1
- package/dist/cjs/operations/mrt/member.d.ts +281 -0
- package/dist/cjs/operations/mrt/member.js +244 -0
- package/dist/cjs/operations/mrt/member.js.map +1 -0
- package/dist/cjs/operations/mrt/notification.d.ts +252 -0
- package/dist/cjs/operations/mrt/notification.js +206 -0
- package/dist/cjs/operations/mrt/notification.js.map +1 -0
- package/dist/cjs/operations/mrt/organization.d.ts +80 -0
- package/dist/cjs/operations/mrt/organization.js +53 -0
- package/dist/cjs/operations/mrt/organization.js.map +1 -0
- package/dist/cjs/operations/mrt/project.d.ts +261 -0
- package/dist/cjs/operations/mrt/project.js +232 -0
- package/dist/cjs/operations/mrt/project.js.map +1 -0
- package/dist/cjs/operations/mrt/push.d.ts +122 -8
- package/dist/cjs/operations/mrt/push.js +83 -10
- package/dist/cjs/operations/mrt/push.js.map +1 -1
- package/dist/cjs/operations/mrt/redirect.d.ts +337 -0
- package/dist/cjs/operations/mrt/redirect.js +256 -0
- package/dist/cjs/operations/mrt/redirect.js.map +1 -0
- package/dist/cjs/operations/mrt/user.d.ts +135 -0
- package/dist/cjs/operations/mrt/user.js +153 -0
- package/dist/cjs/operations/mrt/user.js.map +1 -0
- package/dist/esm/cli/mrt-command.d.ts +2 -1
- package/dist/esm/cli/mrt-command.js +3 -2
- package/dist/esm/cli/mrt-command.js.map +1 -1
- package/dist/esm/clients/cdn-zones.d.ts +154 -0
- package/dist/esm/clients/cdn-zones.generated.d.ts +8330 -0
- package/dist/esm/clients/cdn-zones.generated.js +6 -0
- package/dist/esm/clients/cdn-zones.generated.js.map +1 -0
- package/dist/esm/clients/cdn-zones.js +100 -0
- package/dist/esm/clients/cdn-zones.js.map +1 -0
- package/dist/esm/clients/error-utils.d.ts +35 -0
- package/dist/esm/clients/error-utils.js +69 -0
- package/dist/esm/clients/error-utils.js.map +1 -0
- package/dist/esm/clients/index.d.ts +5 -0
- package/dist/esm/clients/index.js +3 -0
- package/dist/esm/clients/index.js.map +1 -1
- package/dist/esm/clients/middleware-registry.d.ts +1 -1
- package/dist/esm/clients/middleware-registry.js.map +1 -1
- package/dist/esm/clients/mrt-b2c.d.ts +114 -0
- package/dist/esm/clients/mrt-b2c.generated.d.ts +176 -0
- package/dist/esm/clients/mrt-b2c.generated.js +6 -0
- package/dist/esm/clients/mrt-b2c.generated.js.map +1 -0
- package/dist/esm/clients/mrt-b2c.js +86 -0
- package/dist/esm/clients/mrt-b2c.js.map +1 -0
- package/dist/esm/config/dw-json.d.ts +4 -0
- package/dist/esm/config/dw-json.js.map +1 -1
- package/dist/esm/config/mapping.js +1 -0
- package/dist/esm/config/mapping.js.map +1 -1
- package/dist/esm/config/resolver.js +3 -0
- package/dist/esm/config/resolver.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operations/code/deploy.js +9 -3
- package/dist/esm/operations/code/deploy.js.map +1 -1
- package/dist/esm/operations/mrt/access-control.d.ts +192 -0
- package/dist/esm/operations/mrt/access-control.js +152 -0
- package/dist/esm/operations/mrt/access-control.js.map +1 -0
- package/dist/esm/operations/mrt/b2c-config.d.ts +201 -0
- package/dist/esm/operations/mrt/b2c-config.js +195 -0
- package/dist/esm/operations/mrt/b2c-config.js.map +1 -0
- package/dist/esm/operations/mrt/cache.d.ts +80 -0
- package/dist/esm/operations/mrt/cache.js +65 -0
- package/dist/esm/operations/mrt/cache.js.map +1 -0
- package/dist/esm/operations/mrt/deployment.d.ts +157 -0
- package/dist/esm/operations/mrt/deployment.js +109 -0
- package/dist/esm/operations/mrt/deployment.js.map +1 -0
- package/dist/esm/operations/mrt/env.d.ts +141 -0
- package/dist/esm/operations/mrt/env.js +119 -0
- package/dist/esm/operations/mrt/env.js.map +1 -1
- package/dist/esm/operations/mrt/index.d.ts +24 -4
- package/dist/esm/operations/mrt/index.js +23 -3
- package/dist/esm/operations/mrt/index.js.map +1 -1
- package/dist/esm/operations/mrt/member.d.ts +281 -0
- package/dist/esm/operations/mrt/member.js +244 -0
- package/dist/esm/operations/mrt/member.js.map +1 -0
- package/dist/esm/operations/mrt/notification.d.ts +252 -0
- package/dist/esm/operations/mrt/notification.js +206 -0
- package/dist/esm/operations/mrt/notification.js.map +1 -0
- package/dist/esm/operations/mrt/organization.d.ts +80 -0
- package/dist/esm/operations/mrt/organization.js +53 -0
- package/dist/esm/operations/mrt/organization.js.map +1 -0
- package/dist/esm/operations/mrt/project.d.ts +261 -0
- package/dist/esm/operations/mrt/project.js +232 -0
- package/dist/esm/operations/mrt/project.js.map +1 -0
- package/dist/esm/operations/mrt/push.d.ts +122 -8
- package/dist/esm/operations/mrt/push.js +83 -10
- package/dist/esm/operations/mrt/push.js.map +1 -1
- package/dist/esm/operations/mrt/redirect.d.ts +337 -0
- package/dist/esm/operations/mrt/redirect.js +256 -0
- package/dist/esm/operations/mrt/redirect.js.map +1 -0
- package/dist/esm/operations/mrt/user.d.ts +135 -0
- package/dist/esm/operations/mrt/user.js +153 -0
- package/dist/esm/operations/mrt/user.js.map +1 -0
- package/package.json +2 -2
- package/specs/cdn-zones-v1.yaml +9324 -0
- package/specs/mrt-b2c.json +384 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification operations for Managed Runtime.
|
|
3
|
+
*
|
|
4
|
+
* Handles listing, creating, updating, and deleting project notifications.
|
|
5
|
+
*
|
|
6
|
+
* @module operations/mrt/notification
|
|
7
|
+
*/
|
|
8
|
+
import type { AuthStrategy } from '../../auth/types.js';
|
|
9
|
+
import type { components } from '../../clients/mrt.js';
|
|
10
|
+
/**
|
|
11
|
+
* Email notification type from API.
|
|
12
|
+
*/
|
|
13
|
+
export type MrtEmailNotification = components['schemas']['EmailNotification'];
|
|
14
|
+
/**
|
|
15
|
+
* Polymorphic notification (currently only email).
|
|
16
|
+
*/
|
|
17
|
+
export type MrtNotification = components['schemas']['PolymorphicNotification'];
|
|
18
|
+
/**
|
|
19
|
+
* Patched notification for updates.
|
|
20
|
+
*/
|
|
21
|
+
export type PatchedMrtNotification = components['schemas']['PatchedPolymorphicNotification'];
|
|
22
|
+
/**
|
|
23
|
+
* Options for listing notifications.
|
|
24
|
+
*/
|
|
25
|
+
export interface ListNotificationsOptions {
|
|
26
|
+
/**
|
|
27
|
+
* The project slug.
|
|
28
|
+
*/
|
|
29
|
+
projectSlug: string;
|
|
30
|
+
/**
|
|
31
|
+
* Maximum number of results to return.
|
|
32
|
+
*/
|
|
33
|
+
limit?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Offset for pagination.
|
|
36
|
+
*/
|
|
37
|
+
offset?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Filter by target slug.
|
|
40
|
+
*/
|
|
41
|
+
targetSlug?: string;
|
|
42
|
+
/**
|
|
43
|
+
* MRT API origin URL.
|
|
44
|
+
* @default "https://cloud.mobify.com"
|
|
45
|
+
*/
|
|
46
|
+
origin?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Result of listing notifications.
|
|
50
|
+
*/
|
|
51
|
+
export interface ListNotificationsResult {
|
|
52
|
+
/**
|
|
53
|
+
* Total count of notifications.
|
|
54
|
+
*/
|
|
55
|
+
count: number;
|
|
56
|
+
/**
|
|
57
|
+
* URL for next page of results.
|
|
58
|
+
*/
|
|
59
|
+
next: string | null;
|
|
60
|
+
/**
|
|
61
|
+
* URL for previous page of results.
|
|
62
|
+
*/
|
|
63
|
+
previous: string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Array of notifications.
|
|
66
|
+
*/
|
|
67
|
+
notifications: MrtNotification[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Lists notifications for an MRT project.
|
|
71
|
+
*
|
|
72
|
+
* @param options - List options including project slug
|
|
73
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
74
|
+
* @returns Paginated list of notifications
|
|
75
|
+
* @throws Error if request fails
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth';
|
|
80
|
+
* import { listNotifications } from '@salesforce/b2c-tooling-sdk/operations/mrt';
|
|
81
|
+
*
|
|
82
|
+
* const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization');
|
|
83
|
+
*
|
|
84
|
+
* const result = await listNotifications({
|
|
85
|
+
* projectSlug: 'my-storefront'
|
|
86
|
+
* }, auth);
|
|
87
|
+
*
|
|
88
|
+
* for (const notification of result.notifications) {
|
|
89
|
+
* console.log(`Notification ${notification.id}`);
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function listNotifications(options: ListNotificationsOptions, auth: AuthStrategy): Promise<ListNotificationsResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Options for creating a notification.
|
|
96
|
+
*/
|
|
97
|
+
export interface CreateNotificationOptions {
|
|
98
|
+
/**
|
|
99
|
+
* The project slug.
|
|
100
|
+
*/
|
|
101
|
+
projectSlug: string;
|
|
102
|
+
/**
|
|
103
|
+
* Target slugs to associate with this notification.
|
|
104
|
+
*/
|
|
105
|
+
targets: string[];
|
|
106
|
+
/**
|
|
107
|
+
* Email recipients for this notification.
|
|
108
|
+
*/
|
|
109
|
+
recipients: string[];
|
|
110
|
+
/**
|
|
111
|
+
* Trigger notification when deployment starts.
|
|
112
|
+
*/
|
|
113
|
+
deploymentStart?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Trigger notification when deployment succeeds.
|
|
116
|
+
*/
|
|
117
|
+
deploymentSuccess?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Trigger notification when deployment fails.
|
|
120
|
+
*/
|
|
121
|
+
deploymentFailed?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* MRT API origin URL.
|
|
124
|
+
* @default "https://cloud.mobify.com"
|
|
125
|
+
*/
|
|
126
|
+
origin?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Creates a notification for an MRT project.
|
|
130
|
+
*
|
|
131
|
+
* @param options - Create notification options
|
|
132
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
133
|
+
* @returns The created notification
|
|
134
|
+
* @throws Error if request fails
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth';
|
|
139
|
+
* import { createNotification } from '@salesforce/b2c-tooling-sdk/operations/mrt';
|
|
140
|
+
*
|
|
141
|
+
* const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization');
|
|
142
|
+
*
|
|
143
|
+
* const notification = await createNotification({
|
|
144
|
+
* projectSlug: 'my-storefront',
|
|
145
|
+
* targets: ['staging', 'production'],
|
|
146
|
+
* recipients: ['team@example.com'],
|
|
147
|
+
* deploymentStart: true,
|
|
148
|
+
* deploymentFailed: true
|
|
149
|
+
* }, auth);
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare function createNotification(options: CreateNotificationOptions, auth: AuthStrategy): Promise<MrtNotification>;
|
|
153
|
+
/**
|
|
154
|
+
* Options for getting a notification.
|
|
155
|
+
*/
|
|
156
|
+
export interface GetNotificationOptions {
|
|
157
|
+
/**
|
|
158
|
+
* The project slug.
|
|
159
|
+
*/
|
|
160
|
+
projectSlug: string;
|
|
161
|
+
/**
|
|
162
|
+
* Notification ID.
|
|
163
|
+
*/
|
|
164
|
+
notificationId: string;
|
|
165
|
+
/**
|
|
166
|
+
* MRT API origin URL.
|
|
167
|
+
* @default "https://cloud.mobify.com"
|
|
168
|
+
*/
|
|
169
|
+
origin?: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Gets a notification from an MRT project.
|
|
173
|
+
*
|
|
174
|
+
* @param options - Get notification options
|
|
175
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
176
|
+
* @returns The notification
|
|
177
|
+
* @throws Error if request fails
|
|
178
|
+
*/
|
|
179
|
+
export declare function getNotification(options: GetNotificationOptions, auth: AuthStrategy): Promise<MrtNotification>;
|
|
180
|
+
/**
|
|
181
|
+
* Options for updating a notification.
|
|
182
|
+
*/
|
|
183
|
+
export interface UpdateNotificationOptions {
|
|
184
|
+
/**
|
|
185
|
+
* The project slug.
|
|
186
|
+
*/
|
|
187
|
+
projectSlug: string;
|
|
188
|
+
/**
|
|
189
|
+
* Notification ID.
|
|
190
|
+
*/
|
|
191
|
+
notificationId: string;
|
|
192
|
+
/**
|
|
193
|
+
* Target slugs to associate with this notification.
|
|
194
|
+
*/
|
|
195
|
+
targets?: string[];
|
|
196
|
+
/**
|
|
197
|
+
* Email recipients for this notification.
|
|
198
|
+
*/
|
|
199
|
+
recipients?: string[];
|
|
200
|
+
/**
|
|
201
|
+
* Trigger notification when deployment starts.
|
|
202
|
+
*/
|
|
203
|
+
deploymentStart?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Trigger notification when deployment succeeds.
|
|
206
|
+
*/
|
|
207
|
+
deploymentSuccess?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Trigger notification when deployment fails.
|
|
210
|
+
*/
|
|
211
|
+
deploymentFailed?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* MRT API origin URL.
|
|
214
|
+
* @default "https://cloud.mobify.com"
|
|
215
|
+
*/
|
|
216
|
+
origin?: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Updates a notification in an MRT project.
|
|
220
|
+
*
|
|
221
|
+
* @param options - Update notification options
|
|
222
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
223
|
+
* @returns The updated notification
|
|
224
|
+
* @throws Error if request fails
|
|
225
|
+
*/
|
|
226
|
+
export declare function updateNotification(options: UpdateNotificationOptions, auth: AuthStrategy): Promise<MrtNotification>;
|
|
227
|
+
/**
|
|
228
|
+
* Options for deleting a notification.
|
|
229
|
+
*/
|
|
230
|
+
export interface DeleteNotificationOptions {
|
|
231
|
+
/**
|
|
232
|
+
* The project slug.
|
|
233
|
+
*/
|
|
234
|
+
projectSlug: string;
|
|
235
|
+
/**
|
|
236
|
+
* Notification ID.
|
|
237
|
+
*/
|
|
238
|
+
notificationId: string;
|
|
239
|
+
/**
|
|
240
|
+
* MRT API origin URL.
|
|
241
|
+
* @default "https://cloud.mobify.com"
|
|
242
|
+
*/
|
|
243
|
+
origin?: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Deletes a notification from an MRT project.
|
|
247
|
+
*
|
|
248
|
+
* @param options - Delete notification options
|
|
249
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
250
|
+
* @throws Error if request fails
|
|
251
|
+
*/
|
|
252
|
+
export declare function deleteNotification(options: DeleteNotificationOptions, auth: AuthStrategy): Promise<void>;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { createMrtClient, DEFAULT_MRT_ORIGIN } from '../../clients/mrt.js';
|
|
2
|
+
import { getLogger } from '../../logging/logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* Lists notifications for an MRT project.
|
|
5
|
+
*
|
|
6
|
+
* @param options - List options including project slug
|
|
7
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
8
|
+
* @returns Paginated list of notifications
|
|
9
|
+
* @throws Error if request fails
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth';
|
|
14
|
+
* import { listNotifications } from '@salesforce/b2c-tooling-sdk/operations/mrt';
|
|
15
|
+
*
|
|
16
|
+
* const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization');
|
|
17
|
+
*
|
|
18
|
+
* const result = await listNotifications({
|
|
19
|
+
* projectSlug: 'my-storefront'
|
|
20
|
+
* }, auth);
|
|
21
|
+
*
|
|
22
|
+
* for (const notification of result.notifications) {
|
|
23
|
+
* console.log(`Notification ${notification.id}`);
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export async function listNotifications(options, auth) {
|
|
28
|
+
const logger = getLogger();
|
|
29
|
+
const { projectSlug, limit, offset, targetSlug, origin } = options;
|
|
30
|
+
logger.debug({ projectSlug }, '[MRT] Listing notifications');
|
|
31
|
+
const client = createMrtClient({ origin: origin || DEFAULT_MRT_ORIGIN }, auth);
|
|
32
|
+
const { data, error } = await client.GET('/api/projects/{project_slug}/notifications/', {
|
|
33
|
+
params: {
|
|
34
|
+
path: { project_slug: projectSlug },
|
|
35
|
+
query: {
|
|
36
|
+
limit,
|
|
37
|
+
offset,
|
|
38
|
+
targets__slug: targetSlug,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
if (error) {
|
|
43
|
+
const errorMessage = typeof error === 'object' && error !== null && 'message' in error
|
|
44
|
+
? String(error.message)
|
|
45
|
+
: JSON.stringify(error);
|
|
46
|
+
throw new Error(`Failed to list notifications: ${errorMessage}`);
|
|
47
|
+
}
|
|
48
|
+
logger.debug({ count: data.count }, '[MRT] Notifications listed');
|
|
49
|
+
return {
|
|
50
|
+
count: data.count ?? 0,
|
|
51
|
+
next: data.next ?? null,
|
|
52
|
+
previous: data.previous ?? null,
|
|
53
|
+
notifications: data.results ?? [],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a notification for an MRT project.
|
|
58
|
+
*
|
|
59
|
+
* @param options - Create notification options
|
|
60
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
61
|
+
* @returns The created notification
|
|
62
|
+
* @throws Error if request fails
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth';
|
|
67
|
+
* import { createNotification } from '@salesforce/b2c-tooling-sdk/operations/mrt';
|
|
68
|
+
*
|
|
69
|
+
* const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization');
|
|
70
|
+
*
|
|
71
|
+
* const notification = await createNotification({
|
|
72
|
+
* projectSlug: 'my-storefront',
|
|
73
|
+
* targets: ['staging', 'production'],
|
|
74
|
+
* recipients: ['team@example.com'],
|
|
75
|
+
* deploymentStart: true,
|
|
76
|
+
* deploymentFailed: true
|
|
77
|
+
* }, auth);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export async function createNotification(options, auth) {
|
|
81
|
+
const logger = getLogger();
|
|
82
|
+
const { projectSlug, targets, recipients, deploymentStart, deploymentSuccess, deploymentFailed, origin } = options;
|
|
83
|
+
logger.debug({ projectSlug, targets, recipients }, '[MRT] Creating notification');
|
|
84
|
+
const client = createMrtClient({ origin: origin || DEFAULT_MRT_ORIGIN }, auth);
|
|
85
|
+
const body = {
|
|
86
|
+
resourcetype: 'EmailNotification',
|
|
87
|
+
targets,
|
|
88
|
+
recipients,
|
|
89
|
+
deployment_start: deploymentStart,
|
|
90
|
+
deployment_success: deploymentSuccess,
|
|
91
|
+
deployment_failed: deploymentFailed,
|
|
92
|
+
};
|
|
93
|
+
const { data, error } = await client.POST('/api/projects/{project_slug}/notifications/', {
|
|
94
|
+
params: {
|
|
95
|
+
path: { project_slug: projectSlug },
|
|
96
|
+
},
|
|
97
|
+
body,
|
|
98
|
+
});
|
|
99
|
+
if (error) {
|
|
100
|
+
const errorMessage = typeof error === 'object' && error !== null && 'message' in error
|
|
101
|
+
? String(error.message)
|
|
102
|
+
: JSON.stringify(error);
|
|
103
|
+
throw new Error(`Failed to create notification: ${errorMessage}`);
|
|
104
|
+
}
|
|
105
|
+
logger.debug({ id: data.id }, '[MRT] Notification created');
|
|
106
|
+
return data;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Gets a notification from an MRT project.
|
|
110
|
+
*
|
|
111
|
+
* @param options - Get notification options
|
|
112
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
113
|
+
* @returns The notification
|
|
114
|
+
* @throws Error if request fails
|
|
115
|
+
*/
|
|
116
|
+
export async function getNotification(options, auth) {
|
|
117
|
+
const logger = getLogger();
|
|
118
|
+
const { projectSlug, notificationId, origin } = options;
|
|
119
|
+
logger.debug({ projectSlug, notificationId }, '[MRT] Getting notification');
|
|
120
|
+
const client = createMrtClient({ origin: origin || DEFAULT_MRT_ORIGIN }, auth);
|
|
121
|
+
const { data, error } = await client.GET('/api/projects/{project_slug}/notifications/{id}/', {
|
|
122
|
+
params: {
|
|
123
|
+
path: { project_slug: projectSlug, id: notificationId },
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
if (error) {
|
|
127
|
+
const errorMessage = typeof error === 'object' && error !== null && 'message' in error
|
|
128
|
+
? String(error.message)
|
|
129
|
+
: JSON.stringify(error);
|
|
130
|
+
throw new Error(`Failed to get notification: ${errorMessage}`);
|
|
131
|
+
}
|
|
132
|
+
logger.debug({ id: data.id }, '[MRT] Notification retrieved');
|
|
133
|
+
return data;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Updates a notification in an MRT project.
|
|
137
|
+
*
|
|
138
|
+
* @param options - Update notification options
|
|
139
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
140
|
+
* @returns The updated notification
|
|
141
|
+
* @throws Error if request fails
|
|
142
|
+
*/
|
|
143
|
+
export async function updateNotification(options, auth) {
|
|
144
|
+
const logger = getLogger();
|
|
145
|
+
const { projectSlug, notificationId, targets, recipients, deploymentStart, deploymentSuccess, deploymentFailed, origin, } = options;
|
|
146
|
+
logger.debug({ projectSlug, notificationId }, '[MRT] Updating notification');
|
|
147
|
+
const client = createMrtClient({ origin: origin || DEFAULT_MRT_ORIGIN }, auth);
|
|
148
|
+
const body = {
|
|
149
|
+
resourcetype: 'EmailNotification',
|
|
150
|
+
};
|
|
151
|
+
if (targets !== undefined) {
|
|
152
|
+
body.targets = targets;
|
|
153
|
+
}
|
|
154
|
+
if (recipients !== undefined) {
|
|
155
|
+
body.recipients = recipients;
|
|
156
|
+
}
|
|
157
|
+
if (deploymentStart !== undefined) {
|
|
158
|
+
body.deployment_start = deploymentStart;
|
|
159
|
+
}
|
|
160
|
+
if (deploymentSuccess !== undefined) {
|
|
161
|
+
body.deployment_success = deploymentSuccess;
|
|
162
|
+
}
|
|
163
|
+
if (deploymentFailed !== undefined) {
|
|
164
|
+
body.deployment_failed = deploymentFailed;
|
|
165
|
+
}
|
|
166
|
+
const { data, error } = await client.PATCH('/api/projects/{project_slug}/notifications/{id}/', {
|
|
167
|
+
params: {
|
|
168
|
+
path: { project_slug: projectSlug, id: notificationId },
|
|
169
|
+
},
|
|
170
|
+
body,
|
|
171
|
+
});
|
|
172
|
+
if (error) {
|
|
173
|
+
const errorMessage = typeof error === 'object' && error !== null && 'message' in error
|
|
174
|
+
? String(error.message)
|
|
175
|
+
: JSON.stringify(error);
|
|
176
|
+
throw new Error(`Failed to update notification: ${errorMessage}`);
|
|
177
|
+
}
|
|
178
|
+
logger.debug({ id: data.id }, '[MRT] Notification updated');
|
|
179
|
+
return data;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Deletes a notification from an MRT project.
|
|
183
|
+
*
|
|
184
|
+
* @param options - Delete notification options
|
|
185
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
186
|
+
* @throws Error if request fails
|
|
187
|
+
*/
|
|
188
|
+
export async function deleteNotification(options, auth) {
|
|
189
|
+
const logger = getLogger();
|
|
190
|
+
const { projectSlug, notificationId, origin } = options;
|
|
191
|
+
logger.debug({ projectSlug, notificationId }, '[MRT] Deleting notification');
|
|
192
|
+
const client = createMrtClient({ origin: origin || DEFAULT_MRT_ORIGIN }, auth);
|
|
193
|
+
const { error } = await client.DELETE('/api/projects/{project_slug}/notifications/{id}/', {
|
|
194
|
+
params: {
|
|
195
|
+
path: { project_slug: projectSlug, id: notificationId },
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
if (error) {
|
|
199
|
+
const errorMessage = typeof error === 'object' && error !== null && 'message' in error
|
|
200
|
+
? String(error.message)
|
|
201
|
+
: JSON.stringify(error);
|
|
202
|
+
throw new Error(`Failed to delete notification: ${errorMessage}`);
|
|
203
|
+
}
|
|
204
|
+
logger.debug({ notificationId }, '[MRT] Notification deleted');
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../../../src/operations/mrt/notification.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAyElD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAiC,EACjC,IAAkB;IAElB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,EA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BAA4B,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization operations for Managed Runtime.
|
|
3
|
+
*
|
|
4
|
+
* Handles listing and retrieving MRT organizations.
|
|
5
|
+
*
|
|
6
|
+
* @module operations/mrt/organization
|
|
7
|
+
*/
|
|
8
|
+
import type { AuthStrategy } from '../../auth/types.js';
|
|
9
|
+
import type { components } from '../../clients/mrt.js';
|
|
10
|
+
/**
|
|
11
|
+
* MRT organization type from API.
|
|
12
|
+
*/
|
|
13
|
+
export type MrtOrganization = components['schemas']['APIOrganization'];
|
|
14
|
+
/**
|
|
15
|
+
* Organization limits from API.
|
|
16
|
+
*/
|
|
17
|
+
export type OrganizationLimits = components['schemas']['OrganizationLimits'];
|
|
18
|
+
/**
|
|
19
|
+
* Options for listing MRT organizations.
|
|
20
|
+
*/
|
|
21
|
+
export interface ListOrganizationsOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Maximum number of results to return.
|
|
24
|
+
*/
|
|
25
|
+
limit?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Offset for pagination.
|
|
28
|
+
*/
|
|
29
|
+
offset?: number;
|
|
30
|
+
/**
|
|
31
|
+
* MRT API origin URL.
|
|
32
|
+
* @default "https://cloud.mobify.com"
|
|
33
|
+
*/
|
|
34
|
+
origin?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Result of listing organizations.
|
|
38
|
+
*/
|
|
39
|
+
export interface ListOrganizationsResult {
|
|
40
|
+
/**
|
|
41
|
+
* Total count of organizations.
|
|
42
|
+
*/
|
|
43
|
+
count: number;
|
|
44
|
+
/**
|
|
45
|
+
* URL for next page of results.
|
|
46
|
+
*/
|
|
47
|
+
next: string | null;
|
|
48
|
+
/**
|
|
49
|
+
* URL for previous page of results.
|
|
50
|
+
*/
|
|
51
|
+
previous: string | null;
|
|
52
|
+
/**
|
|
53
|
+
* Array of organizations.
|
|
54
|
+
*/
|
|
55
|
+
organizations: MrtOrganization[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Lists organizations accessible to the authenticated user.
|
|
59
|
+
*
|
|
60
|
+
* @param options - List options including pagination
|
|
61
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
62
|
+
* @returns Paginated list of organizations
|
|
63
|
+
* @throws Error if request fails
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth';
|
|
68
|
+
* import { listOrganizations } from '@salesforce/b2c-tooling-sdk/operations/mrt';
|
|
69
|
+
*
|
|
70
|
+
* const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization');
|
|
71
|
+
*
|
|
72
|
+
* const result = await listOrganizations({}, auth);
|
|
73
|
+
* console.log(`Found ${result.count} organizations`);
|
|
74
|
+
*
|
|
75
|
+
* for (const org of result.organizations) {
|
|
76
|
+
* console.log(`- ${org.name} (${org.slug})`);
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function listOrganizations(options: ListOrganizationsOptions, auth: AuthStrategy): Promise<ListOrganizationsResult>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createMrtClient, DEFAULT_MRT_ORIGIN } from '../../clients/mrt.js';
|
|
2
|
+
import { getLogger } from '../../logging/logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* Lists organizations accessible to the authenticated user.
|
|
5
|
+
*
|
|
6
|
+
* @param options - List options including pagination
|
|
7
|
+
* @param auth - Authentication strategy (ApiKeyStrategy)
|
|
8
|
+
* @returns Paginated list of organizations
|
|
9
|
+
* @throws Error if request fails
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth';
|
|
14
|
+
* import { listOrganizations } from '@salesforce/b2c-tooling-sdk/operations/mrt';
|
|
15
|
+
*
|
|
16
|
+
* const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization');
|
|
17
|
+
*
|
|
18
|
+
* const result = await listOrganizations({}, auth);
|
|
19
|
+
* console.log(`Found ${result.count} organizations`);
|
|
20
|
+
*
|
|
21
|
+
* for (const org of result.organizations) {
|
|
22
|
+
* console.log(`- ${org.name} (${org.slug})`);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export async function listOrganizations(options, auth) {
|
|
27
|
+
const logger = getLogger();
|
|
28
|
+
const { limit, offset, origin } = options;
|
|
29
|
+
logger.debug({ limit, offset }, '[MRT] Listing organizations');
|
|
30
|
+
const client = createMrtClient({ origin: origin || DEFAULT_MRT_ORIGIN }, auth);
|
|
31
|
+
const { data, error } = await client.GET('/api/organizations/', {
|
|
32
|
+
params: {
|
|
33
|
+
query: {
|
|
34
|
+
limit,
|
|
35
|
+
offset,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (error) {
|
|
40
|
+
const errorMessage = typeof error === 'object' && error !== null && 'message' in error
|
|
41
|
+
? String(error.message)
|
|
42
|
+
: JSON.stringify(error);
|
|
43
|
+
throw new Error(`Failed to list organizations: ${errorMessage}`);
|
|
44
|
+
}
|
|
45
|
+
logger.debug({ count: data.count }, '[MRT] Organizations listed');
|
|
46
|
+
return {
|
|
47
|
+
count: data.count ?? 0,
|
|
48
|
+
next: data.next ?? null,
|
|
49
|
+
previous: data.previous ?? null,
|
|
50
|
+
organizations: data.results ?? [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=organization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.js","sourceRoot":"","sources":["../../../../src/operations/mrt/organization.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAEzE,OAAO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