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
package/build/lib/graph/graph.js
DELETED
@@ -1,152 +0,0 @@
|
|
1
|
-
import { S } from '#lib/kit-temp/effect';
|
2
|
-
// ─── Schema ──────────────────────────────────────────────────────────────────
|
3
|
-
/**
|
4
|
-
* Dependency graph for tracking relationships between nodes
|
5
|
-
* Used to efficiently handle dependencies in various contexts
|
6
|
-
*/
|
7
|
-
export const DependencyGraph = S.Struct({
|
8
|
-
/**
|
9
|
-
* Map from parent ID to array of child IDs (parent depends on children)
|
10
|
-
*/
|
11
|
-
dependencies: S.Record({ key: S.String, value: S.Array(S.String) }),
|
12
|
-
/**
|
13
|
-
* Map from child ID to array of parent IDs (child is depended on by parents)
|
14
|
-
*/
|
15
|
-
dependents: S.Record({ key: S.String, value: S.Array(S.String) }),
|
16
|
-
}).annotations({
|
17
|
-
identifier: 'DependencyGraph',
|
18
|
-
description: 'A directed graph tracking dependencies between nodes',
|
19
|
-
});
|
20
|
-
// ─── Constructors ────────────────────────────────────────────────────────────
|
21
|
-
export const make = DependencyGraph.make;
|
22
|
-
/**
|
23
|
-
* Create an empty dependency graph
|
24
|
-
*/
|
25
|
-
export const create = () => make({
|
26
|
-
dependencies: {},
|
27
|
-
dependents: {},
|
28
|
-
});
|
29
|
-
// ─── Domain Logic ────────────────────────────────────────────────────────────
|
30
|
-
/**
|
31
|
-
* Add a dependency relationship (immutable)
|
32
|
-
* @param graph - The dependency graph
|
33
|
-
* @param parent - The parent node ID
|
34
|
-
* @param child - The child node ID that the parent depends on
|
35
|
-
* @returns A new graph with the dependency added
|
36
|
-
*/
|
37
|
-
export const addDependency = (graph, parent, child) => {
|
38
|
-
// Get existing arrays or create empty ones
|
39
|
-
const children = graph.dependencies[parent] || [];
|
40
|
-
const parents = graph.dependents[child] || [];
|
41
|
-
// Add child if not already present
|
42
|
-
const newChildren = children.includes(child) ? children : [...children, child];
|
43
|
-
// Add parent if not already present
|
44
|
-
const newParents = parents.includes(parent) ? parents : [...parents, parent];
|
45
|
-
return make({
|
46
|
-
dependencies: {
|
47
|
-
...graph.dependencies,
|
48
|
-
[parent]: newChildren,
|
49
|
-
},
|
50
|
-
dependents: {
|
51
|
-
...graph.dependents,
|
52
|
-
[child]: newParents,
|
53
|
-
},
|
54
|
-
});
|
55
|
-
};
|
56
|
-
/**
|
57
|
-
* Add a dependency relationship (mutable)
|
58
|
-
* @param graph - The dependency graph to mutate
|
59
|
-
* @param parent - The parent node ID
|
60
|
-
* @param child - The child node ID that the parent depends on
|
61
|
-
*/
|
62
|
-
export const addDependencyMutable = (graph, parent, child) => {
|
63
|
-
// Cast to mutable for mutation
|
64
|
-
const mutableGraph = graph;
|
65
|
-
// Add to dependencies
|
66
|
-
if (!mutableGraph.dependencies[parent]) {
|
67
|
-
mutableGraph.dependencies[parent] = [];
|
68
|
-
}
|
69
|
-
if (!mutableGraph.dependencies[parent].includes(child)) {
|
70
|
-
mutableGraph.dependencies[parent].push(child);
|
71
|
-
}
|
72
|
-
// Add to dependents
|
73
|
-
if (!mutableGraph.dependents[child]) {
|
74
|
-
mutableGraph.dependents[child] = [];
|
75
|
-
}
|
76
|
-
if (!mutableGraph.dependents[child].includes(parent)) {
|
77
|
-
mutableGraph.dependents[child].push(parent);
|
78
|
-
}
|
79
|
-
};
|
80
|
-
/**
|
81
|
-
* Find all nodes that have no dependencies (leaf nodes)
|
82
|
-
*/
|
83
|
-
export const findLeafNodes = (graph) => {
|
84
|
-
const leaves = new Set();
|
85
|
-
// Check all nodes that appear as children
|
86
|
-
for (const child of Object.keys(graph.dependents)) {
|
87
|
-
const deps = graph.dependencies[child];
|
88
|
-
if (!deps || deps.length === 0) {
|
89
|
-
leaves.add(child);
|
90
|
-
}
|
91
|
-
}
|
92
|
-
return leaves;
|
93
|
-
};
|
94
|
-
/**
|
95
|
-
* Check if all dependencies of a node have been processed
|
96
|
-
*/
|
97
|
-
export const areDependenciesReady = (node, graph, processed) => {
|
98
|
-
const deps = graph.dependencies[node];
|
99
|
-
if (!deps)
|
100
|
-
return true;
|
101
|
-
return deps.every(dep => processed.has(dep));
|
102
|
-
};
|
103
|
-
/**
|
104
|
-
* Get topological ordering of nodes (children before parents)
|
105
|
-
* This ensures we process dependencies before the nodes that depend on them
|
106
|
-
*
|
107
|
-
* @param graph - The dependency graph
|
108
|
-
* @returns Array of node IDs in topological order
|
109
|
-
*/
|
110
|
-
export const topologicalSort = (graph) => {
|
111
|
-
const result = [];
|
112
|
-
const visited = new Set();
|
113
|
-
const visiting = new Set(); // For cycle detection
|
114
|
-
// Get all nodes
|
115
|
-
const allNodes = new Set();
|
116
|
-
for (const parent of Object.keys(graph.dependencies)) {
|
117
|
-
allNodes.add(parent);
|
118
|
-
}
|
119
|
-
for (const child of Object.keys(graph.dependents)) {
|
120
|
-
allNodes.add(child);
|
121
|
-
}
|
122
|
-
const visit = (node) => {
|
123
|
-
if (visited.has(node))
|
124
|
-
return;
|
125
|
-
if (visiting.has(node)) {
|
126
|
-
// Cycle detected - just skip this node
|
127
|
-
return;
|
128
|
-
}
|
129
|
-
visiting.add(node);
|
130
|
-
// Visit all children first
|
131
|
-
const children = graph.dependencies[node];
|
132
|
-
if (children) {
|
133
|
-
for (const child of children) {
|
134
|
-
visit(child);
|
135
|
-
}
|
136
|
-
}
|
137
|
-
visiting.delete(node);
|
138
|
-
visited.add(node);
|
139
|
-
result.push(node);
|
140
|
-
};
|
141
|
-
// Visit all nodes
|
142
|
-
for (const node of allNodes) {
|
143
|
-
visit(node);
|
144
|
-
}
|
145
|
-
return result;
|
146
|
-
};
|
147
|
-
// ─── Codec ───────────────────────────────────────────────────────────────────
|
148
|
-
export const decode = S.decode(DependencyGraph);
|
149
|
-
export const decodeSync = S.decodeSync(DependencyGraph);
|
150
|
-
export const encode = S.encode(DependencyGraph);
|
151
|
-
export const encodeSync = S.encodeSync(DependencyGraph);
|
152
|
-
//# sourceMappingURL=graph.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../../src/lib/graph/graph.ts"],"names":[],"mappings":"AAAA,OAAO,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,CAAC,CAAA;AAC/C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAAA"}
|
package/build/lib/mask/$$.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/lib/mask/$$.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/build/lib/mask/$$.js
DELETED
package/build/lib/mask/$$.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$$.js","sourceRoot":"","sources":["../../../src/lib/mask/$$.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/build/lib/mask/$.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$.d.ts","sourceRoot":"","sources":["../../../src/lib/mask/$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA"}
|
package/build/lib/mask/$.js
DELETED
package/build/lib/mask/$.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$.js","sourceRoot":"","sources":["../../../src/lib/mask/$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA"}
|
@@ -1,86 +0,0 @@
|
|
1
|
-
import { type ExtendsExact } from '#lib/kit-temp';
|
2
|
-
import type { GetDataType, Mask } from './mask.js';
|
3
|
-
/**
|
4
|
-
* Type-level function that applies a mask to data.
|
5
|
-
*
|
6
|
-
* @template Data - The data type
|
7
|
-
* @template M - The mask type
|
8
|
-
*
|
9
|
-
* Binary masks:
|
10
|
-
* - show=true returns the data unchanged
|
11
|
-
* - show=false returns undefined
|
12
|
-
*
|
13
|
-
* Properties masks:
|
14
|
-
* - 'allow' mode returns Pick<Data, keys>
|
15
|
-
* - 'deny' mode returns Omit<Data, keys>
|
16
|
-
* - Non-objects throw an error at runtime
|
17
|
-
*/
|
18
|
-
export type Apply<$Data, $M extends Mask> = $M extends {
|
19
|
-
type: `binary`;
|
20
|
-
show: boolean;
|
21
|
-
} ? $M[`show`] extends true ? $Data : undefined : $M extends {
|
22
|
-
type: `properties`;
|
23
|
-
mode: string;
|
24
|
-
properties: any[];
|
25
|
-
} ? $Data extends object ? $M[`mode`] extends `allow` ? Pick<$Data, Extract<$M[`properties`][number], keyof $Data>> : Omit<$Data, Extract<$M[`properties`][number], keyof $Data>> : never : never;
|
26
|
-
/**
|
27
|
-
* Apply mask to data with standard covariance.
|
28
|
-
*
|
29
|
-
* Data must be assignable to the mask's expected type (may have excess properties).
|
30
|
-
*
|
31
|
-
* @param data - The data to mask
|
32
|
-
* @param mask - The mask to apply
|
33
|
-
* @returns The masked data
|
34
|
-
*
|
35
|
-
* @example
|
36
|
-
* ```ts
|
37
|
-
* const user = { name: 'John', email: 'john@example.com', password: 'secret' }
|
38
|
-
* const mask = Mask.pick<User>(['name', 'email'])
|
39
|
-
* const safeUser = apply(user, mask) // { name: 'John', email: 'john@example.com' }
|
40
|
-
* ```
|
41
|
-
*/
|
42
|
-
export declare const apply: <data extends GetDataType<mask>, mask extends Mask>(data: data, mask: mask) => Apply<data, mask>;
|
43
|
-
/**
|
44
|
-
* Apply mask to partial data.
|
45
|
-
*
|
46
|
-
* Data may have only a subset of the mask's expected properties.
|
47
|
-
* Useful when working with incomplete data or optional fields.
|
48
|
-
*
|
49
|
-
* @param data - The partial data to mask
|
50
|
-
* @param mask - The mask to apply
|
51
|
-
* @returns The masked data
|
52
|
-
*
|
53
|
-
* @example
|
54
|
-
* ```ts
|
55
|
-
* const partialUser = { name: 'John' } // missing email
|
56
|
-
* const mask = Mask.pick<User>(['name', 'email'])
|
57
|
-
* const result = applyPartial(partialUser, mask) // { name: 'John' }
|
58
|
-
* ```
|
59
|
-
*/
|
60
|
-
export declare const applyPartial: <data extends Partial<GetDataType<mask>>, mask extends Mask>(data: data, mask: mask) => Apply<data, mask>;
|
61
|
-
/**
|
62
|
-
* Apply mask to data with exact type matching.
|
63
|
-
*
|
64
|
-
* Data must exactly match the mask's expected type - no missing or excess properties.
|
65
|
-
* Provides the strictest type checking.
|
66
|
-
*
|
67
|
-
* @param data - The data to mask (must exactly match expected type)
|
68
|
-
* @param mask - The mask to apply
|
69
|
-
* @returns The masked data
|
70
|
-
*
|
71
|
-
* @example
|
72
|
-
* ```ts
|
73
|
-
* type User = { name: string; email: string }
|
74
|
-
* const mask = Mask.pick<User>(['name'])
|
75
|
-
*
|
76
|
-
* // This works - exact match
|
77
|
-
* const user: User = { name: 'John', email: 'john@example.com' }
|
78
|
-
* const result = applyExact(user, mask)
|
79
|
-
*
|
80
|
-
* // This fails - has extra property
|
81
|
-
* const userWithExtra = { name: 'John', email: 'john@example.com', age: 30 }
|
82
|
-
* const result2 = applyExact(userWithExtra, mask) // Type error!
|
83
|
-
* ```
|
84
|
-
*/
|
85
|
-
export declare const applyExact: <data, mask extends Mask>(data: ExtendsExact<data, GetDataType<mask>>, mask: mask) => Apply<data, mask>;
|
86
|
-
//# sourceMappingURL=apply.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/lib/mask/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,eAAe,CAAA;AAGlE,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAElD;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,KAAK,CAAC,KAAK,EAAE,EAAE,SAAS,IAAI,IACpC,EAAE,SAAS;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACxC,EAAE,CAAC,MAAM,CAAC,SAAS,IAAI,GACrB,KAAK,GACL,SAAS,GACX,EAAE,SAAS;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,GAAG,EAAE,CAAA;CAAE,GAChE,KAAK,SAAS,MAAM,GAClB,EAAE,CAAC,MAAM,CAAC,SAAS,OAAO,GACxB,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,GAC3D,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,GAC7D,KAAK,GACP,KAAK,CAAA;AAEf;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,KAAK,GAChB,IAAI,SAAS,WAAW,CAAC,IAAI,CAAC,EAC9B,IAAI,SAAS,IAAI,EACjB,MAAM,IAAI,EAAE,MAAM,IAAI,KAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAE1C,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,GACvB,IAAI,SAAS,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EACvC,IAAI,SAAS,IAAI,EACjB,MAAM,IAAI,EAAE,MAAM,IAAI,KAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAE1C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,UAAU,GACrB,IAAI,EACJ,IAAI,SAAS,IAAI,EAEjB,MAAM,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EAC3C,MAAM,IAAI,KACT,KAAK,CAAC,IAAI,EAAE,IAAI,CAElB,CAAA"}
|
package/build/lib/mask/apply.js
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
import { objPolicyFilter } from '#lib/kit-temp';
|
2
|
-
import { Obj } from '@wollybeard/kit';
|
3
|
-
import { never } from '@wollybeard/kit/language';
|
4
|
-
/**
|
5
|
-
* Apply mask to data with standard covariance.
|
6
|
-
*
|
7
|
-
* Data must be assignable to the mask's expected type (may have excess properties).
|
8
|
-
*
|
9
|
-
* @param data - The data to mask
|
10
|
-
* @param mask - The mask to apply
|
11
|
-
* @returns The masked data
|
12
|
-
*
|
13
|
-
* @example
|
14
|
-
* ```ts
|
15
|
-
* const user = { name: 'John', email: 'john@example.com', password: 'secret' }
|
16
|
-
* const mask = Mask.pick<User>(['name', 'email'])
|
17
|
-
* const safeUser = apply(user, mask) // { name: 'John', email: 'john@example.com' }
|
18
|
-
* ```
|
19
|
-
*/
|
20
|
-
export const apply = (data, mask) => {
|
21
|
-
return applyInternal(data, mask);
|
22
|
-
};
|
23
|
-
/**
|
24
|
-
* Apply mask to partial data.
|
25
|
-
*
|
26
|
-
* Data may have only a subset of the mask's expected properties.
|
27
|
-
* Useful when working with incomplete data or optional fields.
|
28
|
-
*
|
29
|
-
* @param data - The partial data to mask
|
30
|
-
* @param mask - The mask to apply
|
31
|
-
* @returns The masked data
|
32
|
-
*
|
33
|
-
* @example
|
34
|
-
* ```ts
|
35
|
-
* const partialUser = { name: 'John' } // missing email
|
36
|
-
* const mask = Mask.pick<User>(['name', 'email'])
|
37
|
-
* const result = applyPartial(partialUser, mask) // { name: 'John' }
|
38
|
-
* ```
|
39
|
-
*/
|
40
|
-
export const applyPartial = (data, mask) => {
|
41
|
-
return applyInternal(data, mask);
|
42
|
-
};
|
43
|
-
/**
|
44
|
-
* Apply mask to data with exact type matching.
|
45
|
-
*
|
46
|
-
* Data must exactly match the mask's expected type - no missing or excess properties.
|
47
|
-
* Provides the strictest type checking.
|
48
|
-
*
|
49
|
-
* @param data - The data to mask (must exactly match expected type)
|
50
|
-
* @param mask - The mask to apply
|
51
|
-
* @returns The masked data
|
52
|
-
*
|
53
|
-
* @example
|
54
|
-
* ```ts
|
55
|
-
* type User = { name: string; email: string }
|
56
|
-
* const mask = Mask.pick<User>(['name'])
|
57
|
-
*
|
58
|
-
* // This works - exact match
|
59
|
-
* const user: User = { name: 'John', email: 'john@example.com' }
|
60
|
-
* const result = applyExact(user, mask)
|
61
|
-
*
|
62
|
-
* // This fails - has extra property
|
63
|
-
* const userWithExtra = { name: 'John', email: 'john@example.com', age: 30 }
|
64
|
-
* const result2 = applyExact(userWithExtra, mask) // Type error!
|
65
|
-
* ```
|
66
|
-
*/
|
67
|
-
export const applyExact = (data, mask) => {
|
68
|
-
return applyInternal(data, mask);
|
69
|
-
};
|
70
|
-
// Internal implementation
|
71
|
-
const applyInternal = (data, mask) => {
|
72
|
-
// ━ Handle binary mask
|
73
|
-
if (mask.type === `binary`) {
|
74
|
-
return mask.show ? data : undefined;
|
75
|
-
}
|
76
|
-
// ━ Handle properties mask
|
77
|
-
if (mask.type === `properties`) {
|
78
|
-
// Properties mask requires object data
|
79
|
-
if (!Obj.is(data)) {
|
80
|
-
throw new Error(`Cannot apply properties mask to non-object data`);
|
81
|
-
}
|
82
|
-
return objPolicyFilter(mask.mode, data, mask.properties);
|
83
|
-
}
|
84
|
-
never();
|
85
|
-
};
|
86
|
-
//# sourceMappingURL=apply.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/lib/mask/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,eAAe,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAgChD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAGnB,IAAU,EAAE,IAAU,EAAqB,EAAE;IAC7C,OAAO,aAAa,CAAC,IAAI,EAAE,IAAI,CAAsB,CAAA;AACvD,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAG1B,IAAU,EAAE,IAAU,EAAqB,EAAE;IAC7C,OAAO,aAAa,CAAC,IAAI,EAAE,IAAI,CAAsB,CAAA;AACvD,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAIxB,IAA2C,EAC3C,IAAU,EACS,EAAE;IACrB,OAAO,aAAa,CAAC,IAAI,EAAE,IAAI,CAAsB,CAAA;AACvD,CAAC,CAAA;AAED,0BAA0B;AAC1B,MAAM,aAAa,GAAG,CAAC,IAAS,EAAE,IAAU,EAAO,EAAE;IACnD,uBAAuB;IACvB,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;IACrC,CAAC;IAED,2BAA2B;IAC3B,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC/B,uCAAuC;QACvC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;QACpE,CAAC;QAED,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;IAC1D,CAAC;IAED,KAAK,EAAE,CAAA;AACT,CAAC,CAAA"}
|
package/build/lib/mask/mask.d.ts
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* A mask that can either hide/show data entirely (BinaryMask) or
|
3
|
-
* selectively hide/show object properties (PropertiesMask).
|
4
|
-
*
|
5
|
-
* @template $Data - The data type being masked
|
6
|
-
*/
|
7
|
-
export type Mask<$Data = any> = BinaryMask<$Data> | PropertiesMask<$Data extends object ? $Data : object>;
|
8
|
-
/**
|
9
|
-
* Create a mask based on the provided options.
|
10
|
-
*
|
11
|
-
* @param options - Mask configuration:
|
12
|
-
* - `boolean`: Creates a binary mask (true = show, false = hide)
|
13
|
-
* - `string[]`: Creates a properties mask that allows only the specified keys
|
14
|
-
* - `object`: Creates a properties mask based on true/false values per key
|
15
|
-
*
|
16
|
-
* @returns A mask that can be applied to data
|
17
|
-
*
|
18
|
-
* @example
|
19
|
-
* ```ts
|
20
|
-
* // Binary mask
|
21
|
-
* const showAll = create(true)
|
22
|
-
* const hideAll = create(false)
|
23
|
-
*
|
24
|
-
* // Properties mask with array
|
25
|
-
* const allowMask = create<User>(['name', 'email'])
|
26
|
-
*
|
27
|
-
* // Properties mask with object
|
28
|
-
* const objectMask = create<User>({
|
29
|
-
* name: true,
|
30
|
-
* email: true,
|
31
|
-
* password: false
|
32
|
-
* })
|
33
|
-
* ```
|
34
|
-
*/
|
35
|
-
export declare const create: <$Data = unknown>(options: InferOptions<$Data>) => Mask<$Data>;
|
36
|
-
/**
|
37
|
-
* Valid options for creating a mask for the given data type.
|
38
|
-
*
|
39
|
-
* @template $Data - The data type to be masked
|
40
|
-
*/
|
41
|
-
export type InferOptions<$Data> = unknown extends $Data ? boolean | string[] | Record<string, boolean> : $Data extends object ? (boolean | (keyof $Data)[] | Partial<{
|
42
|
-
[K in keyof $Data]: boolean;
|
43
|
-
}>) : boolean;
|
44
|
-
/**
|
45
|
-
* A mask that selectively shows or hides object properties.
|
46
|
-
*
|
47
|
-
* @template $Data - The object type being masked
|
48
|
-
*/
|
49
|
-
export interface PropertiesMask<$Data extends object = object> {
|
50
|
-
type: `properties`;
|
51
|
-
/** Whether to allow only specified properties or deny them */
|
52
|
-
mode: `allow` | `deny`;
|
53
|
-
/** The list of property keys to allow or deny */
|
54
|
-
properties: (keyof $Data)[];
|
55
|
-
}
|
56
|
-
/**
|
57
|
-
* Create a properties mask.
|
58
|
-
*
|
59
|
-
* @param mode - 'allow' to show only specified properties, 'deny' to hide them
|
60
|
-
* @param properties - Array of property keys to allow or deny
|
61
|
-
* @returns A PropertiesMask
|
62
|
-
*/
|
63
|
-
export declare const createProperties: <$Data extends object = object>(mode: `allow` | `deny`, properties: (keyof $Data)[]) => PropertiesMask<$Data>;
|
64
|
-
/**
|
65
|
-
* A mask that either shows or hides data entirely.
|
66
|
-
*
|
67
|
-
* @template _$Data - The data type being masked (used for type inference)
|
68
|
-
*/
|
69
|
-
export interface BinaryMask<_$Data = any> {
|
70
|
-
type: `binary`;
|
71
|
-
/** Whether to show (true) or hide (false) the data */
|
72
|
-
show: boolean;
|
73
|
-
}
|
74
|
-
/**
|
75
|
-
* Create a binary mask.
|
76
|
-
*
|
77
|
-
* @param show - Whether to show (true) or hide (false) the data
|
78
|
-
* @returns A BinaryMask
|
79
|
-
*/
|
80
|
-
export declare const createBinary: <$Data = any>(show: boolean) => BinaryMask<$Data>;
|
81
|
-
/**
|
82
|
-
* Create a mask that shows all data.
|
83
|
-
* @returns A BinaryMask with show=true
|
84
|
-
*/
|
85
|
-
export declare const show: () => BinaryMask;
|
86
|
-
/**
|
87
|
-
* Create a mask that hides all data.
|
88
|
-
* @returns A BinaryMask with show=false
|
89
|
-
*/
|
90
|
-
export declare const hide: () => BinaryMask;
|
91
|
-
/**
|
92
|
-
* Create a mask that shows only the specified properties.
|
93
|
-
*
|
94
|
-
* @param properties - Array of property keys to show
|
95
|
-
* @returns A PropertiesMask in 'allow' mode
|
96
|
-
*
|
97
|
-
* @example
|
98
|
-
* ```ts
|
99
|
-
* const userMask = pick<User>(['name', 'email'])
|
100
|
-
* // Only 'name' and 'email' will be shown
|
101
|
-
* ```
|
102
|
-
*/
|
103
|
-
export declare const pick: <$Data extends object = object>(properties: (keyof $Data)[]) => PropertiesMask<$Data>;
|
104
|
-
/**
|
105
|
-
* Create a mask that hides the specified properties.
|
106
|
-
*
|
107
|
-
* @param properties - Array of property keys to hide
|
108
|
-
* @returns A PropertiesMask in 'deny' mode
|
109
|
-
*
|
110
|
-
* @example
|
111
|
-
* ```ts
|
112
|
-
* const userMask = omit<User>(['password', 'ssn'])
|
113
|
-
* // Everything except 'password' and 'ssn' will be shown
|
114
|
-
* ```
|
115
|
-
*/
|
116
|
-
export declare const omit: <$Data extends object = object>(properties: (keyof $Data)[]) => PropertiesMask<$Data>;
|
117
|
-
/**
|
118
|
-
* Extract the data type from a mask.
|
119
|
-
*
|
120
|
-
* @template $Mask - The mask type
|
121
|
-
* @returns The data type the mask is designed for
|
122
|
-
*/
|
123
|
-
export type GetDataType<$Mask extends Mask> = $Mask extends BinaryMask<infer $Data> ? $Data : $Mask extends PropertiesMask<infer $Data> ? $Data : never;
|
124
|
-
//# sourceMappingURL=mask.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../../../src/lib/mask/mask.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,MAAM,MAAM,IAAI,CAAC,KAAK,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,KAAK,SAAS,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC,CAAA;AAEzG;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,GAAG,OAAO,EACpC,SAAS,YAAY,CAAC,KAAK,CAAC,KAC3B,IAAI,CAAC,KAAK,CA4BZ,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,IAAI,OAAO,SAAS,KAAK,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClG,KAAK,SAAS,MAAM,GAAG,CACnB,OAAO,GACP,CAAC,MAAM,KAAK,CAAC,EAAE,GACf,OAAO,CACP;KACG,CAAC,IAAI,MAAM,KAAK,GAAG,OAAO;CAC5B,CACF,CACF,GACD,OAAO,CAAA;AAUX;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IAC3D,IAAI,EAAE,YAAY,CAAA;IAClB,8DAA8D;IAC9D,IAAI,EAAE,OAAO,GAAG,MAAM,CAAA;IACtB,iDAAiD;IACjD,UAAU,EAA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-
//
|
5
|
-
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ • Mask
|
6
|
-
//
|
7
|
-
//
|
8
|
-
/**
|
9
|
-
* Create a mask based on the provided options.
|
10
|
-
*
|
11
|
-
* @param options - Mask configuration:
|
12
|
-
* - `boolean`: Creates a binary mask (true = show, false = hide)
|
13
|
-
* - `string[]`: Creates a properties mask that allows only the specified keys
|
14
|
-
* - `object`: Creates a properties mask based on true/false values per key
|
15
|
-
*
|
16
|
-
* @returns A mask that can be applied to data
|
17
|
-
*
|
18
|
-
* @example
|
19
|
-
* ```ts
|
20
|
-
* // Binary mask
|
21
|
-
* const showAll = create(true)
|
22
|
-
* const hideAll = create(false)
|
23
|
-
*
|
24
|
-
* // Properties mask with array
|
25
|
-
* const allowMask = create<User>(['name', 'email'])
|
26
|
-
*
|
27
|
-
* // Properties mask with object
|
28
|
-
* const objectMask = create<User>({
|
29
|
-
* name: true,
|
30
|
-
* email: true,
|
31
|
-
* password: false
|
32
|
-
* })
|
33
|
-
* ```
|
34
|
-
*/
|
35
|
-
export const create = (options) => {
|
36
|
-
if (typeof options === `boolean`) {
|
37
|
-
return createBinary(options);
|
38
|
-
}
|
39
|
-
// Array input -> PropertiesMask with 'allow' mode
|
40
|
-
if (Array.isArray(options)) {
|
41
|
-
return createProperties(`allow`, options);
|
42
|
-
}
|
43
|
-
// Object input -> PropertiesMask based on true/false values
|
44
|
-
const entries = Object.entries(options);
|
45
|
-
const allowedKeys = entries
|
46
|
-
.filter(([_, include]) => include === true)
|
47
|
-
.map(([key]) => key);
|
48
|
-
const deniedKeys = entries
|
49
|
-
.filter(([_, include]) => include === false)
|
50
|
-
.map(([key]) => key);
|
51
|
-
// If we have denied keys, use deny mode
|
52
|
-
if (deniedKeys.length > 0 && allowedKeys.length === 0) {
|
53
|
-
return createProperties(`deny`, deniedKeys);
|
54
|
-
}
|
55
|
-
// Default to allow mode with allowed keys
|
56
|
-
return createProperties(`allow`, allowedKeys);
|
57
|
-
};
|
58
|
-
/**
|
59
|
-
* Create a properties mask.
|
60
|
-
*
|
61
|
-
* @param mode - 'allow' to show only specified properties, 'deny' to hide them
|
62
|
-
* @param properties - Array of property keys to allow or deny
|
63
|
-
* @returns A PropertiesMask
|
64
|
-
*/
|
65
|
-
export const createProperties = (mode, properties) => ({
|
66
|
-
type: `properties`,
|
67
|
-
mode,
|
68
|
-
properties,
|
69
|
-
});
|
70
|
-
/**
|
71
|
-
* Create a binary mask.
|
72
|
-
*
|
73
|
-
* @param show - Whether to show (true) or hide (false) the data
|
74
|
-
* @returns A BinaryMask
|
75
|
-
*/
|
76
|
-
export const createBinary = (show) => ({
|
77
|
-
type: `binary`,
|
78
|
-
show,
|
79
|
-
});
|
80
|
-
//
|
81
|
-
//
|
82
|
-
//
|
83
|
-
//
|
84
|
-
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ • Convenience Constructors with Semantic Names
|
85
|
-
//
|
86
|
-
//
|
87
|
-
/**
|
88
|
-
* Create a mask that shows all data.
|
89
|
-
* @returns A BinaryMask with show=true
|
90
|
-
*/
|
91
|
-
export const show = () => ({
|
92
|
-
type: `binary`,
|
93
|
-
show: true,
|
94
|
-
});
|
95
|
-
/**
|
96
|
-
* Create a mask that hides all data.
|
97
|
-
* @returns A BinaryMask with show=false
|
98
|
-
*/
|
99
|
-
export const hide = () => ({
|
100
|
-
type: `binary`,
|
101
|
-
show: false,
|
102
|
-
});
|
103
|
-
/**
|
104
|
-
* Create a mask that shows only the specified properties.
|
105
|
-
*
|
106
|
-
* @param properties - Array of property keys to show
|
107
|
-
* @returns A PropertiesMask in 'allow' mode
|
108
|
-
*
|
109
|
-
* @example
|
110
|
-
* ```ts
|
111
|
-
* const userMask = pick<User>(['name', 'email'])
|
112
|
-
* // Only 'name' and 'email' will be shown
|
113
|
-
* ```
|
114
|
-
*/
|
115
|
-
export const pick = (properties) => ({
|
116
|
-
type: `properties`,
|
117
|
-
mode: `allow`,
|
118
|
-
properties,
|
119
|
-
});
|
120
|
-
/**
|
121
|
-
* Create a mask that hides the specified properties.
|
122
|
-
*
|
123
|
-
* @param properties - Array of property keys to hide
|
124
|
-
* @returns A PropertiesMask in 'deny' mode
|
125
|
-
*
|
126
|
-
* @example
|
127
|
-
* ```ts
|
128
|
-
* const userMask = omit<User>(['password', 'ssn'])
|
129
|
-
* // Everything except 'password' and 'ssn' will be shown
|
130
|
-
* ```
|
131
|
-
*/
|
132
|
-
export const omit = (properties) => ({
|
133
|
-
type: `properties`,
|
134
|
-
mode: `deny`,
|
135
|
-
properties,
|
136
|
-
});
|
137
|
-
//# sourceMappingURL=mask.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mask.js","sourceRoot":"","sources":["../../../src/lib/mask/mask.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,EAAE;AACF,EAAE;AACF,EAAE;AACF,oDAAoD;AACpD,EAAE;AACF,EAAE;AAUF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,OAA4B,EACf,EAAE;IACf,IAAI,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,YAAY,CAAC,OAAO,CAAQ,CAAA;IACrC,CAAC;IAED,kDAAkD;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,gBAAgB,CAAC,OAAO,EAAE,OAAc,CAAQ,CAAA;IACzD,CAAC;IAED,4DAA4D;IAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAEvC,MAAM,WAAW,GAAG,OAAO;SACxB,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC;SAC1C,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAA;IAEtB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