@inverted-tech/fragments 0.10.9 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform API client utilities
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic: works in Next.js (SSR/SSG), browser SPAs, and Node.js.
|
|
5
|
+
* The caller is responsible for resolving the base URL from their environment.
|
|
6
|
+
*
|
|
7
|
+
* @example Next.js
|
|
8
|
+
* ```ts
|
|
9
|
+
* const isServer = typeof window === 'undefined';
|
|
10
|
+
* const baseUrl = isServer
|
|
11
|
+
* ? (process.env.API_BASE_URL ?? process.env.NEXT_PUBLIC_API_BASE_URL ?? '')
|
|
12
|
+
* : (process.env.NEXT_PUBLIC_API_BASE_URL ?? '');
|
|
13
|
+
* export const api = createApiClient(baseUrl);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example Vite SPA
|
|
17
|
+
* ```ts
|
|
18
|
+
* export const api = createApiClient(import.meta.env.VITE_API_BASE_URL ?? '');
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
type FetchCacheMode = 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
|
|
22
|
+
/** Subset of fetch init options we care about, plus an escape hatch for anything else. */
|
|
23
|
+
export interface FetchInit {
|
|
24
|
+
method?: string;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
body?: string | null;
|
|
27
|
+
cache?: FetchCacheMode;
|
|
28
|
+
mode?: string;
|
|
29
|
+
credentials?: string;
|
|
30
|
+
signal?: unknown;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
/** Next.js extended fetch options — passed through as-is; non-Next runtimes ignore them. */
|
|
34
|
+
export interface NextFetchExtensions {
|
|
35
|
+
next?: {
|
|
36
|
+
tags?: string[];
|
|
37
|
+
revalidate?: number | false;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export type ApiCallOptions = FetchInit & NextFetchExtensions;
|
|
41
|
+
/**
|
|
42
|
+
* Cross-platform fetch wrapper with error handling.
|
|
43
|
+
*
|
|
44
|
+
* - Merges caller headers on top of the default Content-Type header.
|
|
45
|
+
* - Defaults cache to `no-store` unless `cache` or `next` is explicitly provided
|
|
46
|
+
* (avoids the Next.js 2 MB data-cache write limit).
|
|
47
|
+
* - Passes `next` through transparently for Next.js ISR tag/revalidation support.
|
|
48
|
+
*/
|
|
49
|
+
export declare function apiCall<T>(url: string, options?: ApiCallOptions): Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Build the endpoint map for a given base URL.
|
|
52
|
+
* Call once during app initialization with your resolved base URL.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createApiEndpoints(baseUrl: string): {
|
|
55
|
+
readonly auth: {
|
|
56
|
+
readonly login: `${string}/auth/login`;
|
|
57
|
+
readonly logout: `${string}/auth/logout`;
|
|
58
|
+
readonly createUser: `${string}/auth/createuser`;
|
|
59
|
+
readonly adminCreateUser: `${string}/auth/admin/createuser`;
|
|
60
|
+
readonly refresh: `${string}/auth/renewtoken`;
|
|
61
|
+
readonly changePassword: `${string}/auth/password`;
|
|
62
|
+
readonly adminChangePassword: `${string}/auth/admin/password`;
|
|
63
|
+
readonly getCurrentUser: `${string}/auth/user`;
|
|
64
|
+
readonly editOwnUser: `${string}/auth/user`;
|
|
65
|
+
readonly getUserById: (userId: string) => string;
|
|
66
|
+
readonly getUserByName: (userName: string) => string;
|
|
67
|
+
readonly getUserIds: `${string}/auth/user/ids`;
|
|
68
|
+
readonly getProfileImage: `${string}/auth/profileimage`;
|
|
69
|
+
readonly getUserProfileImage: (userId: string) => string;
|
|
70
|
+
readonly uploadProfileImage: `${string}/auth/profileimage`;
|
|
71
|
+
readonly adminUploadProfileImage: `${string}/auth/admin/profileimage`;
|
|
72
|
+
readonly totp: `${string}/auth/totp`;
|
|
73
|
+
readonly disableTotp: (id: string) => string;
|
|
74
|
+
readonly verifyTotp: (id: string) => string;
|
|
75
|
+
readonly adminGetUsers: `${string}/auth/admin/user`;
|
|
76
|
+
readonly adminAddUser: `${string}/auth/admin/user`;
|
|
77
|
+
readonly adminGetUser: (userId: string) => string;
|
|
78
|
+
readonly adminDisableUser: (userId: string) => string;
|
|
79
|
+
readonly adminEnableUser: (userId: string) => string;
|
|
80
|
+
readonly adminSetRoles: `${string}/auth/admin/user/roles`;
|
|
81
|
+
readonly adminSearch: `${string}/auth/admin/search`;
|
|
82
|
+
readonly adminGetTotp: (userId: string) => string;
|
|
83
|
+
readonly adminCreateTotp: (userId: string) => string;
|
|
84
|
+
readonly adminDisableTotp: (userId: string, totpId: string) => string;
|
|
85
|
+
readonly adminVerifyTotp: (userId: string, totpId: string) => string;
|
|
86
|
+
};
|
|
87
|
+
readonly asset: {
|
|
88
|
+
readonly getAssetData: (id: string) => string;
|
|
89
|
+
readonly createAudioAsset: `${string}/cms/asset/audio`;
|
|
90
|
+
readonly createAsset: `${string}/cms/admin/asset`;
|
|
91
|
+
readonly getAsset: (id: string) => string;
|
|
92
|
+
readonly adminGetAsset: (id: string) => string;
|
|
93
|
+
readonly adminGetAssetByOldId: (id: string) => string;
|
|
94
|
+
readonly adminGetImageAssets: `${string}/cms/admin/asset/image`;
|
|
95
|
+
readonly searchAssets: `${string}/cms/admin/asset/search`;
|
|
96
|
+
};
|
|
97
|
+
readonly auditLog: {
|
|
98
|
+
readonly adminGetAuditLog: `${string}/admin/audit-log`;
|
|
99
|
+
};
|
|
100
|
+
readonly careers: {
|
|
101
|
+
readonly createCareer: `${string}/admin/careers`;
|
|
102
|
+
readonly getCareersAdmin: `${string}/admin/careers`;
|
|
103
|
+
readonly getCareer: (id: string) => string;
|
|
104
|
+
readonly getCareers: `${string}/careers`;
|
|
105
|
+
readonly adminUpdateCareer: (id: string) => string;
|
|
106
|
+
readonly adminDeleteCareer: (id: string) => string;
|
|
107
|
+
};
|
|
108
|
+
readonly category: {
|
|
109
|
+
readonly createCategory: `${string}/settings/category/create`;
|
|
110
|
+
readonly deleteCategory: (id: string) => string;
|
|
111
|
+
};
|
|
112
|
+
readonly channel: {
|
|
113
|
+
readonly getChannels: `${string}/settings/channel`;
|
|
114
|
+
readonly createChannel: `${string}/settings/channel/create`;
|
|
115
|
+
readonly deleteChannel: (id: string) => string;
|
|
116
|
+
readonly getChannelDetails: (id: string) => string;
|
|
117
|
+
};
|
|
118
|
+
readonly comment: {
|
|
119
|
+
readonly adminDeleteComment: (id: string) => string;
|
|
120
|
+
readonly adminPinComment: (id: string) => string;
|
|
121
|
+
readonly adminUndeleteComment: (id: string) => string;
|
|
122
|
+
readonly adminUnpinComment: (id: string) => string;
|
|
123
|
+
readonly createCommentForContent: (id: string) => string;
|
|
124
|
+
readonly createCommentForComment: (id: string) => string;
|
|
125
|
+
readonly deleteOwnComment: (id: string) => string;
|
|
126
|
+
readonly editOwnComment: (id: string) => string;
|
|
127
|
+
readonly getCommentForContent: (id: string) => string;
|
|
128
|
+
readonly getCommentsForComment: (id: string) => string;
|
|
129
|
+
readonly likeComment: (id: string) => string;
|
|
130
|
+
readonly unlikeComment: (id: string) => string;
|
|
131
|
+
};
|
|
132
|
+
readonly cms: {
|
|
133
|
+
readonly announceContent: (id: string) => string;
|
|
134
|
+
readonly createContent: `${string}/cms/admin/content`;
|
|
135
|
+
readonly adminListContent: `${string}/cms/admin/content`;
|
|
136
|
+
readonly deleteContent: (id: string) => string;
|
|
137
|
+
readonly adminGetContentById: (id: string) => string;
|
|
138
|
+
readonly adminUpdateContent: (id: string) => string;
|
|
139
|
+
readonly listContent: `${string}/cms/content`;
|
|
140
|
+
readonly getContentById: (id: string) => string;
|
|
141
|
+
readonly getContentByUrl: (url: string) => string;
|
|
142
|
+
readonly getRecentCategories: `${string}/cms/categories/recent`;
|
|
143
|
+
readonly getRecentTags: `${string}/cms/tags/recent`;
|
|
144
|
+
readonly getContentByChannel: (channelId: string, pageSize?: number) => string;
|
|
145
|
+
readonly getRelated: (contentId: string, pageSize?: number) => string;
|
|
146
|
+
readonly publishContent: (id: string) => string;
|
|
147
|
+
readonly searchContent: `${string}/cms/search`;
|
|
148
|
+
readonly unannounceContent: (id: string) => string;
|
|
149
|
+
readonly undeleteContent: (id: string) => string;
|
|
150
|
+
readonly unpublishContent: (id: string) => string;
|
|
151
|
+
readonly createPage: `${string}/cms/admin/page`;
|
|
152
|
+
readonly adminListPages: `${string}/cms/admin/page`;
|
|
153
|
+
readonly deletePage: (id: string) => string;
|
|
154
|
+
readonly adminGetPageById: (id: string) => string;
|
|
155
|
+
readonly adminUpdatePage: (id: string) => string;
|
|
156
|
+
readonly listPages: `${string}/cms/page`;
|
|
157
|
+
readonly getPageById: (id: string) => string;
|
|
158
|
+
readonly getPageByUrl: `${string}/cms/page/url`;
|
|
159
|
+
readonly publishPage: (id: string) => string;
|
|
160
|
+
readonly searchPages: `${string}/cms/page/search`;
|
|
161
|
+
readonly undeletePage: (id: string) => string;
|
|
162
|
+
readonly unpublishPage: (id: string) => string;
|
|
163
|
+
};
|
|
164
|
+
readonly settings: {
|
|
165
|
+
readonly publicSettings: `${string}/settings/public`;
|
|
166
|
+
readonly publicSettingsNewer: (version: string) => string;
|
|
167
|
+
readonly adminSettings: `${string}/settings/admin`;
|
|
168
|
+
readonly adminSettingsNewer: (version: string) => string;
|
|
169
|
+
readonly ownerSettings: `${string}/settings/owner`;
|
|
170
|
+
readonly ownerSettingsNewer: (version: string) => string;
|
|
171
|
+
readonly channels: `${string}/settings/channel`;
|
|
172
|
+
readonly channelById: (channelId: string) => string;
|
|
173
|
+
readonly saveCmsPublic: `${string}/settings/cms/public`;
|
|
174
|
+
readonly saveCmsPrivate: `${string}/settings/cms/private`;
|
|
175
|
+
readonly saveCmsOwner: `${string}/settings/cms/owner`;
|
|
176
|
+
readonly savePersonalizationPublic: `${string}/settings/personalization/public`;
|
|
177
|
+
readonly savePersonalizationPrivate: `${string}/settings/personalization/private`;
|
|
178
|
+
readonly savePersonalizationOwner: `${string}/settings/personalization/owner`;
|
|
179
|
+
readonly saveSubscriptionPublic: `${string}/settings/subscription/public`;
|
|
180
|
+
readonly saveSubscriptionPrivate: `${string}/settings/subscription/private`;
|
|
181
|
+
readonly saveSubscriptionOwner: `${string}/settings/subscription/owner`;
|
|
182
|
+
readonly saveCommentsPublic: `${string}/settings/comments/public`;
|
|
183
|
+
readonly saveCommentsPrivate: `${string}/settings/comments/private`;
|
|
184
|
+
readonly saveCommentsOwner: `${string}/settings/comments/owner`;
|
|
185
|
+
readonly saveNotificationPublic: `${string}/settings/notification/public`;
|
|
186
|
+
readonly saveNotificationPrivate: `${string}/settings/notification/private`;
|
|
187
|
+
readonly saveNotificationOwner: `${string}/settings/notification/owner`;
|
|
188
|
+
readonly saveEventsPublic: `${string}/settings/events/public`;
|
|
189
|
+
readonly saveEventsPrivate: `${string}/settings/events/private`;
|
|
190
|
+
readonly saveEventsOwner: `${string}/settings/events/owner`;
|
|
191
|
+
};
|
|
192
|
+
readonly dashboard: {
|
|
193
|
+
readonly getDashboard: `${string}/admin/dashboard`;
|
|
194
|
+
};
|
|
195
|
+
readonly events: {
|
|
196
|
+
readonly getEvent: (eventId: string) => string;
|
|
197
|
+
readonly getEvents: `${string}/events`;
|
|
198
|
+
readonly getTicket: (eventId: string, ticketId: string) => string;
|
|
199
|
+
readonly getTickets: (eventId: string) => string;
|
|
200
|
+
readonly cancelTicket: (eventId: string, ticketId: string) => string;
|
|
201
|
+
readonly reserveTicket: (eventId: string) => string;
|
|
202
|
+
readonly useTicket: `${string}/events/tickets/use`;
|
|
203
|
+
};
|
|
204
|
+
readonly adminEvents: {
|
|
205
|
+
readonly createEvent: `${string}/admin/events/create`;
|
|
206
|
+
readonly createRecurringEvent: `${string}/admin/events/create-recurring`;
|
|
207
|
+
readonly getEvent: (eventId: string) => string;
|
|
208
|
+
readonly getEvents: `${string}/admin/events`;
|
|
209
|
+
readonly modifyEvent: `${string}/admin/events/modify`;
|
|
210
|
+
readonly cancelEvent: `${string}/admin/events/cancel`;
|
|
211
|
+
readonly cancelAllRecurring: `${string}/admin/events/cancel-all-recurring`;
|
|
212
|
+
readonly getTicket: (eventId: string, ticketId: string) => string;
|
|
213
|
+
readonly getTickets: (eventId: string) => string;
|
|
214
|
+
readonly cancelTicket: (eventId: string, ticketId: string) => string;
|
|
215
|
+
readonly reserveTicket: (eventId: string) => string;
|
|
216
|
+
};
|
|
217
|
+
readonly payments: {
|
|
218
|
+
readonly getSubscriptions: `${string}/payment/subscription`;
|
|
219
|
+
readonly getSubscriptionById: (id: string) => string;
|
|
220
|
+
readonly reconcileSubscription: `${string}/payment/subscription/reconcile`;
|
|
221
|
+
readonly newSubscription: (level: number, postalCode: string, successUrl: string, cancelUrl: string) => string;
|
|
222
|
+
readonly cancelSubscription: `${string}/payment/subscription/cancel`;
|
|
223
|
+
readonly getSinglePayments: `${string}/payment/single`;
|
|
224
|
+
readonly getSinglePayment: (id: string) => string;
|
|
225
|
+
readonly newSinglePayment: `${string}/payment/single/new`;
|
|
226
|
+
readonly finishStripe: `${string}/payment/stripe/subscription/finish`;
|
|
227
|
+
readonly finishFortis: `${string}/payment/fortis/subscription/finish`;
|
|
228
|
+
readonly newPaypal: `${string}/payment/paypal/subscription/new`;
|
|
229
|
+
};
|
|
230
|
+
readonly adminPayments: {
|
|
231
|
+
readonly bulkCancel: `${string}/payment/admin/bulk/cancel`;
|
|
232
|
+
readonly bulkStart: `${string}/payment/admin/bulk/start`;
|
|
233
|
+
readonly getBulk: `${string}/payment/admin/bulk`;
|
|
234
|
+
readonly cancelUserSubscription: (userId: string, subscriptionId: string) => string;
|
|
235
|
+
readonly getUserSubscription: (userId: string, subscriptionId: string) => string;
|
|
236
|
+
readonly getUserSubscriptions: (userId: string) => string;
|
|
237
|
+
readonly getUserSinglePayment: (userId: string, paymentId: string) => string;
|
|
238
|
+
readonly getUserSinglePayments: (userId: string) => string;
|
|
239
|
+
readonly reconcileUserSubscription: (userId: string, subscriptionId: string) => string;
|
|
240
|
+
readonly getSubscriptions: `${string}/payment/admin/subscriptions`;
|
|
241
|
+
};
|
|
242
|
+
readonly manualPayments: {
|
|
243
|
+
readonly adminCancelSubscription: (userId: string, subscriptionId: string) => string;
|
|
244
|
+
readonly cancelSubscription: (subscriptionId: string) => string;
|
|
245
|
+
readonly adminGetSubscription: (userId: string, subscriptionId: string) => string;
|
|
246
|
+
readonly adminGetSubscriptions: (userId: string) => string;
|
|
247
|
+
readonly getSubscriptions: `${string}/payment/manual/subscription`;
|
|
248
|
+
readonly getSubscription: (subscriptionId: string) => string;
|
|
249
|
+
readonly adminNewSubscription: (userId: string) => string;
|
|
250
|
+
readonly newSubscription: `${string}/payment/manual/subscription/new`;
|
|
251
|
+
};
|
|
252
|
+
readonly stats: {
|
|
253
|
+
readonly like: (contentId: string) => string;
|
|
254
|
+
readonly unlike: (contentId: string) => string;
|
|
255
|
+
readonly progress: (contentId: string) => string;
|
|
256
|
+
readonly save: (contentId: string) => string;
|
|
257
|
+
readonly unSave: (contentId: string) => string;
|
|
258
|
+
readonly logShare: (contentId: string) => string;
|
|
259
|
+
readonly getContentStats: (contentId: string) => string;
|
|
260
|
+
readonly getUserStats: (userId: string) => string;
|
|
261
|
+
readonly getCurrentUserStats: `${string}/stats/user`;
|
|
262
|
+
readonly getUserLikes: `${string}/stats/user/likes`;
|
|
263
|
+
readonly getUserProgress: `${string}/stats/user/progress`;
|
|
264
|
+
readonly getUserSaves: `${string}/stats/user/saves`;
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
export type ApiEndpoints = ReturnType<typeof createApiEndpoints>;
|
|
268
|
+
/**
|
|
269
|
+
* Create a complete API client bound to a base URL.
|
|
270
|
+
*
|
|
271
|
+
* Returns `endpoints` (the full URL map) and `call` (the fetch wrapper),
|
|
272
|
+
* both pre-bound to the provided base URL.
|
|
273
|
+
*/
|
|
274
|
+
export declare function createApiClient(baseUrl: string): {
|
|
275
|
+
endpoints: {
|
|
276
|
+
readonly auth: {
|
|
277
|
+
readonly login: `${string}/auth/login`;
|
|
278
|
+
readonly logout: `${string}/auth/logout`;
|
|
279
|
+
readonly createUser: `${string}/auth/createuser`;
|
|
280
|
+
readonly adminCreateUser: `${string}/auth/admin/createuser`;
|
|
281
|
+
readonly refresh: `${string}/auth/renewtoken`;
|
|
282
|
+
readonly changePassword: `${string}/auth/password`;
|
|
283
|
+
readonly adminChangePassword: `${string}/auth/admin/password`;
|
|
284
|
+
readonly getCurrentUser: `${string}/auth/user`;
|
|
285
|
+
readonly editOwnUser: `${string}/auth/user`;
|
|
286
|
+
readonly getUserById: (userId: string) => string;
|
|
287
|
+
readonly getUserByName: (userName: string) => string;
|
|
288
|
+
readonly getUserIds: `${string}/auth/user/ids`;
|
|
289
|
+
readonly getProfileImage: `${string}/auth/profileimage`;
|
|
290
|
+
readonly getUserProfileImage: (userId: string) => string;
|
|
291
|
+
readonly uploadProfileImage: `${string}/auth/profileimage`;
|
|
292
|
+
readonly adminUploadProfileImage: `${string}/auth/admin/profileimage`;
|
|
293
|
+
readonly totp: `${string}/auth/totp`;
|
|
294
|
+
readonly disableTotp: (id: string) => string;
|
|
295
|
+
readonly verifyTotp: (id: string) => string;
|
|
296
|
+
readonly adminGetUsers: `${string}/auth/admin/user`;
|
|
297
|
+
readonly adminAddUser: `${string}/auth/admin/user`;
|
|
298
|
+
readonly adminGetUser: (userId: string) => string;
|
|
299
|
+
readonly adminDisableUser: (userId: string) => string;
|
|
300
|
+
readonly adminEnableUser: (userId: string) => string;
|
|
301
|
+
readonly adminSetRoles: `${string}/auth/admin/user/roles`;
|
|
302
|
+
readonly adminSearch: `${string}/auth/admin/search`;
|
|
303
|
+
readonly adminGetTotp: (userId: string) => string;
|
|
304
|
+
readonly adminCreateTotp: (userId: string) => string;
|
|
305
|
+
readonly adminDisableTotp: (userId: string, totpId: string) => string;
|
|
306
|
+
readonly adminVerifyTotp: (userId: string, totpId: string) => string;
|
|
307
|
+
};
|
|
308
|
+
readonly asset: {
|
|
309
|
+
readonly getAssetData: (id: string) => string;
|
|
310
|
+
readonly createAudioAsset: `${string}/cms/asset/audio`;
|
|
311
|
+
readonly createAsset: `${string}/cms/admin/asset`;
|
|
312
|
+
readonly getAsset: (id: string) => string;
|
|
313
|
+
readonly adminGetAsset: (id: string) => string;
|
|
314
|
+
readonly adminGetAssetByOldId: (id: string) => string;
|
|
315
|
+
readonly adminGetImageAssets: `${string}/cms/admin/asset/image`;
|
|
316
|
+
readonly searchAssets: `${string}/cms/admin/asset/search`;
|
|
317
|
+
};
|
|
318
|
+
readonly auditLog: {
|
|
319
|
+
readonly adminGetAuditLog: `${string}/admin/audit-log`;
|
|
320
|
+
};
|
|
321
|
+
readonly careers: {
|
|
322
|
+
readonly createCareer: `${string}/admin/careers`;
|
|
323
|
+
readonly getCareersAdmin: `${string}/admin/careers`;
|
|
324
|
+
readonly getCareer: (id: string) => string;
|
|
325
|
+
readonly getCareers: `${string}/careers`;
|
|
326
|
+
readonly adminUpdateCareer: (id: string) => string;
|
|
327
|
+
readonly adminDeleteCareer: (id: string) => string;
|
|
328
|
+
};
|
|
329
|
+
readonly category: {
|
|
330
|
+
readonly createCategory: `${string}/settings/category/create`;
|
|
331
|
+
readonly deleteCategory: (id: string) => string;
|
|
332
|
+
};
|
|
333
|
+
readonly channel: {
|
|
334
|
+
readonly getChannels: `${string}/settings/channel`;
|
|
335
|
+
readonly createChannel: `${string}/settings/channel/create`;
|
|
336
|
+
readonly deleteChannel: (id: string) => string;
|
|
337
|
+
readonly getChannelDetails: (id: string) => string;
|
|
338
|
+
};
|
|
339
|
+
readonly comment: {
|
|
340
|
+
readonly adminDeleteComment: (id: string) => string;
|
|
341
|
+
readonly adminPinComment: (id: string) => string;
|
|
342
|
+
readonly adminUndeleteComment: (id: string) => string;
|
|
343
|
+
readonly adminUnpinComment: (id: string) => string;
|
|
344
|
+
readonly createCommentForContent: (id: string) => string;
|
|
345
|
+
readonly createCommentForComment: (id: string) => string;
|
|
346
|
+
readonly deleteOwnComment: (id: string) => string;
|
|
347
|
+
readonly editOwnComment: (id: string) => string;
|
|
348
|
+
readonly getCommentForContent: (id: string) => string;
|
|
349
|
+
readonly getCommentsForComment: (id: string) => string;
|
|
350
|
+
readonly likeComment: (id: string) => string;
|
|
351
|
+
readonly unlikeComment: (id: string) => string;
|
|
352
|
+
};
|
|
353
|
+
readonly cms: {
|
|
354
|
+
readonly announceContent: (id: string) => string;
|
|
355
|
+
readonly createContent: `${string}/cms/admin/content`;
|
|
356
|
+
readonly adminListContent: `${string}/cms/admin/content`;
|
|
357
|
+
readonly deleteContent: (id: string) => string;
|
|
358
|
+
readonly adminGetContentById: (id: string) => string;
|
|
359
|
+
readonly adminUpdateContent: (id: string) => string;
|
|
360
|
+
readonly listContent: `${string}/cms/content`;
|
|
361
|
+
readonly getContentById: (id: string) => string;
|
|
362
|
+
readonly getContentByUrl: (url: string) => string;
|
|
363
|
+
readonly getRecentCategories: `${string}/cms/categories/recent`;
|
|
364
|
+
readonly getRecentTags: `${string}/cms/tags/recent`;
|
|
365
|
+
readonly getContentByChannel: (channelId: string, pageSize?: number) => string;
|
|
366
|
+
readonly getRelated: (contentId: string, pageSize?: number) => string;
|
|
367
|
+
readonly publishContent: (id: string) => string;
|
|
368
|
+
readonly searchContent: `${string}/cms/search`;
|
|
369
|
+
readonly unannounceContent: (id: string) => string;
|
|
370
|
+
readonly undeleteContent: (id: string) => string;
|
|
371
|
+
readonly unpublishContent: (id: string) => string;
|
|
372
|
+
readonly createPage: `${string}/cms/admin/page`;
|
|
373
|
+
readonly adminListPages: `${string}/cms/admin/page`;
|
|
374
|
+
readonly deletePage: (id: string) => string;
|
|
375
|
+
readonly adminGetPageById: (id: string) => string;
|
|
376
|
+
readonly adminUpdatePage: (id: string) => string;
|
|
377
|
+
readonly listPages: `${string}/cms/page`;
|
|
378
|
+
readonly getPageById: (id: string) => string;
|
|
379
|
+
readonly getPageByUrl: `${string}/cms/page/url`;
|
|
380
|
+
readonly publishPage: (id: string) => string;
|
|
381
|
+
readonly searchPages: `${string}/cms/page/search`;
|
|
382
|
+
readonly undeletePage: (id: string) => string;
|
|
383
|
+
readonly unpublishPage: (id: string) => string;
|
|
384
|
+
};
|
|
385
|
+
readonly settings: {
|
|
386
|
+
readonly publicSettings: `${string}/settings/public`;
|
|
387
|
+
readonly publicSettingsNewer: (version: string) => string;
|
|
388
|
+
readonly adminSettings: `${string}/settings/admin`;
|
|
389
|
+
readonly adminSettingsNewer: (version: string) => string;
|
|
390
|
+
readonly ownerSettings: `${string}/settings/owner`;
|
|
391
|
+
readonly ownerSettingsNewer: (version: string) => string;
|
|
392
|
+
readonly channels: `${string}/settings/channel`;
|
|
393
|
+
readonly channelById: (channelId: string) => string;
|
|
394
|
+
readonly saveCmsPublic: `${string}/settings/cms/public`;
|
|
395
|
+
readonly saveCmsPrivate: `${string}/settings/cms/private`;
|
|
396
|
+
readonly saveCmsOwner: `${string}/settings/cms/owner`;
|
|
397
|
+
readonly savePersonalizationPublic: `${string}/settings/personalization/public`;
|
|
398
|
+
readonly savePersonalizationPrivate: `${string}/settings/personalization/private`;
|
|
399
|
+
readonly savePersonalizationOwner: `${string}/settings/personalization/owner`;
|
|
400
|
+
readonly saveSubscriptionPublic: `${string}/settings/subscription/public`;
|
|
401
|
+
readonly saveSubscriptionPrivate: `${string}/settings/subscription/private`;
|
|
402
|
+
readonly saveSubscriptionOwner: `${string}/settings/subscription/owner`;
|
|
403
|
+
readonly saveCommentsPublic: `${string}/settings/comments/public`;
|
|
404
|
+
readonly saveCommentsPrivate: `${string}/settings/comments/private`;
|
|
405
|
+
readonly saveCommentsOwner: `${string}/settings/comments/owner`;
|
|
406
|
+
readonly saveNotificationPublic: `${string}/settings/notification/public`;
|
|
407
|
+
readonly saveNotificationPrivate: `${string}/settings/notification/private`;
|
|
408
|
+
readonly saveNotificationOwner: `${string}/settings/notification/owner`;
|
|
409
|
+
readonly saveEventsPublic: `${string}/settings/events/public`;
|
|
410
|
+
readonly saveEventsPrivate: `${string}/settings/events/private`;
|
|
411
|
+
readonly saveEventsOwner: `${string}/settings/events/owner`;
|
|
412
|
+
};
|
|
413
|
+
readonly dashboard: {
|
|
414
|
+
readonly getDashboard: `${string}/admin/dashboard`;
|
|
415
|
+
};
|
|
416
|
+
readonly events: {
|
|
417
|
+
readonly getEvent: (eventId: string) => string;
|
|
418
|
+
readonly getEvents: `${string}/events`;
|
|
419
|
+
readonly getTicket: (eventId: string, ticketId: string) => string;
|
|
420
|
+
readonly getTickets: (eventId: string) => string;
|
|
421
|
+
readonly cancelTicket: (eventId: string, ticketId: string) => string;
|
|
422
|
+
readonly reserveTicket: (eventId: string) => string;
|
|
423
|
+
readonly useTicket: `${string}/events/tickets/use`;
|
|
424
|
+
};
|
|
425
|
+
readonly adminEvents: {
|
|
426
|
+
readonly createEvent: `${string}/admin/events/create`;
|
|
427
|
+
readonly createRecurringEvent: `${string}/admin/events/create-recurring`;
|
|
428
|
+
readonly getEvent: (eventId: string) => string;
|
|
429
|
+
readonly getEvents: `${string}/admin/events`;
|
|
430
|
+
readonly modifyEvent: `${string}/admin/events/modify`;
|
|
431
|
+
readonly cancelEvent: `${string}/admin/events/cancel`;
|
|
432
|
+
readonly cancelAllRecurring: `${string}/admin/events/cancel-all-recurring`;
|
|
433
|
+
readonly getTicket: (eventId: string, ticketId: string) => string;
|
|
434
|
+
readonly getTickets: (eventId: string) => string;
|
|
435
|
+
readonly cancelTicket: (eventId: string, ticketId: string) => string;
|
|
436
|
+
readonly reserveTicket: (eventId: string) => string;
|
|
437
|
+
};
|
|
438
|
+
readonly payments: {
|
|
439
|
+
readonly getSubscriptions: `${string}/payment/subscription`;
|
|
440
|
+
readonly getSubscriptionById: (id: string) => string;
|
|
441
|
+
readonly reconcileSubscription: `${string}/payment/subscription/reconcile`;
|
|
442
|
+
readonly newSubscription: (level: number, postalCode: string, successUrl: string, cancelUrl: string) => string;
|
|
443
|
+
readonly cancelSubscription: `${string}/payment/subscription/cancel`;
|
|
444
|
+
readonly getSinglePayments: `${string}/payment/single`;
|
|
445
|
+
readonly getSinglePayment: (id: string) => string;
|
|
446
|
+
readonly newSinglePayment: `${string}/payment/single/new`;
|
|
447
|
+
readonly finishStripe: `${string}/payment/stripe/subscription/finish`;
|
|
448
|
+
readonly finishFortis: `${string}/payment/fortis/subscription/finish`;
|
|
449
|
+
readonly newPaypal: `${string}/payment/paypal/subscription/new`;
|
|
450
|
+
};
|
|
451
|
+
readonly adminPayments: {
|
|
452
|
+
readonly bulkCancel: `${string}/payment/admin/bulk/cancel`;
|
|
453
|
+
readonly bulkStart: `${string}/payment/admin/bulk/start`;
|
|
454
|
+
readonly getBulk: `${string}/payment/admin/bulk`;
|
|
455
|
+
readonly cancelUserSubscription: (userId: string, subscriptionId: string) => string;
|
|
456
|
+
readonly getUserSubscription: (userId: string, subscriptionId: string) => string;
|
|
457
|
+
readonly getUserSubscriptions: (userId: string) => string;
|
|
458
|
+
readonly getUserSinglePayment: (userId: string, paymentId: string) => string;
|
|
459
|
+
readonly getUserSinglePayments: (userId: string) => string;
|
|
460
|
+
readonly reconcileUserSubscription: (userId: string, subscriptionId: string) => string;
|
|
461
|
+
readonly getSubscriptions: `${string}/payment/admin/subscriptions`;
|
|
462
|
+
};
|
|
463
|
+
readonly manualPayments: {
|
|
464
|
+
readonly adminCancelSubscription: (userId: string, subscriptionId: string) => string;
|
|
465
|
+
readonly cancelSubscription: (subscriptionId: string) => string;
|
|
466
|
+
readonly adminGetSubscription: (userId: string, subscriptionId: string) => string;
|
|
467
|
+
readonly adminGetSubscriptions: (userId: string) => string;
|
|
468
|
+
readonly getSubscriptions: `${string}/payment/manual/subscription`;
|
|
469
|
+
readonly getSubscription: (subscriptionId: string) => string;
|
|
470
|
+
readonly adminNewSubscription: (userId: string) => string;
|
|
471
|
+
readonly newSubscription: `${string}/payment/manual/subscription/new`;
|
|
472
|
+
};
|
|
473
|
+
readonly stats: {
|
|
474
|
+
readonly like: (contentId: string) => string;
|
|
475
|
+
readonly unlike: (contentId: string) => string;
|
|
476
|
+
readonly progress: (contentId: string) => string;
|
|
477
|
+
readonly save: (contentId: string) => string;
|
|
478
|
+
readonly unSave: (contentId: string) => string;
|
|
479
|
+
readonly logShare: (contentId: string) => string;
|
|
480
|
+
readonly getContentStats: (contentId: string) => string;
|
|
481
|
+
readonly getUserStats: (userId: string) => string;
|
|
482
|
+
readonly getCurrentUserStats: `${string}/stats/user`;
|
|
483
|
+
readonly getUserLikes: `${string}/stats/user/likes`;
|
|
484
|
+
readonly getUserProgress: `${string}/stats/user/progress`;
|
|
485
|
+
readonly getUserSaves: `${string}/stats/user/saves`;
|
|
486
|
+
};
|
|
487
|
+
};
|
|
488
|
+
call: <T>(url: string, options?: ApiCallOptions) => Promise<T>;
|
|
489
|
+
};
|
|
490
|
+
export type ApiClient = ReturnType<typeof createApiClient>;
|
|
491
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inverted-tech/fragments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Types and JS runtime for Inverted protocol buffers (Fragments)",
|
|
5
5
|
"types": "dist/protos/index.d.ts",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -297,9 +297,9 @@
|
|
|
297
297
|
"types": "./dist/protos/validation.d.ts",
|
|
298
298
|
"import": "./dist/esm/validation.js"
|
|
299
299
|
},
|
|
300
|
-
"./
|
|
301
|
-
"types": "./dist/protos/
|
|
302
|
-
"import": "./dist/esm/
|
|
300
|
+
"./api": {
|
|
301
|
+
"types": "./dist/protos/api.d.ts",
|
|
302
|
+
"import": "./dist/esm/api.js"
|
|
303
303
|
},
|
|
304
304
|
"./*": {
|
|
305
305
|
"types": "./dist/*",
|
|
@@ -330,7 +330,8 @@
|
|
|
330
330
|
"dependencies": {
|
|
331
331
|
"@bufbuild/protobuf": "^2.10.0",
|
|
332
332
|
"@bufbuild/protovalidate": "^1.0.0",
|
|
333
|
-
"@connectrpc/connect": "^1.7.0"
|
|
333
|
+
"@connectrpc/connect": "^1.7.0",
|
|
334
|
+
"pino": "^10.3.1"
|
|
334
335
|
},
|
|
335
336
|
"scripts": {
|
|
336
337
|
"gen": "node ./generate-ts.mjs && node ./scripts/fix-empty-indexes.mjs",
|
|
@@ -347,7 +348,7 @@
|
|
|
347
348
|
"lint": "eslint . --ext .ts",
|
|
348
349
|
"lint:gen": "eslint ts-gen --ext .ts",
|
|
349
350
|
"lint:gen:fix": "eslint ts-gen --ext .ts --fix",
|
|
350
|
-
"clean": "node -e \"const fs=require('fs'),path=require('path'); const rm=(p)=>fs.rmSync(p,{recursive:true,force:true}); if(fs.existsSync('dist')) rm('dist'); const base='ts-gen'; if(fs.existsSync(base)){ for(const ent of fs.readdirSync(base,{withFileTypes:true})) { if(ent.name==='validation.ts' || ent.name==='
|
|
351
|
+
"clean": "node -e \"const fs=require('fs'),path=require('path'); const rm=(p)=>fs.rmSync(p,{recursive:true,force:true}); if(fs.existsSync('dist')) rm('dist'); const base='ts-gen'; if(fs.existsSync(base)){ for(const ent of fs.readdirSync(base,{withFileTypes:true})) { if(ent.name==='validation.ts' || ent.name==='api.ts') continue; rm(path.join(base, ent.name)); } }\"",
|
|
351
352
|
"clean:pack": "node -e \"const fs=require('fs'); const path=require('path'); fs.rmSync('__pack_extract__',{recursive:true,force:true}); fs.readdirSync('.').filter(f=>f.endsWith('.tgz')).forEach(f=>fs.rmSync(path.join('.',f),{force:true})); console.log('Removed __pack_extract__ and *.tgz');\"",
|
|
352
353
|
"clean:dist": "node -e \"const fs=require('fs'); fs.rmSync('dist',{recursive:true,force:true});\"",
|
|
353
354
|
"rebuild": "npm run clean:dist && node ./scripts/ensure-gen.mjs && npm run build",
|