@capybara-hq/plugin-sdk 0.1.0-rc.67 → 0.1.0-rc.68
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/field-meta.d.ts +3 -2
- package/dist/field-meta.js +8 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/platform-only.d.ts +3 -2
- package/dist/platform-only.js +5 -5
- package/package.json +1 -1
package/dist/field-meta.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ type Meta = Record<string, unknown>;
|
|
|
9
9
|
export declare function wrapperChain(schema: z.ZodTypeAny): z.ZodTypeAny[];
|
|
10
10
|
/**
|
|
11
11
|
* The meta of a config field merged across its wrapper chain: an outer key wins over an inner one,
|
|
12
|
-
* except `secret`, which
|
|
13
|
-
* never hides a secret). Zod's `id` is
|
|
12
|
+
* except `secret` and `platformOnly`, which are true when any node of the chain carries them
|
|
13
|
+
* (fail-safe: a wrapper's meta never hides a secret or clears a platform-only mark). Zod's `id` is
|
|
14
|
+
* left out: it names one schema instance.
|
|
14
15
|
*/
|
|
15
16
|
export declare function chainMeta(schema: z.ZodTypeAny): Meta;
|
|
16
17
|
/** Sets `key: value` on the schema's meta, keeping every mark found through its wrappers. */
|
package/dist/field-meta.js
CHANGED
|
@@ -23,23 +23,29 @@ export function wrapperChain(schema) {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* The meta of a config field merged across its wrapper chain: an outer key wins over an inner one,
|
|
26
|
-
* except `secret`, which
|
|
27
|
-
* never hides a secret). Zod's `id` is
|
|
26
|
+
* except `secret` and `platformOnly`, which are true when any node of the chain carries them
|
|
27
|
+
* (fail-safe: a wrapper's meta never hides a secret or clears a platform-only mark). Zod's `id` is
|
|
28
|
+
* left out: it names one schema instance.
|
|
28
29
|
*/
|
|
29
30
|
export function chainMeta(schema) {
|
|
30
31
|
const out = {};
|
|
31
32
|
let secret = false;
|
|
33
|
+
let platformOnly = false;
|
|
32
34
|
for (const node of wrapperChain(schema).reverse()) {
|
|
33
35
|
const m = node.meta();
|
|
34
36
|
if (!m)
|
|
35
37
|
continue;
|
|
36
38
|
if (m.secret === true)
|
|
37
39
|
secret = true;
|
|
40
|
+
if (m.platformOnly === true)
|
|
41
|
+
platformOnly = true;
|
|
38
42
|
Object.assign(out, m);
|
|
39
43
|
}
|
|
40
44
|
delete out.id;
|
|
41
45
|
if (secret)
|
|
42
46
|
out.secret = true;
|
|
47
|
+
if (platformOnly)
|
|
48
|
+
out.platformOnly = true;
|
|
43
49
|
return out;
|
|
44
50
|
}
|
|
45
51
|
/** Sets `key: value` on the schema's meta, keeping every mark found through its wrappers. */
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/platform-only.d.ts
CHANGED
|
@@ -20,7 +20,8 @@ import type { z } from "zod";
|
|
|
20
20
|
export declare function platformOnly<T extends z.ZodTypeAny>(schema: T): T;
|
|
21
21
|
/**
|
|
22
22
|
* Whether a schema carries the {@link platformOnly} mark. It sees through `.optional()`,
|
|
23
|
-
* `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()` (
|
|
24
|
-
*
|
|
23
|
+
* `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()` (true when any node of
|
|
24
|
+
* the chain carries the mark, like `secret`: an outer `false` never clears an inner `true`), so it
|
|
25
|
+
* agrees with the `"x-platform-only"` that `configJsonSchema` publishes.
|
|
25
26
|
*/
|
|
26
27
|
export declare function isPlatformOnly(schema: z.ZodTypeAny): boolean;
|
package/dist/platform-only.js
CHANGED
|
@@ -22,14 +22,14 @@ export function platformOnly(schema) {
|
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Whether a schema carries the {@link platformOnly} mark. It sees through `.optional()`,
|
|
25
|
-
* `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()` (
|
|
26
|
-
*
|
|
25
|
+
* `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()` (true when any node of
|
|
26
|
+
* the chain carries the mark, like `secret`: an outer `false` never clears an inner `true`), so it
|
|
27
|
+
* agrees with the `"x-platform-only"` that `configJsonSchema` publishes.
|
|
27
28
|
*/
|
|
28
29
|
export function isPlatformOnly(schema) {
|
|
29
30
|
for (const node of wrapperChain(schema)) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return v === true;
|
|
31
|
+
if (node.meta()?.platformOnly === true)
|
|
32
|
+
return true;
|
|
33
33
|
}
|
|
34
34
|
return false;
|
|
35
35
|
}
|