@promptlycms/prompts 0.6.1 → 0.6.2

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.
Files changed (2) hide show
  1. package/dist/cli.js +56 -50
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -365,63 +365,57 @@ var generateTypeDeclaration = (prompts, composers = []) => {
365
365
  }
366
366
  }
367
367
  lines.push(" }");
368
- if (composers.length > 0) {
369
- lines.push(" interface ComposerVariableMap {");
370
- for (const composer of composers) {
371
- const variables = extractComposerVariables(composer);
372
- const composerKey = typePropertyKey(composer.composerId);
373
- const schemaMap = buildSchemaMap(composer.config.schema);
374
- const versions = ["'latest'"];
375
- if (composer.publishedVersions) {
376
- for (const pv of composer.publishedVersions) {
377
- versions.push(`'${pv.version}'`);
378
- }
379
- } else {
380
- versions.push(`'${composer.version}'`);
368
+ lines.push(" interface ComposerVariableMap {");
369
+ for (const composer of composers) {
370
+ const variables = extractComposerVariables(composer);
371
+ const composerKey = typePropertyKey(composer.composerId);
372
+ const schemaMap = buildSchemaMap(composer.config.schema);
373
+ const versions = ["'latest'"];
374
+ if (composer.publishedVersions) {
375
+ for (const pv of composer.publishedVersions) {
376
+ versions.push(`'${pv.version}'`);
381
377
  }
382
- lines.push(` ${composerKey}: {`);
383
- if (versions.length === 1) {
384
- if (variables.length === 0) {
385
- lines.push(` [V in ${versions[0]}]: Record<string, never>;`);
386
- } else {
387
- lines.push(` [V in ${versions[0]}]: {`);
388
- for (const v of variables) {
389
- lines.push(
390
- ` ${v}: ${schemaFieldToTsType(schemaMap.get(v))};`
391
- );
392
- }
393
- lines.push(" };");
394
- }
378
+ } else {
379
+ versions.push(`'${composer.version}'`);
380
+ }
381
+ lines.push(` ${composerKey}: {`);
382
+ if (versions.length === 1) {
383
+ if (variables.length === 0) {
384
+ lines.push(` [V in ${versions[0]}]: Record<string, never>;`);
395
385
  } else {
396
- const versionUnion = versions.join(" | ");
397
- if (variables.length === 0) {
398
- lines.push(` [V in ${versionUnion}]: Record<string, never>;`);
399
- } else {
400
- lines.push(` [V in ${versionUnion}]: {`);
401
- for (const v of variables) {
402
- lines.push(
403
- ` ${v}: ${schemaFieldToTsType(schemaMap.get(v))};`
404
- );
405
- }
406
- lines.push(" };");
386
+ lines.push(` [V in ${versions[0]}]: {`);
387
+ for (const v of variables) {
388
+ lines.push(` ${v}: ${schemaFieldToTsType(schemaMap.get(v))};`);
407
389
  }
390
+ lines.push(" };");
408
391
  }
409
- lines.push(" };");
410
- }
411
- lines.push(" }");
412
- lines.push(" interface ComposerPromptMap {");
413
- for (const composer of composers) {
414
- const names = extractComposerPromptNames(composer);
415
- const composerKey = typePropertyKey(composer.composerId);
416
- if (names.length === 0) {
417
- lines.push(` ${composerKey}: never;`);
392
+ } else {
393
+ const versionUnion = versions.join(" | ");
394
+ if (variables.length === 0) {
395
+ lines.push(` [V in ${versionUnion}]: Record<string, never>;`);
418
396
  } else {
419
- const union = names.map((n) => `'${n}'`).join(" | ");
420
- lines.push(` ${composerKey}: ${union};`);
397
+ lines.push(` [V in ${versionUnion}]: {`);
398
+ for (const v of variables) {
399
+ lines.push(` ${v}: ${schemaFieldToTsType(schemaMap.get(v))};`);
400
+ }
401
+ lines.push(" };");
421
402
  }
422
403
  }
423
- lines.push(" }");
404
+ lines.push(" };");
405
+ }
406
+ lines.push(" }");
407
+ lines.push(" interface ComposerPromptMap {");
408
+ for (const composer of composers) {
409
+ const names = extractComposerPromptNames(composer);
410
+ const composerKey = typePropertyKey(composer.composerId);
411
+ if (names.length === 0) {
412
+ lines.push(` ${composerKey}: never;`);
413
+ } else {
414
+ const union = names.map((n) => `'${n}'`).join(" | ");
415
+ lines.push(` ${composerKey}: ${union};`);
416
+ }
424
417
  }
418
+ lines.push(" }");
425
419
  lines.push("}");
426
420
  lines.push("");
427
421
  return lines.join("\n");
@@ -473,7 +467,19 @@ var warnMissingProviders = (prompts, composers = []) => {
473
467
  var generate = async (apiKey, outputPath, baseUrl) => {
474
468
  const [prompts, composers] = await Promise.all([
475
469
  fetchAllPrompts(apiKey, baseUrl),
476
- fetchAllComposers(apiKey, baseUrl).catch(() => [])
470
+ fetchAllComposers(apiKey, baseUrl).catch((err) => {
471
+ if (err instanceof PromptlyError) {
472
+ console.warn(
473
+ ` Warning: failed to fetch composers (${err.code}, HTTP ${err.status}): ${err.message}`
474
+ );
475
+ console.warn(
476
+ " Composer types will be omitted from promptly-env.d.ts."
477
+ );
478
+ } else {
479
+ console.warn(` Warning: failed to fetch composers: ${String(err)}`);
480
+ }
481
+ return [];
482
+ })
477
483
  ]);
478
484
  if (prompts.length === 0 && composers.length === 0) {
479
485
  console.log(" No prompts or composers found for this API key.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptlycms/prompts",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "TypeScript SDK for Promptly CMS — fetch prompts, build Zod schemas, generate typed code",
5
5
  "type": "module",
6
6
  "exports": {