@syntaxcircus/cmsify-client 0.2.4 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -4287,6 +4287,7 @@ interface components {
4287
4287
  effectiveStartAt?: string | null;
4288
4288
  /** Format: date-time */
4289
4289
  effectiveEndAt?: string | null;
4290
+ overrideWorkflow?: boolean | null;
4290
4291
  };
4291
4292
  PublishContentResponse: {
4292
4293
  content: components["schemas"]["ContentItemDetailResponse"];
@@ -4942,6 +4943,25 @@ declare function getFormatHint(fieldConfig: unknown): TextFormatHint;
4942
4943
  */
4943
4944
  declare function isProseHint(hint: TextFormatHint): boolean;
4944
4945
 
4946
+ /**
4947
+ * Renders `${{name}}` placeholder tokens in Cmsify content field text against a caller-supplied
4948
+ * variable dictionary. This is purely a client-side string transform -- the Cmsify server has no
4949
+ * concept of variables and never sees or stores rendered output. Content authors write literal
4950
+ * `${{name}}` tokens into Text/Markdown fields, and each consuming application decides what
4951
+ * values to supply at read time (e.g. from its own configuration).
4952
+ *
4953
+ * A variable name present in `variables` with a `null`/`undefined` value renders as an empty
4954
+ * string -- an explicit "blank this out." A variable name *not* present in `variables` at all is
4955
+ * left untouched in the output as the literal `${{name}}` token. This is deliberate: a typo'd
4956
+ * variable name (e.g. `${{supprtEmail}}`) should be visibly wrong on the rendered page, not
4957
+ * silently disappear.
4958
+ */
4959
+ /**
4960
+ * Replaces every recognized `${{name}}` token in `template` with the corresponding value from
4961
+ * `variables`. Tokens whose name is not a key in `variables` are left untouched.
4962
+ */
4963
+ declare function renderCmsifyTemplate(template: string, variables: Record<string, string | null | undefined>): string;
4964
+
4945
4965
  declare const createCmsifyFetchClient: (baseUrl: string, fetchImpl?: typeof fetch) => openapi_fetch.Client<paths, `${string}/${string}`>;
4946
4966
 
4947
- export { CmsifyApiError, CmsifyClient, type CmsifyClientOptions, CmsifyTimeoutError, type ContentItem, type ContentListItem, type ContentListOptions, type Delay, ETagStore, type MediaAsset, type PageOptions, type PageResult, type PagedResult, type ProblemDetails, type RequestOptions, TEXT_FORMAT_HINTS, type Template, type TemplateListItem, type TextFormatHint, type TextFormatHintConfig, type Workspace, type components, createCmsifyFetchClient, schema as generated, getFormatHint, isProseHint, listAll, type paths, toMimeType };
4967
+ export { CmsifyApiError, CmsifyClient, type CmsifyClientOptions, CmsifyTimeoutError, type ContentItem, type ContentListItem, type ContentListOptions, type Delay, ETagStore, type MediaAsset, type PageOptions, type PageResult, type PagedResult, type ProblemDetails, type RequestOptions, TEXT_FORMAT_HINTS, type Template, type TemplateListItem, type TextFormatHint, type TextFormatHintConfig, type Workspace, type components, createCmsifyFetchClient, schema as generated, getFormatHint, isProseHint, listAll, type paths, renderCmsifyTemplate, toMimeType };
package/dist/index.d.ts CHANGED
@@ -4287,6 +4287,7 @@ interface components {
4287
4287
  effectiveStartAt?: string | null;
4288
4288
  /** Format: date-time */
4289
4289
  effectiveEndAt?: string | null;
4290
+ overrideWorkflow?: boolean | null;
4290
4291
  };
4291
4292
  PublishContentResponse: {
4292
4293
  content: components["schemas"]["ContentItemDetailResponse"];
@@ -4942,6 +4943,25 @@ declare function getFormatHint(fieldConfig: unknown): TextFormatHint;
4942
4943
  */
4943
4944
  declare function isProseHint(hint: TextFormatHint): boolean;
4944
4945
 
4946
+ /**
4947
+ * Renders `${{name}}` placeholder tokens in Cmsify content field text against a caller-supplied
4948
+ * variable dictionary. This is purely a client-side string transform -- the Cmsify server has no
4949
+ * concept of variables and never sees or stores rendered output. Content authors write literal
4950
+ * `${{name}}` tokens into Text/Markdown fields, and each consuming application decides what
4951
+ * values to supply at read time (e.g. from its own configuration).
4952
+ *
4953
+ * A variable name present in `variables` with a `null`/`undefined` value renders as an empty
4954
+ * string -- an explicit "blank this out." A variable name *not* present in `variables` at all is
4955
+ * left untouched in the output as the literal `${{name}}` token. This is deliberate: a typo'd
4956
+ * variable name (e.g. `${{supprtEmail}}`) should be visibly wrong on the rendered page, not
4957
+ * silently disappear.
4958
+ */
4959
+ /**
4960
+ * Replaces every recognized `${{name}}` token in `template` with the corresponding value from
4961
+ * `variables`. Tokens whose name is not a key in `variables` are left untouched.
4962
+ */
4963
+ declare function renderCmsifyTemplate(template: string, variables: Record<string, string | null | undefined>): string;
4964
+
4945
4965
  declare const createCmsifyFetchClient: (baseUrl: string, fetchImpl?: typeof fetch) => openapi_fetch.Client<paths, `${string}/${string}`>;
4946
4966
 
4947
- export { CmsifyApiError, CmsifyClient, type CmsifyClientOptions, CmsifyTimeoutError, type ContentItem, type ContentListItem, type ContentListOptions, type Delay, ETagStore, type MediaAsset, type PageOptions, type PageResult, type PagedResult, type ProblemDetails, type RequestOptions, TEXT_FORMAT_HINTS, type Template, type TemplateListItem, type TextFormatHint, type TextFormatHintConfig, type Workspace, type components, createCmsifyFetchClient, schema as generated, getFormatHint, isProseHint, listAll, type paths, toMimeType };
4967
+ export { CmsifyApiError, CmsifyClient, type CmsifyClientOptions, CmsifyTimeoutError, type ContentItem, type ContentListItem, type ContentListOptions, type Delay, ETagStore, type MediaAsset, type PageOptions, type PageResult, type PagedResult, type ProblemDetails, type RequestOptions, TEXT_FORMAT_HINTS, type Template, type TemplateListItem, type TextFormatHint, type TextFormatHintConfig, type Workspace, type components, createCmsifyFetchClient, schema as generated, getFormatHint, isProseHint, listAll, type paths, renderCmsifyTemplate, toMimeType };
package/dist/index.js CHANGED
@@ -264,6 +264,18 @@ function isProseHint(hint) {
264
264
  return hint === "plaintext" || hint === "markdown" || hint === "html";
265
265
  }
266
266
 
267
+ // src/templating.ts
268
+ var TOKEN_PATTERN = /\$\{\{\s*([A-Za-z][A-Za-z0-9_.-]*)\s*\}\}/g;
269
+ function renderCmsifyTemplate(template, variables) {
270
+ if (!template.includes("${{")) {
271
+ return template;
272
+ }
273
+ return template.replace(
274
+ TOKEN_PATTERN,
275
+ (full, name) => Object.prototype.hasOwnProperty.call(variables, name) ? variables[name] ?? "" : full
276
+ );
277
+ }
278
+
267
279
  // src/generated/schema.ts
268
280
  var schema_exports = {};
269
281
 
@@ -281,6 +293,7 @@ export {
281
293
  getFormatHint,
282
294
  isProseHint,
283
295
  listAll,
296
+ renderCmsifyTemplate,
284
297
  toMimeType
285
298
  };
286
299
  //# sourceMappingURL=index.js.map