@anuragpal02/zcl-contracts 0.35.0 → 0.36.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/dist/looks.d.ts CHANGED
@@ -95,6 +95,24 @@ export declare const adminLookTestResponseSchema: z.ZodObject<{
95
95
  imageBase64: z.ZodString;
96
96
  contentType: z.ZodString;
97
97
  }, z.core.$strip>;
98
+ export declare const LOOK_SUBJECT_PLACEHOLDER = "{subject}";
99
+ /**
100
+ * Compose the FINAL generation prompt from a look's style template and the
101
+ * user's subject — the single definition of what "applying a look" means,
102
+ * shared by the admin test window and the web app's concept step so the two
103
+ * can never drift.
104
+ *
105
+ * Rules:
106
+ * - Template contains `{subject}` → substitute (every occurrence) with the
107
+ * trimmed subject. With an empty subject the marker is simply removed and
108
+ * the template stands alone.
109
+ * - No marker → the subject leads and the style follows: `<subject>. <template>`
110
+ * (subject-first scenes read best with image models). Empty subject → the
111
+ * template unchanged.
112
+ * Whitespace is collapsed at the join so templates/subjects with stray spaces
113
+ * don't produce double gaps.
114
+ */
115
+ export declare function applyLookPrompt(lookPrompt: string, subject: string): string;
98
116
  export type Look = z.infer<typeof lookSchema>;
99
117
  export type ListLooksResponse = z.infer<typeof listLooksResponseSchema>;
100
118
  export type GetLookResponse = z.infer<typeof getLookResponseSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"looks.d.ts","sourceRoot":"","sources":["../src/looks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,eAAO,MAAM,UAAU;;;;;;;;;;iBAUrB,CAAA;AAIF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;iBAElC,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;iBAA+B,CAAA;AAEjE,eAAO,MAAM,4BAA4B;;;;;;iBAMvC,CAAA;AAEF,eAAO,MAAM,4BAA4B;;;;;;iBAIrC,CAAA;AAGJ,eAAO,MAAM,2BA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,qCAAqC,CAAC,CAAA;AACnG,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAC7E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA"}
package/dist/looks.js CHANGED
@@ -3,6 +3,11 @@ import { apiSuccessSchema, idSchema, isoDateSchema } from './common.js';
3
3
  // An admin-managed look prompt template for the looks page: a named, categorized
4
4
  // prompt (plus optional thumbnail) users pick as a starting point for generation.
5
5
  // `isActive` gates visibility on the public list; `sortOrder` orders it.
6
+ //
7
+ // A look's prompt is a STYLE TEMPLATE, not necessarily a complete prompt: the
8
+ // user supplies the subject and the platform composes the final generation
9
+ // prompt (see applyLookPrompt). Mark where the subject lands with `{subject}`;
10
+ // templates without the marker get the style appended after the subject.
6
11
  export const lookSchema = z.object({
7
12
  id: idSchema,
8
13
  name: z.string(),
@@ -53,3 +58,34 @@ export const adminLookTestResponseSchema = z.object({
53
58
  imageBase64: z.string(),
54
59
  contentType: z.string()
55
60
  });
61
+ // The marker a look prompt uses to pin where the user's subject lands.
62
+ export const LOOK_SUBJECT_PLACEHOLDER = '{subject}';
63
+ /**
64
+ * Compose the FINAL generation prompt from a look's style template and the
65
+ * user's subject — the single definition of what "applying a look" means,
66
+ * shared by the admin test window and the web app's concept step so the two
67
+ * can never drift.
68
+ *
69
+ * Rules:
70
+ * - Template contains `{subject}` → substitute (every occurrence) with the
71
+ * trimmed subject. With an empty subject the marker is simply removed and
72
+ * the template stands alone.
73
+ * - No marker → the subject leads and the style follows: `<subject>. <template>`
74
+ * (subject-first scenes read best with image models). Empty subject → the
75
+ * template unchanged.
76
+ * Whitespace is collapsed at the join so templates/subjects with stray spaces
77
+ * don't produce double gaps.
78
+ */
79
+ export function applyLookPrompt(lookPrompt, subject) {
80
+ const template = lookPrompt.trim();
81
+ const trimmedSubject = subject.trim();
82
+ if (template.includes(LOOK_SUBJECT_PLACEHOLDER)) {
83
+ return template
84
+ .split(LOOK_SUBJECT_PLACEHOLDER)
85
+ .join(trimmedSubject)
86
+ .replace(/ {2,}/g, ' ')
87
+ .replace(/ ,/g, ',')
88
+ .trim();
89
+ }
90
+ return trimmedSubject ? `${trimmedSubject}. ${template}` : template;
91
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuragpal02/zcl-contracts",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",