@vtex-email/vtex 0.0.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/capabilities.d.ts +3 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +120 -0
- package/dist/simulator.d.ts +3 -0
- package/dist/simulator.d.ts.map +1 -0
- package/package.json +19 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD,eAAO,MAAM,qBAAqB,EAAE,eA2DnC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAK/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEpD,eAAO,MAAM,SAAS,EAAE,OAGvB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// src/capabilities.ts
|
|
2
|
+
var messageCenterEmission = {
|
|
3
|
+
id: "p0-message-center-experimental",
|
|
4
|
+
allowParentSegments: true,
|
|
5
|
+
capabilities: [
|
|
6
|
+
{
|
|
7
|
+
name: "each",
|
|
8
|
+
form: "block",
|
|
9
|
+
evidence: "documented",
|
|
10
|
+
note: "Native Handlebars helper. The item context replaces the current context. The fallback uses the outer context.",
|
|
11
|
+
context: "item",
|
|
12
|
+
elseContext: "outer"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "if",
|
|
16
|
+
form: "block",
|
|
17
|
+
evidence: "documented",
|
|
18
|
+
note: "Handlebars truthiness. 0, an empty string, and an empty array are false. The toolchain does not use Boolean(). Both branches keep the current context.",
|
|
19
|
+
context: "preserve",
|
|
20
|
+
elseContext: "preserve"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "unless",
|
|
24
|
+
form: "block",
|
|
25
|
+
evidence: "documented",
|
|
26
|
+
note: "Negation of if. Both branches keep the current context.",
|
|
27
|
+
context: "preserve",
|
|
28
|
+
elseContext: "preserve"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "../",
|
|
32
|
+
form: "path",
|
|
33
|
+
evidence: "documented",
|
|
34
|
+
note: "Parent segment documented by Handlebars. A path cannot climb above the template root."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "formatCurrency",
|
|
38
|
+
form: "inline",
|
|
39
|
+
evidence: "documented",
|
|
40
|
+
note: "VTEX documents 20000 as 200,00, without a symbol. Other integers follow the same local simulator, without verified parity.",
|
|
41
|
+
arity: { min: 1, max: 1 },
|
|
42
|
+
args: ["path"]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "replace",
|
|
46
|
+
form: "inline",
|
|
47
|
+
evidence: "documented",
|
|
48
|
+
note: "The official example replaces one occurrence of a literal in a path. The simulator follows that arity.",
|
|
49
|
+
arity: { min: 3, max: 3 },
|
|
50
|
+
args: ["path", "literal", "literal"]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "eq",
|
|
54
|
+
form: "block",
|
|
55
|
+
evidence: "experimental",
|
|
56
|
+
note: "The official example compares two paths. Comparing against a literal is a local simulator until Message Center verification. The DSL does not emit eq.",
|
|
57
|
+
context: "preserve",
|
|
58
|
+
elseContext: "preserve"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/simulator.ts
|
|
64
|
+
function formatCurrency(value) {
|
|
65
|
+
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
66
|
+
throw new Error("formatCurrency: the local simulator expects integer cents.");
|
|
67
|
+
}
|
|
68
|
+
const sign = value < 0 ? "-" : "";
|
|
69
|
+
const absolute = Math.abs(value);
|
|
70
|
+
const units = Math.trunc(absolute / 100);
|
|
71
|
+
const cents = String(absolute % 100).padStart(2, "0");
|
|
72
|
+
return `${sign}${units},${cents}`;
|
|
73
|
+
}
|
|
74
|
+
function replaceOnce(value, search, next) {
|
|
75
|
+
if (typeof value !== "string" || typeof search !== "string" || typeof next !== "string") {
|
|
76
|
+
throw new Error("replace: the local simulator expects three strings.");
|
|
77
|
+
}
|
|
78
|
+
const index = value.indexOf(search);
|
|
79
|
+
if (index < 0) return value;
|
|
80
|
+
return value.slice(0, index) + next + value.slice(index + search.length);
|
|
81
|
+
}
|
|
82
|
+
var messageCenterSimulator = {
|
|
83
|
+
helpers: [
|
|
84
|
+
{
|
|
85
|
+
name: "formatCurrency",
|
|
86
|
+
kind: "inline",
|
|
87
|
+
evidence: "documented",
|
|
88
|
+
note: "20000 -> 200,00 is documented. Other integers are a local contract.",
|
|
89
|
+
apply: formatCurrency
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "replace",
|
|
93
|
+
kind: "inline",
|
|
94
|
+
evidence: "documented",
|
|
95
|
+
note: "One occurrence. A path and two literals.",
|
|
96
|
+
apply: replaceOnce
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "eq",
|
|
100
|
+
kind: "block",
|
|
101
|
+
evidence: "experimental",
|
|
102
|
+
note: "Local strict equality. Not verified on VTEX.",
|
|
103
|
+
apply: (context, values, options) => {
|
|
104
|
+
const [left, right] = values;
|
|
105
|
+
return left === right ? options.fn(context) : options.inverse(context);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// src/index.ts
|
|
112
|
+
var p0Profile = {
|
|
113
|
+
...messageCenterEmission,
|
|
114
|
+
helpers: messageCenterSimulator.helpers
|
|
115
|
+
};
|
|
116
|
+
export {
|
|
117
|
+
messageCenterEmission,
|
|
118
|
+
messageCenterSimulator,
|
|
119
|
+
p0Profile
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulator.d.ts","sourceRoot":"","sources":["../src/simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAsBtD,eAAO,MAAM,sBAAsB,EAAE,cA2BpC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vtex-email/vtex",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist"
|
|
6
|
+
],
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@vtex-email/core": "0.0.0"
|
|
18
|
+
}
|
|
19
|
+
}
|