@blamejs/blamejs-shop 0.1.29 → 0.1.30
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/CHANGELOG.md +2 -0
- package/README.md +3 -1
- package/SECURITY.md +9 -0
- package/lib/admin.js +317 -1
- package/lib/asset-manifest.json +1 -1
- package/lib/product-qa.js +88 -0
- package/lib/storefront.js +225 -1
- package/lib/vendor/MANIFEST.json +2 -2
- package/lib/vendor/blamejs/CHANGELOG.md +6 -0
- package/lib/vendor/blamejs/README.md +3 -0
- package/lib/vendor/blamejs/api-snapshot.json +74 -2
- package/lib/vendor/blamejs/index.js +6 -0
- package/lib/vendor/blamejs/lib/base32.js +154 -0
- package/lib/vendor/blamejs/lib/json-schema.js +740 -0
- package/lib/vendor/blamejs/lib/totp.js +10 -31
- package/lib/vendor/blamejs/lib/uri-template.js +286 -0
- package/lib/vendor/blamejs/package.json +1 -1
- package/lib/vendor/blamejs/release-notes/v0.12.64.json +18 -0
- package/lib/vendor/blamejs/release-notes/v0.12.65.json +27 -0
- package/lib/vendor/blamejs/release-notes/v0.12.66.json +18 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/base32.test.js +79 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/json-schema.test.js +134 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/uri-template.test.js +99 -0
- package/package.json +1 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Layer 0 — b.uriTemplate (RFC 6570).
|
|
4
|
+
* Oracle: the official uri-templates/uritemplate-test suite (spec-examples,
|
|
5
|
+
* extended-tests, negative-tests) — all 135 cases pass during development.
|
|
6
|
+
* This file embeds a representative slice across all four levels plus the
|
|
7
|
+
* surface, compile-reuse, and malformed-template paths.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var b = require("../../index");
|
|
11
|
+
var helpers = require("../helpers");
|
|
12
|
+
var check = helpers.check;
|
|
13
|
+
function code(fn) { try { fn(); return "NO-THROW"; } catch (e) { return e.code; } }
|
|
14
|
+
|
|
15
|
+
var VARS = {
|
|
16
|
+
count: ["one", "two", "three"], dom: ["example", "com"],
|
|
17
|
+
dub: "me/too", hello: "Hello World!", half: "50%", "var": "value",
|
|
18
|
+
who: "fred", base: "http://example.com/home/", path: "/foo/bar",
|
|
19
|
+
list: ["red", "green", "blue"], keys: { semi: ";", dot: ".", comma: "," },
|
|
20
|
+
v: "6", x: "1024", y: "768", empty: "", undef: undefined,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function testSurface() {
|
|
24
|
+
check("b.uriTemplate.expand is a function", typeof b.uriTemplate.expand === "function");
|
|
25
|
+
check("b.uriTemplate.compile is a function", typeof b.uriTemplate.compile === "function");
|
|
26
|
+
check("b.uriTemplate.UriTemplateError is a class", typeof b.uriTemplate.UriTemplateError === "function");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function eq(tmpl, want) { check(tmpl + " → " + want, b.uriTemplate.expand(tmpl, VARS) === want); }
|
|
30
|
+
|
|
31
|
+
function testLevels() {
|
|
32
|
+
// Level 1 — simple string expansion.
|
|
33
|
+
eq("{var}", "value");
|
|
34
|
+
eq("{hello}", "Hello%20World%21");
|
|
35
|
+
// Level 2 — reserved + fragment.
|
|
36
|
+
eq("{+var}", "value");
|
|
37
|
+
eq("{+path}/here", "/foo/bar/here");
|
|
38
|
+
eq("{#path}", "#/foo/bar");
|
|
39
|
+
eq("{+half}", "50%25");
|
|
40
|
+
// Level 3 — multiple vars + path/label/params/query operators.
|
|
41
|
+
eq("{x,y}", "1024,768");
|
|
42
|
+
eq("{+x,hello,y}", "1024,Hello%20World!,768");
|
|
43
|
+
eq("{/var}", "/value");
|
|
44
|
+
eq("{.who}", ".fred");
|
|
45
|
+
eq("{;x,y}", ";x=1024;y=768");
|
|
46
|
+
eq("{?x,y}", "?x=1024&y=768");
|
|
47
|
+
eq("{&x}", "&x=1024");
|
|
48
|
+
// empty value under named operators.
|
|
49
|
+
eq("{;empty}", ";empty");
|
|
50
|
+
eq("{?empty}", "?empty=");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function testLevel4() {
|
|
54
|
+
// Prefix modifier.
|
|
55
|
+
eq("{var:3}", "val");
|
|
56
|
+
eq("{var:30}", "value");
|
|
57
|
+
// Explode — list.
|
|
58
|
+
eq("{list}", "red,green,blue");
|
|
59
|
+
eq("{list*}", "red,green,blue");
|
|
60
|
+
eq("{/list*}", "/red/green/blue");
|
|
61
|
+
eq("{?list*}", "?list=red&list=green&list=blue");
|
|
62
|
+
// Explode — associative array.
|
|
63
|
+
eq("{keys}", "semi,%3B,dot,.,comma,%2C");
|
|
64
|
+
eq("{;keys*}", ";semi=%3B;dot=.;comma=%2C");
|
|
65
|
+
eq("{?keys*}", "?semi=%3B&dot=.&comma=%2C");
|
|
66
|
+
// Undefined variables are omitted.
|
|
67
|
+
eq("{undef}", "");
|
|
68
|
+
eq("x{?undef}", "x");
|
|
69
|
+
// Undefined / null members of a list or map are ignored (RFC 6570 §3.2.1).
|
|
70
|
+
check("undefined list member skipped", b.uriTemplate.expand("{?l*}", { l: ["a", undefined, "b", null, "c"] }) === "?l=a&l=b&l=c");
|
|
71
|
+
check("undefined list member skipped (joined)", b.uriTemplate.expand("{l}", { l: ["a", undefined, "b"] }) === "a,b");
|
|
72
|
+
check("all-undefined list omitted", b.uriTemplate.expand("x{?l*}", { l: [undefined, null] }) === "x");
|
|
73
|
+
check("undefined map value skipped", b.uriTemplate.expand("{?m*}", { m: { a: 1, b: undefined, c: 3 } }) === "?a=1&c=3");
|
|
74
|
+
check("undefined map value skipped (joined)", b.uriTemplate.expand("{m}", { m: { a: "1", b: undefined, c: "3" } }) === "a,1,c,3");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function testCompileReuse() {
|
|
78
|
+
var t = b.uriTemplate.compile("/users/{id}{?fields*}");
|
|
79
|
+
check("compiled expand A", t.expand({ id: 7, fields: ["name", "email"] }) === "/users/7?fields=name&fields=email");
|
|
80
|
+
check("compiled expand B (reused)", t.expand({ id: 9 }) === "/users/9");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function testMalformed() {
|
|
84
|
+
check("unclosed expression throws", code(function () { b.uriTemplate.expand("{var", {}); }) === "uri-template/unclosed");
|
|
85
|
+
check("reserved operator throws", code(function () { b.uriTemplate.expand("{=var}", {}); }) === "uri-template/reserved-operator");
|
|
86
|
+
check("non-numeric prefix throws", code(function () { b.uriTemplate.expand("{var:x}", {}); }) === "uri-template/bad-prefix");
|
|
87
|
+
check("prefix on list throws", code(function () { b.uriTemplate.expand("{list:3}", VARS); }) === "uri-template/prefix-on-list");
|
|
88
|
+
check("unmatched brace throws", code(function () { b.uriTemplate.expand("/id*}", {}); }) === "uri-template/unmatched-brace");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function run() {
|
|
92
|
+
testSurface();
|
|
93
|
+
testLevels();
|
|
94
|
+
testLevel4();
|
|
95
|
+
testCompileReuse();
|
|
96
|
+
testMalformed();
|
|
97
|
+
}
|
|
98
|
+
module.exports = { run: run };
|
|
99
|
+
if (require.main === module) { run().then(function () { console.log("[uri-template] OK — " + helpers.getChecks() + " checks passed"); }, function (e) { console.error("FAIL:", e && e.stack || e); process.exit(1); }); }
|
package/package.json
CHANGED