@promptlycms/prompts 0.5.0-canary.caa390f → 0.5.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/README.md CHANGED
@@ -171,11 +171,6 @@ const output = formatComposer({
171
171
  });
172
172
  ```
173
173
 
174
- Prompt results are treated as text by default. Newlines in strings or `{ text }`
175
- results are preserved as `<br>` tags when the composer output is assembled. If a
176
- prompt result already contains trusted HTML, pass `{ html: '<p>...</p>' }` to
177
- `formatComposer()` to insert it without newline conversion.
178
-
179
174
  Batch fetch multiple composers in parallel:
180
175
 
181
176
  ```typescript
@@ -203,9 +198,6 @@ for (const segment of composer.segments) {
203
198
 
204
199
  Variable references inside an `html_block` (e.g. `<span data-variable-ref data-field-path="country">`) are interpolated normally during `formatComposer()` / `compose()`. Embedded prompt references inside an `html_block` are passed through opaquely — they aren't resolved as named prompts.
205
200
 
206
- HTML blocks are otherwise left raw, including whitespace, comments, and empty
207
- paragraphs.
208
-
209
201
  ## Model auto-detection
210
202
 
211
203
  The SDK automatically resolves models configured in the CMS to the correct AI SDK provider based on the model name prefix:
package/dist/index.cjs CHANGED
@@ -186,21 +186,6 @@ var toCamelCase = (name) => name.replace(/[^a-zA-Z0-9]+(.)/g, (_, char) => char.
186
186
  var VARIABLE_REF_REGEX = /<span[^>]*\sdata-variable-ref(?:="[^"]*")?[^>]*\sdata-field-path="([^"]+)"[^>]*><\/span>/g;
187
187
  var VARIABLE_REF_ALT_REGEX = /<span[^>]*\sdata-field-path="([^"]+)"[^>]*\sdata-variable-ref(?:="[^"]*")?[^>]*><\/span>/g;
188
188
  var MUSTACHE_REGEX = /\{\{(\w[\w.]*)\}\}/g;
189
- var EMPTY_PARAGRAPH_REGEX = /<p(\s[^>]*)?>\s*<\/p>/gi;
190
- var preserveEmptyParagraphs = (content) => content.replace(
191
- EMPTY_PARAGRAPH_REGEX,
192
- (_, attributes) => `<p${attributes ?? ""}><br></p>`
193
- );
194
- var preserveTextLineBreaks = (content) => content.replace(/\r\n?/g, "\n").replaceAll("\n", "<br>");
195
- var formatComposerInput = (input) => {
196
- if (typeof input === "string") {
197
- return preserveTextLineBreaks(input);
198
- }
199
- if ("html" in input) {
200
- return input.html;
201
- }
202
- return preserveTextLineBreaks(input.text);
203
- };
204
189
  var interpolateStaticSegment = (content, input) => {
205
190
  let result = content;
206
191
  result = result.replace(
@@ -286,9 +271,7 @@ var createPromptlyClient = (config) => {
286
271
  if (segment.type === "static") {
287
272
  processedSegments.push({
288
273
  type: "static",
289
- content: preserveEmptyParagraphs(
290
- interpolateStaticSegment(segment.content, input)
291
- )
274
+ content: interpolateStaticSegment(segment.content, input)
292
275
  });
293
276
  continue;
294
277
  }
@@ -329,7 +312,7 @@ var createPromptlyClient = (config) => {
329
312
  if (val === void 0) {
330
313
  continue;
331
314
  }
332
- parts.push(formatComposerInput(val));
315
+ parts.push(typeof val === "string" ? val : val.text);
333
316
  }
334
317
  return parts.join("");
335
318
  };
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PromptlyClientConfig, a as PromptlyClient, E as ErrorCode } from './types-BStQVsgZ.cjs';
2
- export { C as ComposerConfig, b as ComposerFormatFn, c as ComposerGenerateFn, d as ComposerHtmlBlockSegment, e as ComposerId, f as ComposerInputFor, g as ComposerPrompt, h as ComposerPromptMap, i as ComposerPromptNamesFor, j as ComposerPromptSegment, k as ComposerRequest, l as ComposerResponse, m as ComposerResult, n as ComposerSegment, o as ComposerStaticSegment, p as ComposerVariableMap, q as ComposerVersion, r as ErrorResponse, F as FormatInput, G as GetComposerOptions, s as GetOptions, t as PromptConfig, u as PromptId, v as PromptMessage, w as PromptRequest, x as PromptResponse, y as PromptResult, z as PromptVariableMap, A as PromptVersion, B as PublishedVersion, S as SchemaField, D as SchemaFieldParams, V as ValidationRule } from './types-BStQVsgZ.cjs';
1
+ import { P as PromptlyClientConfig, a as PromptlyClient, E as ErrorCode } from './types-DaIU82yN.cjs';
2
+ export { C as ComposerConfig, b as ComposerFormatFn, c as ComposerGenerateFn, d as ComposerHtmlBlockSegment, e as ComposerId, f as ComposerInputFor, g as ComposerPrompt, h as ComposerPromptMap, i as ComposerPromptNamesFor, j as ComposerPromptSegment, k as ComposerRequest, l as ComposerResponse, m as ComposerResult, n as ComposerSegment, o as ComposerStaticSegment, p as ComposerVariableMap, q as ComposerVersion, r as ErrorResponse, F as FormatInput, G as GetComposerOptions, s as GetOptions, t as PromptConfig, u as PromptId, v as PromptMessage, w as PromptRequest, x as PromptResponse, y as PromptResult, z as PromptVariableMap, A as PromptVersion, B as PublishedVersion, S as SchemaField, D as SchemaFieldParams, V as ValidationRule } from './types-DaIU82yN.cjs';
3
3
  import 'ai';
4
4
 
5
5
  declare const getSdkModelId: (modelId: string) => string;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PromptlyClientConfig, a as PromptlyClient, E as ErrorCode } from './types-BStQVsgZ.js';
2
- export { C as ComposerConfig, b as ComposerFormatFn, c as ComposerGenerateFn, d as ComposerHtmlBlockSegment, e as ComposerId, f as ComposerInputFor, g as ComposerPrompt, h as ComposerPromptMap, i as ComposerPromptNamesFor, j as ComposerPromptSegment, k as ComposerRequest, l as ComposerResponse, m as ComposerResult, n as ComposerSegment, o as ComposerStaticSegment, p as ComposerVariableMap, q as ComposerVersion, r as ErrorResponse, F as FormatInput, G as GetComposerOptions, s as GetOptions, t as PromptConfig, u as PromptId, v as PromptMessage, w as PromptRequest, x as PromptResponse, y as PromptResult, z as PromptVariableMap, A as PromptVersion, B as PublishedVersion, S as SchemaField, D as SchemaFieldParams, V as ValidationRule } from './types-BStQVsgZ.js';
1
+ import { P as PromptlyClientConfig, a as PromptlyClient, E as ErrorCode } from './types-DaIU82yN.js';
2
+ export { C as ComposerConfig, b as ComposerFormatFn, c as ComposerGenerateFn, d as ComposerHtmlBlockSegment, e as ComposerId, f as ComposerInputFor, g as ComposerPrompt, h as ComposerPromptMap, i as ComposerPromptNamesFor, j as ComposerPromptSegment, k as ComposerRequest, l as ComposerResponse, m as ComposerResult, n as ComposerSegment, o as ComposerStaticSegment, p as ComposerVariableMap, q as ComposerVersion, r as ErrorResponse, F as FormatInput, G as GetComposerOptions, s as GetOptions, t as PromptConfig, u as PromptId, v as PromptMessage, w as PromptRequest, x as PromptResponse, y as PromptResult, z as PromptVariableMap, A as PromptVersion, B as PublishedVersion, S as SchemaField, D as SchemaFieldParams, V as ValidationRule } from './types-DaIU82yN.js';
3
3
  import 'ai';
4
4
 
5
5
  declare const getSdkModelId: (modelId: string) => string;
package/dist/index.js CHANGED
@@ -145,21 +145,6 @@ var toCamelCase = (name) => name.replace(/[^a-zA-Z0-9]+(.)/g, (_, char) => char.
145
145
  var VARIABLE_REF_REGEX = /<span[^>]*\sdata-variable-ref(?:="[^"]*")?[^>]*\sdata-field-path="([^"]+)"[^>]*><\/span>/g;
146
146
  var VARIABLE_REF_ALT_REGEX = /<span[^>]*\sdata-field-path="([^"]+)"[^>]*\sdata-variable-ref(?:="[^"]*")?[^>]*><\/span>/g;
147
147
  var MUSTACHE_REGEX = /\{\{(\w[\w.]*)\}\}/g;
148
- var EMPTY_PARAGRAPH_REGEX = /<p(\s[^>]*)?>\s*<\/p>/gi;
149
- var preserveEmptyParagraphs = (content) => content.replace(
150
- EMPTY_PARAGRAPH_REGEX,
151
- (_, attributes) => `<p${attributes ?? ""}><br></p>`
152
- );
153
- var preserveTextLineBreaks = (content) => content.replace(/\r\n?/g, "\n").replaceAll("\n", "<br>");
154
- var formatComposerInput = (input) => {
155
- if (typeof input === "string") {
156
- return preserveTextLineBreaks(input);
157
- }
158
- if ("html" in input) {
159
- return input.html;
160
- }
161
- return preserveTextLineBreaks(input.text);
162
- };
163
148
  var interpolateStaticSegment = (content, input) => {
164
149
  let result = content;
165
150
  result = result.replace(
@@ -245,9 +230,7 @@ var createPromptlyClient = (config) => {
245
230
  if (segment.type === "static") {
246
231
  processedSegments.push({
247
232
  type: "static",
248
- content: preserveEmptyParagraphs(
249
- interpolateStaticSegment(segment.content, input)
250
- )
233
+ content: interpolateStaticSegment(segment.content, input)
251
234
  });
252
235
  continue;
253
236
  }
@@ -288,7 +271,7 @@ var createPromptlyClient = (config) => {
288
271
  if (val === void 0) {
289
272
  continue;
290
273
  }
291
- parts.push(formatComposerInput(val));
274
+ parts.push(typeof val === "string" ? val : val.text);
292
275
  }
293
276
  return parts.join("");
294
277
  };
package/dist/schema.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { S as SchemaField } from './types-BStQVsgZ.cjs';
2
+ import { S as SchemaField } from './types-DaIU82yN.cjs';
3
3
  import 'ai';
4
4
 
5
5
  declare const buildFieldSchema: (field: SchemaField) => z.ZodTypeAny;
package/dist/schema.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { S as SchemaField } from './types-BStQVsgZ.js';
2
+ import { S as SchemaField } from './types-DaIU82yN.js';
3
3
  import 'ai';
4
4
 
5
5
  declare const buildFieldSchema: (field: SchemaField) => z.ZodTypeAny;
@@ -147,10 +147,10 @@ type ComposerPrompt = {
147
147
  };
148
148
  type FormatInput = {
149
149
  text: string;
150
- } | {
151
- html: string;
152
150
  } | string;
153
- type ComposerGenerateFn = (prompt: ComposerPrompt) => Promise<FormatInput>;
151
+ type ComposerGenerateFn = (prompt: ComposerPrompt) => Promise<{
152
+ text: string;
153
+ } | string>;
154
154
  type ComposerFormatFn<Names extends string = string> = (results: Record<Names, FormatInput>) => string;
155
155
  type ComposerResult<Names extends string = string> = {
156
156
  composerId: string;
@@ -147,10 +147,10 @@ type ComposerPrompt = {
147
147
  };
148
148
  type FormatInput = {
149
149
  text: string;
150
- } | {
151
- html: string;
152
150
  } | string;
153
- type ComposerGenerateFn = (prompt: ComposerPrompt) => Promise<FormatInput>;
151
+ type ComposerGenerateFn = (prompt: ComposerPrompt) => Promise<{
152
+ text: string;
153
+ } | string>;
154
154
  type ComposerFormatFn<Names extends string = string> = (results: Record<Names, FormatInput>) => string;
155
155
  type ComposerResult<Names extends string = string> = {
156
156
  composerId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptlycms/prompts",
3
- "version": "0.5.0-canary.caa390f",
3
+ "version": "0.5.0",
4
4
  "description": "TypeScript SDK for Promptly CMS — fetch prompts, build Zod schemas, generate typed code",
5
5
  "type": "module",
6
6
  "exports": {