@vtex-email/core 0.1.0 → 0.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/expression/path.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,EAAE,CAAA;CAAE,CAAA;AAExD,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3G,wBAAgB,UAAU,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAO9D;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,UAAU,CAiCzE;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAc5D"}
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/expression/path.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,EAAE,CAAA;CAAE,CAAA;AAExD,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3G,wBAAgB,UAAU,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAO9D;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,UAAU,CAoCzE;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAc5D"}
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ export declare const fixtureMetaSchema: z.ZodObject<{
3
+ description: z.ZodString;
4
+ origin: z.ZodString;
5
+ event: z.ZodString;
6
+ purpose: z.ZodString;
7
+ expectedLocale: z.ZodOptional<z.ZodString>;
8
+ expect: z.ZodDefault<z.ZodEnum<{
9
+ valid: "valid";
10
+ invalid: "invalid";
11
+ }>>;
12
+ }, z.core.$strict>;
13
+ export declare const fixtureFileSchema: z.ZodObject<{
14
+ $schema: z.ZodOptional<z.ZodString>;
15
+ meta: z.ZodObject<{
16
+ description: z.ZodString;
17
+ origin: z.ZodString;
18
+ event: z.ZodString;
19
+ purpose: z.ZodString;
20
+ expectedLocale: z.ZodOptional<z.ZodString>;
21
+ expect: z.ZodDefault<z.ZodEnum<{
22
+ valid: "valid";
23
+ invalid: "invalid";
24
+ }>>;
25
+ }, z.core.$strict>;
26
+ data: z.ZodJSONSchema;
27
+ }, z.core.$strict>;
28
+ export type FixtureMeta = z.infer<typeof fixtureMetaSchema>;
29
+ export type FixtureFile = z.infer<typeof fixtureFileSchema>;
30
+ export declare function fixtureFileJsonSchema(): Record<string, unknown>;
31
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/fixture/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB;;;;;;;;;;kBASnB,CAAA;AAEX,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;kBAMnB,CAAA;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAC3D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE/D"}
@@ -0,0 +1,85 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "$schema": {
6
+ "type": "string"
7
+ },
8
+ "meta": {
9
+ "type": "object",
10
+ "properties": {
11
+ "description": {
12
+ "type": "string"
13
+ },
14
+ "origin": {
15
+ "type": "string"
16
+ },
17
+ "event": {
18
+ "type": "string"
19
+ },
20
+ "purpose": {
21
+ "type": "string"
22
+ },
23
+ "expectedLocale": {
24
+ "type": "string"
25
+ },
26
+ "expect": {
27
+ "default": "valid",
28
+ "type": "string",
29
+ "enum": [
30
+ "valid",
31
+ "invalid"
32
+ ]
33
+ }
34
+ },
35
+ "required": [
36
+ "description",
37
+ "origin",
38
+ "event",
39
+ "purpose"
40
+ ],
41
+ "additionalProperties": false
42
+ },
43
+ "data": {
44
+ "$ref": "#/$defs/__schema0"
45
+ }
46
+ },
47
+ "required": [
48
+ "meta",
49
+ "data"
50
+ ],
51
+ "additionalProperties": false,
52
+ "$defs": {
53
+ "__schema0": {
54
+ "anyOf": [
55
+ {
56
+ "type": "string"
57
+ },
58
+ {
59
+ "type": "number"
60
+ },
61
+ {
62
+ "type": "boolean"
63
+ },
64
+ {
65
+ "type": "null"
66
+ },
67
+ {
68
+ "type": "array",
69
+ "items": {
70
+ "$ref": "#/$defs/__schema0"
71
+ }
72
+ },
73
+ {
74
+ "type": "object",
75
+ "propertyNames": {
76
+ "type": "string"
77
+ },
78
+ "additionalProperties": {
79
+ "$ref": "#/$defs/__schema0"
80
+ }
81
+ }
82
+ ]
83
+ }
84
+ }
85
+ }
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export { isSafeEmailId, type EmailDefinition, type EmailDocument, type EmailI18n
6
6
  export { errorDiagnostic, warningDiagnostic, type Diagnostic, type DiagnosticSource, type Failure } from './diagnostics';
7
7
  export { emitPath, parentHops, parsePath, type Expression, type PathResult } from './expression/path';
8
8
  export { checkFixture, schemaMutates } from './fixture/check';
9
+ export { fixtureFileJsonSchema, fixtureFileSchema, fixtureMetaSchema, type FixtureFile, type FixtureMeta, } from './fixture/file';
9
10
  export { readPathValue, withForcedLocale } from './fixture/locale-path';
10
11
  export { emitBlockClose, emitBlockOpen, emitHelperCall, emitInterpolation, emitLiteral } from './hbs/source';
11
12
  export { checkCatalogs } from './i18n/catalog';
@@ -13,10 +14,10 @@ export { mergeLocaleDocuments } from './i18n/merge';
13
14
  export { parseMessage, placeholderSignature, type MessagePart, type ParsedMessage } from './i18n/message';
14
15
  export { bindSites, type BindResult } from './markers/bind';
15
16
  export { restoreHandlebars, type RestoreResult } from './markers/restore';
16
- export type { BlockName, DynamicAttribute, ResolvedPath, SiteArgument, SiteRecord } from './markers/sites';
17
+ export type { BlockName, DynamicAttribute, ResolvedPath, SiteArgument, SiteHash, SiteRecord } from './markers/sites';
17
18
  export { mintToken, opaqueTokenIssue, scanTokens, TOKEN_BODY_LENGTH, TOKEN_LENGTH, TOKEN_PREFIX, type AttrMarker, type ElseMarker, type Marker, type OpenMarker, type TextMarker, } from './markers/tokens';
18
19
  export { commitArtifacts, releaseArtifacts } from './output/commit';
19
- export { findCapability, syntaxHelperNames, type BlockHelper, type BlockOptions, type EmissionCapability, type EmissionProfile, type Evidence, type InlineHelper, type LocalSimulator, type Profile, type SimulatorHelper, } from './profile';
20
+ export { findCapability, syntaxHelperNames, type BlockHelper, type BlockOptions, type EmissionCapability, type EmissionProfile, type Evidence, type HashArg, type InlineHelper, type LocalSimulator, type Profile, type SimulatorHelper, } from './profile';
20
21
  export { singleDocumentIssue } from './runtime/document';
21
22
  export { evaluateArtifact, renderTemplate, TemplateFailure } from './runtime/evaluate';
22
23
  export { analyzePaths, analyzeRootPath } from './scope/analyze-paths';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,MAAM,EACN,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EACL,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,uBAAuB,GAC7B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAA;AACxH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACrG,OAAO,EAAE,YAAY,EAAE,aA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AAuB,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAA"}
package/dist/index.js CHANGED
@@ -183,15 +183,16 @@ function checkCapabilities(sites, profile) {
183
183
  const diagnostics = [];
184
184
  for (const site of sites.values()) {
185
185
  if (site.kind === "helper") {
186
- const capability = findCapability(profile, site.helper ?? "");
186
+ const capability = findCapability(profile, site.helper ?? "", "inline");
187
187
  if (!capability || capability.form !== "inline") {
188
188
  diagnostics.push(errorDiagnostic("HBS002", `Helper is not enabled: ${site.helper ?? ""}`));
189
189
  continue;
190
190
  }
191
191
  diagnostics.push(...checkArguments(capability, site));
192
+ diagnostics.push(...checkLiterals(capability, site));
192
193
  }
193
194
  if (site.kind === "block") {
194
- const capability = findCapability(profile, site.block ?? "");
195
+ const capability = findCapability(profile, site.block ?? "", "block");
195
196
  if (!capability || capability.form !== "block") {
196
197
  diagnostics.push(errorDiagnostic("HBS002", `Block is not enabled: ${site.block ?? ""}`));
197
198
  continue;
@@ -199,9 +200,19 @@ function checkCapabilities(sites, profile) {
199
200
  if (capability.context === void 0 || capability.elseContext === void 0) {
200
201
  diagnostics.push(errorDiagnostic("HBS002", `Block ${site.block ?? ""} does not declare its context.`));
201
202
  }
203
+ diagnostics.push(...checkArguments(capability, site));
204
+ diagnostics.push(...checkHash(capability, site));
205
+ diagnostics.push(...checkLiterals(capability, site));
206
+ }
207
+ if (site.path?.emitted === "@index") {
208
+ const capability = findCapability(profile, "@index", "path");
209
+ if (!capability) {
210
+ diagnostics.push(errorDiagnostic("HBS002", "The profile does not enable the @index path.", { path: "@index" }));
211
+ }
202
212
  }
203
213
  diagnostics.push(...checkParentCapability(site.path, profile));
204
214
  for (const arg of site.args ?? []) diagnostics.push(...checkParentCapability(arg.path, profile));
215
+ for (const arg of Object.values(site.hash ?? {})) diagnostics.push(...checkParentCapability(arg.path, profile));
205
216
  }
206
217
  return diagnostics;
207
218
  }
@@ -219,7 +230,16 @@ function checkArguments(capability, site) {
219
230
  const diagnostics = [];
220
231
  capability.args.forEach((expected, index) => {
221
232
  const actual = args[index];
222
- if (actual && actual.kind !== expected) {
233
+ if (!actual) return;
234
+ if (expected === "expression") {
235
+ if (actual.kind !== "path" && actual.kind !== "literal") {
236
+ diagnostics.push(
237
+ errorDiagnostic("HBS002", `Helper ${capability.name} argument ${index + 1} must be a path or literal.`)
238
+ );
239
+ }
240
+ return;
241
+ }
242
+ if (actual.kind !== expected) {
223
243
  diagnostics.push(
224
244
  errorDiagnostic("HBS002", `Helper ${capability.name} argument ${index + 1} must be a ${expected}.`)
225
245
  );
@@ -227,6 +247,73 @@ function checkArguments(capability, site) {
227
247
  });
228
248
  return diagnostics;
229
249
  }
250
+ function checkHashKind(expected, actual) {
251
+ if (expected === "expression") return actual.kind === "path" || actual.kind === "literal";
252
+ return actual.kind === expected;
253
+ }
254
+ function checkHash(capability, site) {
255
+ if (!capability.hash) {
256
+ if (site.hash && Object.keys(site.hash).length > 0) {
257
+ return [errorDiagnostic("HBS002", `Helper ${capability.name} does not accept named arguments.`)];
258
+ }
259
+ return [];
260
+ }
261
+ const diagnostics = [];
262
+ const provided = site.hash ?? {};
263
+ for (const expected of capability.hash) {
264
+ const actual = provided[expected.name];
265
+ if (!actual) {
266
+ diagnostics.push(errorDiagnostic("HBS002", `Helper ${capability.name} requires named argument ${expected.name}.`));
267
+ continue;
268
+ }
269
+ if (!checkHashKind(expected.kind, actual)) {
270
+ diagnostics.push(
271
+ errorDiagnostic(
272
+ "HBS002",
273
+ `Helper ${capability.name} named argument ${expected.name} must be a ${expected.kind === "expression" ? "path or literal" : expected.kind}.`
274
+ )
275
+ );
276
+ }
277
+ if (expected.name === "by" && actual.kind === "literal") {
278
+ const raw = unwrapQuotedLiteral(actual.emitted);
279
+ if (raw === null || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(raw)) {
280
+ diagnostics.push(
281
+ errorDiagnostic("HBS002", `Helper ${capability.name} named argument by must be an identifier literal.`)
282
+ );
283
+ }
284
+ }
285
+ }
286
+ for (const name of Object.keys(provided)) {
287
+ if (!capability.hash.some((item) => item.name === name)) {
288
+ diagnostics.push(errorDiagnostic("HBS002", `Helper ${capability.name} does not accept named argument ${name}.`));
289
+ }
290
+ }
291
+ return diagnostics;
292
+ }
293
+ function checkLiterals(capability, site) {
294
+ if (!capability.literals) return [];
295
+ const diagnostics = [];
296
+ for (const rule of capability.literals) {
297
+ const actual = site.args?.[rule.index];
298
+ if (!actual || actual.kind !== "literal") continue;
299
+ const raw = unwrapQuotedLiteral(actual.emitted);
300
+ if (raw === null || !rule.values.includes(raw)) {
301
+ diagnostics.push(
302
+ errorDiagnostic(
303
+ "HBS002",
304
+ `Helper ${capability.name} argument ${rule.index + 1} must be one of ${rule.values.join(", ")}.`
305
+ )
306
+ );
307
+ }
308
+ }
309
+ return diagnostics;
310
+ }
311
+ function unwrapQuotedLiteral(emitted) {
312
+ if (emitted.length >= 2 && emitted.startsWith('"') && emitted.endsWith('"')) {
313
+ return emitted.slice(1, -1).replaceAll('\\"', '"').replaceAll("\\\\", "\\");
314
+ }
315
+ return null;
316
+ }
230
317
  function checkParentCapability(path2, profile) {
231
318
  if (!path2 || path2.parentHops === 0) return [];
232
319
  const capability = findCapability(profile, "../", "path");
@@ -243,9 +330,11 @@ function checkScope(sites, anchors, profile) {
243
330
  diagnostics.push(errorDiagnostic("TOK001", `Marker ${id} was not located for scope validation.`));
244
331
  continue;
245
332
  }
246
- const depth = depthAt(anchor.start, id, regions);
247
- diagnostics.push(...checkDepth(site.path, depth));
248
- for (const arg of site.args ?? []) diagnostics.push(...checkDepth(arg.path, depth));
333
+ const depth = depthAt(anchor.start, id, regions, "item");
334
+ const eachDepth = depthAt(anchor.start, id, regions, "each");
335
+ diagnostics.push(...checkDepth(site.path, depth, eachDepth));
336
+ for (const arg of site.args ?? []) diagnostics.push(...checkDepth(arg.path, depth, eachDepth));
337
+ for (const arg of Object.values(site.hash ?? {})) diagnostics.push(...checkDepth(arg.path, depth, eachDepth));
249
338
  }
250
339
  return diagnostics;
251
340
  }
@@ -254,22 +343,36 @@ function regionsFrom(sites, anchors, profile) {
254
343
  for (const [id, site] of sites) {
255
344
  if (site.kind !== "block" || !site.block) continue;
256
345
  const anchor = anchors.get(id);
257
- const capability = findCapability(profile, site.block);
346
+ const capability = findCapability(profile, site.block, "block");
258
347
  if (!anchor || !capability) continue;
259
- regions.push({ ...anchor, id, pushes: capability.context === "item" });
348
+ regions.push({
349
+ ...anchor,
350
+ id,
351
+ pushes: capability.context === "item",
352
+ each: site.block === "each"
353
+ });
260
354
  }
261
355
  return regions;
262
356
  }
263
- function depthAt(offset, selfId, regions) {
357
+ function depthAt(offset, selfId, regions, mode) {
264
358
  let depth = 0;
265
359
  for (const region of regions) {
266
- if (!region.pushes || region.id === selfId) continue;
360
+ if (region.id === selfId) continue;
361
+ if (mode === "item" && !region.pushes) continue;
362
+ if (mode === "each" && !region.each) continue;
267
363
  if (offset > region.start && offset < region.end) depth += 1;
268
364
  }
269
365
  return depth;
270
366
  }
271
- function checkDepth(path2, depth) {
272
- if (!path2 || path2.parentHops <= depth) return [];
367
+ function checkDepth(path2, depth, eachDepth) {
368
+ if (!path2) return [];
369
+ if (path2.emitted === "@index") {
370
+ if (eachDepth < 1) {
371
+ return [errorDiagnostic("HBS001", 'Path "@index" is only available inside each.', { path: "@index" })];
372
+ }
373
+ return [];
374
+ }
375
+ if (path2.parentHops <= depth) return [];
273
376
  return [errorDiagnostic("HBS001", `Path "${path2.emitted}" goes beyond the root context.`, { path: path2.emitted })];
274
377
  }
275
378
  function usedCapabilities(sites, profile) {
@@ -277,8 +380,14 @@ function usedCapabilities(sites, profile) {
277
380
  for (const site of sites.values()) {
278
381
  if (site.kind === "block" && site.block) names.add(site.block);
279
382
  if (site.kind === "helper" && site.helper) names.add(site.helper);
383
+ if (site.path?.emitted === "@index") names.add("@index");
280
384
  if (site.path && site.path.parentHops > 0) names.add("../");
281
385
  for (const arg of site.args ?? []) {
386
+ if (arg.path?.emitted === "@index") names.add("@index");
387
+ if (arg.path && arg.path.parentHops > 0) names.add("../");
388
+ }
389
+ for (const arg of Object.values(site.hash ?? {})) {
390
+ if (arg.path?.emitted === "@index") names.add("@index");
282
391
  if (arg.path && arg.path.parentHops > 0) names.add("../");
283
392
  }
284
393
  }
@@ -307,17 +416,28 @@ function materialize(marker, site) {
307
416
  if (literal) return { ok: true, marker: { ...marker, replacement: emitInterpolation(literal.emitted) } };
308
417
  }
309
418
  if (marker.kind === "attr" && site.kind === "attr") {
310
- const path2 = site.path;
311
- const literal = site.args?.find((arg) => arg.kind === "literal");
312
- if (path2) return { ok: true, marker: { ...marker, replacement: emitInterpolation(path2.emitted) } };
313
- if (literal) return { ok: true, marker: { ...marker, replacement: emitInterpolation(literal.emitted) } };
419
+ if (site.path) {
420
+ return { ok: true, marker: { ...marker, replacement: emitInterpolation(site.path.emitted) } };
421
+ }
422
+ const args = site.args ?? [];
423
+ if (args.length === 1 && args[0]?.kind === "literal" && args[0].emitted.startsWith('"')) {
424
+ return { ok: true, marker: { ...marker, replacement: emitInterpolation(args[0].emitted) } };
425
+ }
426
+ if (args.length >= 1) {
427
+ const replacement = args.map((arg) => arg.kind === "path" ? emitInterpolation(arg.emitted) : arg.emitted).join("");
428
+ return { ok: true, marker: { ...marker, replacement } };
429
+ }
314
430
  }
315
431
  if (marker.kind === "open" && site.kind === "block" && site.block && site.path) {
432
+ const parts = [site.path.emitted, ...(site.args ?? []).map((arg) => arg.emitted)];
433
+ for (const [name, arg] of Object.entries(site.hash ?? {})) {
434
+ parts.push(`${name}=${arg.emitted}`);
435
+ }
316
436
  return {
317
437
  ok: true,
318
438
  marker: {
319
439
  ...marker,
320
- open: emitBlockOpen(site.block, [site.path.emitted]),
440
+ open: emitBlockOpen(site.block, parts),
321
441
  close: emitBlockClose(site.block)
322
442
  }
323
443
  };
@@ -540,20 +660,30 @@ function openEdits(source, id, marker, markers, located) {
540
660
  const closed = explicitElement(source, id, located.get(id));
541
661
  if (!closed.ok) return closed;
542
662
  const { location } = closed;
663
+ const startTag = location.startTag;
664
+ const endTag = location.endTag;
665
+ if (!startTag || !endTag) return fail("TOK001", `Opening ${id} has no explicit tags.`);
543
666
  const attr = location.attrs?.["data-anchor"];
544
667
  if (!attr) return fail("TOK001", `Opening ${id} was not located.`);
545
668
  const attrText = source.slice(attr.startOffset, attr.endOffset);
546
669
  if (attrText !== `data-anchor="${id}"`) return fail("TOK001", `Anchor ${id} was escaped or shifted.`);
670
+ const startExpected = source.slice(startTag.startOffset, startTag.endOffset);
547
671
  const edits = [
548
- { start: location.startOffset, end: location.startOffset, text: marker.open, expected: "", rank: 0 },
549
- anchorRemoval(source, attr.startOffset, attr.endOffset, attrText)
672
+ {
673
+ start: startTag.startOffset,
674
+ end: startTag.endOffset,
675
+ text: marker.open,
676
+ expected: startExpected,
677
+ rank: 0
678
+ }
550
679
  ];
551
680
  if (!marker.elseId) {
681
+ const endExpected2 = source.slice(endTag.startOffset, endTag.endOffset);
552
682
  edits.push({
553
- start: location.endOffset,
554
- end: location.endOffset,
683
+ start: endTag.startOffset,
684
+ end: endTag.endOffset,
555
685
  text: marker.close,
556
- expected: "",
686
+ expected: endExpected2,
557
687
  rank: 1
558
688
  });
559
689
  return { ok: true, edits };
@@ -562,6 +692,14 @@ function openEdits(source, id, marker, markers, located) {
562
692
  if (!alternative || alternative.kind !== "else" || alternative.openId !== id) {
563
693
  return fail("TOK001", `Alternative for block ${id} is not balanced.`);
564
694
  }
695
+ const endExpected = source.slice(endTag.startOffset, endTag.endOffset);
696
+ edits.push({
697
+ start: endTag.startOffset,
698
+ end: endTag.endOffset,
699
+ text: "",
700
+ expected: endExpected,
701
+ rank: 1
702
+ });
565
703
  return { ok: true, edits };
566
704
  }
567
705
  function elseEdits(source, id, marker, markers, located) {
@@ -572,6 +710,9 @@ function elseEdits(source, id, marker, markers, located) {
572
710
  }
573
711
  if (!closed.ok) return closed;
574
712
  const { location } = closed;
713
+ const startTag = location.startTag;
714
+ const endTag = location.endTag;
715
+ if (!startTag || !endTag) return fail("TOK001", `Alternative for block ${id} is not balanced.`);
575
716
  const attr = location.attrs?.["data-anchor"];
576
717
  if (!attr) return fail("TOK001", `Closing for block ${id} is not balanced.`);
577
718
  const attrText = source.slice(attr.startOffset, attr.endOffset);
@@ -579,9 +720,20 @@ function elseEdits(source, id, marker, markers, located) {
579
720
  return {
580
721
  ok: true,
581
722
  edits: [
582
- { start: location.startOffset, end: location.startOffset, text: "{{else}}", expected: "", rank: 0 },
583
- anchorRemoval(source, attr.startOffset, attr.endOffset, attrText),
584
- { start: location.endOffset, end: location.endOffset, text: opener.close, expected: "", rank: 1 }
723
+ {
724
+ start: startTag.startOffset,
725
+ end: startTag.endOffset,
726
+ text: "{{else}}",
727
+ expected: source.slice(startTag.startOffset, startTag.endOffset),
728
+ rank: 0
729
+ },
730
+ {
731
+ start: endTag.startOffset,
732
+ end: endTag.endOffset,
733
+ text: opener.close,
734
+ expected: source.slice(endTag.startOffset, endTag.endOffset),
735
+ rank: 1
736
+ }
585
737
  ]
586
738
  };
587
739
  }
@@ -616,16 +768,6 @@ function isImagePreload(element, attribute) {
616
768
  const as = element.attrs.find((attr) => attr.name === "as")?.value;
617
769
  return rel === "preload" && as === "image";
618
770
  }
619
- function anchorRemoval(source, start, end, attrText) {
620
- const withSpace = start > 0 && source[start - 1] === " ";
621
- return {
622
- start: withSpace ? start - 1 : start,
623
- end,
624
- text: "",
625
- expected: withSpace ? ` ${attrText}` : attrText,
626
- rank: 2
627
- };
628
- }
629
771
  function fail(code, message) {
630
772
  return { ok: false, diagnostics: [errorDiagnostic(code, message)] };
631
773
  }
@@ -739,6 +881,9 @@ function parentHops(segments) {
739
881
  }
740
882
  function parsePath(input, allowParent) {
741
883
  if (input.length === 0) return { ok: false, message: "Empty path." };
884
+ if (input === "@index") {
885
+ return { ok: true, segments: ["@index"], emitted: "@index" };
886
+ }
742
887
  if (input.includes("@") || input.includes("[") || input.includes("]")) {
743
888
  return { ok: false, message: `Unsupported path syntax: ${input}` };
744
889
  }
@@ -863,6 +1008,25 @@ function checkFixture(schema, data) {
863
1008
  return null;
864
1009
  }
865
1010
 
1011
+ // src/fixture/file.ts
1012
+ import { z as z2 } from "zod";
1013
+ var fixtureMetaSchema = z2.object({
1014
+ description: z2.string(),
1015
+ origin: z2.string(),
1016
+ event: z2.string(),
1017
+ purpose: z2.string(),
1018
+ expectedLocale: z2.string().optional(),
1019
+ expect: z2.enum(["valid", "invalid"]).default("valid")
1020
+ }).strict();
1021
+ var fixtureFileSchema = z2.object({
1022
+ $schema: z2.string().optional(),
1023
+ meta: fixtureMetaSchema,
1024
+ data: z2.json()
1025
+ }).strict();
1026
+ function fixtureFileJsonSchema() {
1027
+ return z2.toJSONSchema(fixtureFileSchema, { io: "input" });
1028
+ }
1029
+
866
1030
  // src/fixture/locale-path.ts
867
1031
  function readPathValue(data, pathExpression) {
868
1032
  const parsed = parsePath(pathExpression, false);
@@ -1148,8 +1312,12 @@ function renderTemplate(source, data, simulator) {
1148
1312
  } else {
1149
1313
  const apply = helper.apply;
1150
1314
  instance.registerHelper(helper.name, function(...args) {
1151
- const blockOptions = args.at(-1);
1152
- return apply(this, args.slice(0, -1), blockOptions);
1315
+ const raw = args.at(-1);
1316
+ return apply(this, args.slice(0, -1), {
1317
+ fn: raw.fn,
1318
+ inverse: raw.inverse,
1319
+ hash: raw.hash ?? {}
1320
+ });
1153
1321
  });
1154
1322
  }
1155
1323
  }
@@ -1191,6 +1359,11 @@ function walk(nodes, stack, guards) {
1191
1359
  diagnostics.push(...inspectRef(node, stack, guards));
1192
1360
  continue;
1193
1361
  }
1362
+ if (node.path === "@index") {
1363
+ diagnostics.push(...walk(node.children, stack, guards));
1364
+ diagnostics.push(...walk(node.fallback, stack, guards));
1365
+ continue;
1366
+ }
1194
1367
  const absolute = absoluteSegments(node.path, node.parentHops, stack);
1195
1368
  const missing = absolute ? null : contractDiagnostic(node.path, "missing");
1196
1369
  if (!absolute || missing) {
@@ -1211,9 +1384,37 @@ function walk(nodes, stack, guards) {
1211
1384
  continue;
1212
1385
  }
1213
1386
  const child = { schema: elements, prefix: [...absolute.segments, "[]"] };
1214
- const outer = framesAt(stack, node.parentHops);
1215
- diagnostics.push(...walk(node.children, [...outer, child], guards));
1216
- diagnostics.push(...walk(node.fallback, outer, guards));
1387
+ diagnostics.push(...walk(node.children, [...stack, child], guards));
1388
+ diagnostics.push(...walk(node.fallback, stack, guards));
1389
+ continue;
1390
+ }
1391
+ if (node.block === "group") {
1392
+ const elements = arrayElements(lookup.schema);
1393
+ if (!elements) {
1394
+ diagnostics.push(errorDiagnostic("PATH001", `Path "${node.path}" is not an array.`, { path: node.path }));
1395
+ continue;
1396
+ }
1397
+ const child = {
1398
+ schema: groupFrameSchema(elements),
1399
+ prefix: [...absolute.segments, "group"]
1400
+ };
1401
+ diagnostics.push(...walk(node.children, [...stack, child], guards));
1402
+ diagnostics.push(...walk(node.fallback, stack, guards));
1403
+ continue;
1404
+ }
1405
+ if (node.block === "with") {
1406
+ const child = { schema: lookup.schema, prefix: absolute.segments };
1407
+ diagnostics.push(...walk(node.children, [...stack, child], guards));
1408
+ diagnostics.push(...walk(node.fallback, stack, guards));
1409
+ continue;
1410
+ }
1411
+ if (node.block === "richShippingData") {
1412
+ const child = {
1413
+ schema: enrichShippingSchema(lookup.schema),
1414
+ prefix: absolute.segments
1415
+ };
1416
+ diagnostics.push(...walk(node.children, [...stack, child], guards));
1417
+ diagnostics.push(...walk(node.fallback, stack, guards));
1217
1418
  continue;
1218
1419
  }
1219
1420
  const nextGuards = [...guards, absolute.segments];
@@ -1231,6 +1432,7 @@ function inspectRef(node, stack, guards) {
1231
1432
  return diagnostics;
1232
1433
  }
1233
1434
  function inspectPath(path2, hops, stack, guards) {
1435
+ if (path2 === "@index") return [];
1234
1436
  const absolute = absoluteSegments(path2, hops, stack);
1235
1437
  if (!absolute) {
1236
1438
  const missing = contractDiagnostic(path2, "missing");
@@ -1298,6 +1500,12 @@ function resolve(schema, segments) {
1298
1500
  return { status: "found", optional: peeled.optional || next.optional, schema: next.schema };
1299
1501
  }
1300
1502
  if (current?.type === "array" && current.element) {
1503
+ if (segments[0] === "length") {
1504
+ if (segments.length === 1) {
1505
+ return { status: "found", optional: peeled.optional, schema: { def: { type: "number" } } };
1506
+ }
1507
+ return { status: "missing" };
1508
+ }
1301
1509
  if (!/^[0-9]+$/.test(segments[0] ?? "")) return { status: "missing" };
1302
1510
  const next = resolve(current.element, segments.slice(1));
1303
1511
  if (next.status !== "found") return next;
@@ -1322,6 +1530,76 @@ function arrayElements(schema) {
1322
1530
  }
1323
1531
  return null;
1324
1532
  }
1533
+ function groupFrameSchema(element) {
1534
+ return {
1535
+ def: {
1536
+ type: "object",
1537
+ shape: {
1538
+ index: { def: { type: "number" } },
1539
+ value: { def: { type: "string" } },
1540
+ items: { def: { type: "array", element } }
1541
+ }
1542
+ }
1543
+ };
1544
+ }
1545
+ var derivedLogisticsFields = {
1546
+ packageId: { def: { type: "string" } },
1547
+ shippingEstimate: { def: { type: "string" } },
1548
+ shippingEstimateDate: { def: { type: "string" } },
1549
+ shippingEstimateDays: { def: { type: "string" } },
1550
+ shippingEstimateDaysType: { def: { type: "string" } },
1551
+ deliveryWindow: {
1552
+ def: {
1553
+ type: "object",
1554
+ shape: {
1555
+ startDateUtc: { def: { type: "string" } },
1556
+ endDateUtc: { def: { type: "string" } }
1557
+ }
1558
+ }
1559
+ },
1560
+ availableDeliveryWindows: {
1561
+ def: {
1562
+ type: "array",
1563
+ element: {
1564
+ def: {
1565
+ type: "object",
1566
+ shape: {
1567
+ startDateUtc: { def: { type: "string" } },
1568
+ endDateUtc: { def: { type: "string" } }
1569
+ }
1570
+ }
1571
+ }
1572
+ }
1573
+ }
1574
+ };
1575
+ function enrichShippingSchema(schema) {
1576
+ const peeled = peelSchema(schema);
1577
+ if (peeled.status !== "ready") return schema;
1578
+ const current = schemaDef(peeled.schema);
1579
+ if (!current || current.type !== "object" || !current.shape) return schema;
1580
+ const logistics = current.shape.logisticsInfo;
1581
+ if (!logistics) return schema;
1582
+ const elements = arrayElements(logistics);
1583
+ if (!elements) return schema;
1584
+ const elementPeeled = peelSchema(elements);
1585
+ const elementDef = elementPeeled.status === "ready" ? schemaDef(elementPeeled.schema) : null;
1586
+ const baseShape = elementDef?.type === "object" && elementDef.shape ? { ...elementDef.shape } : {};
1587
+ const enrichedElement = {
1588
+ def: {
1589
+ type: "object",
1590
+ shape: { ...baseShape, ...derivedLogisticsFields }
1591
+ }
1592
+ };
1593
+ return {
1594
+ def: {
1595
+ type: "object",
1596
+ shape: {
1597
+ ...current.shape,
1598
+ logisticsInfo: { def: { type: "array", element: enrichedElement } }
1599
+ }
1600
+ }
1601
+ };
1602
+ }
1325
1603
  export {
1326
1604
  TOKEN_BODY_LENGTH,
1327
1605
  TOKEN_LENGTH,
@@ -1343,6 +1621,9 @@ export {
1343
1621
  errorDiagnostic,
1344
1622
  evaluateArtifact,
1345
1623
  findCapability,
1624
+ fixtureFileJsonSchema,
1625
+ fixtureFileSchema,
1626
+ fixtureMetaSchema,
1346
1627
  isSafeEmailId,
1347
1628
  mergeLocaleDocuments,
1348
1629
  mintToken,
@@ -1 +1 @@
1
- {"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../src/markers/bind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AActC,MAAM,MAAM,UAAU,GAClB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAAC,SAAS,EAAE,SAAS,EAAE,CAAA;CAAE,GAC9F,OAAO,CAAA;AAEX,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EACtC,OAAO,EAAE,eAAe,GACvB,UAAU,CAuBZ"}
1
+ {"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../src/markers/bind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,EAAW,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EAA8B,UAAU,EAAE,MAAM,SAAS,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AActC,MAAM,MAAM,UAAU,GAClB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAAC,SAAS,EAAE,SAAS,EAAE,CAAA;CAAE,GAC9F,OAAO,CAAA;AAEX,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EACtC,OAAO,EAAE,eAAe,GACvB,UAAU,CAuBZ"}
@@ -1,21 +1,25 @@
1
- import type { ArgKind } from '../profile';
2
- export type BlockName = 'each' | 'if' | 'unless';
1
+ export type BlockName = 'each' | 'if' | 'unless' | 'ifCond' | 'hasSubStr' | 'group' | 'eq' | 'with' | 'math' | 'richShippingData';
3
2
  export type DynamicAttribute = 'href' | 'src' | 'alt' | 'title';
3
+ export type SiteArgKind = 'path' | 'literal';
4
4
  export interface ResolvedPath {
5
5
  emitted: string;
6
6
  parentHops: number;
7
7
  }
8
8
  export interface SiteArgument {
9
- kind: ArgKind;
9
+ kind: SiteArgKind;
10
10
  emitted: string;
11
11
  path?: ResolvedPath;
12
12
  }
13
+ export interface SiteHash {
14
+ readonly [name: string]: SiteArgument;
15
+ }
13
16
  export interface SiteRecord {
14
17
  kind: 'value' | 'helper' | 'block' | 'attr' | 'literal';
15
18
  path?: ResolvedPath;
16
19
  block?: BlockName;
17
20
  helper?: string;
18
21
  args?: readonly SiteArgument[];
22
+ hash?: SiteHash;
19
23
  attribute?: DynamicAttribute;
20
24
  }
21
25
  //# sourceMappingURL=sites.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../../src/markers/sites.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAA;AAEhD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,CAAA;AAE/D,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,YAAY,CAAA;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;IACvD,IAAI,CAAC,EAAE,YAAY,CAAA;IACnB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;IAC9B,SAAS,CAAC,EAAE,gBAAgB,CAAA;CAC7B"}
1
+ {"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../../src/markers/sites.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,IAAI,GACJ,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,OAAO,GACP,IAAI,GACJ,MAAM,GACN,MAAM,GACN,kBAAkB,CAAA;AAEtB,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,CAAA;AAE/D,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,CAAA;AAE5C,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,YAAY,CAAA;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;CACtC;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;IACvD,IAAI,CAAC,EAAE,YAAY,CAAA;IACnB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;IAC9B,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,SAAS,CAAC,EAAE,gBAAgB,CAAA;CAC7B"}
package/dist/profile.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export type Evidence = 'documented' | 'verified' | 'experimental';
2
- export type ArgKind = 'path' | 'literal';
2
+ export type ArgKind = 'path' | 'literal' | 'expression';
3
+ export interface HashArg {
4
+ name: string;
5
+ kind: ArgKind;
6
+ }
3
7
  export interface EmissionCapability {
4
8
  name: string;
5
9
  form: 'inline' | 'block' | 'path';
@@ -10,6 +14,11 @@ export interface EmissionCapability {
10
14
  max: number;
11
15
  };
12
16
  args?: readonly ArgKind[];
17
+ hash?: readonly HashArg[];
18
+ literals?: ReadonlyArray<{
19
+ index: number;
20
+ values: readonly string[];
21
+ }>;
13
22
  context?: 'preserve' | 'item';
14
23
  elseContext?: 'preserve' | 'outer';
15
24
  }
@@ -28,6 +37,7 @@ export interface InlineHelper {
28
37
  export interface BlockOptions {
29
38
  fn: (context: unknown) => string;
30
39
  inverse: (context: unknown) => string;
40
+ hash: Readonly<Record<string, unknown>>;
31
41
  }
32
42
  export interface BlockHelper {
33
43
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,cAAc,CAAA;AAEjE,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;AAExC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IACjC,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACpC,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAA;IACzB,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;IAC7B,WAAW,CAAC,EAAE,UAAU,GAAG,OAAO,CAAA;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,mBAAmB,E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AKtC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,GAAG,MAAM,CAyB/F;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,EAAE,cAAc,CAAA;CAC1B,GAAG,MAAM,CAQT"}
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/runtime/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMjE,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAA;gBAEtB,WAAW,EAAE,UAAU,EAAE;CAKtC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,GAAG,MAAM,CAiC/F;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,EAAE,cAAc,CAAA;CAC1B,GAAG,MAAM,CAQT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex-email/core",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/marcelotk15/vtex-react-email.git"
@@ -15,7 +15,8 @@
15
15
  "types": "./dist/index.d.ts",
16
16
  "import": "./dist/index.js",
17
17
  "default": "./dist/index.js"
18
- }
18
+ },
19
+ "./fixture.schema.json": "./dist/fixture.schema.json"
19
20
  },
20
21
  "dependencies": {
21
22
  "handlebars": "4.7.9",