@templatical/core 0.51.1 → 0.52.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloud/index.d.ts +0 -34
- package/dist/cloud/index.js +17 -34
- package/dist/cloud/index.js.map +1 -1
- package/dist/index.d.ts +0 -28
- package/dist/index.js +14 -28
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cloud/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AuthConfig, AuthRequestOptions, Block, CommentResponse, CommentsProvider, CustomFont, ExportResult, FontsConfig, HealthCheckResult, MediaProvider, PlanConfig, PlanFeatures, RenderProvider, SavedBlock, SavedBlocksProvider, SdkAuthConfig, Template, TemplateContent, TemplatePatch, TemplateVersionResponse, TemplatesProvider, TestEmailConfig, TestEmailProvider, UserConfig, VersionHistoryProvider, WebSocketServerConfig } from "@templatical/types";
|
|
2
2
|
import { ComputedRef, Ref } from "vue";
|
|
3
3
|
import { Channel, PresenceChannel } from "pusher-js";
|
|
4
|
-
//#region src/cloud/auth.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Whether a token-refresh failure is worth interrupting the user over.
|
|
7
6
|
*
|
|
@@ -51,8 +50,6 @@ export declare class AuthManager {
|
|
|
51
50
|
authenticatedFetch(url: string, options?: RequestInit): Promise<Response>;
|
|
52
51
|
}
|
|
53
52
|
export declare function createSdkAuthManager(config: SdkAuthConfig, onError?: (error: Error) => void): AuthManager;
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/cloud/api.d.ts
|
|
56
53
|
export declare class ApiClient {
|
|
57
54
|
private readonly authManager;
|
|
58
55
|
constructor(authManager: AuthManager);
|
|
@@ -128,8 +125,6 @@ export declare class ApiClient {
|
|
|
128
125
|
}>): Promise<SavedBlock>;
|
|
129
126
|
deleteModule(id: string): Promise<void>;
|
|
130
127
|
}
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/cloud/media-api.d.ts
|
|
133
128
|
/**
|
|
134
129
|
* Cloud's HTTP row for one media file. Same field names as
|
|
135
130
|
* {@link MediaAsset}. `thumbnailUrl` is optional; omit it and the grid
|
|
@@ -210,8 +205,6 @@ export declare class MediaApiClient {
|
|
|
210
205
|
importFromUrl(url: string, folderId?: string | null): Promise<CloudMediaItem>;
|
|
211
206
|
replaceMedia(mediaId: string, file: File): Promise<CloudMediaItem>;
|
|
212
207
|
}
|
|
213
|
-
//#endregion
|
|
214
|
-
//#region src/cloud/url-builder.d.ts
|
|
215
208
|
export declare function buildUrl(template: string, params: Record<string, string>): string;
|
|
216
209
|
export declare const API_ROUTES: {
|
|
217
210
|
readonly health: "/api/v1/health";
|
|
@@ -251,8 +244,6 @@ export declare const API_ROUTES: {
|
|
|
251
244
|
readonly "savedModules.update": "/api/v1/projects/{project}/tenants/{tenant}/saved-modules/{savedModule}";
|
|
252
245
|
readonly "savedModules.destroy": "/api/v1/projects/{project}/tenants/{tenant}/saved-modules/{savedModule}";
|
|
253
246
|
};
|
|
254
|
-
//#endregion
|
|
255
|
-
//#region src/cloud/websocket-client.d.ts
|
|
256
247
|
interface WebSocketConfig {
|
|
257
248
|
host: string;
|
|
258
249
|
port: number;
|
|
@@ -283,8 +274,6 @@ export declare class WebSocketClient {
|
|
|
283
274
|
getSocketId(): string | null;
|
|
284
275
|
get isConnected(): boolean;
|
|
285
276
|
}
|
|
286
|
-
//#endregion
|
|
287
|
-
//#region src/cloud/comments-provider.d.ts
|
|
288
277
|
/**
|
|
289
278
|
* The two methods this adapter needs from a Pusher channel, named structurally.
|
|
290
279
|
*
|
|
@@ -337,8 +326,6 @@ interface CreateCloudCommentsProviderOptions {
|
|
|
337
326
|
* header is fine too.
|
|
338
327
|
*/
|
|
339
328
|
export declare function createCloudCommentsProvider(options: CreateCloudCommentsProviderOptions): CommentsProvider;
|
|
340
|
-
//#endregion
|
|
341
|
-
//#region src/cloud/web-socket.d.ts
|
|
342
329
|
interface UseWebSocketOptions {
|
|
343
330
|
authManager: AuthManager;
|
|
344
331
|
onError?: (error: Error) => void;
|
|
@@ -351,8 +338,6 @@ interface UseWebSocketReturn {
|
|
|
351
338
|
getSocketId: () => string | null;
|
|
352
339
|
}
|
|
353
340
|
export declare function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn;
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region src/cloud/saved-blocks-provider.d.ts
|
|
356
341
|
/**
|
|
357
342
|
* Cloud-backed {@link SavedBlocksProvider} — the Templatical Cloud adapter for
|
|
358
343
|
* the same contract consumers implement themselves.
|
|
@@ -374,8 +359,6 @@ export declare function useWebSocket(options: UseWebSocketOptions): UseWebSocket
|
|
|
374
359
|
* to "no timestamp label, every action allowed" rather than breaking.
|
|
375
360
|
*/
|
|
376
361
|
export declare function createCloudSavedBlocksProvider(authManager: AuthManager): SavedBlocksProvider;
|
|
377
|
-
//#endregion
|
|
378
|
-
//#region src/cloud/media-provider.d.ts
|
|
379
362
|
/**
|
|
380
363
|
* Cloud-backed {@link MediaProvider} — the Templatical Cloud adapter for the
|
|
381
364
|
* same DAM contract consumers implement themselves.
|
|
@@ -395,8 +378,6 @@ export declare function createCloudSavedBlocksProvider(authManager: AuthManager)
|
|
|
395
378
|
* freezes the getters — `initCloud()` must `Object.assign`, never spread.
|
|
396
379
|
*/
|
|
397
380
|
export declare function createCloudMediaProvider(authManager: AuthManager, getPlanConfig?: () => PlanConfig | null): MediaProvider;
|
|
398
|
-
//#endregion
|
|
399
|
-
//#region src/cloud/templates-provider.d.ts
|
|
400
381
|
/**
|
|
401
382
|
* Cloud-backed {@link TemplatesProvider} — the Templatical Cloud adapter for the
|
|
402
383
|
* same save/load contract consumers implement themselves.
|
|
@@ -424,8 +405,6 @@ export declare function createCloudMediaProvider(authManager: AuthManager, getPl
|
|
|
424
405
|
* degrade all six silently.
|
|
425
406
|
*/
|
|
426
407
|
export declare function createCloudTemplatesProvider(authManager: AuthManager): TemplatesProvider;
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region src/cloud/render-provider.d.ts
|
|
429
408
|
interface CreateCloudRenderProviderOptions {
|
|
430
409
|
authManager: AuthManager;
|
|
431
410
|
/** The loaded template's id, or `null` before one exists. */
|
|
@@ -463,8 +442,6 @@ interface CreateCloudRenderProviderOptions {
|
|
|
463
442
|
* compiling.
|
|
464
443
|
*/
|
|
465
444
|
export declare function createCloudRenderProvider(options: CreateCloudRenderProviderOptions): RenderProvider;
|
|
466
|
-
//#endregion
|
|
467
|
-
//#region src/cloud/version-history-provider.d.ts
|
|
468
445
|
/**
|
|
469
446
|
* Cloud-backed {@link VersionHistoryProvider} — the Templatical Cloud adapter for
|
|
470
447
|
* the same contract consumers implement themselves.
|
|
@@ -479,8 +456,6 @@ export declare function createCloudRenderProvider(options: CreateCloudRenderProv
|
|
|
479
456
|
* `create` here is for a version a person asked for.
|
|
480
457
|
*/
|
|
481
458
|
export declare function createCloudVersionHistoryProvider(authManager: AuthManager): VersionHistoryProvider;
|
|
482
|
-
//#endregion
|
|
483
|
-
//#region src/cloud/test-email.d.ts
|
|
484
459
|
/**
|
|
485
460
|
* Cloud's test-email *configuration* — whether the project has the feature, who
|
|
486
461
|
* may be sent to, and the signature that lets the backend verify that list.
|
|
@@ -508,8 +483,6 @@ interface UseTestEmailReturn {
|
|
|
508
483
|
getSignature: () => string | null;
|
|
509
484
|
}
|
|
510
485
|
export declare function useTestEmail(options: UseTestEmailOptions): UseTestEmailReturn;
|
|
511
|
-
//#endregion
|
|
512
|
-
//#region src/cloud/test-email-provider.d.ts
|
|
513
486
|
interface CreateCloudTestEmailProviderOptions {
|
|
514
487
|
authManager: AuthManager;
|
|
515
488
|
getTemplateId: () => string | null;
|
|
@@ -542,8 +515,6 @@ interface CreateCloudTestEmailProviderOptions {
|
|
|
542
515
|
* should not spend a render pass producing MJML nobody reads.
|
|
543
516
|
*/
|
|
544
517
|
export declare function createCloudTestEmailProvider(options: CreateCloudTestEmailProviderOptions): TestEmailProvider;
|
|
545
|
-
//#endregion
|
|
546
|
-
//#region src/cloud/export.d.ts
|
|
547
518
|
/** The fonts half of an export request, as Cloud's endpoint expects it. */
|
|
548
519
|
interface ExportFontsPayload {
|
|
549
520
|
customFonts: CustomFont[];
|
|
@@ -571,8 +542,6 @@ export declare function resolveExportFonts(fonts: FontsConfig | undefined): Expo
|
|
|
571
542
|
* policy lives.
|
|
572
543
|
*/
|
|
573
544
|
export declare function useExport(options: UseExportOptions): UseExportReturn;
|
|
574
|
-
//#endregion
|
|
575
|
-
//#region src/cloud/plan-config.d.ts
|
|
576
545
|
interface UsePlanConfigOptions {
|
|
577
546
|
authManager: AuthManager;
|
|
578
547
|
onError?: (error: Error) => void;
|
|
@@ -585,13 +554,10 @@ interface UsePlanConfigReturn {
|
|
|
585
554
|
fetchConfig: () => Promise<void>;
|
|
586
555
|
}
|
|
587
556
|
export declare function usePlanConfig(options: UsePlanConfigOptions): UsePlanConfigReturn;
|
|
588
|
-
//#endregion
|
|
589
|
-
//#region src/cloud/health-check.d.ts
|
|
590
557
|
interface HealthCheckOptions {
|
|
591
558
|
authManager?: AuthManager;
|
|
592
559
|
baseUrl?: string;
|
|
593
560
|
}
|
|
594
561
|
export declare function performHealthCheck(options?: HealthCheckOptions): Promise<HealthCheckResult>;
|
|
595
|
-
//#endregion
|
|
596
562
|
export type { AuthConfig, AuthRequestOptions, CloudMediaBrowseParams, CloudMediaBrowseResponse, CloudMediaFolder, CloudMediaItem, CloudMediaUsageInfo, CloudMediaUsageResponse, CreateCloudCommentsProviderOptions, CreateCloudRenderProviderOptions, CreateCloudTestEmailProviderOptions, ExportFontsPayload, PresenceMember, RealtimeChannel, SdkAuthConfig, TestEmailConfig, UseExportOptions, UseExportReturn, UsePlanConfigOptions, UsePlanConfigReturn, UseTestEmailOptions, UseTestEmailReturn, UseWebSocketOptions, UseWebSocketReturn, UserConfig, WebSocketClientOptions, WebSocketConfig };
|
|
597
563
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cloud/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SdkError } from "@templatical/types";
|
|
2
2
|
import { computed, ref, watch } from "vue";
|
|
3
|
-
|
|
3
|
+
// src/cloud/auth.ts
|
|
4
4
|
/**
|
|
5
5
|
* Whether a token-refresh failure is worth interrupting the user over.
|
|
6
6
|
*
|
|
@@ -171,8 +171,7 @@ function createSdkAuthManager(config, onError) {
|
|
|
171
171
|
onError
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
|
|
175
|
-
//#region src/cloud/url-builder.ts
|
|
174
|
+
// src/cloud/url-builder.ts
|
|
176
175
|
function buildUrl(template, params) {
|
|
177
176
|
return template.replace(/\{(\w+)\}/g, (_, key) => encodeURIComponent(params[key] ?? ""));
|
|
178
177
|
}
|
|
@@ -219,8 +218,7 @@ const API_ROUTES = {
|
|
|
219
218
|
"savedModules.update": `${MODULES}/{savedModule}`,
|
|
220
219
|
"savedModules.destroy": `${MODULES}/{savedModule}`
|
|
221
220
|
};
|
|
222
|
-
|
|
223
|
-
//#region src/cloud/api.ts
|
|
221
|
+
// src/cloud/api.ts
|
|
224
222
|
var ApiClient = class {
|
|
225
223
|
authManager;
|
|
226
224
|
constructor(authManager) {
|
|
@@ -431,8 +429,7 @@ var ApiClient = class {
|
|
|
431
429
|
}), { method: "DELETE" });
|
|
432
430
|
}
|
|
433
431
|
};
|
|
434
|
-
|
|
435
|
-
//#region src/cloud/media-api.ts
|
|
432
|
+
// src/cloud/media-api.ts
|
|
436
433
|
/**
|
|
437
434
|
* Cloud's HTTP client for media. Auth and project/tenant scoping come from
|
|
438
435
|
* {@link AuthManager}. The BYO contract lives on
|
|
@@ -603,8 +600,7 @@ var MediaApiClient = class {
|
|
|
603
600
|
return (await response.json()).data;
|
|
604
601
|
}
|
|
605
602
|
};
|
|
606
|
-
|
|
607
|
-
//#region src/cloud/websocket-client.ts
|
|
603
|
+
// src/cloud/websocket-client.ts
|
|
608
604
|
function resolveWebSocketConfig(serverConfig) {
|
|
609
605
|
return {
|
|
610
606
|
host: serverConfig.host,
|
|
@@ -684,8 +680,7 @@ var WebSocketClient = class {
|
|
|
684
680
|
return this.pusher?.connection.state === "connected";
|
|
685
681
|
}
|
|
686
682
|
};
|
|
687
|
-
|
|
688
|
-
//#region src/cloud/comments-provider.ts
|
|
683
|
+
// src/cloud/comments-provider.ts
|
|
689
684
|
/** The Pusher event Cloud's backend fans comment writes out on. */
|
|
690
685
|
const BROADCAST_EVENT = "comment-broadcast";
|
|
691
686
|
/**
|
|
@@ -808,8 +803,7 @@ function createCloudCommentsProvider(options) {
|
|
|
808
803
|
}
|
|
809
804
|
};
|
|
810
805
|
}
|
|
811
|
-
|
|
812
|
-
//#region src/cloud/web-socket.ts
|
|
806
|
+
// src/cloud/web-socket.ts
|
|
813
807
|
function useWebSocket(options) {
|
|
814
808
|
const { authManager, onError } = options;
|
|
815
809
|
const channel = ref(null);
|
|
@@ -855,8 +849,7 @@ function useWebSocket(options) {
|
|
|
855
849
|
getSocketId
|
|
856
850
|
};
|
|
857
851
|
}
|
|
858
|
-
|
|
859
|
-
//#region src/cloud/saved-blocks-provider.ts
|
|
852
|
+
// src/cloud/saved-blocks-provider.ts
|
|
860
853
|
/**
|
|
861
854
|
* Cloud-backed {@link SavedBlocksProvider} — the Templatical Cloud adapter for
|
|
862
855
|
* the same contract consumers implement themselves.
|
|
@@ -894,8 +887,7 @@ function createCloudSavedBlocksProvider(authManager) {
|
|
|
894
887
|
}
|
|
895
888
|
};
|
|
896
889
|
}
|
|
897
|
-
|
|
898
|
-
//#region src/cloud/media-provider.ts
|
|
890
|
+
// src/cloud/media-provider.ts
|
|
899
891
|
/**
|
|
900
892
|
* Cloud's HTTP row → {@link MediaAsset}. Omits null optionals so
|
|
901
893
|
* `thumbnailUrl` / `width` / `height` are absent rather than `null` —
|
|
@@ -1040,8 +1032,7 @@ function createCloudMediaProvider(authManager, getPlanConfig) {
|
|
|
1040
1032
|
}
|
|
1041
1033
|
};
|
|
1042
1034
|
}
|
|
1043
|
-
|
|
1044
|
-
//#region src/cloud/templates-provider.ts
|
|
1035
|
+
// src/cloud/templates-provider.ts
|
|
1045
1036
|
/**
|
|
1046
1037
|
* How often a save may also record an automatic version. Cloud's storage, Cloud's
|
|
1047
1038
|
* number — an editor-side default would be guessing on someone else's behalf.
|
|
@@ -1108,8 +1099,7 @@ function createCloudTemplatesProvider(authManager) {
|
|
|
1108
1099
|
}
|
|
1109
1100
|
};
|
|
1110
1101
|
}
|
|
1111
|
-
|
|
1112
|
-
//#region src/cloud/export.ts
|
|
1102
|
+
// src/cloud/export.ts
|
|
1113
1103
|
/**
|
|
1114
1104
|
* Flatten a {@link FontsConfig} into the export payload.
|
|
1115
1105
|
*
|
|
@@ -1146,8 +1136,7 @@ function useExport(options) {
|
|
|
1146
1136
|
getMjmlSource
|
|
1147
1137
|
};
|
|
1148
1138
|
}
|
|
1149
|
-
|
|
1150
|
-
//#region src/cloud/render-provider.ts
|
|
1139
|
+
// src/cloud/render-provider.ts
|
|
1151
1140
|
/**
|
|
1152
1141
|
* Templatical Cloud's renderer, shaped as a {@link RenderProvider} so it plugs
|
|
1153
1142
|
* into the same editor seam a consumer's own backend would.
|
|
@@ -1203,8 +1192,7 @@ function createCloudRenderProvider(options) {
|
|
|
1203
1192
|
}
|
|
1204
1193
|
};
|
|
1205
1194
|
}
|
|
1206
|
-
|
|
1207
|
-
//#region src/cloud/version-history-provider.ts
|
|
1195
|
+
// src/cloud/version-history-provider.ts
|
|
1208
1196
|
/**
|
|
1209
1197
|
* Cloud's HTTP row → {@link TemplateVersion}. Copies the contract fields
|
|
1210
1198
|
* and drops `templateId`.
|
|
@@ -1254,8 +1242,7 @@ function createCloudVersionHistoryProvider(authManager) {
|
|
|
1254
1242
|
}
|
|
1255
1243
|
};
|
|
1256
1244
|
}
|
|
1257
|
-
|
|
1258
|
-
//#region src/cloud/test-email.ts
|
|
1245
|
+
// src/cloud/test-email.ts
|
|
1259
1246
|
function useTestEmail(options) {
|
|
1260
1247
|
const { authManager, isAuthReady } = options;
|
|
1261
1248
|
const testEmailConfig = ref(null);
|
|
@@ -1273,8 +1260,7 @@ function useTestEmail(options) {
|
|
|
1273
1260
|
getSignature
|
|
1274
1261
|
};
|
|
1275
1262
|
}
|
|
1276
|
-
|
|
1277
|
-
//#region src/cloud/test-email-provider.ts
|
|
1263
|
+
// src/cloud/test-email-provider.ts
|
|
1278
1264
|
/**
|
|
1279
1265
|
* Templatical Cloud's test-email sender, shaped as a {@link TestEmailProvider}
|
|
1280
1266
|
* so it plugs into the same editor seam a consumer's own sender would.
|
|
@@ -1320,8 +1306,7 @@ function createCloudTestEmailProvider(options) {
|
|
|
1320
1306
|
}
|
|
1321
1307
|
};
|
|
1322
1308
|
}
|
|
1323
|
-
|
|
1324
|
-
//#region src/cloud/plan-config.ts
|
|
1309
|
+
// src/cloud/plan-config.ts
|
|
1325
1310
|
function usePlanConfig(options) {
|
|
1326
1311
|
const { authManager, onError } = options;
|
|
1327
1312
|
const config = ref(null);
|
|
@@ -1350,8 +1335,7 @@ function usePlanConfig(options) {
|
|
|
1350
1335
|
fetchConfig
|
|
1351
1336
|
};
|
|
1352
1337
|
}
|
|
1353
|
-
|
|
1354
|
-
//#region src/cloud/health-check.ts
|
|
1338
|
+
// src/cloud/health-check.ts
|
|
1355
1339
|
const WS_HANDSHAKE_TIMEOUT = 5e3;
|
|
1356
1340
|
function resolveHealthUrl(options) {
|
|
1357
1341
|
if (options.authManager) return options.authManager.resolveUrl(API_ROUTES.health);
|
|
@@ -1463,7 +1447,6 @@ async function performHealthCheck(options = {}) {
|
|
|
1463
1447
|
overall: result.api.ok && result.auth.ok
|
|
1464
1448
|
};
|
|
1465
1449
|
}
|
|
1466
|
-
//#endregion
|
|
1467
1450
|
export { API_ROUTES, ApiClient, AuthManager, MediaApiClient, WebSocketClient, buildUrl, createCloudCommentsProvider, createCloudMediaProvider, createCloudRenderProvider, createCloudSavedBlocksProvider, createCloudTemplatesProvider, createCloudTestEmailProvider, createCloudVersionHistoryProvider, createSdkAuthManager, isFatalAuthError, performHealthCheck, resolveExportFonts, resolveWebSocketConfig, useExport, usePlanConfig, useTestEmail, useWebSocket };
|
|
1468
1451
|
|
|
1469
1452
|
//# sourceMappingURL=index.js.map
|