@promptlycms/prompts 0.4.0-canary.375b6a8 → 0.4.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.
Files changed (2) hide show
  1. package/dist/cli.js +8 -33
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -86,28 +86,6 @@ var extractTemplateVariables = (text) => {
86
86
  }
87
87
  return [...vars];
88
88
  };
89
- var extractStaticSegmentVariables = (content) => {
90
- const vars = /* @__PURE__ */ new Set();
91
- const varRefRegex = /<span[^>]*\sdata-variable-ref(?:="[^"]*")?[^>]*\sdata-field-path="([^"]+)"[^>]*><\/span>/g;
92
- const varRefAltRegex = /<span[^>]*\sdata-field-path="([^"]+)"[^>]*\sdata-variable-ref(?:="[^"]*")?[^>]*><\/span>/g;
93
- const mustacheRegex = /\{\{(\w[\w.]*)\}\}/g;
94
- for (const match of content.matchAll(varRefRegex)) {
95
- if (match[1]) {
96
- vars.add(match[1]);
97
- }
98
- }
99
- for (const match of content.matchAll(varRefAltRegex)) {
100
- if (match[1]) {
101
- vars.add(match[1]);
102
- }
103
- }
104
- for (const match of content.matchAll(mustacheRegex)) {
105
- if (match[1]) {
106
- vars.add(match[1]);
107
- }
108
- }
109
- return [...vars];
110
- };
111
89
  var fetchAllPrompts = async (apiKey, baseUrl) => {
112
90
  const url = new URL("/prompts", baseUrl ?? DEFAULT_BASE_URL);
113
91
  url.searchParams.set("include_versions", "true");
@@ -137,17 +115,14 @@ var fetchAllComposers = async (apiKey, baseUrl) => {
137
115
  var extractComposerVariables = (composer) => {
138
116
  const vars = /* @__PURE__ */ new Set();
139
117
  for (const segment of composer.segments) {
140
- if (segment.type === "prompt") {
141
- if (!segment.userMessage) {
142
- continue;
143
- }
144
- for (const v of extractTemplateVariables(segment.userMessage)) {
145
- vars.add(v);
146
- }
147
- } else if (segment.type === "static") {
148
- for (const v of extractStaticSegmentVariables(segment.content)) {
149
- vars.add(v);
150
- }
118
+ if (segment.type !== "prompt") {
119
+ continue;
120
+ }
121
+ if (!segment.userMessage) {
122
+ continue;
123
+ }
124
+ for (const v of extractTemplateVariables(segment.userMessage)) {
125
+ vars.add(v);
151
126
  }
152
127
  }
153
128
  return [...vars];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptlycms/prompts",
3
- "version": "0.4.0-canary.375b6a8",
3
+ "version": "0.4.0",
4
4
  "description": "TypeScript SDK for Promptly CMS — fetch prompts, build Zod schemas, generate typed code",
5
5
  "type": "module",
6
6
  "exports": {