@fonderie/vue-courier-admin 0.2.0 → 0.3.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 +23 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -18
- package/dist/index.d.ts +4 -18
- package/dist/index.js +22 -69
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,69 +20,22 @@ 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: () =>
|
|
25
|
-
useDeleteTemplate: () => useDeleteTemplate,
|
|
26
|
-
useSaveTemplate: () => useSaveTemplate,
|
|
23
|
+
CourierAdminClient: () => import_client4.CourierAdminClient,
|
|
24
|
+
FonderieApiError: () => import_client4.FonderieApiError,
|
|
27
25
|
useTemplate: () => useTemplate,
|
|
28
26
|
useTemplateRevisions: () => useTemplateRevisions,
|
|
29
27
|
useTemplates: () => useTemplates
|
|
30
28
|
});
|
|
31
29
|
module.exports = __toCommonJS(index_exports);
|
|
32
|
-
var
|
|
30
|
+
var import_client4 = require("@fonderie/client");
|
|
33
31
|
|
|
34
|
-
// src/composables/
|
|
32
|
+
// src/composables/useTemplate.ts
|
|
35
33
|
var import_client = require("@fonderie/client");
|
|
36
34
|
var import_vue = require("vue");
|
|
37
|
-
function useDeleteTemplate(client) {
|
|
38
|
-
const isLoading = (0, import_vue.ref)(false);
|
|
39
|
-
const error = (0, import_vue.ref)(null);
|
|
40
|
-
async function deleteTemplate(type, locale) {
|
|
41
|
-
isLoading.value = true;
|
|
42
|
-
error.value = null;
|
|
43
|
-
try {
|
|
44
|
-
await client.deleteTemplate(type, locale);
|
|
45
|
-
} catch (err) {
|
|
46
|
-
const apiError = err instanceof import_client.FonderieApiError ? err : new import_client.FonderieApiError("unknown", String(err), 0);
|
|
47
|
-
error.value = apiError;
|
|
48
|
-
throw apiError;
|
|
49
|
-
} finally {
|
|
50
|
-
isLoading.value = false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return { deleteTemplate, isLoading, error };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// src/composables/useSaveTemplate.ts
|
|
57
|
-
var import_client2 = require("@fonderie/client");
|
|
58
|
-
var import_vue2 = require("vue");
|
|
59
|
-
function useSaveTemplate(client) {
|
|
60
|
-
const isLoading = (0, import_vue2.ref)(false);
|
|
61
|
-
const error = (0, import_vue2.ref)(null);
|
|
62
|
-
async function saveTemplate(type, input, locale) {
|
|
63
|
-
isLoading.value = true;
|
|
64
|
-
error.value = null;
|
|
65
|
-
try {
|
|
66
|
-
const { result } = await client.setTemplate(type, input, locale);
|
|
67
|
-
return result;
|
|
68
|
-
} catch (err) {
|
|
69
|
-
const apiError = err instanceof import_client2.FonderieApiError ? err : new import_client2.FonderieApiError("unknown", String(err), 0);
|
|
70
|
-
error.value = apiError;
|
|
71
|
-
throw apiError;
|
|
72
|
-
} finally {
|
|
73
|
-
isLoading.value = false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return { saveTemplate, isLoading, error };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// src/composables/useTemplate.ts
|
|
80
|
-
var import_client3 = require("@fonderie/client");
|
|
81
|
-
var import_vue3 = require("vue");
|
|
82
35
|
function useTemplate(client, type, locale) {
|
|
83
|
-
const template = (0,
|
|
84
|
-
const isLoading = (0,
|
|
85
|
-
const error = (0,
|
|
36
|
+
const template = (0, import_vue.ref)(null);
|
|
37
|
+
const isLoading = (0, import_vue.ref)(true);
|
|
38
|
+
const error = (0, import_vue.ref)(null);
|
|
86
39
|
async function refresh() {
|
|
87
40
|
isLoading.value = true;
|
|
88
41
|
error.value = null;
|
|
@@ -90,7 +43,7 @@ function useTemplate(client, type, locale) {
|
|
|
90
43
|
const { result } = await client.getTemplate(type, locale);
|
|
91
44
|
template.value = result;
|
|
92
45
|
} catch (err) {
|
|
93
|
-
const apiError = err instanceof
|
|
46
|
+
const apiError = err instanceof import_client.FonderieApiError ? err : new import_client.FonderieApiError("unknown", String(err), 0);
|
|
94
47
|
error.value = apiError;
|
|
95
48
|
} finally {
|
|
96
49
|
isLoading.value = false;
|
|
@@ -101,12 +54,12 @@ function useTemplate(client, type, locale) {
|
|
|
101
54
|
}
|
|
102
55
|
|
|
103
56
|
// src/composables/useTemplateRevisions.ts
|
|
104
|
-
var
|
|
105
|
-
var
|
|
57
|
+
var import_client2 = require("@fonderie/client");
|
|
58
|
+
var import_vue2 = require("vue");
|
|
106
59
|
function useTemplateRevisions(client, type, locale) {
|
|
107
|
-
const revisions = (0,
|
|
108
|
-
const isLoading = (0,
|
|
109
|
-
const error = (0,
|
|
60
|
+
const revisions = (0, import_vue2.ref)([]);
|
|
61
|
+
const isLoading = (0, import_vue2.ref)(true);
|
|
62
|
+
const error = (0, import_vue2.ref)(null);
|
|
110
63
|
async function refresh() {
|
|
111
64
|
isLoading.value = true;
|
|
112
65
|
error.value = null;
|
|
@@ -114,7 +67,7 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
114
67
|
const { result } = await client.listRevisions(type, locale);
|
|
115
68
|
revisions.value = result;
|
|
116
69
|
} catch (err) {
|
|
117
|
-
const apiError = err instanceof
|
|
70
|
+
const apiError = err instanceof import_client2.FonderieApiError ? err : new import_client2.FonderieApiError("unknown", String(err), 0);
|
|
118
71
|
error.value = apiError;
|
|
119
72
|
} finally {
|
|
120
73
|
isLoading.value = false;
|
|
@@ -127,7 +80,7 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
127
80
|
await refresh();
|
|
128
81
|
return result;
|
|
129
82
|
} catch (err) {
|
|
130
|
-
const apiError = err instanceof
|
|
83
|
+
const apiError = err instanceof import_client2.FonderieApiError ? err : new import_client2.FonderieApiError("unknown", String(err), 0);
|
|
131
84
|
error.value = apiError;
|
|
132
85
|
throw apiError;
|
|
133
86
|
}
|
|
@@ -137,12 +90,12 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
137
90
|
}
|
|
138
91
|
|
|
139
92
|
// src/composables/useTemplates.ts
|
|
140
|
-
var
|
|
141
|
-
var
|
|
93
|
+
var import_client3 = require("@fonderie/client");
|
|
94
|
+
var import_vue3 = require("vue");
|
|
142
95
|
function useTemplates(client) {
|
|
143
|
-
const templates = (0,
|
|
144
|
-
const isLoading = (0,
|
|
145
|
-
const error = (0,
|
|
96
|
+
const templates = (0, import_vue3.ref)([]);
|
|
97
|
+
const isLoading = (0, import_vue3.ref)(true);
|
|
98
|
+
const error = (0, import_vue3.ref)(null);
|
|
146
99
|
async function refresh() {
|
|
147
100
|
isLoading.value = true;
|
|
148
101
|
error.value = null;
|
|
@@ -150,7 +103,7 @@ function useTemplates(client) {
|
|
|
150
103
|
const { result } = await client.listTemplates();
|
|
151
104
|
templates.value = result;
|
|
152
105
|
} catch (err) {
|
|
153
|
-
const apiError = err instanceof
|
|
106
|
+
const apiError = err instanceof import_client3.FonderieApiError ? err : new import_client3.FonderieApiError("unknown", String(err), 0);
|
|
154
107
|
error.value = apiError;
|
|
155
108
|
} finally {
|
|
156
109
|
isLoading.value = false;
|
|
@@ -164,7 +117,7 @@ function useTemplates(client) {
|
|
|
164
117
|
await refresh();
|
|
165
118
|
return result;
|
|
166
119
|
} catch (err) {
|
|
167
|
-
const apiError = err instanceof
|
|
120
|
+
const apiError = err instanceof import_client3.FonderieApiError ? err : new import_client3.FonderieApiError("unknown", String(err), 0);
|
|
168
121
|
error.value = apiError;
|
|
169
122
|
throw apiError;
|
|
170
123
|
}
|
|
@@ -175,7 +128,7 @@ function useTemplates(client) {
|
|
|
175
128
|
await client.deleteTemplate(type, locale);
|
|
176
129
|
await refresh();
|
|
177
130
|
} catch (err) {
|
|
178
|
-
const apiError = err instanceof
|
|
131
|
+
const apiError = err instanceof import_client3.FonderieApiError ? err : new import_client3.FonderieApiError("unknown", String(err), 0);
|
|
179
132
|
error.value = apiError;
|
|
180
133
|
throw apiError;
|
|
181
134
|
}
|
|
@@ -186,8 +139,6 @@ function useTemplates(client) {
|
|
|
186
139
|
0 && (module.exports = {
|
|
187
140
|
CourierAdminClient,
|
|
188
141
|
FonderieApiError,
|
|
189
|
-
useDeleteTemplate,
|
|
190
|
-
useSaveTemplate,
|
|
191
142
|
useTemplate,
|
|
192
143
|
useTemplateRevisions,
|
|
193
144
|
useTemplates
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/composables/
|
|
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;AAQA,IAAAA,iBAAqD;;;ACPrD,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,CAAC;AACvF,YAAM,QAAQ;AAAA,IACf,UAAE;AACD,gBAAU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AAClB,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,cAAc;AAC9C,gBAAU,QAAQ;AAAA,IACnB,SAAS,KAAK;AACb,YAAM,WACL,eAAe,kCAAmB,MAAM,IAAI,gCAAiB,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,eAAe,kCAAmB,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"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import * as _fonderie_client from '@fonderie/client';
|
|
2
|
-
import { CourierAdminClient,
|
|
2
|
+
import { CourierAdminClient, ITemplateEntry, FonderieApiError, ITemplateRevision, ISetTemplateInput } from '@fonderie/client';
|
|
3
3
|
export { CourierAdminClient, FonderieApiError, ICourierAdminClientOptions, IRollbackTemplateInput, ISetTemplateInput, ITemplateEntry, ITemplateRevision } from '@fonderie/client';
|
|
4
4
|
import * as vue from 'vue';
|
|
5
5
|
|
|
6
|
-
/** @deprecated Use useTemplates(client).removeTemplate — the list composable self-refreshes after the write. */
|
|
7
|
-
declare function useDeleteTemplate(client: CourierAdminClient): {
|
|
8
|
-
deleteTemplate: (type: string, locale?: string | null) => Promise<void>;
|
|
9
|
-
isLoading: vue.Ref<boolean, boolean>;
|
|
10
|
-
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/** @deprecated Use useTemplates(client).saveTemplate — the list composable self-refreshes after the write. */
|
|
14
|
-
declare function useSaveTemplate(client: CourierAdminClient): {
|
|
15
|
-
saveTemplate: (type: string, input: ISetTemplateInput, locale?: string | null) => Promise<_fonderie_client.ITemplateEntry>;
|
|
16
|
-
isLoading: vue.Ref<boolean, boolean>;
|
|
17
|
-
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
6
|
declare function useTemplate(client: CourierAdminClient, type: string, locale?: string | null): {
|
|
21
7
|
template: vue.Ref<{
|
|
22
8
|
type: string;
|
|
@@ -95,8 +81,8 @@ declare function useTemplates(client: CourierAdminClient): {
|
|
|
95
81
|
isLoading: vue.Ref<boolean, boolean>;
|
|
96
82
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
97
83
|
refresh: () => Promise<void>;
|
|
98
|
-
saveTemplate: (type: string, input: ISetTemplateInput, locale?: string) => Promise<ITemplateEntry>;
|
|
99
|
-
removeTemplate: (type: string, locale?: string) => Promise<void>;
|
|
84
|
+
saveTemplate: (type: string, input: ISetTemplateInput, locale?: string | null) => Promise<ITemplateEntry>;
|
|
85
|
+
removeTemplate: (type: string, locale?: string | null) => Promise<void>;
|
|
100
86
|
};
|
|
101
87
|
|
|
102
|
-
export {
|
|
88
|
+
export { useTemplate, useTemplateRevisions, useTemplates };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import * as _fonderie_client from '@fonderie/client';
|
|
2
|
-
import { CourierAdminClient,
|
|
2
|
+
import { CourierAdminClient, ITemplateEntry, FonderieApiError, ITemplateRevision, ISetTemplateInput } from '@fonderie/client';
|
|
3
3
|
export { CourierAdminClient, FonderieApiError, ICourierAdminClientOptions, IRollbackTemplateInput, ISetTemplateInput, ITemplateEntry, ITemplateRevision } from '@fonderie/client';
|
|
4
4
|
import * as vue from 'vue';
|
|
5
5
|
|
|
6
|
-
/** @deprecated Use useTemplates(client).removeTemplate — the list composable self-refreshes after the write. */
|
|
7
|
-
declare function useDeleteTemplate(client: CourierAdminClient): {
|
|
8
|
-
deleteTemplate: (type: string, locale?: string | null) => Promise<void>;
|
|
9
|
-
isLoading: vue.Ref<boolean, boolean>;
|
|
10
|
-
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/** @deprecated Use useTemplates(client).saveTemplate — the list composable self-refreshes after the write. */
|
|
14
|
-
declare function useSaveTemplate(client: CourierAdminClient): {
|
|
15
|
-
saveTemplate: (type: string, input: ISetTemplateInput, locale?: string | null) => Promise<_fonderie_client.ITemplateEntry>;
|
|
16
|
-
isLoading: vue.Ref<boolean, boolean>;
|
|
17
|
-
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
6
|
declare function useTemplate(client: CourierAdminClient, type: string, locale?: string | null): {
|
|
21
7
|
template: vue.Ref<{
|
|
22
8
|
type: string;
|
|
@@ -95,8 +81,8 @@ declare function useTemplates(client: CourierAdminClient): {
|
|
|
95
81
|
isLoading: vue.Ref<boolean, boolean>;
|
|
96
82
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
97
83
|
refresh: () => Promise<void>;
|
|
98
|
-
saveTemplate: (type: string, input: ISetTemplateInput, locale?: string) => Promise<ITemplateEntry>;
|
|
99
|
-
removeTemplate: (type: string, locale?: string) => Promise<void>;
|
|
84
|
+
saveTemplate: (type: string, input: ISetTemplateInput, locale?: string | null) => Promise<ITemplateEntry>;
|
|
85
|
+
removeTemplate: (type: string, locale?: string | null) => Promise<void>;
|
|
100
86
|
};
|
|
101
87
|
|
|
102
|
-
export {
|
|
88
|
+
export { useTemplate, useTemplateRevisions, useTemplates };
|
package/dist/index.js
CHANGED
|
@@ -1,58 +1,13 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { CourierAdminClient, FonderieApiError as
|
|
2
|
+
import { CourierAdminClient, FonderieApiError as FonderieApiError4 } from "@fonderie/client";
|
|
3
3
|
|
|
4
|
-
// src/composables/
|
|
4
|
+
// src/composables/useTemplate.ts
|
|
5
5
|
import { FonderieApiError } from "@fonderie/client";
|
|
6
6
|
import { ref } from "vue";
|
|
7
|
-
function useDeleteTemplate(client) {
|
|
8
|
-
const isLoading = ref(false);
|
|
9
|
-
const error = ref(null);
|
|
10
|
-
async function deleteTemplate(type, locale) {
|
|
11
|
-
isLoading.value = true;
|
|
12
|
-
error.value = null;
|
|
13
|
-
try {
|
|
14
|
-
await client.deleteTemplate(type, locale);
|
|
15
|
-
} catch (err) {
|
|
16
|
-
const apiError = err instanceof FonderieApiError ? err : new FonderieApiError("unknown", String(err), 0);
|
|
17
|
-
error.value = apiError;
|
|
18
|
-
throw apiError;
|
|
19
|
-
} finally {
|
|
20
|
-
isLoading.value = false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return { deleteTemplate, isLoading, error };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// src/composables/useSaveTemplate.ts
|
|
27
|
-
import { FonderieApiError as FonderieApiError2 } from "@fonderie/client";
|
|
28
|
-
import { ref as ref2 } from "vue";
|
|
29
|
-
function useSaveTemplate(client) {
|
|
30
|
-
const isLoading = ref2(false);
|
|
31
|
-
const error = ref2(null);
|
|
32
|
-
async function saveTemplate(type, input, locale) {
|
|
33
|
-
isLoading.value = true;
|
|
34
|
-
error.value = null;
|
|
35
|
-
try {
|
|
36
|
-
const { result } = await client.setTemplate(type, input, locale);
|
|
37
|
-
return result;
|
|
38
|
-
} catch (err) {
|
|
39
|
-
const apiError = err instanceof FonderieApiError2 ? err : new FonderieApiError2("unknown", String(err), 0);
|
|
40
|
-
error.value = apiError;
|
|
41
|
-
throw apiError;
|
|
42
|
-
} finally {
|
|
43
|
-
isLoading.value = false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return { saveTemplate, isLoading, error };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/composables/useTemplate.ts
|
|
50
|
-
import { FonderieApiError as FonderieApiError3 } from "@fonderie/client";
|
|
51
|
-
import { ref as ref3 } from "vue";
|
|
52
7
|
function useTemplate(client, type, locale) {
|
|
53
|
-
const template =
|
|
54
|
-
const isLoading =
|
|
55
|
-
const error =
|
|
8
|
+
const template = ref(null);
|
|
9
|
+
const isLoading = ref(true);
|
|
10
|
+
const error = ref(null);
|
|
56
11
|
async function refresh() {
|
|
57
12
|
isLoading.value = true;
|
|
58
13
|
error.value = null;
|
|
@@ -60,7 +15,7 @@ function useTemplate(client, type, locale) {
|
|
|
60
15
|
const { result } = await client.getTemplate(type, locale);
|
|
61
16
|
template.value = result;
|
|
62
17
|
} catch (err) {
|
|
63
|
-
const apiError = err instanceof
|
|
18
|
+
const apiError = err instanceof FonderieApiError ? err : new FonderieApiError("unknown", String(err), 0);
|
|
64
19
|
error.value = apiError;
|
|
65
20
|
} finally {
|
|
66
21
|
isLoading.value = false;
|
|
@@ -71,12 +26,12 @@ function useTemplate(client, type, locale) {
|
|
|
71
26
|
}
|
|
72
27
|
|
|
73
28
|
// src/composables/useTemplateRevisions.ts
|
|
74
|
-
import { FonderieApiError as
|
|
75
|
-
import { ref as
|
|
29
|
+
import { FonderieApiError as FonderieApiError2 } from "@fonderie/client";
|
|
30
|
+
import { ref as ref2 } from "vue";
|
|
76
31
|
function useTemplateRevisions(client, type, locale) {
|
|
77
|
-
const revisions =
|
|
78
|
-
const isLoading =
|
|
79
|
-
const error =
|
|
32
|
+
const revisions = ref2([]);
|
|
33
|
+
const isLoading = ref2(true);
|
|
34
|
+
const error = ref2(null);
|
|
80
35
|
async function refresh() {
|
|
81
36
|
isLoading.value = true;
|
|
82
37
|
error.value = null;
|
|
@@ -84,7 +39,7 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
84
39
|
const { result } = await client.listRevisions(type, locale);
|
|
85
40
|
revisions.value = result;
|
|
86
41
|
} catch (err) {
|
|
87
|
-
const apiError = err instanceof
|
|
42
|
+
const apiError = err instanceof FonderieApiError2 ? err : new FonderieApiError2("unknown", String(err), 0);
|
|
88
43
|
error.value = apiError;
|
|
89
44
|
} finally {
|
|
90
45
|
isLoading.value = false;
|
|
@@ -97,7 +52,7 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
97
52
|
await refresh();
|
|
98
53
|
return result;
|
|
99
54
|
} catch (err) {
|
|
100
|
-
const apiError = err instanceof
|
|
55
|
+
const apiError = err instanceof FonderieApiError2 ? err : new FonderieApiError2("unknown", String(err), 0);
|
|
101
56
|
error.value = apiError;
|
|
102
57
|
throw apiError;
|
|
103
58
|
}
|
|
@@ -107,12 +62,12 @@ function useTemplateRevisions(client, type, locale) {
|
|
|
107
62
|
}
|
|
108
63
|
|
|
109
64
|
// src/composables/useTemplates.ts
|
|
110
|
-
import { FonderieApiError as
|
|
111
|
-
import { ref as
|
|
65
|
+
import { FonderieApiError as FonderieApiError3 } from "@fonderie/client";
|
|
66
|
+
import { ref as ref3 } from "vue";
|
|
112
67
|
function useTemplates(client) {
|
|
113
|
-
const templates =
|
|
114
|
-
const isLoading =
|
|
115
|
-
const error =
|
|
68
|
+
const templates = ref3([]);
|
|
69
|
+
const isLoading = ref3(true);
|
|
70
|
+
const error = ref3(null);
|
|
116
71
|
async function refresh() {
|
|
117
72
|
isLoading.value = true;
|
|
118
73
|
error.value = null;
|
|
@@ -120,7 +75,7 @@ function useTemplates(client) {
|
|
|
120
75
|
const { result } = await client.listTemplates();
|
|
121
76
|
templates.value = result;
|
|
122
77
|
} catch (err) {
|
|
123
|
-
const apiError = err instanceof
|
|
78
|
+
const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
|
|
124
79
|
error.value = apiError;
|
|
125
80
|
} finally {
|
|
126
81
|
isLoading.value = false;
|
|
@@ -134,7 +89,7 @@ function useTemplates(client) {
|
|
|
134
89
|
await refresh();
|
|
135
90
|
return result;
|
|
136
91
|
} catch (err) {
|
|
137
|
-
const apiError = err instanceof
|
|
92
|
+
const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
|
|
138
93
|
error.value = apiError;
|
|
139
94
|
throw apiError;
|
|
140
95
|
}
|
|
@@ -145,7 +100,7 @@ function useTemplates(client) {
|
|
|
145
100
|
await client.deleteTemplate(type, locale);
|
|
146
101
|
await refresh();
|
|
147
102
|
} catch (err) {
|
|
148
|
-
const apiError = err instanceof
|
|
103
|
+
const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
|
|
149
104
|
error.value = apiError;
|
|
150
105
|
throw apiError;
|
|
151
106
|
}
|
|
@@ -154,9 +109,7 @@ function useTemplates(client) {
|
|
|
154
109
|
}
|
|
155
110
|
export {
|
|
156
111
|
CourierAdminClient,
|
|
157
|
-
|
|
158
|
-
useDeleteTemplate,
|
|
159
|
-
useSaveTemplate,
|
|
112
|
+
FonderieApiError4 as FonderieApiError,
|
|
160
113
|
useTemplate,
|
|
161
114
|
useTemplateRevisions,
|
|
162
115
|
useTemplates
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/composables/
|
|
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":";AAQA,SAAS,oBAAoB,oBAAAA,yBAAwB;;;ACPrD,SAAS,wBAAwB;AACjC,SAAS,WAAW;AAEb,SAAS,YAAY,QAA4B,MAAc,QAAwB;AAC7F,QAAM,WAAW,IAA2B,IAAI;AAChD,QAAM,YAAY,IAAI,IAAI;AAC1B,QAAM,QAAQ,IAA6B,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,mBAAmB,MAAM,IAAI,iBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QAAQ;AAAA,IACf,UAAE;AACD,gBAAU,QAAQ;AAAA,IACnB;AAAA,EACD;AAEA,OAAK,QAAQ;AAEb,SAAO,EAAE,UAAU,WAAW,OAAO,QAAQ;AAC9C;;;AC1BA,SAAS,oBAAAC,yBAAwB;AACjC,SAAS,OAAAC,YAAW;AAEb,SAAS,qBACf,QACA,MACA,QACC;AACD,QAAM,YAAYA,KAAyB,CAAC,CAAC;AAC7C,QAAM,YAAYA,KAAI,IAAI;AAC1B,QAAM,QAAQA,KAA6B,IAAI;AAE/C,iBAAe,UAAU;AACxB,cAAU,QAAQ;AAClB,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,cAAc,MAAM,MAAM;AAC1D,gBAAU,QAAQ;AAAA,IACnB,SAAS,KAAK;AACb,YAAM,WACL,eAAeD,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QA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,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonderie/vue-courier-admin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|