@vtex-email/preview 0.1.2 → 0.1.3

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.js CHANGED
@@ -67,7 +67,6 @@ function classifyChange(input) {
67
67
  fixtures.delete(id);
68
68
  schemas.delete(id);
69
69
  }
70
- for (const id of schemas) fixtures.delete(id);
71
70
  if (compile.size === 0 && fixtures.size === 0 && schemas.size === 0) return { kind: "none" };
72
71
  return { kind: "partial", compile: [...compile], fixtures: [...fixtures], schemas: [...schemas] };
73
72
  }
@@ -163,25 +162,25 @@ function createPreviewSession(input) {
163
162
  if (token !== generation || closed) return state;
164
163
  failed = !applyCompile(ids, result);
165
164
  }
166
- if (!failed && plan.kind === "partial") {
167
- for (const id of plan.schemas) {
168
- const current = emails.find((email) => email.id === id);
169
- if (!current) continue;
170
- const revalidated = await input.services.revalidateSchema(current);
171
- if (token !== generation || closed) return state;
172
- emails = emails.map((email) => email.id === id ? revalidated : email);
173
- state = { ...state, diagnostics: revalidated.diagnostics };
174
- if (revalidated.diagnostics.some((item) => item.severity === "error")) failed = true;
175
- }
165
+ if (plan.kind === "partial") {
176
166
  if (!failed) {
177
- for (const id of plan.fixtures) {
167
+ for (const id of plan.schemas) {
178
168
  const current = emails.find((email) => email.id === id);
179
169
  if (!current) continue;
180
- const refreshed = await input.services.refreshFixtures(current);
170
+ const revalidated = await input.services.revalidateSchema(current);
181
171
  if (token !== generation || closed) return state;
182
- emails = emails.map((email) => email.id === id ? refreshed : email);
172
+ emails = emails.map((email) => email.id === id ? revalidated : email);
173
+ state = { ...state, diagnostics: revalidated.diagnostics };
174
+ if (revalidated.diagnostics.some((item) => item.severity === "error")) failed = true;
183
175
  }
184
176
  }
177
+ for (const id of plan.fixtures) {
178
+ const current = emails.find((email) => email.id === id);
179
+ if (!current) continue;
180
+ const refreshed = await input.services.refreshFixtures(current);
181
+ if (token !== generation || closed) return state;
182
+ emails = emails.map((email) => email.id === id ? refreshed : email);
183
+ }
185
184
  }
186
185
  if (token !== generation || closed) return state;
187
186
  if (failed) {
@@ -226,20 +225,20 @@ function createPreviewSession(input) {
226
225
  }
227
226
  function applyCompile(ids, result) {
228
227
  state = { ...state, diagnostics: result.diagnostics };
229
- if (!result.ok) return false;
228
+ if (!result.ok && result.emails.length === 0) return false;
230
229
  if (ids === null) {
231
230
  emails = result.emails.slice();
232
- return true;
233
- }
234
- for (const email of result.emails) {
235
- const index = emails.findIndex((item) => item.id === email.id);
236
- if (index >= 0) emails[index] = email;
237
- else emails.push(email);
238
- }
239
- for (const id of ids) {
240
- if (result.removedEmailIds?.includes(id)) emails = emails.filter((email) => email.id !== id);
231
+ } else {
232
+ for (const email of result.emails) {
233
+ const index = emails.findIndex((item) => item.id === email.id);
234
+ if (index >= 0) emails[index] = email;
235
+ else emails.push(email);
236
+ }
237
+ for (const id of ids) {
238
+ if (result.removedEmailIds?.includes(id)) emails = emails.filter((email) => email.id !== id);
239
+ }
241
240
  }
242
- return true;
241
+ return result.ok;
243
242
  }
244
243
  async function evaluate() {
245
244
  const email = normalize();
@@ -1 +1 @@
1
- {"version":3,"file":"change-plan.d.ts","sourceRoot":"","sources":["../../src/session/change-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAKzD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,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,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAEjF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAK7D;AAED,wBAAgB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,KAAK,EAAE,YAAY,CAAA;IACnB,MAAM,EAAE,SAAS,UAAU,EAAE,CAAA;IAC7B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACxB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CACpC,GAAG,UAAU,CAiDb;AA2BD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEpF;AAOD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAKxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex-email/preview",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/marcelotk15/vtex-react-email.git"
@@ -17,7 +17,7 @@
17
17
  }
18
18
  },
19
19
  "dependencies": {
20
- "@vtex-email/cli": "0.2.1",
20
+ "@vtex-email/cli": "0.2.2",
21
21
  "vite": "7.3.1"
22
22
  },
23
23
  "devDependencies": {