polen 0.11.0-next.17 → 0.11.0-next.18
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/build/api/builder/ssg/generate.d.ts.map +1 -1
- package/build/api/builder/ssg/generate.js +5 -5
- package/build/api/builder/ssg/generate.js.map +1 -1
- package/build/api/builder/ssg/page-generator.worker.js +13 -3
- package/build/api/builder/ssg/page-generator.worker.js.map +1 -1
- package/build/api/config/input.d.ts +88 -3
- package/build/api/config/input.d.ts.map +1 -1
- package/build/api/config/normalized.d.ts +92 -7
- package/build/api/config/normalized.d.ts.map +1 -1
- package/build/api/config/normalized.js +11 -3
- package/build/api/config/normalized.js.map +1 -1
- package/build/api/config-template/template.js +2 -2
- package/build/api/config-template/template.js.map +1 -1
- package/build/api/content/sidebar.d.ts.map +1 -1
- package/build/api/content/sidebar.js +2 -1
- package/build/api/content/sidebar.js.map +1 -1
- package/build/api/examples/config.d.ts +366 -3
- package/build/api/examples/config.d.ts.map +1 -1
- package/build/api/examples/config.js +25 -3
- package/build/api/examples/config.js.map +1 -1
- package/build/api/examples/diagnostic/diagnostic.d.ts +1 -1
- package/build/api/examples/diagnostic/validation-error.d.ts +3 -2
- package/build/api/examples/diagnostic/validation-error.d.ts.map +1 -1
- package/build/api/examples/diagnostic/validation-error.js +9 -3
- package/build/api/examples/diagnostic/validation-error.js.map +1 -1
- package/build/api/examples/diagnostic/validator.d.ts.map +1 -1
- package/build/api/examples/diagnostic/validator.js +115 -68
- package/build/api/examples/diagnostic/validator.js.map +1 -1
- package/build/api/examples/filter.d.ts.map +1 -1
- package/build/api/examples/filter.js +9 -6
- package/build/api/examples/filter.js.map +1 -1
- package/build/api/examples/scanner.d.ts.map +1 -1
- package/build/api/examples/scanner.js +89 -103
- package/build/api/examples/scanner.js.map +1 -1
- package/build/api/examples/type-usage-indexer.d.ts.map +1 -1
- package/build/api/examples/type-usage-indexer.js +17 -30
- package/build/api/examples/type-usage-indexer.js.map +1 -1
- package/build/api/iso/schema/routing.d.ts.map +1 -1
- package/build/api/iso/schema/routing.js +8 -8
- package/build/api/iso/schema/routing.js.map +1 -1
- package/build/api/iso/schema/validation.d.ts.map +1 -1
- package/build/api/iso/schema/validation.js +3 -2
- package/build/api/iso/schema/validation.js.map +1 -1
- package/build/api/schema/input-sources/directory.js +2 -2
- package/build/api/schema/input-sources/directory.js.map +1 -1
- package/build/api/schema/input-sources/versioned-directory.d.ts.map +1 -1
- package/build/api/schema/input-sources/versioned-directory.js +3 -3
- package/build/api/schema/input-sources/versioned-directory.js.map +1 -1
- package/build/api/schema/load.d.ts.map +1 -1
- package/build/api/schema/load.js +1 -1
- package/build/api/schema/load.js.map +1 -1
- package/build/lib/catalog/catalog.d.ts +43 -3
- package/build/lib/catalog/catalog.d.ts.map +1 -1
- package/build/lib/catalog/catalog.js +67 -5
- package/build/lib/catalog/catalog.js.map +1 -1
- package/build/lib/catalog/versioned.d.ts +11 -1
- package/build/lib/catalog/versioned.d.ts.map +1 -1
- package/build/lib/catalog/versioned.js +23 -5
- package/build/lib/catalog/versioned.js.map +1 -1
- package/build/lib/document/document.d.ts +55 -5
- package/build/lib/document/document.d.ts.map +1 -1
- package/build/lib/document/document.js +96 -2
- package/build/lib/document/document.js.map +1 -1
- package/build/lib/document/versioned.d.ts +2 -2
- package/build/lib/document/versioned.d.ts.map +1 -1
- package/build/lib/document/versioned.js +7 -7
- package/build/lib/document/versioned.js.map +1 -1
- package/build/lib/lifecycles/lifecycles.d.ts +5 -4
- package/build/lib/lifecycles/lifecycles.d.ts.map +1 -1
- package/build/lib/lifecycles/lifecycles.js +14 -12
- package/build/lib/lifecycles/lifecycles.js.map +1 -1
- package/build/lib/version-coverage/$$.d.ts +2 -0
- package/build/lib/version-coverage/$$.d.ts.map +1 -0
- package/build/lib/version-coverage/$$.js +2 -0
- package/build/lib/version-coverage/$$.js.map +1 -0
- package/build/lib/version-coverage/$.d.ts.map +1 -0
- package/build/lib/version-coverage/$.js.map +1 -0
- package/build/lib/{version-selection/version-selection.d.ts → version-coverage/version-coverage.d.ts} +1 -1
- package/build/lib/version-coverage/version-coverage.d.ts.map +1 -0
- package/build/lib/{version-selection/version-selection.js → version-coverage/version-coverage.js} +2 -2
- package/build/lib/version-coverage/version-coverage.js.map +1 -0
- package/build/template/components/GraphQLDocument.d.ts +1 -1
- package/build/template/components/GraphQLDocument.d.ts.map +1 -1
- package/build/template/components/GraphQLDocument.js +10 -39
- package/build/template/components/GraphQLDocument.js.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts +28 -0
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.js +60 -27
- package/build/template/components/GraphQLInteractive/lib/parser.js.map +1 -1
- package/build/template/components/VersionCoveragePicker.d.ts +1 -1
- package/build/template/components/VersionCoveragePicker.d.ts.map +1 -1
- package/build/template/components/VersionCoveragePicker.js +4 -6
- package/build/template/components/VersionCoveragePicker.js.map +1 -1
- package/build/template/components/home/QuickStart.d.ts.map +1 -1
- package/build/template/components/home/QuickStart.js +8 -4
- package/build/template/components/home/QuickStart.js.map +1 -1
- package/build/template/hooks/use-highlighted.d.ts.map +1 -1
- package/build/template/hooks/use-highlighted.js +19 -13
- package/build/template/hooks/use-highlighted.js.map +1 -1
- package/build/template/lib/fetch-text.d.ts +18 -0
- package/build/template/lib/fetch-text.d.ts.map +1 -1
- package/build/template/lib/fetch-text.js +32 -4
- package/build/template/lib/fetch-text.js.map +1 -1
- package/build/template/routes/examples/name.d.ts.map +1 -1
- package/build/template/routes/examples/name.js +4 -2
- package/build/template/routes/examples/name.js.map +1 -1
- package/build/template/stores/toast.d.ts.map +1 -1
- package/build/template/stores/toast.js +5 -3
- package/build/template/stores/toast.js.map +1 -1
- package/package.json +7 -7
- package/src/api/builder/ssg/generate.ts +10 -5
- package/src/api/builder/ssg/page-generator.worker.ts +18 -3
- package/src/api/config/normalized.ts +12 -3
- package/src/api/config-template/template.ts +2 -2
- package/src/api/content/sidebar.ts +3 -3
- package/src/api/examples/config.test.ts +10 -0
- package/src/api/examples/config.ts +33 -4
- package/src/api/examples/diagnostic/validation-error.ts +9 -3
- package/src/api/examples/diagnostic/validator.test.ts +30 -0
- package/src/api/examples/diagnostic/validator.ts +148 -103
- package/src/api/examples/filter.ts +9 -6
- package/src/api/examples/scanner.ts +136 -117
- package/src/api/examples/type-usage-indexer.ts +24 -36
- package/src/api/iso/schema/routing.ts +10 -10
- package/src/api/iso/schema/validation.ts +3 -2
- package/src/api/schema/input-sources/directory.ts +2 -2
- package/src/api/schema/input-sources/versioned-directory.ts +5 -7
- package/src/api/schema/load.ts +1 -1
- package/src/lib/catalog/catalog.ts +89 -6
- package/src/lib/catalog/versioned.ts +26 -5
- package/src/lib/document/document.ts +135 -2
- package/src/lib/document/versioned.ts +8 -8
- package/src/lib/lifecycles/lifecycles.ts +32 -27
- package/src/lib/version-coverage/$$.ts +1 -0
- package/src/lib/{version-selection/version-selection.ts → version-coverage/version-coverage.ts} +1 -1
- package/src/template/components/GraphQLDocument.tsx +11 -69
- package/src/template/components/GraphQLInteractive/lib/parser.ts +81 -29
- package/src/template/components/VersionCoveragePicker.tsx +4 -5
- package/src/template/components/home/QuickStart.tsx +16 -7
- package/src/template/hooks/use-highlighted.ts +31 -19
- package/src/template/lib/fetch-text.ts +45 -4
- package/src/template/routes/examples/name.tsx +4 -2
- package/src/template/stores/toast.ts +6 -3
- package/build/lib/graph/$$.d.ts +0 -2
- package/build/lib/graph/$$.d.ts.map +0 -1
- package/build/lib/graph/$$.js +0 -2
- package/build/lib/graph/$$.js.map +0 -1
- package/build/lib/graph/$.d.ts +0 -2
- package/build/lib/graph/$.d.ts.map +0 -1
- package/build/lib/graph/$.js +0 -2
- package/build/lib/graph/$.js.map +0 -1
- package/build/lib/graph/graph.d.ts +0 -127
- package/build/lib/graph/graph.d.ts.map +0 -1
- package/build/lib/graph/graph.js +0 -152
- package/build/lib/graph/graph.js.map +0 -1
- package/build/lib/mask/$$.d.ts +0 -3
- package/build/lib/mask/$$.d.ts.map +0 -1
- package/build/lib/mask/$$.js +0 -3
- package/build/lib/mask/$$.js.map +0 -1
- package/build/lib/mask/$.d.ts +0 -2
- package/build/lib/mask/$.d.ts.map +0 -1
- package/build/lib/mask/$.js +0 -2
- package/build/lib/mask/$.js.map +0 -1
- package/build/lib/mask/apply.d.ts +0 -86
- package/build/lib/mask/apply.d.ts.map +0 -1
- package/build/lib/mask/apply.js +0 -86
- package/build/lib/mask/apply.js.map +0 -1
- package/build/lib/mask/mask.d.ts +0 -124
- package/build/lib/mask/mask.d.ts.map +0 -1
- package/build/lib/mask/mask.js +0 -137
- package/build/lib/mask/mask.js.map +0 -1
- package/build/lib/mask/mask.test-d.d.ts +0 -2
- package/build/lib/mask/mask.test-d.d.ts.map +0 -1
- package/build/lib/mask/mask.test-d.js +0 -102
- package/build/lib/mask/mask.test-d.js.map +0 -1
- package/build/lib/version-selection/$$.d.ts +0 -2
- package/build/lib/version-selection/$$.d.ts.map +0 -1
- package/build/lib/version-selection/$$.js +0 -2
- package/build/lib/version-selection/$$.js.map +0 -1
- package/build/lib/version-selection/$.d.ts.map +0 -1
- package/build/lib/version-selection/$.js.map +0 -1
- package/build/lib/version-selection/version-selection.d.ts.map +0 -1
- package/build/lib/version-selection/version-selection.js.map +0 -1
- package/src/lib/graph/$$.ts +0 -1
- package/src/lib/graph/$.ts +0 -1
- package/src/lib/graph/graph.ts +0 -197
- package/src/lib/mask/$$.ts +0 -2
- package/src/lib/mask/$.test.ts +0 -226
- package/src/lib/mask/$.ts +0 -1
- package/src/lib/mask/apply.ts +0 -134
- package/src/lib/mask/mask.test-d.ts +0 -156
- package/src/lib/mask/mask.ts +0 -244
- package/src/lib/version-selection/$$.ts +0 -1
- /package/build/lib/{version-selection → version-coverage}/$.d.ts +0 -0
- /package/build/lib/{version-selection → version-coverage}/$.js +0 -0
- /package/src/lib/{version-selection → version-coverage}/$.ts +0 -0
@@ -1,102 +0,0 @@
|
|
1
|
-
import { Ts } from '@wollybeard/kit';
|
2
|
-
import { Mask } from './$.js';
|
3
|
-
// Test 1: InferOptions with unknown should accept all option types
|
4
|
-
{
|
5
|
-
// All of these should be valid options
|
6
|
-
const option1 = true;
|
7
|
-
const option2 = false;
|
8
|
-
const option3 = [`name`, `age`];
|
9
|
-
const option4 = [];
|
10
|
-
const option5 = { name: true, age: false };
|
11
|
-
const option6 = {};
|
12
|
-
}
|
13
|
-
// Test 2: Mask.create with unknown data type should accept all option types
|
14
|
-
{
|
15
|
-
// Boolean options
|
16
|
-
const mask1 = Mask.create(true);
|
17
|
-
const mask2 = Mask.create(false);
|
18
|
-
// Without explicit type parameter, returns union type
|
19
|
-
Ts.assertEqual()(mask1);
|
20
|
-
Ts.assertEqual()(mask2);
|
21
|
-
// Array options (no type parameter needed)
|
22
|
-
const mask3 = Mask.create([`name`, `age`]);
|
23
|
-
const mask4 = Mask.create([]);
|
24
|
-
const mask5 = Mask.create([`a`, `b`, `c`]);
|
25
|
-
// Returns union type with inferred properties
|
26
|
-
Ts.assertEqual()(mask3);
|
27
|
-
Ts.assertEqual()(mask4);
|
28
|
-
Ts.assertEqual()(mask5);
|
29
|
-
// Object options
|
30
|
-
const mask6 = Mask.create({ name: true, age: false });
|
31
|
-
const mask7 = Mask.create({});
|
32
|
-
const mask8 = Mask.create({ foo: true, bar: true, baz: false });
|
33
|
-
// Returns union type with inferred properties
|
34
|
-
Ts.assertEqual()(mask6);
|
35
|
-
Ts.assertEqual()(mask7);
|
36
|
-
Ts.assertEqual()(mask8);
|
37
|
-
}
|
38
|
-
// Test 3: With specific data type, options are constrained
|
39
|
-
{
|
40
|
-
// Valid options
|
41
|
-
const mask1 = Mask.create(true);
|
42
|
-
const mask2 = Mask.create([`name`, `age`]);
|
43
|
-
const mask3 = Mask.create({ name: true, age: false, email: true });
|
44
|
-
// With explicit type parameter, still returns union type
|
45
|
-
Ts.assertEqual()(mask1);
|
46
|
-
Ts.assertEqual()(mask2);
|
47
|
-
Ts.assertEqual()(mask3);
|
48
|
-
// Invalid cases would be compile errors
|
49
|
-
// const mask4 = Mask.create<User>(['invalid']) // Error: 'invalid' is not a key of User
|
50
|
-
// const mask5 = Mask.create<User>({ invalid: true }) // Error: 'invalid' is not a property of User
|
51
|
-
}
|
52
|
-
// Test 4: Non-object types only accept boolean
|
53
|
-
{
|
54
|
-
const mask1 = Mask.create(true);
|
55
|
-
const mask2 = Mask.create(false);
|
56
|
-
Ts.assertEqual()(mask1);
|
57
|
-
Ts.assertEqual()(mask2);
|
58
|
-
// Invalid cases would be compile errors
|
59
|
-
// const mask3 = Mask.create<string>(['prop']) // Error: string is not an object
|
60
|
-
// const mask4 = Mask.create<string>({ prop: true }) // Error: string is not an object
|
61
|
-
}
|
62
|
-
// Test 5: Test inference in practical scenarios
|
63
|
-
{
|
64
|
-
// Should infer PropertiesMask with object data type
|
65
|
-
const userMask = Mask.create([`name`, `email`, `password`]);
|
66
|
-
Ts.assertEqual()(userMask);
|
67
|
-
// When mask is a union type, apply returns a union of possible results
|
68
|
-
const user1 = { name: `John`, email: `john@example.com`, password: `secret`, extra: `data` };
|
69
|
-
const maskedUser1 = Mask.apply(user1, userMask);
|
70
|
-
// Can't use assertSub with union types
|
71
|
-
// For partial data, use applyPartial
|
72
|
-
const user2 = { name: `Jane`, email: `jane@example.com` };
|
73
|
-
const maskedUser2 = Mask.applyPartial(user2, userMask);
|
74
|
-
}
|
75
|
-
// Test 6: Pick and omit helpers
|
76
|
-
{
|
77
|
-
const pick1 = Mask.pick([`name`, `email`]);
|
78
|
-
const omit1 = Mask.omit([`password`, `secret`]);
|
79
|
-
// Infers specific property types
|
80
|
-
Ts.assertEqual()(pick1);
|
81
|
-
Ts.assertEqual()(omit1);
|
82
|
-
const pick2 = Mask.pick([`name`, `email`]);
|
83
|
-
const omit2 = Mask.omit([`password`]);
|
84
|
-
Ts.assertEqual()(pick2);
|
85
|
-
Ts.assertEqual()(omit2);
|
86
|
-
}
|
87
|
-
// Test 7: Apply type transformations
|
88
|
-
{
|
89
|
-
const user = { name: `John`, email: `john@example.com`, password: `secret` };
|
90
|
-
// Binary mask
|
91
|
-
const showMask = Mask.create(true);
|
92
|
-
const hideMask = Mask.create(false);
|
93
|
-
const shown = Mask.apply(user, showMask);
|
94
|
-
const hidden = Mask.apply(user, hideMask);
|
95
|
-
// Properties mask - allow mode
|
96
|
-
const allowMask = Mask.create([`name`, `email`]);
|
97
|
-
const allowed = Mask.apply(user, allowMask);
|
98
|
-
// Properties mask - deny mode
|
99
|
-
const denyMask = Mask.create({ password: false });
|
100
|
-
const denied = Mask.apply(user, denyMask);
|
101
|
-
}
|
102
|
-
//# sourceMappingURL=mask.test-d.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mask.test-d.js","sourceRoot":"","sources":["../../../src/lib/mask/mask.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAG7B,mEAAmE;AACnE,CAAC;IAMC,uCAAuC;IACvC,MAAM,OAAO,GAAY,IAAI,CAAA;IAC7B,MAAM,OAAO,GAAY,KAAK,CAAA;IAC9B,MAAM,OAAO,GAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IACxC,MAAM,OAAO,GAAY,EAAE,CAAA;IAC3B,MAAM,OAAO,GAAY,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;IACnD,MAAM,OAAO,GAAY,EAAE,CAAA;AAC7B,CAAC;AAED,4EAA4E;AAC5E,CAAC;IACC,kBAAkB;IAClB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAChC,sDAAsD;IACtD,EAAE,CAAC,WAAW,EAAqB,CAAC,KAAK,CAAC,C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AAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACtD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IAI3C,8BAA8B;IAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;IACvD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAG3C,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/lib/version-selection/$$.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$$.js","sourceRoot":"","sources":["../../../src/lib/version-selection/$$.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$.d.ts","sourceRoot":"","sources":["../../../src/lib/version-selection/$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,SAAS,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$.js","sourceRoot":"","sources":["../../../src/lib/version-selection/$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,SAAS,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"version-selection.d.ts","sourceRoot":"","sources":["../../../src/lib/version-selection/version-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAS,OAAO,EAAQ,MAAM,QAAQ,CAAA;AAM7C,eAAO,MAAM,kBAAkB,oOAAkB,CAAA;AACjD,eAAO,MAAM,kBAAkB,+OAA6B,CAAA;AAE5D;;;GAGG;AACH,eAAO,MAAM,eAAe,8dAM1B,CAAA;AAMF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,eAAe,CAAC,CAAA;AAUnE,eAAO,MAAM,EAAE,6VAAwB,CAAA;AAEvC,eAAO,MAAM,QAAQ,kNAAa,CAAA;AAElC,eAAO,MAAM,KAAK,GAAI,WAAW,eAAe,KAAG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CACvE,CAAA;AAMxB,eAAO,MAAM,MAAM,scAA4B,CAAA;AAC/C,eAAO,MAAM,UAAU,sXAAgC,CAAA;AACvD,eAAO,MAAM,MAAM,scAA4B,CAAA;AAC/C,eAAO,MAAM,UAAU,sXAAgC,CAAA;AAMvD,eAAO,MAAM,WAAW,8SAAiC,CAAA;AAMzD;;GAEG;AACH,eAAO,MAAM,QAAQ,GACnB,iBAAiB,eAAe,EAChC,SAAS,OAAO,CAAC,OAAO,KACvB,OAKF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,iBAAiB,eAAe,KAAG,MAE1D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,iBAAiB,eAAe,KAAG,OAAO,CAAC,OAAO,EAK5E,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GAAI,iBAAiB,eAAe,KAAG,OAAO,CAAC,OAcpE,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"version-selection.js","sourceRoot":"","sources":["../../../src/lib/version-selection/version-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7C,+EA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AAC,CAAA;IACrE,CAAC;IAED,kDAAkD;IAClD,uCAAuC;IACvC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAC3E,CAAC,CAAA"}
|
package/src/lib/graph/$$.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './graph.js'
|
package/src/lib/graph/$.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * as Graph from './$$.js'
|
package/src/lib/graph/graph.ts
DELETED
@@ -1,197 +0,0 @@
|
|
1
|
-
import { S } from '#lib/kit-temp/effect'
|
2
|
-
|
3
|
-
// ─── Schema ──────────────────────────────────────────────────────────────────
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Dependency graph for tracking relationships between nodes
|
7
|
-
* Used to efficiently handle dependencies in various contexts
|
8
|
-
*/
|
9
|
-
export const DependencyGraph = S.Struct({
|
10
|
-
/**
|
11
|
-
* Map from parent ID to array of child IDs (parent depends on children)
|
12
|
-
*/
|
13
|
-
dependencies: S.Record({ key: S.String, value: S.Array(S.String) }),
|
14
|
-
|
15
|
-
/**
|
16
|
-
* Map from child ID to array of parent IDs (child is depended on by parents)
|
17
|
-
*/
|
18
|
-
dependents: S.Record({ key: S.String, value: S.Array(S.String) }),
|
19
|
-
}).annotations({
|
20
|
-
identifier: 'DependencyGraph',
|
21
|
-
description: 'A directed graph tracking dependencies between nodes',
|
22
|
-
})
|
23
|
-
|
24
|
-
export type DependencyGraph = typeof DependencyGraph.Type
|
25
|
-
|
26
|
-
// ─── Constructors ────────────────────────────────────────────────────────────
|
27
|
-
|
28
|
-
export const make = DependencyGraph.make
|
29
|
-
|
30
|
-
/**
|
31
|
-
* Create an empty dependency graph
|
32
|
-
*/
|
33
|
-
export const create = (): DependencyGraph =>
|
34
|
-
make({
|
35
|
-
dependencies: {},
|
36
|
-
dependents: {},
|
37
|
-
})
|
38
|
-
|
39
|
-
// ─── Domain Logic ────────────────────────────────────────────────────────────
|
40
|
-
|
41
|
-
/**
|
42
|
-
* Add a dependency relationship (immutable)
|
43
|
-
* @param graph - The dependency graph
|
44
|
-
* @param parent - The parent node ID
|
45
|
-
* @param child - The child node ID that the parent depends on
|
46
|
-
* @returns A new graph with the dependency added
|
47
|
-
*/
|
48
|
-
export const addDependency = (
|
49
|
-
graph: DependencyGraph,
|
50
|
-
parent: string,
|
51
|
-
child: string,
|
52
|
-
): DependencyGraph => {
|
53
|
-
// Get existing arrays or create empty ones
|
54
|
-
const children = graph.dependencies[parent] || []
|
55
|
-
const parents = graph.dependents[child] || []
|
56
|
-
|
57
|
-
// Add child if not already present
|
58
|
-
const newChildren = children.includes(child) ? children : [...children, child]
|
59
|
-
|
60
|
-
// Add parent if not already present
|
61
|
-
const newParents = parents.includes(parent) ? parents : [...parents, parent]
|
62
|
-
|
63
|
-
return make({
|
64
|
-
dependencies: {
|
65
|
-
...graph.dependencies,
|
66
|
-
[parent]: newChildren,
|
67
|
-
},
|
68
|
-
dependents: {
|
69
|
-
...graph.dependents,
|
70
|
-
[child]: newParents,
|
71
|
-
},
|
72
|
-
})
|
73
|
-
}
|
74
|
-
|
75
|
-
/**
|
76
|
-
* Add a dependency relationship (mutable)
|
77
|
-
* @param graph - The dependency graph to mutate
|
78
|
-
* @param parent - The parent node ID
|
79
|
-
* @param child - The child node ID that the parent depends on
|
80
|
-
*/
|
81
|
-
export const addDependencyMutable = (
|
82
|
-
graph: DependencyGraph,
|
83
|
-
parent: string,
|
84
|
-
child: string,
|
85
|
-
): void => {
|
86
|
-
// Cast to mutable for mutation
|
87
|
-
const mutableGraph = graph as {
|
88
|
-
dependencies: Record<string, string[]>
|
89
|
-
dependents: Record<string, string[]>
|
90
|
-
}
|
91
|
-
|
92
|
-
// Add to dependencies
|
93
|
-
if (!mutableGraph.dependencies[parent]) {
|
94
|
-
mutableGraph.dependencies[parent] = []
|
95
|
-
}
|
96
|
-
if (!mutableGraph.dependencies[parent].includes(child)) {
|
97
|
-
mutableGraph.dependencies[parent].push(child)
|
98
|
-
}
|
99
|
-
|
100
|
-
// Add to dependents
|
101
|
-
if (!mutableGraph.dependents[child]) {
|
102
|
-
mutableGraph.dependents[child] = []
|
103
|
-
}
|
104
|
-
if (!mutableGraph.dependents[child].includes(parent)) {
|
105
|
-
mutableGraph.dependents[child].push(parent)
|
106
|
-
}
|
107
|
-
}
|
108
|
-
|
109
|
-
/**
|
110
|
-
* Find all nodes that have no dependencies (leaf nodes)
|
111
|
-
*/
|
112
|
-
export const findLeafNodes = (graph: DependencyGraph): Set<string> => {
|
113
|
-
const leaves = new Set<string>()
|
114
|
-
|
115
|
-
// Check all nodes that appear as children
|
116
|
-
for (const child of Object.keys(graph.dependents)) {
|
117
|
-
const deps = graph.dependencies[child]
|
118
|
-
if (!deps || deps.length === 0) {
|
119
|
-
leaves.add(child)
|
120
|
-
}
|
121
|
-
}
|
122
|
-
|
123
|
-
return leaves
|
124
|
-
}
|
125
|
-
|
126
|
-
/**
|
127
|
-
* Check if all dependencies of a node have been processed
|
128
|
-
*/
|
129
|
-
export const areDependenciesReady = (
|
130
|
-
node: string,
|
131
|
-
graph: DependencyGraph,
|
132
|
-
processed: Set<string>,
|
133
|
-
): boolean => {
|
134
|
-
const deps = graph.dependencies[node]
|
135
|
-
if (!deps) return true
|
136
|
-
|
137
|
-
return deps.every(dep => processed.has(dep))
|
138
|
-
}
|
139
|
-
|
140
|
-
/**
|
141
|
-
* Get topological ordering of nodes (children before parents)
|
142
|
-
* This ensures we process dependencies before the nodes that depend on them
|
143
|
-
*
|
144
|
-
* @param graph - The dependency graph
|
145
|
-
* @returns Array of node IDs in topological order
|
146
|
-
*/
|
147
|
-
export const topologicalSort = (graph: DependencyGraph): string[] => {
|
148
|
-
const result: string[] = []
|
149
|
-
const visited = new Set<string>()
|
150
|
-
const visiting = new Set<string>() // For cycle detection
|
151
|
-
|
152
|
-
// Get all nodes
|
153
|
-
const allNodes = new Set<string>()
|
154
|
-
for (const parent of Object.keys(graph.dependencies)) {
|
155
|
-
allNodes.add(parent)
|
156
|
-
}
|
157
|
-
for (const child of Object.keys(graph.dependents)) {
|
158
|
-
allNodes.add(child)
|
159
|
-
}
|
160
|
-
|
161
|
-
const visit = (node: string): void => {
|
162
|
-
if (visited.has(node)) return
|
163
|
-
|
164
|
-
if (visiting.has(node)) {
|
165
|
-
// Cycle detected - just skip this node
|
166
|
-
return
|
167
|
-
}
|
168
|
-
|
169
|
-
visiting.add(node)
|
170
|
-
|
171
|
-
// Visit all children first
|
172
|
-
const children = graph.dependencies[node]
|
173
|
-
if (children) {
|
174
|
-
for (const child of children) {
|
175
|
-
visit(child)
|
176
|
-
}
|
177
|
-
}
|
178
|
-
|
179
|
-
visiting.delete(node)
|
180
|
-
visited.add(node)
|
181
|
-
result.push(node)
|
182
|
-
}
|
183
|
-
|
184
|
-
// Visit all nodes
|
185
|
-
for (const node of allNodes) {
|
186
|
-
visit(node)
|
187
|
-
}
|
188
|
-
|
189
|
-
return result
|
190
|
-
}
|
191
|
-
|
192
|
-
// ─── Codec ───────────────────────────────────────────────────────────────────
|
193
|
-
|
194
|
-
export const decode = S.decode(DependencyGraph)
|
195
|
-
export const decodeSync = S.decodeSync(DependencyGraph)
|
196
|
-
export const encode = S.encode(DependencyGraph)
|
197
|
-
export const encodeSync = S.encodeSync(DependencyGraph)
|
package/src/lib/mask/$$.ts
DELETED
package/src/lib/mask/$.test.ts
DELETED
@@ -1,226 +0,0 @@
|
|
1
|
-
import * as fc from 'fast-check'
|
2
|
-
import { describe, expect, test } from 'vitest'
|
3
|
-
import { Test } from '../../../tests/unit/helpers/test.js'
|
4
|
-
import { Mask } from './$.js'
|
5
|
-
|
6
|
-
// dprint-ignore
|
7
|
-
Test.suite<{ options: any; expectedType: 'binary' | 'properties'; expectedMode?: 'allow' | 'deny'; expectedShow?: boolean; expectedProperties?: string[] }>('Mask.create', [
|
8
|
-
{ name: 'boolean true creates binary show mask', options: true, expectedType: 'binary', expectedShow: true },
|
9
|
-
{ name: 'boolean false creates binary hide mask', options: false, expectedType: 'binary', expectedShow: false },
|
10
|
-
{ name: 'array creates allow mode properties mask', options: ['name', 'age'], expectedType: 'properties', expectedMode: 'allow', expectedProperties: ['name', 'age'] },
|
11
|
-
{ name: 'object with true values creates allow mode', options: { name: true, age: true, password: false }, expectedType: 'properties', expectedMode: 'allow', expectedProperties: ['name', 'age'] },
|
12
|
-
{ name: 'object with false values creates deny mode', options: { password: false, secret: false }, expectedType: 'properties', expectedMode: 'deny', expectedProperties: ['password', 'secret'] },
|
13
|
-
], ({ options, expectedType, expectedMode, expectedShow, expectedProperties }) => {
|
14
|
-
const mask = Mask.create(options)
|
15
|
-
expect(mask.type).toBe(expectedType)
|
16
|
-
|
17
|
-
if (expectedType === 'binary' && mask.type === 'binary') {
|
18
|
-
expect(mask.show).toBe(expectedShow)
|
19
|
-
}
|
20
|
-
|
21
|
-
if (expectedType === 'properties' && mask.type === 'properties') {
|
22
|
-
expect(mask.mode).toBe(expectedMode)
|
23
|
-
expect(mask.properties).toEqual(expectedProperties)
|
24
|
-
}
|
25
|
-
})
|
26
|
-
|
27
|
-
// dprint-ignore
|
28
|
-
Test.suite<{ data: any; maskOptions: any; shouldThrow?: boolean; expected?: any }>('Mask.apply', [
|
29
|
-
{ name: 'binary show mask returns data', data: { a: 1 }, maskOptions: true, expected: { a: 1 } },
|
30
|
-
{ name: 'binary hide mask returns undefined', data: { a: 1 }, maskOptions: false, expected: undefined },
|
31
|
-
{ name: 'allow mode filters properties', data: { name: 'John', age: 30, password: 'secret' }, maskOptions: ['name', 'age'], expected: { name: 'John', age: 30 } },
|
32
|
-
{ name: 'deny mode removes properties', data: { name: 'John', age: 30, password: 'secret' }, maskOptions: { password: false }, expected: { name: 'John', age: 30 } },
|
33
|
-
{ name: 'properties mask throws for string', data: 'string', maskOptions: ['name'], shouldThrow: true },
|
34
|
-
{ name: 'properties mask throws for number', data: 123, maskOptions: ['name'], shouldThrow: true },
|
35
|
-
{ name: 'properties mask throws for null', data: null, maskOptions: ['name'], shouldThrow: true },
|
36
|
-
], ({ data, maskOptions, shouldThrow, expected }) => {
|
37
|
-
const mask = Mask.create(maskOptions)
|
38
|
-
|
39
|
-
if (shouldThrow) {
|
40
|
-
expect(() => Mask.apply(data as any, mask)).toThrow()
|
41
|
-
} else {
|
42
|
-
const result = Mask.apply(data, mask)
|
43
|
-
if (expected === undefined) {
|
44
|
-
expect(result).toBe(undefined)
|
45
|
-
} else {
|
46
|
-
expect(result).toEqual(expected)
|
47
|
-
}
|
48
|
-
}
|
49
|
-
})
|
50
|
-
|
51
|
-
// dprint-ignore
|
52
|
-
Test.suite<{ method: 'applyPartial' | 'applyExact'; data: any; maskOptions: any; expected: any }>('apply variants', [
|
53
|
-
{ name: 'applyPartial allows missing properties', method: 'applyPartial', data: { name: 'John' }, maskOptions: ['name', 'age'], expected: { name: 'John' } },
|
54
|
-
{ name: 'applyPartial with empty object', method: 'applyPartial', data: {}, maskOptions: ['name', 'age'], expected: {} },
|
55
|
-
{ name: 'applyExact with binary show mask', method: 'applyExact', data: 'hello', maskOptions: true, expected: 'hello' },
|
56
|
-
{ name: 'applyExact with binary hide mask', method: 'applyExact', data: 'hello', maskOptions: false, expected: undefined },
|
57
|
-
], ({ method, data, maskOptions, expected }) => {
|
58
|
-
const mask = Mask.create(maskOptions)
|
59
|
-
|
60
|
-
const result = method === 'applyPartial'
|
61
|
-
? Mask.applyPartial(data, mask)
|
62
|
-
: Mask.applyExact(data as any, mask)
|
63
|
-
|
64
|
-
if (expected === undefined) {
|
65
|
-
expect(result).toBe(undefined)
|
66
|
-
} else {
|
67
|
-
expect(result).toEqual(expected)
|
68
|
-
}
|
69
|
-
})
|
70
|
-
|
71
|
-
describe('property-based tests', () => {
|
72
|
-
test('binary masks - invariants', () => {
|
73
|
-
fc.assert(
|
74
|
-
fc.property(fc.anything(), (data) => {
|
75
|
-
expect(Mask.apply(data, Mask.create(true))).toBe(data)
|
76
|
-
expect(Mask.apply(data, Mask.create(false))).toBe(undefined)
|
77
|
-
}),
|
78
|
-
)
|
79
|
-
})
|
80
|
-
|
81
|
-
test('properties mask - allow mode filters correctly', () => {
|
82
|
-
fc.assert(
|
83
|
-
fc.property(
|
84
|
-
fc.dictionary(fc.string(), fc.anything()),
|
85
|
-
fc.array(fc.string(), { minLength: 1 }),
|
86
|
-
(obj, keys) => {
|
87
|
-
const mask = Mask.create(keys)
|
88
|
-
const result = Mask.apply(obj as any, mask)
|
89
|
-
const resultKeys = Object.keys(result as any)
|
90
|
-
|
91
|
-
// Result contains only keys that were in both mask and object
|
92
|
-
expect(resultKeys.every(key => keys.includes(key))).toBe(true)
|
93
|
-
|
94
|
-
// All requested keys that are own properties of obj are in result
|
95
|
-
keys.forEach(key => {
|
96
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
97
|
-
expect(result).toHaveProperty(key, (obj as any)[key])
|
98
|
-
}
|
99
|
-
})
|
100
|
-
},
|
101
|
-
),
|
102
|
-
)
|
103
|
-
})
|
104
|
-
|
105
|
-
test('properties mask - deny mode filters correctly', () => {
|
106
|
-
fc.assert(
|
107
|
-
fc.property(
|
108
|
-
fc.dictionary(fc.string(), fc.anything()),
|
109
|
-
fc.uniqueArray(fc.string(), { minLength: 1 }),
|
110
|
-
(data, keysToRemove) => {
|
111
|
-
const maskSpec = Object.fromEntries(keysToRemove.map(k => [k, false]))
|
112
|
-
const mask = Mask.create(maskSpec)
|
113
|
-
|
114
|
-
expect(mask.type).toBe('properties')
|
115
|
-
if (mask.type !== 'properties') return
|
116
|
-
expect(mask.mode).toBe('deny')
|
117
|
-
|
118
|
-
const result = Mask.apply(data as any, mask)
|
119
|
-
|
120
|
-
// Result should not have any of the denied keys
|
121
|
-
keysToRemove.forEach(key => {
|
122
|
-
expect(Object.prototype.hasOwnProperty.call(result, key)).toBe(false)
|
123
|
-
})
|
124
|
-
|
125
|
-
// Result should have all other keys from data
|
126
|
-
Object.keys(data).forEach(key => {
|
127
|
-
if (!keysToRemove.includes(key)) {
|
128
|
-
expect(Object.prototype.hasOwnProperty.call(result, key)).toBe(true)
|
129
|
-
expect((result as any)[key]).toBe((data as any)[key])
|
130
|
-
}
|
131
|
-
})
|
132
|
-
},
|
133
|
-
),
|
134
|
-
)
|
135
|
-
})
|
136
|
-
|
137
|
-
test('undefined values are preserved', () => {
|
138
|
-
fc.assert(
|
139
|
-
fc.property(
|
140
|
-
fc.record({
|
141
|
-
a: fc.oneof(fc.anything(), fc.constant(undefined)),
|
142
|
-
b: fc.oneof(fc.anything(), fc.constant(undefined)),
|
143
|
-
c: fc.oneof(fc.anything(), fc.constant(undefined)),
|
144
|
-
}),
|
145
|
-
fc.shuffledSubarray(['a', 'b', 'c'], { minLength: 1 }),
|
146
|
-
(obj, keys) => {
|
147
|
-
const result = Mask.apply(obj as any, Mask.create(keys))
|
148
|
-
|
149
|
-
keys.forEach(key => {
|
150
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
151
|
-
expect(result).toHaveProperty(key)
|
152
|
-
expect((result as any)[key]).toBe((obj as any)[key])
|
153
|
-
}
|
154
|
-
})
|
155
|
-
},
|
156
|
-
),
|
157
|
-
)
|
158
|
-
})
|
159
|
-
|
160
|
-
test('apply and applyPartial are consistent for complete data', () => {
|
161
|
-
fc.assert(
|
162
|
-
fc.property(
|
163
|
-
fc.dictionary(fc.string(), fc.anything()),
|
164
|
-
fc.array(fc.string(), { minLength: 1 }),
|
165
|
-
(data, keys) => {
|
166
|
-
const mask = Mask.create(keys)
|
167
|
-
expect(Mask.apply(data as any, mask)).toEqual(Mask.applyPartial(data as any, mask))
|
168
|
-
},
|
169
|
-
),
|
170
|
-
)
|
171
|
-
})
|
172
|
-
|
173
|
-
test('non-objects throw with properties masks', () => {
|
174
|
-
fc.assert(
|
175
|
-
fc.property(
|
176
|
-
fc.oneof(
|
177
|
-
fc.string(),
|
178
|
-
fc.integer(),
|
179
|
-
fc.boolean(),
|
180
|
-
fc.constant(null),
|
181
|
-
fc.constant(undefined),
|
182
|
-
),
|
183
|
-
fc.array(fc.string(), { minLength: 1 }),
|
184
|
-
(nonObject, keys) => {
|
185
|
-
const mask = Mask.create(keys)
|
186
|
-
expect(() => Mask.apply(nonObject as any, mask)).toThrow('Cannot apply properties mask to non-object data')
|
187
|
-
},
|
188
|
-
),
|
189
|
-
)
|
190
|
-
})
|
191
|
-
|
192
|
-
test('immutability invariants', () => {
|
193
|
-
fc.assert(
|
194
|
-
fc.property(
|
195
|
-
fc.dictionary(
|
196
|
-
fc.string(),
|
197
|
-
fc.oneof(
|
198
|
-
fc.string(),
|
199
|
-
fc.integer(),
|
200
|
-
fc.boolean(),
|
201
|
-
fc.constant(null),
|
202
|
-
),
|
203
|
-
),
|
204
|
-
fc.oneof(
|
205
|
-
fc.boolean(),
|
206
|
-
fc.array(fc.string()),
|
207
|
-
fc.dictionary(fc.string(), fc.boolean()),
|
208
|
-
),
|
209
|
-
(data, maskOptions) => {
|
210
|
-
const mask = Mask.create(maskOptions as any)
|
211
|
-
const originalData = { ...data }
|
212
|
-
const originalMask = JSON.parse(JSON.stringify(mask))
|
213
|
-
|
214
|
-
try {
|
215
|
-
Mask.apply(data as any, mask)
|
216
|
-
} catch {
|
217
|
-
// Ignore errors for invalid combinations
|
218
|
-
}
|
219
|
-
|
220
|
-
expect(data).toEqual(originalData)
|
221
|
-
expect(mask).toEqual(originalMask)
|
222
|
-
},
|
223
|
-
),
|
224
|
-
)
|
225
|
-
})
|
226
|
-
})
|
package/src/lib/mask/$.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * as Mask from './$$.js'
|