@unlayer/types 1.509.0 → 1.512.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.
@@ -36,8 +36,46 @@ export type User = {
36
36
  id?: string | number;
37
37
  name?: string | null | undefined;
38
38
  avatar?: string | null | undefined;
39
- email?: string;
39
+ email?: string | null;
40
40
  signature?: string;
41
+ /**
42
+ * Signed feature policy generated on your server. Supersedes `signature`: it
43
+ * covers the same user id and additionally carries the features this
44
+ * particular end user may use.
45
+ *
46
+ * Build it with your project secret, never in the browser:
47
+ *
48
+ * ```js
49
+ * const claims = { id, exp, features: { ai: { fullTemplateGeneration: false } } };
50
+ * const payload = Buffer.from(JSON.stringify(claims)).toString('base64url');
51
+ * const salt = 'unlayer:end-user-policy-token:v1:salt';
52
+ * const info = 'unlayer:end-user-policy-token:v1:signing-key';
53
+ * const key = Buffer.from(hkdfSync('sha256', SECRET, salt, info, 32));
54
+ * const signed = `v1.${payload}`;
55
+ * const token = `${signed}.${createHmac('sha256', key).update(signed).digest('hex')}`;
56
+ * ```
57
+ *
58
+ * `features` accepts the boolean feature-flag portion of
59
+ * `unlayer.init({ features })`: objects are containers and every leaf must be
60
+ * `true` or `false`. It can only restrict; a policy cannot grant a feature
61
+ * the project's plan excludes.
62
+ */
63
+ featurePolicyToken?: string | null;
64
+ /**
65
+ * Your own fields. Anything beyond the properties above is stored with the
66
+ * end user and returned on the next session, merged into what is already
67
+ * stored — so a field you stop sending keeps its last value. Unlayer never
68
+ * interprets them.
69
+ *
70
+ * Reserved names are dropped here: the credentials above, plus `projectId`,
71
+ * `customId`, `consoleAttestation`, `entitlements`, `featurePolicy`,
72
+ * `policyExp`, `featurePolicyVerified`, `legacySignatureVerified`,
73
+ * `consoleSession`, `_consoleSession`, `_consoleSessionId`,
74
+ * `_consoleSessionProof`, `_consoleUserId`, `consoleContextVerified`,
75
+ * `consoleSessionExp`, `consoleSessionId`, `consoleUserId`, and
76
+ * `consoleSessionProof`. Prefer names specific to your application.
77
+ */
78
+ [field: string]: unknown;
41
79
  };
42
80
 
43
81
  export type JSONSchema = Record<string, unknown>;
@@ -431,12 +431,41 @@ declare class EditorClass<TClassDisplayMode extends DisplayMode | undefined = un
431
431
  setTextDirection(textDirection: TextDirection | null): void;
432
432
  setTranslations(translations: Translations): void;
433
433
  loadBlank(bodyValues?: object): void;
434
+ /**
435
+ * Loads a design JSON into the editor, replacing the current design.
436
+ *
437
+ * Get design JSON from `saveDesign()` or `exportHtml()`, or generate it from React code with
438
+ * `renderToJson()` from `@unlayer/react-elements` (templates written in code by developers,
439
+ * coding agents, or an LLM at runtime stay editable here).
440
+ *
441
+ * @see https://docs.unlayer.com/builder/load-and-save-designs
442
+ * @see https://docs.unlayer.com/elements
443
+ */
434
444
  loadDesign<TDisplayMode extends DisplayMode | undefined = TClassDisplayMode>(design: JSONTemplate<TDisplayMode>): void;
445
+ /**
446
+ * Returns the current design JSON in the callback. Store it and pass it to `loadDesign()` to
447
+ * reopen the design for editing later.
448
+ *
449
+ * @see https://docs.unlayer.com/builder/load-and-save-designs
450
+ */
435
451
  saveDesign<TDisplayMode extends DisplayMode | undefined = TClassDisplayMode>(callback: (data: JSONTemplate<TDisplayMode>) => void, options?: SaveDesignOptions): void;
452
+ /**
453
+ * Exports the current design as HTML. The callback receives `{ html, design }`: send or render
454
+ * the `html`, and store the `design` JSON to reopen it with `loadDesign()`.
455
+ *
456
+ * @see https://docs.unlayer.com/builder/export-html
457
+ */
436
458
  exportHtml<TDisplayMode extends DisplayMode | undefined = TClassDisplayMode>(callback: (data: ExportHtmlResult<TDisplayMode>) => void, options?: ExportHtmlOptions): void;
437
459
  exportLiveHtml<TDisplayMode extends DisplayMode | undefined = TClassDisplayMode>(callback: (data: ExportLiveHtmlResult<TDisplayMode>) => void, options?: ExportLiveHtmlOptions): void;
438
460
  exportPlainText<TDisplayMode extends DisplayMode | undefined = TClassDisplayMode>(callback: (data: ExportPlainTextResult<TDisplayMode>) => void, options?: ExportPlainTextOptions): void;
439
461
  exportImage<TDisplayMode extends DisplayMode | undefined = TClassDisplayMode>(callback: (data: ExportFromApiResult<TDisplayMode>) => void, options?: ExportImageFromApiOptions): void;
462
+ /**
463
+ * Exports the current design as a PDF. Unlike `exportHtml()`, the PDF is generated by Unlayer's
464
+ * Cloud API, uploaded to your connected file storage, and the callback receives
465
+ * `{ url, design }`.
466
+ *
467
+ * @see https://docs.unlayer.com/builder/export-pdf
468
+ */
440
469
  exportPdf<TDisplayMode extends DisplayMode | undefined = TClassDisplayMode>(callback: (data: ExportFromApiResult<TDisplayMode>) => void, options?: ExportPdfFromApiOptions): void;
441
470
  exportZip<TDisplayMode extends DisplayMode | undefined = TClassDisplayMode>(callback: (data: ExportFromApiResult<TDisplayMode>) => void, options?: ExportZipFromApiOptions): void;
442
471
  setAppearance(appearance: DeepPartial<AppearanceConfig>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unlayer/types",
3
- "version": "1.509.0",
3
+ "version": "1.512.0",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "types": "./dist/index.d.ts",