@fonderie/react-courier-admin 0.3.0 → 0.4.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  React hooks for the Fonderie courier admin API — `useTemplates`,
4
4
  `useTemplate`, `useSaveTemplate`, `useDeleteTemplate`, and
5
5
  `useTemplateRevisions` (list + rollback). Thin bindings over
6
- [`@fonderie/client`](https://github.com/fonderiejs/sdk/tree/main/packages/client)'s
6
+ [`@fonderie/client`](https://github.com/fonderiejs/fonderie/tree/main/packages/client)'s
7
7
  `CourierAdminClient`: loading/error state and the request itself, nothing
8
8
  else. Bring your own UI.
9
9
 
@@ -48,14 +48,14 @@ session — the same model `@fonderie/config`'s admin surface and the
48
48
  `AuthClient`/`BillingClient`/`WorkspacesClient`.
49
49
 
50
50
  Want pre-built screens instead of wiring your own editor?
51
- See [`@fonderie/react-courier-admin-screens`](https://github.com/fonderiejs/sdk/tree/main/packages/react-courier-admin-screens).
51
+ See [`@fonderie/react-courier-admin-screens`](https://github.com/fonderiejs/fonderie/tree/main/packages/react-courier-admin-screens).
52
52
 
53
53
  ## Why this exists
54
54
 
55
55
  You've shipped this plumbing before — auth, teams, billing, messaging —
56
56
  and the next project will ask for it again. Fonderie packages it once:
57
57
  plain TypeScript modules for
58
- [`@fonderie/core`](https://github.com/fonderiejs/sdk/tree/main/packages/core),
58
+ [`@fonderie/core`](https://github.com/fonderiejs/fonderie/tree/main/packages/core),
59
59
  PostgreSQL-backed, self-hosted, MIT. No external control plane, no
60
60
  per-seat anything. Register the modules you need; skip the ones you don't.
61
61
 
@@ -64,7 +64,7 @@ state management around `@fonderie/client`, nothing more. No business logic
64
64
  lives here; it lives in `@fonderie/courier` on the server.
65
65
 
66
66
  Browse the whole set at
67
- [fonderiejs/sdk](https://github.com/fonderiejs/sdk) · follow
67
+ [fonderiejs/fonderie](https://github.com/fonderiejs/fonderie) · follow
68
68
  [@fonderiejs](https://x.com/fonderiejs)
69
69
 
70
70
  ## License
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: () => import_client4.CourierAdminClient,
24
- FonderieApiError: () => import_client4.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 import_client4 = require("@fonderie/client");
31
+ var import_client5 = require("@fonderie/client");
31
32
 
32
33
  // src/hooks/useTemplate.ts
33
34
  var import_client = require("@fonderie/client");
@@ -150,11 +151,41 @@ function useTemplates(client) {
150
151
  }, [refresh]);
151
152
  return { templates, isLoading, error, refresh, saveTemplate, removeTemplate };
152
153
  }
154
+
155
+ // src/hooks/useTemplatePreview.ts
156
+ var import_client4 = require("@fonderie/client");
157
+ var import_react4 = require("react");
158
+ function useTemplatePreview(client) {
159
+ const [preview, setPreview] = (0, import_react4.useState)(null);
160
+ const [isPreviewing, setIsPreviewing] = (0, import_react4.useState)(false);
161
+ const [error, setError] = (0, import_react4.useState)(null);
162
+ const renderPreview = (0, import_react4.useCallback)(
163
+ async (type, input, locale) => {
164
+ setIsPreviewing(true);
165
+ setError(null);
166
+ try {
167
+ const { result } = await client.previewTemplate(type, input, locale);
168
+ setPreview(result);
169
+ return result;
170
+ } catch (err) {
171
+ const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
172
+ setError(apiError);
173
+ throw apiError;
174
+ } finally {
175
+ setIsPreviewing(false);
176
+ }
177
+ },
178
+ [client]
179
+ );
180
+ const clearPreview = (0, import_react4.useCallback)(() => setPreview(null), []);
181
+ return { preview, isPreviewing, error, renderPreview, clearPreview };
182
+ }
153
183
  // Annotate the CommonJS export names for ESM import in node:
154
184
  0 && (module.exports = {
155
185
  CourierAdminClient,
156
186
  FonderieApiError,
157
187
  useTemplate,
188
+ useTemplatePreview,
158
189
  useTemplateRevisions,
159
190
  useTemplates
160
191
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/hooks/useTemplate.ts","../src/hooks/useTemplateRevisions.ts","../src/hooks/useTemplates.ts"],"sourcesContent":["export type {\n\tICourierAdminClientOptions,\n\tIRollbackTemplateInput,\n\tISetTemplateInput,\n\tITemplateEntry,\n\tITemplateRevision,\n} from '@fonderie/client';\nexport { CourierAdminClient, FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseTemplateReturn,\n\tIUseTemplateRevisionsReturn,\n\tIUseTemplatesReturn,\n} from './hooks';\nexport {\n\tuseTemplate,\n\tuseTemplateRevisions,\n\tuseTemplates,\n} from './hooks';\n","import type { CourierAdminClient, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplateReturn {\n\ttemplate: ITemplateEntry | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n}\n\nexport function useTemplate(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n): IUseTemplateReturn {\n\tconst [template, setTemplate] = useState<ITemplateEntry | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.getTemplate(type, locale);\n\t\t\tsetTemplate(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client, type, locale]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { template, isLoading, error, refresh };\n}\n","import type { CourierAdminClient, ITemplateEntry, ITemplateRevision } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplateRevisionsReturn {\n\trevisions: ITemplateRevision[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n\trollback: (toVersion: number) => Promise<ITemplateEntry>;\n}\n\nexport function useTemplateRevisions(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n): IUseTemplateRevisionsReturn {\n\tconst [revisions, setRevisions] = useState<ITemplateRevision[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.listRevisions(type, locale);\n\t\t\tsetRevisions(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client, type, locale]);\n\n\tconst rollback = useCallback(\n\t\tasync (toVersion: number) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.rollback(type, { toVersion }, locale);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, type, locale, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [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 { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplatesReturn {\n\ttemplates: ITemplateEntry[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n\tsaveTemplate: (\n\t\ttype: string,\n\t\tinput: ISetTemplateInput,\n\t\tlocale?: string | null,\n\t) => Promise<ITemplateEntry>;\n\tremoveTemplate: (type: string, locale?: string | null) => Promise<void>;\n}\n\nexport function useTemplates(client: CourierAdminClient): IUseTemplatesReturn {\n\tconst [templates, setTemplates] = useState<ITemplateEntry[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.listTemplates();\n\t\t\tsetTemplates(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client]);\n\n\tconst saveTemplate = useCallback(\n\t\tasync (type: string, input: ISetTemplateInput, locale?: string | null) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.setTemplate(type, input, locale);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, refresh],\n\t);\n\n\tconst removeTemplate = useCallback(\n\t\tasync (type: string, locale?: string | null) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait client.deleteTemplate(type, locale);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { templates, isLoading, error, refresh, saveTemplate, removeTemplate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,IAAAA,iBAAqD;;;ACNrD,oBAAiC;AACjC,mBAAiD;AAS1C,SAAS,YACf,QACA,MACA,QACqB;AACrB,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAgC,IAAI;AACpE,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,IAAI;AAC/C,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAkC,IAAI;AAEhE,QAAM,cAAU,0BAAY,YAAY;AACvC,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,YAAY,MAAM,MAAM;AACxD,kBAAY,MAAM;AAAA,IACnB,SAAS,KAAK;AACb,YAAM,WACL,eAAe,iCAAmB,MAAM,IAAI,+BAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AAAA,IAClB,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,QAAQ,MAAM,MAAM,CAAC;AAEzB,8BAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,UAAU,WAAW,OAAO,QAAQ;AAC9C;;;ACvCA,IAAAC,iBAAiC;AACjC,IAA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ACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,WAAW,WAAW,OAAO,SAAS,cAAc,eAAe;AAC7E;","names":["import_client","import_client","import_react","import_client","import_react"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/hooks/useTemplate.ts","../src/hooks/useTemplateRevisions.ts","../src/hooks/useTemplates.ts","../src/hooks/useTemplatePreview.ts"],"sourcesContent":["export type {\n\tICourierAdminClientOptions,\n\tIPreviewTemplateInput,\n\tIRenderedTemplateResult,\n\tIRollbackTemplateInput,\n\tISetTemplateInput,\n\tITemplateEntry,\n\tITemplateRevision,\n} from '@fonderie/client';\nexport { CourierAdminClient, FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseTemplatePreviewReturn,\n\tIUseTemplateReturn,\n\tIUseTemplateRevisionsReturn,\n\tIUseTemplatesReturn,\n} from './hooks';\nexport {\n\tuseTemplate,\n\tuseTemplatePreview,\n\tuseTemplateRevisions,\n\tuseTemplates,\n} from './hooks';\n","import type { CourierAdminClient, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplateReturn {\n\ttemplate: ITemplateEntry | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n}\n\nexport function useTemplate(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n): IUseTemplateReturn {\n\tconst [template, setTemplate] = useState<ITemplateEntry | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.getTemplate(type, locale);\n\t\t\tsetTemplate(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client, type, locale]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { template, isLoading, error, refresh };\n}\n","import type { CourierAdminClient, ITemplateEntry, ITemplateRevision } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplateRevisionsReturn {\n\trevisions: ITemplateRevision[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n\trollback: (toVersion: number) => Promise<ITemplateEntry>;\n}\n\nexport function useTemplateRevisions(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n): IUseTemplateRevisionsReturn {\n\tconst [revisions, setRevisions] = useState<ITemplateRevision[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.listRevisions(type, locale);\n\t\t\tsetRevisions(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client, type, locale]);\n\n\tconst rollback = useCallback(\n\t\tasync (toVersion: number) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.rollback(type, { toVersion }, locale);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, type, locale, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [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 { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplatesReturn {\n\ttemplates: ITemplateEntry[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n\tsaveTemplate: (\n\t\ttype: string,\n\t\tinput: ISetTemplateInput,\n\t\tlocale?: string | null,\n\t) => Promise<ITemplateEntry>;\n\tremoveTemplate: (type: string, locale?: string | null) => Promise<void>;\n}\n\nexport function useTemplates(client: CourierAdminClient): IUseTemplatesReturn {\n\tconst [templates, setTemplates] = useState<ITemplateEntry[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.listTemplates();\n\t\t\tsetTemplates(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client]);\n\n\tconst saveTemplate = useCallback(\n\t\tasync (type: string, input: ISetTemplateInput, locale?: string | null) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.setTemplate(type, input, locale);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, refresh],\n\t);\n\n\tconst removeTemplate = useCallback(\n\t\tasync (type: string, locale?: string | null) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait client.deleteTemplate(type, locale);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { templates, isLoading, error, refresh, saveTemplate, removeTemplate };\n}\n","import type {\n\tCourierAdminClient,\n\tIPreviewTemplateInput,\n\tIRenderedTemplateResult,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseTemplatePreviewReturn {\n\tpreview: IRenderedTemplateResult | null;\n\tisPreviewing: boolean;\n\terror: FonderieApiError | null;\n\trenderPreview: (\n\t\ttype: string,\n\t\tinput: IPreviewTemplateInput,\n\t\tlocale?: string | null,\n\t) => Promise<IRenderedTemplateResult>;\n\tclearPreview: () => void;\n}\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): IUseTemplatePreviewReturn {\n\tconst [preview, setPreview] = useState<IRenderedTemplateResult | null>(null);\n\tconst [isPreviewing, setIsPreviewing] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst renderPreview = useCallback(\n\t\tasync (type: string, input: IPreviewTemplateInput, locale?: string | null) => {\n\t\t\tsetIsPreviewing(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.previewTemplate(type, input, locale);\n\t\t\t\tsetPreview(result);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsPreviewing(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\tconst clearPreview = useCallback(() => setPreview(null), []);\n\n\treturn { preview, isPreviewing, error, renderPreview, clearPreview };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAAA,iBAAqD;;;ACRrD,oBAAiC;AACjC,mBAAiD;AAS1C,SAAS,YACf,QACA,MACA,QACqB;AACrB,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAgC,IAAI;AACpE,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,IAAI;AAC/C,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAkC,IAAI;AAEhE,QAAM,cAAU,0BAAY,YAAY;AACvC,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,YAAY,MAAM,MAAM;AACxD,kBAAY,MAAM;AAAA,IACnB,SAAS,KAAK;AACb,YAAM,WACL,eAAe,iCAAmB,MAAM,IAAI,+BAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AAAA,IAClB,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,QAAQ,MAAM,MAAM,CAAC;AAEzB,8BAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,UAAU,WAAW,OAAO,QAAQ;AAC9C;;;ACvCA,IAAAC,iBAAiC;AACjC,IAAAC,gBAAiD;AAU1C,SAAS,qBACf,QACA,MACA,QAC8B;AAC9B,QAAM,CAAC,WAAW,YAAY,QAAI,wBAA8B,CAAC,CAAC;AAClE,QAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,IAAI;A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mB,QAAuD;AACzF,QAAM,CAAC,SAAS,UAAU,QAAI,wBAAyC,IAAI;AAC3E,QAAM,CAAC,cAAc,eAAe,QAAI,wBAAS,KAAK;AACtD,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAkC,IAAI;AAEhE,QAAM,oBAAgB;AAAA,IACrB,OAAO,MAAc,OAA8B,WAA2B;AAC7E,sBAAgB,IAAI;AACpB,eAAS,IAAI;AACb,UAAI;AACH,cAAM,EAAE,OAAO,IAAI,MAAM,OAAO,gBAAgB,MAAM,OAAO,MAAM;AACnE,mBAAW,MAAM;AACjB,eAAO;AAAA,MACR,SAAS,KAAK;AACb,cAAM,WACL,eAAe,kCAAmB,MAAM,IAAI,gCAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AACjB,cAAM;AAAA,MACP,UAAE;AACD,wBAAgB,KAAK;AAAA,MACtB;AAAA,IACD;AAAA,IACA,CAAC,MAAM;AAAA,EACR;AAEA,QAAM,mBAAe,2BAAY,MAAM,WAAW,IAAI,GAAG,CAAC,CAAC;AAE3D,SAAO,EAAE,SAAS,cAAc,OAAO,eAAe,aAAa;AACpE;","names":["import_client","import_client","import_react","import_client","import_react","import_client","import_react"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { ITemplateEntry, FonderieApiError, CourierAdminClient, ITemplateRevision, ISetTemplateInput } from '@fonderie/client';
2
- export { CourierAdminClient, FonderieApiError, ICourierAdminClientOptions, IRollbackTemplateInput, ISetTemplateInput, ITemplateEntry, ITemplateRevision } from '@fonderie/client';
1
+ import { ITemplateEntry, FonderieApiError, CourierAdminClient, ITemplateRevision, ISetTemplateInput, IRenderedTemplateResult, IPreviewTemplateInput } from '@fonderie/client';
2
+ export { CourierAdminClient, FonderieApiError, ICourierAdminClientOptions, IPreviewTemplateInput, IRenderedTemplateResult, IRollbackTemplateInput, ISetTemplateInput, ITemplateEntry, ITemplateRevision } from '@fonderie/client';
3
3
 
4
4
  interface IUseTemplateReturn {
5
5
  template: ITemplateEntry | null;
@@ -28,4 +28,13 @@ interface IUseTemplatesReturn {
28
28
  }
29
29
  declare function useTemplates(client: CourierAdminClient): IUseTemplatesReturn;
30
30
 
31
- export { type IUseTemplateReturn, type IUseTemplateRevisionsReturn, type IUseTemplatesReturn, useTemplate, useTemplateRevisions, useTemplates };
31
+ interface IUseTemplatePreviewReturn {
32
+ preview: IRenderedTemplateResult | null;
33
+ isPreviewing: boolean;
34
+ error: FonderieApiError | null;
35
+ renderPreview: (type: string, input: IPreviewTemplateInput, locale?: string | null) => Promise<IRenderedTemplateResult>;
36
+ clearPreview: () => void;
37
+ }
38
+ declare function useTemplatePreview(client: CourierAdminClient): IUseTemplatePreviewReturn;
39
+
40
+ export { type IUseTemplatePreviewReturn, type IUseTemplateReturn, type IUseTemplateRevisionsReturn, type IUseTemplatesReturn, useTemplate, useTemplatePreview, useTemplateRevisions, useTemplates };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ITemplateEntry, FonderieApiError, CourierAdminClient, ITemplateRevision, ISetTemplateInput } from '@fonderie/client';
2
- export { CourierAdminClient, FonderieApiError, ICourierAdminClientOptions, IRollbackTemplateInput, ISetTemplateInput, ITemplateEntry, ITemplateRevision } from '@fonderie/client';
1
+ import { ITemplateEntry, FonderieApiError, CourierAdminClient, ITemplateRevision, ISetTemplateInput, IRenderedTemplateResult, IPreviewTemplateInput } from '@fonderie/client';
2
+ export { CourierAdminClient, FonderieApiError, ICourierAdminClientOptions, IPreviewTemplateInput, IRenderedTemplateResult, IRollbackTemplateInput, ISetTemplateInput, ITemplateEntry, ITemplateRevision } from '@fonderie/client';
3
3
 
4
4
  interface IUseTemplateReturn {
5
5
  template: ITemplateEntry | null;
@@ -28,4 +28,13 @@ interface IUseTemplatesReturn {
28
28
  }
29
29
  declare function useTemplates(client: CourierAdminClient): IUseTemplatesReturn;
30
30
 
31
- export { type IUseTemplateReturn, type IUseTemplateRevisionsReturn, type IUseTemplatesReturn, useTemplate, useTemplateRevisions, useTemplates };
31
+ interface IUseTemplatePreviewReturn {
32
+ preview: IRenderedTemplateResult | null;
33
+ isPreviewing: boolean;
34
+ error: FonderieApiError | null;
35
+ renderPreview: (type: string, input: IPreviewTemplateInput, locale?: string | null) => Promise<IRenderedTemplateResult>;
36
+ clearPreview: () => void;
37
+ }
38
+ declare function useTemplatePreview(client: CourierAdminClient): IUseTemplatePreviewReturn;
39
+
40
+ export { type IUseTemplatePreviewReturn, type IUseTemplateReturn, type IUseTemplateRevisionsReturn, type IUseTemplatesReturn, useTemplate, useTemplatePreview, useTemplateRevisions, useTemplates };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { CourierAdminClient, FonderieApiError as FonderieApiError4 } from "@fonderie/client";
2
+ import { CourierAdminClient, FonderieApiError as FonderieApiError5 } from "@fonderie/client";
3
3
 
4
4
  // src/hooks/useTemplate.ts
5
5
  import { FonderieApiError } from "@fonderie/client";
@@ -122,10 +122,40 @@ function useTemplates(client) {
122
122
  }, [refresh]);
123
123
  return { templates, isLoading, error, refresh, saveTemplate, removeTemplate };
124
124
  }
125
+
126
+ // src/hooks/useTemplatePreview.ts
127
+ import { FonderieApiError as FonderieApiError4 } from "@fonderie/client";
128
+ import { useCallback as useCallback4, useState as useState4 } from "react";
129
+ function useTemplatePreview(client) {
130
+ const [preview, setPreview] = useState4(null);
131
+ const [isPreviewing, setIsPreviewing] = useState4(false);
132
+ const [error, setError] = useState4(null);
133
+ const renderPreview = useCallback4(
134
+ async (type, input, locale) => {
135
+ setIsPreviewing(true);
136
+ setError(null);
137
+ try {
138
+ const { result } = await client.previewTemplate(type, input, locale);
139
+ setPreview(result);
140
+ return result;
141
+ } catch (err) {
142
+ const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
143
+ setError(apiError);
144
+ throw apiError;
145
+ } finally {
146
+ setIsPreviewing(false);
147
+ }
148
+ },
149
+ [client]
150
+ );
151
+ const clearPreview = useCallback4(() => setPreview(null), []);
152
+ return { preview, isPreviewing, error, renderPreview, clearPreview };
153
+ }
125
154
  export {
126
155
  CourierAdminClient,
127
- FonderieApiError4 as FonderieApiError,
156
+ FonderieApiError5 as FonderieApiError,
128
157
  useTemplate,
158
+ useTemplatePreview,
129
159
  useTemplateRevisions,
130
160
  useTemplates
131
161
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/hooks/useTemplate.ts","../src/hooks/useTemplateRevisions.ts","../src/hooks/useTemplates.ts"],"sourcesContent":["export type {\n\tICourierAdminClientOptions,\n\tIRollbackTemplateInput,\n\tISetTemplateInput,\n\tITemplateEntry,\n\tITemplateRevision,\n} from '@fonderie/client';\nexport { CourierAdminClient, FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseTemplateReturn,\n\tIUseTemplateRevisionsReturn,\n\tIUseTemplatesReturn,\n} from './hooks';\nexport {\n\tuseTemplate,\n\tuseTemplateRevisions,\n\tuseTemplates,\n} from './hooks';\n","import type { CourierAdminClient, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplateReturn {\n\ttemplate: ITemplateEntry | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n}\n\nexport function useTemplate(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n): IUseTemplateReturn {\n\tconst [template, setTemplate] = useState<ITemplateEntry | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.getTemplate(type, locale);\n\t\t\tsetTemplate(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client, type, locale]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { template, isLoading, error, refresh };\n}\n","import type { CourierAdminClient, ITemplateEntry, ITemplateRevision } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplateRevisionsReturn {\n\trevisions: ITemplateRevision[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n\trollback: (toVersion: number) => Promise<ITemplateEntry>;\n}\n\nexport function useTemplateRevisions(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n): IUseTemplateRevisionsReturn {\n\tconst [revisions, setRevisions] = useState<ITemplateRevision[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.listRevisions(type, locale);\n\t\t\tsetRevisions(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client, type, locale]);\n\n\tconst rollback = useCallback(\n\t\tasync (toVersion: number) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.rollback(type, { toVersion }, locale);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, type, locale, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [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 { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplatesReturn {\n\ttemplates: ITemplateEntry[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n\tsaveTemplate: (\n\t\ttype: string,\n\t\tinput: ISetTemplateInput,\n\t\tlocale?: string | null,\n\t) => Promise<ITemplateEntry>;\n\tremoveTemplate: (type: string, locale?: string | null) => Promise<void>;\n}\n\nexport function useTemplates(client: CourierAdminClient): IUseTemplatesReturn {\n\tconst [templates, setTemplates] = useState<ITemplateEntry[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.listTemplates();\n\t\t\tsetTemplates(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client]);\n\n\tconst saveTemplate = useCallback(\n\t\tasync (type: string, input: ISetTemplateInput, locale?: string | null) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.setTemplate(type, input, locale);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, refresh],\n\t);\n\n\tconst removeTemplate = useCallback(\n\t\tasync (type: string, locale?: string | null) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait client.deleteTemplate(type, locale);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { templates, isLoading, error, refresh, saveTemplate, removeTemplate };\n}\n"],"mappings":";AAOA,SAAS,oBAAoB,oBAAAA,yBAAwB;;;ACNrD,SAAS,wBAAwB;AACjC,SAAS,aAAa,WAAW,gBAAgB;AAS1C,SAAS,YACf,QACA,MACA,QACqB;AACrB,QAAM,CAAC,UAAU,WAAW,IAAI,SAAgC,IAAI;AACpE,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,IAAI;AAC/C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkC,IAAI;AAEhE,QAAM,UAAU,YAAY,YAAY;AACvC,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,YAAY,MAAM,MAAM;AACxD,kBAAY,MAAM;AAAA,IACnB,SAAS,KAAK;AACb,YAAM,WACL,eAAe,mBAAmB,MAAM,IAAI,iBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AAAA,IAClB,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,QAAQ,MAAM,MAAM,CAAC;AAEzB,YAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,UAAU,WAAW,OAAO,QAAQ;AAC9C;;;ACvCA,SAAS,oBAAAC,yBAAwB;AACjC,SAAS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IACD;AAAA,IACA,CAAC,QAAQ,OAAO;AAAA,EACjB;AAEA,EAAAE,WAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,WAAW,WAAW,OAAO,SAAS,cAAc,eAAe;AAC7E;","names":["FonderieApiError","FonderieApiError","useCallback","useEffect","useState","FonderieApiError","useCallback","useEffect","useState"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/hooks/useTemplate.ts","../src/hooks/useTemplateRevisions.ts","../src/hooks/useTemplates.ts","../src/hooks/useTemplatePreview.ts"],"sourcesContent":["export type {\n\tICourierAdminClientOptions,\n\tIPreviewTemplateInput,\n\tIRenderedTemplateResult,\n\tIRollbackTemplateInput,\n\tISetTemplateInput,\n\tITemplateEntry,\n\tITemplateRevision,\n} from '@fonderie/client';\nexport { CourierAdminClient, FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseTemplatePreviewReturn,\n\tIUseTemplateReturn,\n\tIUseTemplateRevisionsReturn,\n\tIUseTemplatesReturn,\n} from './hooks';\nexport {\n\tuseTemplate,\n\tuseTemplatePreview,\n\tuseTemplateRevisions,\n\tuseTemplates,\n} from './hooks';\n","import type { CourierAdminClient, ITemplateEntry } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplateReturn {\n\ttemplate: ITemplateEntry | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n}\n\nexport function useTemplate(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n): IUseTemplateReturn {\n\tconst [template, setTemplate] = useState<ITemplateEntry | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.getTemplate(type, locale);\n\t\t\tsetTemplate(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client, type, locale]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { template, isLoading, error, refresh };\n}\n","import type { CourierAdminClient, ITemplateEntry, ITemplateRevision } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplateRevisionsReturn {\n\trevisions: ITemplateRevision[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n\trollback: (toVersion: number) => Promise<ITemplateEntry>;\n}\n\nexport function useTemplateRevisions(\n\tclient: CourierAdminClient,\n\ttype: string,\n\tlocale?: string | null,\n): IUseTemplateRevisionsReturn {\n\tconst [revisions, setRevisions] = useState<ITemplateRevision[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.listRevisions(type, locale);\n\t\t\tsetRevisions(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client, type, locale]);\n\n\tconst rollback = useCallback(\n\t\tasync (toVersion: number) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.rollback(type, { toVersion }, locale);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, type, locale, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [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 { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseTemplatesReturn {\n\ttemplates: ITemplateEntry[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: () => Promise<void>;\n\tsaveTemplate: (\n\t\ttype: string,\n\t\tinput: ISetTemplateInput,\n\t\tlocale?: string | null,\n\t) => Promise<ITemplateEntry>;\n\tremoveTemplate: (type: string, locale?: string | null) => Promise<void>;\n}\n\nexport function useTemplates(client: CourierAdminClient): IUseTemplatesReturn {\n\tconst [templates, setTemplates] = useState<ITemplateEntry[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await client.listTemplates();\n\t\t\tsetTemplates(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\tsetError(apiError);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client]);\n\n\tconst saveTemplate = useCallback(\n\t\tasync (type: string, input: ISetTemplateInput, locale?: string | null) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.setTemplate(type, input, locale);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, refresh],\n\t);\n\n\tconst removeTemplate = useCallback(\n\t\tasync (type: string, locale?: string | null) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait client.deleteTemplate(type, locale);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[client, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { templates, isLoading, error, refresh, saveTemplate, removeTemplate };\n}\n","import type {\n\tCourierAdminClient,\n\tIPreviewTemplateInput,\n\tIRenderedTemplateResult,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseTemplatePreviewReturn {\n\tpreview: IRenderedTemplateResult | null;\n\tisPreviewing: boolean;\n\terror: FonderieApiError | null;\n\trenderPreview: (\n\t\ttype: string,\n\t\tinput: IPreviewTemplateInput,\n\t\tlocale?: string | null,\n\t) => Promise<IRenderedTemplateResult>;\n\tclearPreview: () => void;\n}\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): IUseTemplatePreviewReturn {\n\tconst [preview, setPreview] = useState<IRenderedTemplateResult | null>(null);\n\tconst [isPreviewing, setIsPreviewing] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst renderPreview = useCallback(\n\t\tasync (type: string, input: IPreviewTemplateInput, locale?: string | null) => {\n\t\t\tsetIsPreviewing(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.previewTemplate(type, input, locale);\n\t\t\t\tsetPreview(result);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsPreviewing(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\tconst clearPreview = useCallback(() => setPreview(null), []);\n\n\treturn { preview, isPreviewing, error, renderPreview, clearPreview };\n}\n"],"mappings":";AASA,SAAS,oBAAoB,oBAAAA,yBAAwB;;;ACRrD,SAAS,wBAAwB;AACjC,SAAS,aAAa,WAAW,gBAAgB;AAS1C,SAAS,YACf,QACA,MACA,QACqB;AACrB,QAAM,CAAC,UAAU,WAAW,IAAI,SAAgC,IAAI;AACpE,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,IAAI;AAC/C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkC,IAAI;AAEhE,QAAM,UAAU,YAAY,YAAY;AACvC,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,YAAY,MAAM,MAAM;AACxD,kBAAY,MAAM;AAAA,IACnB,SAAS,KAAK;AACb,YAAM,WACL,eAAe,mBAAmB,MAAM,IAAI,iBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AAAA,IAClB,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,QAAQ,MAAM,MAAM,CAAC;AAEzB,YAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,UAAU,WAAW,OAAO,QAAQ;AAC9C;;;ACvCA,SAAS,oBAAAC,yBAAwB;AACjC,SAAS,eAAAC,cAAa,aAAAC,YAAW,YAAAC,iBAAgB;AAU1C,SAAS,qBACf,Q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U,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,WAAW,WAAW,OAAO,SAAS,cAAc,eAAe;AAC7E;;;ACtEA,SAAS,oBAAAE,yBAAwB;AACjC,SAAS,eAAAC,cAAa,YAAAC,iBAAgB;AAiB/B,SAAS,mBAAmB,QAAuD;AACzF,QAAM,CAAC,SAAS,UAAU,IAAIA,UAAyC,IAAI;AAC3E,QAAM,CAAC,cAAc,eAAe,IAAIA,UAAS,KAAK;AACtD,QAAM,CAAC,OAAO,QAAQ,IAAIA,UAAkC,IAAI;AAEhE,QAAM,gBAAgBD;AAAA,IACrB,OAAO,MAAc,OAA8B,WAA2B;AAC7E,sBAAgB,IAAI;AACpB,eAAS,IAAI;AACb,UAAI;AACH,cAAM,EAAE,OAAO,IAAI,MAAM,OAAO,gBAAgB,MAAM,OAAO,MAAM;AACnE,mBAAW,MAAM;AACjB,eAAO;AAAA,MACR,SAAS,KAAK;AACb,cAAM,WACL,eAAeD,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AACjB,cAAM;AAAA,MACP,UAAE;AACD,wBAAgB,KAAK;AAAA,MACtB;AAAA,IACD;AAAA,IACA,CAAC,MAAM;AAAA,EACR;AAEA,QAAM,eAAeC,aAAY,MAAM,WAAW,IAAI,GAAG,CAAC,CAAC;AAE3D,SAAO,EAAE,SAAS,cAAc,OAAO,eAAe,aAAa;AACpE;","names":["FonderieApiError","FonderieApiError","useCallback","useEffect","useState","FonderieApiError","useCallback","useEffect","useState","FonderieApiError","useCallback","useState"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonderie/react-courier-admin",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "React hooks 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,9 +41,9 @@
41
41
  "react": ">=18.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@types/node": "^26.2.0",
45
- "@types/react": "^19.2.18",
46
- "react": "^19.2.8",
44
+ "@types/node": "^26.6.1",
45
+ "@types/react": "^19.3.0",
46
+ "react": "^19.3.0",
47
47
  "tsup": "^8.5.1",
48
48
  "typescript": "^6.0.3"
49
49
  },