@fonderie/vue-courier-admin 0.3.0 → 0.4.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/dist/index.cjs +47 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +45 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -20,14 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
CourierAdminClient: () =>
|
|
24
|
-
FonderieApiError: () =>
|
|
23
|
+
CourierAdminClient: () => import_client5.CourierAdminClient,
|
|
24
|
+
FonderieApiError: () => import_client5.FonderieApiError,
|
|
25
25
|
useTemplate: () => useTemplate,
|
|
26
|
+
useTemplatePreview: () => useTemplatePreview,
|
|
26
27
|
useTemplateRevisions: () => useTemplateRevisions,
|
|
27
28
|
useTemplates: () => useTemplates
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(index_exports);
|
|
30
|
-
var
|
|
31
|
+
var import_client5 = require("@fonderie/client");
|
|
31
32
|
|
|
32
33
|
// src/composables/useTemplate.ts
|
|
33
34
|
var import_client = require("@fonderie/client");
|
|
@@ -53,13 +54,41 @@ function useTemplate(client, type, locale) {
|
|
|
53
54
|
return { template, isLoading, error, refresh };
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
// src/composables/
|
|
57
|
+
// src/composables/useTemplatePreview.ts
|
|
57
58
|
var import_client2 = require("@fonderie/client");
|
|
58
59
|
var import_vue2 = require("vue");
|
|
59
|
-
function
|
|
60
|
-
const
|
|
61
|
-
const
|
|
60
|
+
function useTemplatePreview(client) {
|
|
61
|
+
const preview = (0, import_vue2.ref)(null);
|
|
62
|
+
const isPreviewing = (0, import_vue2.ref)(false);
|
|
62
63
|
const error = (0, import_vue2.ref)(null);
|
|
64
|
+
async function renderPreview(type, input, locale) {
|
|
65
|
+
isPreviewing.value = true;
|
|
66
|
+
error.value = null;
|
|
67
|
+
try {
|
|
68
|
+
const { result } = await client.previewTemplate(type, input, locale);
|
|
69
|
+
preview.value = result;
|
|
70
|
+
return result;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
const apiError = err instanceof import_client2.FonderieApiError ? err : new import_client2.FonderieApiError("unknown", String(err), 0);
|
|
73
|
+
error.value = apiError;
|
|
74
|
+
throw apiError;
|
|
75
|
+
} finally {
|
|
76
|
+
isPreviewing.value = false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const clearPreview = () => {
|
|
80
|
+
preview.value = null;
|
|
81
|
+
};
|
|
82
|
+
return { preview, isPreviewing, error, renderPreview, clearPreview };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/composables/useTemplateRevisions.ts
|
|
86
|
+
var import_client3 = require("@fonderie/client");
|
|
87
|
+
var import_vue3 = require("vue");
|
|
88
|
+
function useTemplateRevisions(client, type, locale) {
|
|
89
|
+
const revisions = (0, import_vue3.ref)([]);
|
|
90
|
+
const isLoading = (0, import_vue3.ref)(true);
|
|
91
|
+
const error = (0, import_vue3.ref)(null);
|
|
63
92
|
async function refresh() {
|
|
64
93
|
isLoading.value = true;
|
|
65
94
|
error.value = null;
|
|
@@ -67,7 +96,7 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
67
96
|
const { result } = await client.listRevisions(type, locale);
|
|
68
97
|
revisions.value = result;
|
|
69
98
|
} catch (err) {
|
|
70
|
-
const apiError = err instanceof
|
|
99
|
+
const apiError = err instanceof import_client3.FonderieApiError ? err : new import_client3.FonderieApiError("unknown", String(err), 0);
|
|
71
100
|
error.value = apiError;
|
|
72
101
|
} finally {
|
|
73
102
|
isLoading.value = false;
|
|
@@ -80,7 +109,7 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
80
109
|
await refresh();
|
|
81
110
|
return result;
|
|
82
111
|
} catch (err) {
|
|
83
|
-
const apiError = err instanceof
|
|
112
|
+
const apiError = err instanceof import_client3.FonderieApiError ? err : new import_client3.FonderieApiError("unknown", String(err), 0);
|
|
84
113
|
error.value = apiError;
|
|
85
114
|
throw apiError;
|
|
86
115
|
}
|
|
@@ -90,12 +119,12 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
90
119
|
}
|
|
91
120
|
|
|
92
121
|
// src/composables/useTemplates.ts
|
|
93
|
-
var
|
|
94
|
-
var
|
|
122
|
+
var import_client4 = require("@fonderie/client");
|
|
123
|
+
var import_vue4 = require("vue");
|
|
95
124
|
function useTemplates(client) {
|
|
96
|
-
const templates = (0,
|
|
97
|
-
const isLoading = (0,
|
|
98
|
-
const error = (0,
|
|
125
|
+
const templates = (0, import_vue4.ref)([]);
|
|
126
|
+
const isLoading = (0, import_vue4.ref)(true);
|
|
127
|
+
const error = (0, import_vue4.ref)(null);
|
|
99
128
|
async function refresh() {
|
|
100
129
|
isLoading.value = true;
|
|
101
130
|
error.value = null;
|
|
@@ -103,7 +132,7 @@ function useTemplates(client) {
|
|
|
103
132
|
const { result } = await client.listTemplates();
|
|
104
133
|
templates.value = result;
|
|
105
134
|
} catch (err) {
|
|
106
|
-
const apiError = err instanceof
|
|
135
|
+
const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
|
|
107
136
|
error.value = apiError;
|
|
108
137
|
} finally {
|
|
109
138
|
isLoading.value = false;
|
|
@@ -117,7 +146,7 @@ function useTemplates(client) {
|
|
|
117
146
|
await refresh();
|
|
118
147
|
return result;
|
|
119
148
|
} catch (err) {
|
|
120
|
-
const apiError = err instanceof
|
|
149
|
+
const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
|
|
121
150
|
error.value = apiError;
|
|
122
151
|
throw apiError;
|
|
123
152
|
}
|
|
@@ -128,7 +157,7 @@ function useTemplates(client) {
|
|
|
128
157
|
await client.deleteTemplate(type, locale);
|
|
129
158
|
await refresh();
|
|
130
159
|
} catch (err) {
|
|
131
|
-
const apiError = err instanceof
|
|
160
|
+
const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
|
|
132
161
|
error.value = apiError;
|
|
133
162
|
throw apiError;
|
|
134
163
|
}
|
|
@@ -140,6 +169,7 @@ function useTemplates(client) {
|
|
|
140
169
|
CourierAdminClient,
|
|
141
170
|
FonderieApiError,
|
|
142
171
|
useTemplate,
|
|
172
|
+
useTemplatePreview,
|
|
143
173
|
useTemplateRevisions,
|
|
144
174
|
useTemplates
|
|
145
175
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/composables/useTemplate.ts","../src/composables/useTemplateRevisions.ts","../src/composables/useTemplates.ts"],"sourcesContent":["export type {\n\tICourierAdminClientOptions,\n\tIRollbackTemplateInput,\n\tISetTemplateInput,\n\tITemplateEntry,\n\tITemplateRevision,\n} from '@fonderie/client';\n\nexport { CourierAdminClient, FonderieApiError } from '@fonderie/client';\nexport {\n\tuseTemplate,\n\tuseTemplateRevisions,\n\tuseTemplates,\n} from './composables';\n","import type { CourierAdminClient, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplate(client: CourierAdminClient, type: string, locale?: string | null) {\n\tconst template = ref<ITemplateEntry | null>(null);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.getTemplate(type, locale);\n\t\t\ttemplate.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\treturn { template, isLoading, error, refresh };\n}\n","import type { CourierAdminClient, ITemplateRevision } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplateRevisions(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n) {\n\tconst revisions = ref<ITemplateRevision[]>([]);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.listRevisions(type, locale);\n\t\t\trevisions.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tasync function rollback(toVersion: number) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.rollback(type, { toVersion }, locale);\n\t\t\tawait refresh();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\treturn { revisions, isLoading, error, refresh, rollback };\n}\n","import type { CourierAdminClient, ISetTemplateInput, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplates(client: CourierAdminClient) {\n\tconst templates = ref<ITemplateEntry[]>([]);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.listTemplates();\n\t\t\ttemplates.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\tasync function saveTemplate(type: string, input: ISetTemplateInput, locale?: string | null) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.setTemplate(type, input, locale);\n\t\t\tawait refresh();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\tasync function removeTemplate(type: string, locale?: string | null) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait client.deleteTemplate(type, locale);\n\t\t\tawait refresh();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\treturn { templates, isLoading, error, refresh, saveTemplate, removeTemplate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/composables/useTemplate.ts","../src/composables/useTemplatePreview.ts","../src/composables/useTemplateRevisions.ts","../src/composables/useTemplates.ts"],"sourcesContent":["export type {\n\tICourierAdminClientOptions,\n\tIPreviewTemplateInput,\n\tIRenderedTemplateResult,\n\tIRollbackTemplateInput,\n\tISetTemplateInput,\n\tITemplateEntry,\n\tITemplateRevision,\n} from '@fonderie/client';\n\nexport { CourierAdminClient, FonderieApiError } from '@fonderie/client';\nexport {\n\tuseTemplate,\n\tuseTemplatePreview,\n\tuseTemplateRevisions,\n\tuseTemplates,\n} from './composables';\n","import type { CourierAdminClient, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplate(client: CourierAdminClient, type: string, locale?: string | null) {\n\tconst template = ref<ITemplateEntry | null>(null);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.getTemplate(type, locale);\n\t\t\ttemplate.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\treturn { template, isLoading, error, refresh };\n}\n","import type {\n\tCourierAdminClient,\n\tIPreviewTemplateInput,\n\tIRenderedTemplateResult,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\n// On demand, not on mount: the caller decides when the editor's content is\n// worth rendering. Server-side, so what comes back is what the resolver\n// produces — the layout shell and the variable substitution included.\nexport function useTemplatePreview(client: CourierAdminClient) {\n\tconst preview = ref<IRenderedTemplateResult | null>(null);\n\tconst isPreviewing = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function renderPreview(\n\t\ttype: string,\n\t\tinput: IPreviewTemplateInput,\n\t\tlocale?: string | null,\n\t): Promise<IRenderedTemplateResult> {\n\t\tisPreviewing.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.previewTemplate(type, input, locale);\n\t\t\tpreview.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisPreviewing.value = false;\n\t\t}\n\t}\n\n\tconst clearPreview = () => {\n\t\tpreview.value = null;\n\t};\n\n\treturn { preview, isPreviewing, error, renderPreview, clearPreview };\n}\n","import type { CourierAdminClient, ITemplateRevision } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplateRevisions(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n) {\n\tconst revisions = ref<ITemplateRevision[]>([]);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.listRevisions(type, locale);\n\t\t\trevisions.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tasync function rollback(toVersion: number) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.rollback(type, { toVersion }, locale);\n\t\t\tawait refresh();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\treturn { revisions, isLoading, error, refresh, rollback };\n}\n","import type { CourierAdminClient, ISetTemplateInput, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplates(client: CourierAdminClient) {\n\tconst templates = ref<ITemplateEntry[]>([]);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.listTemplates();\n\t\t\ttemplates.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\tasync function saveTemplate(type: string, input: ISetTemplateInput, locale?: string | null) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.setTemplate(type, input, locale);\n\t\t\tawait refresh();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\tasync function removeTemplate(type: string, locale?: string | null) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait client.deleteTemplate(type, locale);\n\t\t\tawait refresh();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\treturn { templates, isLoading, error, refresh, saveTemplate, removeTemplate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,IAAAA,iBAAqD;;;ACTrD,oBAAiC;AACjC,iBAAoB;AAEb,SAAS,YAAY,QAA4B,MAAc,QAAwB;AAC7F,QAAM,eAAW,gBAA2B,IAAI;AAChD,QAAM,gBAAY,gBAAI,IAAI;AAC1B,QAAM,YAAQ,gBAA6B,IAAI;AAE/C,iBAAe,UAAU;AACxB,cAAU,QAAQ;AAClB,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,YAAY,MAAM,MAAM;AACxD,eAAS,QAAQ;AAAA,IAClB,SAAS,KAAK;AACb,YAAM,WACL,eAAe,iCAAmB,MAAM,IAAI,+BAAiB,WAAW,OAAO,GAAG,GAAG,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AAmB,MAAM,IAAI,gCAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QAAQ;AACd,YAAM;AAAA,IACP;AAAA,EACD;AAEA,iBAAe,eAAe,MAAc,QAAwB;AACnE,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,OAAO,eAAe,MAAM,MAAM;AACxC,YAAM,QAAQ;AAAA,IACf,SAAS,KAAK;AACb,YAAM,WACL,eAAe,kCAAmB,MAAM,IAAI,gCAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QAAQ;AACd,YAAM;AAAA,IACP;AAAA,EACD;AAEA,SAAO,EAAE,WAAW,WAAW,OAAO,SAAS,cAAc,eAAe;AAC7E;","names":["import_client","import_client","import_vue","import_client","import_vue","import_client","import_vue"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _fonderie_client from '@fonderie/client';
|
|
2
|
-
import { CourierAdminClient, ITemplateEntry, FonderieApiError, ITemplateRevision, ISetTemplateInput } from '@fonderie/client';
|
|
3
|
-
export { CourierAdminClient, FonderieApiError, ICourierAdminClientOptions, IRollbackTemplateInput, ISetTemplateInput, ITemplateEntry, ITemplateRevision } from '@fonderie/client';
|
|
2
|
+
import { CourierAdminClient, ITemplateEntry, FonderieApiError, IRenderedTemplateResult, IPreviewTemplateInput, ITemplateRevision, ISetTemplateInput } from '@fonderie/client';
|
|
3
|
+
export { CourierAdminClient, FonderieApiError, ICourierAdminClientOptions, IPreviewTemplateInput, IRenderedTemplateResult, IRollbackTemplateInput, ISetTemplateInput, ITemplateEntry, ITemplateRevision } from '@fonderie/client';
|
|
4
4
|
import * as vue from 'vue';
|
|
5
5
|
|
|
6
6
|
declare function useTemplate(client: CourierAdminClient, type: string, locale?: string | null): {
|
|
@@ -30,6 +30,24 @@ declare function useTemplate(client: CourierAdminClient, type: string, locale?:
|
|
|
30
30
|
refresh: () => Promise<void>;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
declare function useTemplatePreview(client: CourierAdminClient): {
|
|
34
|
+
preview: vue.Ref<{
|
|
35
|
+
subject?: string;
|
|
36
|
+
html?: string;
|
|
37
|
+
text: string;
|
|
38
|
+
variables: string[];
|
|
39
|
+
} | null, IRenderedTemplateResult | {
|
|
40
|
+
subject?: string;
|
|
41
|
+
html?: string;
|
|
42
|
+
text: string;
|
|
43
|
+
variables: string[];
|
|
44
|
+
} | null>;
|
|
45
|
+
isPreviewing: vue.Ref<boolean, boolean>;
|
|
46
|
+
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
47
|
+
renderPreview: (type: string, input: IPreviewTemplateInput, locale?: string | null) => Promise<IRenderedTemplateResult>;
|
|
48
|
+
clearPreview: () => void;
|
|
49
|
+
};
|
|
50
|
+
|
|
33
51
|
declare function useTemplateRevisions(client: CourierAdminClient, type: string, locale?: string | null): {
|
|
34
52
|
revisions: vue.Ref<{
|
|
35
53
|
type: string;
|
|
@@ -85,4 +103,4 @@ declare function useTemplates(client: CourierAdminClient): {
|
|
|
85
103
|
removeTemplate: (type: string, locale?: string | null) => Promise<void>;
|
|
86
104
|
};
|
|
87
105
|
|
|
88
|
-
export { useTemplate, useTemplateRevisions, useTemplates };
|
|
106
|
+
export { useTemplate, useTemplatePreview, useTemplateRevisions, useTemplates };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _fonderie_client from '@fonderie/client';
|
|
2
|
-
import { CourierAdminClient, ITemplateEntry, FonderieApiError, ITemplateRevision, ISetTemplateInput } from '@fonderie/client';
|
|
3
|
-
export { CourierAdminClient, FonderieApiError, ICourierAdminClientOptions, IRollbackTemplateInput, ISetTemplateInput, ITemplateEntry, ITemplateRevision } from '@fonderie/client';
|
|
2
|
+
import { CourierAdminClient, ITemplateEntry, FonderieApiError, IRenderedTemplateResult, IPreviewTemplateInput, ITemplateRevision, ISetTemplateInput } from '@fonderie/client';
|
|
3
|
+
export { CourierAdminClient, FonderieApiError, ICourierAdminClientOptions, IPreviewTemplateInput, IRenderedTemplateResult, IRollbackTemplateInput, ISetTemplateInput, ITemplateEntry, ITemplateRevision } from '@fonderie/client';
|
|
4
4
|
import * as vue from 'vue';
|
|
5
5
|
|
|
6
6
|
declare function useTemplate(client: CourierAdminClient, type: string, locale?: string | null): {
|
|
@@ -30,6 +30,24 @@ declare function useTemplate(client: CourierAdminClient, type: string, locale?:
|
|
|
30
30
|
refresh: () => Promise<void>;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
declare function useTemplatePreview(client: CourierAdminClient): {
|
|
34
|
+
preview: vue.Ref<{
|
|
35
|
+
subject?: string;
|
|
36
|
+
html?: string;
|
|
37
|
+
text: string;
|
|
38
|
+
variables: string[];
|
|
39
|
+
} | null, IRenderedTemplateResult | {
|
|
40
|
+
subject?: string;
|
|
41
|
+
html?: string;
|
|
42
|
+
text: string;
|
|
43
|
+
variables: string[];
|
|
44
|
+
} | null>;
|
|
45
|
+
isPreviewing: vue.Ref<boolean, boolean>;
|
|
46
|
+
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
47
|
+
renderPreview: (type: string, input: IPreviewTemplateInput, locale?: string | null) => Promise<IRenderedTemplateResult>;
|
|
48
|
+
clearPreview: () => void;
|
|
49
|
+
};
|
|
50
|
+
|
|
33
51
|
declare function useTemplateRevisions(client: CourierAdminClient, type: string, locale?: string | null): {
|
|
34
52
|
revisions: vue.Ref<{
|
|
35
53
|
type: string;
|
|
@@ -85,4 +103,4 @@ declare function useTemplates(client: CourierAdminClient): {
|
|
|
85
103
|
removeTemplate: (type: string, locale?: string | null) => Promise<void>;
|
|
86
104
|
};
|
|
87
105
|
|
|
88
|
-
export { useTemplate, useTemplateRevisions, useTemplates };
|
|
106
|
+
export { useTemplate, useTemplatePreview, useTemplateRevisions, useTemplates };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { CourierAdminClient, FonderieApiError as
|
|
2
|
+
import { CourierAdminClient, FonderieApiError as FonderieApiError5 } from "@fonderie/client";
|
|
3
3
|
|
|
4
4
|
// src/composables/useTemplate.ts
|
|
5
5
|
import { FonderieApiError } from "@fonderie/client";
|
|
@@ -25,13 +25,41 @@ function useTemplate(client, type, locale) {
|
|
|
25
25
|
return { template, isLoading, error, refresh };
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// src/composables/
|
|
28
|
+
// src/composables/useTemplatePreview.ts
|
|
29
29
|
import { FonderieApiError as FonderieApiError2 } from "@fonderie/client";
|
|
30
30
|
import { ref as ref2 } from "vue";
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
const
|
|
31
|
+
function useTemplatePreview(client) {
|
|
32
|
+
const preview = ref2(null);
|
|
33
|
+
const isPreviewing = ref2(false);
|
|
34
34
|
const error = ref2(null);
|
|
35
|
+
async function renderPreview(type, input, locale) {
|
|
36
|
+
isPreviewing.value = true;
|
|
37
|
+
error.value = null;
|
|
38
|
+
try {
|
|
39
|
+
const { result } = await client.previewTemplate(type, input, locale);
|
|
40
|
+
preview.value = result;
|
|
41
|
+
return result;
|
|
42
|
+
} catch (err) {
|
|
43
|
+
const apiError = err instanceof FonderieApiError2 ? err : new FonderieApiError2("unknown", String(err), 0);
|
|
44
|
+
error.value = apiError;
|
|
45
|
+
throw apiError;
|
|
46
|
+
} finally {
|
|
47
|
+
isPreviewing.value = false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const clearPreview = () => {
|
|
51
|
+
preview.value = null;
|
|
52
|
+
};
|
|
53
|
+
return { preview, isPreviewing, error, renderPreview, clearPreview };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/composables/useTemplateRevisions.ts
|
|
57
|
+
import { FonderieApiError as FonderieApiError3 } from "@fonderie/client";
|
|
58
|
+
import { ref as ref3 } from "vue";
|
|
59
|
+
function useTemplateRevisions(client, type, locale) {
|
|
60
|
+
const revisions = ref3([]);
|
|
61
|
+
const isLoading = ref3(true);
|
|
62
|
+
const error = ref3(null);
|
|
35
63
|
async function refresh() {
|
|
36
64
|
isLoading.value = true;
|
|
37
65
|
error.value = null;
|
|
@@ -39,7 +67,7 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
39
67
|
const { result } = await client.listRevisions(type, locale);
|
|
40
68
|
revisions.value = result;
|
|
41
69
|
} catch (err) {
|
|
42
|
-
const apiError = err instanceof
|
|
70
|
+
const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
|
|
43
71
|
error.value = apiError;
|
|
44
72
|
} finally {
|
|
45
73
|
isLoading.value = false;
|
|
@@ -52,7 +80,7 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
52
80
|
await refresh();
|
|
53
81
|
return result;
|
|
54
82
|
} catch (err) {
|
|
55
|
-
const apiError = err instanceof
|
|
83
|
+
const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
|
|
56
84
|
error.value = apiError;
|
|
57
85
|
throw apiError;
|
|
58
86
|
}
|
|
@@ -62,12 +90,12 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
62
90
|
}
|
|
63
91
|
|
|
64
92
|
// src/composables/useTemplates.ts
|
|
65
|
-
import { FonderieApiError as
|
|
66
|
-
import { ref as
|
|
93
|
+
import { FonderieApiError as FonderieApiError4 } from "@fonderie/client";
|
|
94
|
+
import { ref as ref4 } from "vue";
|
|
67
95
|
function useTemplates(client) {
|
|
68
|
-
const templates =
|
|
69
|
-
const isLoading =
|
|
70
|
-
const error =
|
|
96
|
+
const templates = ref4([]);
|
|
97
|
+
const isLoading = ref4(true);
|
|
98
|
+
const error = ref4(null);
|
|
71
99
|
async function refresh() {
|
|
72
100
|
isLoading.value = true;
|
|
73
101
|
error.value = null;
|
|
@@ -75,7 +103,7 @@ function useTemplates(client) {
|
|
|
75
103
|
const { result } = await client.listTemplates();
|
|
76
104
|
templates.value = result;
|
|
77
105
|
} catch (err) {
|
|
78
|
-
const apiError = err instanceof
|
|
106
|
+
const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
|
|
79
107
|
error.value = apiError;
|
|
80
108
|
} finally {
|
|
81
109
|
isLoading.value = false;
|
|
@@ -89,7 +117,7 @@ function useTemplates(client) {
|
|
|
89
117
|
await refresh();
|
|
90
118
|
return result;
|
|
91
119
|
} catch (err) {
|
|
92
|
-
const apiError = err instanceof
|
|
120
|
+
const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
|
|
93
121
|
error.value = apiError;
|
|
94
122
|
throw apiError;
|
|
95
123
|
}
|
|
@@ -100,7 +128,7 @@ function useTemplates(client) {
|
|
|
100
128
|
await client.deleteTemplate(type, locale);
|
|
101
129
|
await refresh();
|
|
102
130
|
} catch (err) {
|
|
103
|
-
const apiError = err instanceof
|
|
131
|
+
const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
|
|
104
132
|
error.value = apiError;
|
|
105
133
|
throw apiError;
|
|
106
134
|
}
|
|
@@ -109,8 +137,9 @@ function useTemplates(client) {
|
|
|
109
137
|
}
|
|
110
138
|
export {
|
|
111
139
|
CourierAdminClient,
|
|
112
|
-
|
|
140
|
+
FonderieApiError5 as FonderieApiError,
|
|
113
141
|
useTemplate,
|
|
142
|
+
useTemplatePreview,
|
|
114
143
|
useTemplateRevisions,
|
|
115
144
|
useTemplates
|
|
116
145
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/composables/useTemplate.ts","../src/composables/useTemplateRevisions.ts","../src/composables/useTemplates.ts"],"sourcesContent":["export type {\n\tICourierAdminClientOptions,\n\tIRollbackTemplateInput,\n\tISetTemplateInput,\n\tITemplateEntry,\n\tITemplateRevision,\n} from '@fonderie/client';\n\nexport { CourierAdminClient, FonderieApiError } from '@fonderie/client';\nexport {\n\tuseTemplate,\n\tuseTemplateRevisions,\n\tuseTemplates,\n} from './composables';\n","import type { CourierAdminClient, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplate(client: CourierAdminClient, type: string, locale?: string | null) {\n\tconst template = ref<ITemplateEntry | null>(null);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.getTemplate(type, locale);\n\t\t\ttemplate.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\treturn { template, isLoading, error, refresh };\n}\n","import type { CourierAdminClient, ITemplateRevision } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplateRevisions(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n) {\n\tconst revisions = ref<ITemplateRevision[]>([]);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.listRevisions(type, locale);\n\t\t\trevisions.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tasync function rollback(toVersion: number) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.rollback(type, { toVersion }, locale);\n\t\t\tawait refresh();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\treturn { revisions, isLoading, error, refresh, rollback };\n}\n","import type { CourierAdminClient, ISetTemplateInput, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplates(client: CourierAdminClient) {\n\tconst templates = ref<ITemplateEntry[]>([]);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.listTemplates();\n\t\t\ttemplates.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\tasync function saveTemplate(type: string, input: ISetTemplateInput, locale?: string | null) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.setTemplate(type, input, locale);\n\t\t\tawait refresh();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\tasync function removeTemplate(type: string, locale?: string | null) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait client.deleteTemplate(type, locale);\n\t\t\tawait refresh();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\treturn { templates, isLoading, error, refresh, saveTemplate, removeTemplate };\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/composables/useTemplate.ts","../src/composables/useTemplatePreview.ts","../src/composables/useTemplateRevisions.ts","../src/composables/useTemplates.ts"],"sourcesContent":["export type {\n\tICourierAdminClientOptions,\n\tIPreviewTemplateInput,\n\tIRenderedTemplateResult,\n\tIRollbackTemplateInput,\n\tISetTemplateInput,\n\tITemplateEntry,\n\tITemplateRevision,\n} from '@fonderie/client';\n\nexport { CourierAdminClient, FonderieApiError } from '@fonderie/client';\nexport {\n\tuseTemplate,\n\tuseTemplatePreview,\n\tuseTemplateRevisions,\n\tuseTemplates,\n} from './composables';\n","import type { CourierAdminClient, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplate(client: CourierAdminClient, type: string, locale?: string | null) {\n\tconst template = ref<ITemplateEntry | null>(null);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.getTemplate(type, locale);\n\t\t\ttemplate.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\treturn { template, isLoading, error, refresh };\n}\n","import type {\n\tCourierAdminClient,\n\tIPreviewTemplateInput,\n\tIRenderedTemplateResult,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\n// On demand, not on mount: the caller decides when the editor's content is\n// worth rendering. Server-side, so what comes back is what the resolver\n// produces — the layout shell and the variable substitution included.\nexport function useTemplatePreview(client: CourierAdminClient) {\n\tconst preview = ref<IRenderedTemplateResult | null>(null);\n\tconst isPreviewing = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function renderPreview(\n\t\ttype: string,\n\t\tinput: IPreviewTemplateInput,\n\t\tlocale?: string | null,\n\t): Promise<IRenderedTemplateResult> {\n\t\tisPreviewing.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.previewTemplate(type, input, locale);\n\t\t\tpreview.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisPreviewing.value = false;\n\t\t}\n\t}\n\n\tconst clearPreview = () => {\n\t\tpreview.value = null;\n\t};\n\n\treturn { preview, isPreviewing, error, renderPreview, clearPreview };\n}\n","import type { CourierAdminClient, ITemplateRevision } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplateRevisions(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n) {\n\tconst revisions = ref<ITemplateRevision[]>([]);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.listRevisions(type, locale);\n\t\t\trevisions.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tasync function rollback(toVersion: number) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.rollback(type, { toVersion }, locale);\n\t\t\tawait refresh();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\treturn { revisions, isLoading, error, refresh, rollback };\n}\n","import type { CourierAdminClient, ISetTemplateInput, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useTemplates(client: CourierAdminClient) {\n\tconst templates = ref<ITemplateEntry[]>([]);\n\tconst isLoading = ref(true);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.listTemplates();\n\t\t\ttemplates.value = result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tvoid refresh();\n\n\tasync function saveTemplate(type: string, input: ISetTemplateInput, locale?: string | null) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.setTemplate(type, input, locale);\n\t\t\tawait refresh();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\tasync function removeTemplate(type: string, locale?: string | null) {\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait client.deleteTemplate(type, locale);\n\t\t\tawait refresh();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t}\n\t}\n\n\treturn { templates, isLoading, error, refresh, saveTemplate, removeTemplate };\n}\n"],"mappings":";AAUA,SAAS,oBAAoB,oBAAAA,yBAAwB;;;ACTrD,SAAS,wBAAwB;AACjC,SAAS,WAAW;AAEb,SAAS,YAAY,QAA4B,MAAc,QAAwB;A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AAeD,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QAAQ;AAAA,IACf,UAAE;AACD,gBAAU,QAAQ;AAAA,IACnB;AAAA,EACD;AAEA,OAAK,QAAQ;AAEb,iBAAe,aAAa,MAAc,OAA0B,QAAwB;AAC3F,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,YAAY,MAAM,OAAO,MAAM;AAC/D,YAAM,QAAQ;AACd,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,WACL,eAAeA,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QAAQ;AACd,YAAM;AAAA,IACP;AAAA,EACD;AAEA,iBAAe,eAAe,MAAc,QAAwB;AACnE,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,OAAO,eAAe,MAAM,MAAM;AACxC,YAAM,QAAQ;AAAA,IACf,SAAS,KAAK;AACb,YAAM,WACL,eAAeA,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QAAQ;AACd,YAAM;AAAA,IACP;AAAA,EACD;AAEA,SAAO,EAAE,WAAW,WAAW,OAAO,SAAS,cAAc,eAAe;AAC7E;","names":["FonderieApiError","FonderieApiError","ref","FonderieApiError","ref","FonderieApiError","ref"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonderie/vue-courier-admin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Vue 3 composables for the Fonderie courier admin API (email/SMS/push template management) — thin bindings over @fonderie/client's CourierAdminClient.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fonderiejs",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"vue": ">=3.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/node": "^26.
|
|
44
|
+
"@types/node": "^26.6.1",
|
|
45
45
|
"tsup": "^8.5.1",
|
|
46
46
|
"typescript": "^6.0.3",
|
|
47
|
-
"vue": "^3.5.
|
|
47
|
+
"vue": "^3.5.43"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|