@k8ts/metadata 0.10.2 → 0.11.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.
Files changed (94) hide show
  1. package/dist/error.d.ts +1 -1
  2. package/dist/error.d.ts.map +1 -1
  3. package/dist/error.js +3 -3
  4. package/dist/error.js.map +1 -1
  5. package/dist/index.d.ts +2 -3
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -5
  8. package/dist/index.js.map +1 -1
  9. package/dist/input/dict-input.d.ts +5 -8
  10. package/dist/input/dict-input.d.ts.map +1 -1
  11. package/dist/input/index.d.ts +8 -0
  12. package/dist/input/index.d.ts.map +1 -0
  13. package/dist/input/index.js +24 -0
  14. package/dist/input/index.js.map +1 -0
  15. package/dist/input/key/base.d.ts +6 -0
  16. package/dist/input/key/base.d.ts.map +1 -0
  17. package/dist/input/key/base.js +13 -0
  18. package/dist/input/key/base.js.map +1 -0
  19. package/dist/input/key/domain-prefix.d.ts +8 -0
  20. package/dist/input/key/domain-prefix.d.ts.map +1 -0
  21. package/dist/input/key/domain-prefix.js +19 -0
  22. package/dist/input/key/domain-prefix.js.map +1 -0
  23. package/dist/input/key/metadata-key.d.ts +21 -0
  24. package/dist/input/key/metadata-key.d.ts.map +1 -0
  25. package/dist/input/key/metadata-key.js +82 -0
  26. package/dist/input/key/metadata-key.js.map +1 -0
  27. package/dist/input/key/parse-key.d.ts +10 -0
  28. package/dist/input/key/parse-key.d.ts.map +1 -0
  29. package/dist/{key → input/key}/parse-key.js +10 -8
  30. package/dist/input/key/parse-key.js.map +1 -0
  31. package/dist/input/key/string-types.d.ts +10 -0
  32. package/dist/input/key/string-types.d.ts.map +1 -0
  33. package/dist/input/key/string-types.js +3 -0
  34. package/dist/input/key/string-types.js.map +1 -0
  35. package/dist/input/parse-dict.d.ts +3 -2
  36. package/dist/input/parse-dict.d.ts.map +1 -1
  37. package/dist/input/parse-dict.js +16 -7
  38. package/dist/input/parse-dict.js.map +1 -1
  39. package/dist/meta.d.ts +243 -273
  40. package/dist/meta.d.ts.map +1 -1
  41. package/dist/meta.js +259 -297
  42. package/dist/meta.js.map +1 -1
  43. package/dist/util.d.ts +1 -22
  44. package/dist/util.d.ts.map +1 -1
  45. package/dist/util.js +15 -110
  46. package/dist/util.js.map +1 -1
  47. package/dist/utils/map.d.ts +23 -0
  48. package/dist/utils/map.d.ts.map +1 -0
  49. package/dist/utils/map.js +113 -0
  50. package/dist/utils/map.js.map +1 -0
  51. package/dist/utils/order-meta-keyed-object.d.ts.map +1 -0
  52. package/dist/{order-meta-keyed-object.js → utils/order-meta-keyed-object.js} +2 -1
  53. package/dist/utils/order-meta-keyed-object.js.map +1 -0
  54. package/dist/utils/validate.d.ts +4 -0
  55. package/dist/utils/validate.d.ts.map +1 -0
  56. package/dist/utils/validate.js +38 -0
  57. package/dist/utils/validate.js.map +1 -0
  58. package/package.json +2 -8
  59. package/src/error.ts +1 -1
  60. package/src/index.ts +2 -3
  61. package/src/input/dict-input.ts +5 -12
  62. package/src/input/index.ts +7 -0
  63. package/src/input/key/base.ts +10 -0
  64. package/src/input/key/domain-prefix.ts +14 -0
  65. package/src/input/key/metadata-key.ts +90 -0
  66. package/src/{key → input/key}/parse-key.ts +12 -8
  67. package/src/input/key/string-types.ts +15 -0
  68. package/src/input/parse-dict.ts +23 -13
  69. package/src/meta.ts +391 -417
  70. package/src/util.ts +1 -115
  71. package/src/utils/map.ts +115 -0
  72. package/src/{order-meta-keyed-object.ts → utils/order-meta-keyed-object.ts} +2 -1
  73. package/src/utils/validate.ts +32 -0
  74. package/dist/key/index.d.ts +0 -4
  75. package/dist/key/index.d.ts.map +0 -1
  76. package/dist/key/index.js +0 -11
  77. package/dist/key/index.js.map +0 -1
  78. package/dist/key/parse-key.d.ts +0 -8
  79. package/dist/key/parse-key.d.ts.map +0 -1
  80. package/dist/key/parse-key.js.map +0 -1
  81. package/dist/key/repr.d.ts +0 -36
  82. package/dist/key/repr.d.ts.map +0 -1
  83. package/dist/key/repr.js +0 -113
  84. package/dist/key/repr.js.map +0 -1
  85. package/dist/key/types.d.ts +0 -20
  86. package/dist/key/types.d.ts.map +0 -1
  87. package/dist/key/types.js +0 -11
  88. package/dist/key/types.js.map +0 -1
  89. package/dist/order-meta-keyed-object.d.ts.map +0 -1
  90. package/dist/order-meta-keyed-object.js.map +0 -1
  91. package/src/key/index.ts +0 -4
  92. package/src/key/repr.ts +0 -128
  93. package/src/key/types.ts +0 -21
  94. /package/dist/{order-meta-keyed-object.d.ts → utils/order-meta-keyed-object.d.ts} +0 -0
package/dist/meta.d.ts CHANGED
@@ -1,300 +1,270 @@
1
- import type { InputMeta, MetaInputParts } from "./input/dict-input";
2
- import { MetadataKey } from "./key/repr";
3
- import { Key } from "./key/types";
4
- export type Meta = Meta.Meta;
5
- declare const MetaMarker: unique symbol;
6
- export interface MetaLike {
7
- readonly [MetaMarker]: true;
8
- }
9
- export declare namespace Meta {
10
- function _checkNameValue(what: string, v: string): void;
11
- function _checkValue(key: string, v: string): void;
12
- type Input = InputMeta;
1
+ import type { Metadata_Input, MetaInputParts } from "./input/dict-input";
2
+ import type { Metadata_Key_sDomain, Metadata_Key_sValue, NotPrefixed } from "./input/key/string-types";
3
+ /**
4
+ * Mutable storage for k8s metadata. K8s metadata includes labels, annotations, and core fields.
5
+ * These are addressed using `CharPrefix`.
6
+ *
7
+ * - **Labels**: `%key` → `metadata.labels.key`
8
+ * - **Annotations**: `^key` → `metadata.annotations.key`
9
+ * - **Comments**: `#key` → Build-time metadata, not manifested in k8s objects.
10
+ * - **Core metadata**: `key` → `metadata.key` (e.g., `name`, `namespace`, etc.)
11
+ *
12
+ * In addition, you can address different metadata keys under the same domain using a `DomainKey`,
13
+ * of the form `example.com/`. When using a `DomainKey`, you use a `CharPrefix` on the inner keys.
14
+ *
15
+ * This lets you add different kinds of metadata under the same domain with ease.
16
+ *
17
+ * @example
18
+ * meta.add("%app", "my-app") // adds label 'app' with value 'my-app'
19
+ * meta.add("example.section/", {
20
+ * "%label1": "value1", // adds `%example.section/label1` with value 'value1'
21
+ * "^annotation1": "value2" // adds `^example.section/annotation1` with value 'value2'
22
+ * })
23
+ */
24
+ export declare class Metadata implements Iterable<[Metadata_Key_sValue, string]> {
25
+ private readonly _dict;
26
+ /**
27
+ * Constructs a Metadata instance with a single key-value pair.
28
+ *
29
+ * @example
30
+ * const meta = new Metadata("%app", "my-app")
31
+ *
32
+ * @param key The value key
33
+ * @param value The value to associate with the key
34
+ */
35
+ constructor(key: Metadata_Key_sValue, value: string);
13
36
  /**
14
- * Mutable storage for k8s metadata. K8s metadata includes labels, annotations, and core fields.
15
- * These are addressed using `CharPrefix`.
37
+ * Constructs a Metadata instance with key-value pairs within a section namespace.
38
+ *
39
+ * @example
40
+ * const meta = new Metadata("example.com/", { "%label": "value" })
16
41
  *
17
- * - **Labels**: `%key` `metadata.labels.key`
18
- * - **Annotations**: `^key` `metadata.annotations.key`
19
- * - **Comments**: `#key` → Build-time metadata, not manifested in k8s objects.
20
- * - **Core metadata**: `key` `metadata.key` (e.g., `name`, `namespace`, etc.)
42
+ * @param key The section key namespace
43
+ * @param value Nested object containing key-value pairs
44
+ */
45
+ constructor(key: Metadata_Key_sDomain, value: MetaInputParts.Nested);
46
+ /**
47
+ * Constructs a Metadata instance from an input object or returns an empty Metadata if no input
48
+ * provided.
21
49
  *
22
- * In addition, you can address different metadata keys under the same domain using a
23
- * `DomainKey`, of the form `example.com/`. When using a `DomainKey`, you use a `CharPrefix` on
24
- * the inner keys.
50
+ * @example
51
+ * const meta = new Metadata({ "%app": "my-app", name: "resource" })
52
+ * const empty = new Metadata()
25
53
  *
26
- * This lets you add different kinds of metadata under the same domain with ease.
54
+ * @param input Object or map containing key-value pairs
55
+ */
56
+ constructor(input?: Metadata_Input);
57
+ /**
58
+ * Makes Metadata instances iterable, yielding [ValueKey, string] pairs.
27
59
  *
28
60
  * @example
29
- * meta.add("%app", "my-app") // adds label 'app' with value 'my-app'
30
- * meta.add("example.section/", {
31
- * "%label1": "value1", // adds `%example.section/label1` with value 'value1'
32
- * "^annotation1": "value2" // adds `^example.section/annotation1` with value 'value2'
33
- * })
61
+ * for (const [key, value] of meta) {
62
+ * console.log(key.str, value)
63
+ * }
34
64
  */
35
- class Meta implements Iterable<[MetadataKey, string]>, MetaLike {
36
- private readonly _dict;
37
- readonly [MetaMarker] = true;
38
- /**
39
- * Constructs a new Meta instance from a map of key-value pairs. Validates all keys and
40
- * values during construction.
41
- *
42
- * @param _dict Internal map storing metadata key-value pairs
43
- * @throws {MetadataError} If any key or value is invalid
44
- */
45
- constructor(_dict: Map<string, string>);
46
- /**
47
- * Makes Meta instances iterable, yielding [ValueKey, string] pairs.
48
- *
49
- * @example
50
- * for (const [key, value] of meta) {
51
- * console.log(key.str, value)
52
- * }
53
- */
54
- [Symbol.iterator](): Generator<[MetadataKey, string], void, unknown>;
55
- protected _create(raw: Map<string, string>): Meta;
56
- /**
57
- * Creates a deep clone of this object.
58
- *
59
- * @returns
60
- */
61
- clone(): Meta;
62
- /**
63
- * Deletes a single value key from the metadata.
64
- *
65
- * @example
66
- * meta.delete("name") // deletes core metadata 'name'
67
- * meta.delete("%app") // deletes label 'app'
68
- *
69
- * @param key The value key to delete
70
- */
71
- delete(key: Key.Value): Meta;
72
- /**
73
- * Deletes specific keys under a domain prefix.
74
- *
75
- * @example
76
- * meta.delete("example.com/", "key1", "key2") // deletes specific keys in section
77
- *
78
- * @param ns The section key namespace
79
- * @param keys Specific value keys within the section to delete
80
- */
81
- delete(ns: Key.Domain, ...keys: Key.Value[]): Meta;
82
- /**
83
- * Deletes all keys within a section namespace.
84
- *
85
- * @example
86
- * meta.delete("example.com/") // deletes all keys in section
87
- *
88
- * @param ns The section key namespace to delete
89
- */
90
- delete(ns: Key.Domain): Meta;
91
- /**
92
- * Adds a single key-value pair to the metadata. Throws if the key already exists.
93
- *
94
- * @example
95
- * meta.add("%app", "my-app") // adds label
96
- * meta.add("name", "my-resource") // adds core metadata
97
- *
98
- * @param key The value key to add
99
- * @param value The value to associate with the key
100
- */
101
- add(key: Key.Value, value?: string): Meta;
102
- /**
103
- * Adds a nested object of key-value pairs within a section namespace. Throws if any key
104
- * already exists.
105
- *
106
- * @example
107
- * meta.add("example.com/", { "%label": "value", "^annotation": "data" })
108
- *
109
- * @param key The section key namespace
110
- * @param value Nested object containing key-value pairs
111
- */
112
- add(key: Key.Domain, value: MetaInputParts.Nested): Meta;
113
- /**
114
- * Adds multiple key-value pairs from an input object. Throws if any key already exists.
115
- *
116
- * @example
117
- * meta.add({ "%app": "my-app", name: "my-resource" })
118
- *
119
- * @param input Object or map containing key-value pairs to add
120
- */
121
- add(input: InputMeta): Meta;
122
- /**
123
- * Compares this Meta instance to another for equality. Two instances are equal if they
124
- * contain the same key-value pairs.
125
- *
126
- * @param other The other Meta instance or input to compare against
127
- * @returns Whether the two Meta instances are equal
128
- */
129
- equals(other: Meta.Input): boolean;
130
- /**
131
- * Overwrites a single key-value pair, replacing any existing value.
132
- *
133
- * @example
134
- * meta.overwrite("%app", "new-app") // replaces existing label value
135
- *
136
- * @param key The value key to overwrite
137
- * @param value The new value (undefined removes the key)
138
- */
139
- overwrite(key: Key.Value, value: string | undefined): Meta;
140
- /**
141
- * Overwrites key-value pairs within a section namespace.
142
- *
143
- * @example
144
- * meta.overwrite("example.com/", { "%label": "new-value" })
145
- *
146
- * @param key The section key namespace
147
- * @param value Nested object containing key-value pairs to overwrite
148
- */
149
- overwrite(key: Key.Domain, value: MetaInputParts.Nested): Meta;
150
- /**
151
- * Overwrites multiple key-value pairs from an input object.
152
- *
153
- * @example
154
- * meta.overwrite({ "%app": "new-app", name: "new-name" })
155
- *
156
- * @param input Object or map containing key-value pairs to overwrite
157
- */
158
- overwrite(input?: InputMeta): Meta;
159
- /**
160
- * Checks if a key with a given domain prefix exists in the metadata.
161
- *
162
- * @example
163
- * meta.has("example.com/") // Checks for any key with this domain
164
- * meta.has("%app") // Checks for the label 'app'
165
- *
166
- * @param domainPrefix The domain prefix to check for
167
- * @returns True if any keys exist under the specified domain prefix, false otherwise
168
- */
169
- has(domainPrefix: Key.Domain): boolean;
170
- /** @param key */
171
- has(key: Key.Value): boolean;
172
- /**
173
- * Retrieves the value for the specified key. Throws if the key doesn't exist.
174
- *
175
- * @example
176
- * const appName = meta.get("%app")
177
- *
178
- * @param key The value key to retrieve
179
- * @returns The value associated with the key
180
- * @throws {MetadataError} If the key is not found
181
- */
182
- get(key: Key.Value): string;
183
- /**
184
- * Attempts to retrieve the value for the specified key, returning a fallback if not found.
185
- *
186
- * @example
187
- * const appName = meta.tryGet("%app", "default-app")
188
- *
189
- * @param key The value key to retrieve
190
- * @param fallback Optional fallback value if key doesn't exist
191
- * @returns The value associated with the key, or the fallback value
192
- * @throws {MetadataError} If a domain key is provided instead of a value key
193
- */
194
- tryGet(key: Key.Value, fallback?: string): string | undefined;
195
- private _matchDomainPrefixes;
196
- /**
197
- * Creates a new Meta instance containing only some of the keys. You can pass both entire
198
- * keys and domain prefixes to include all keys under that domain.
199
- *
200
- * @example
201
- * const subset = meta.pick("%app", "name", "example.com/")
202
- *
203
- * @param keySpecs Keys or domain prefixes to include in the result
204
- * @returns A new Meta instance with only the picked keys
205
- */
206
- pick(...keySpecs: (Key.Domain | Key.Value)[]): Meta;
207
- private _prefixed;
208
- /**
209
- * Returns all labels as a plain object that can be embedded into a k8s manifest, with keys
210
- * in canonical order.
211
- *
212
- * @example
213
- * const labels = Meta.make({
214
- * "%app": "my-app",
215
- * "%tier": "backend"
216
- * }).labels
217
- * // { app: "my-app", tier: "backend" }
218
- */
219
- get labels(): Record<string, any>;
220
- /**
221
- * Returns all annotations as a plain object that can be embedded into a k8s manifest, with
222
- * keys in canonical order.
223
- *
224
- * @example
225
- * const annotations = Meta.make({
226
- * "^note": "This is important",
227
- * "^description": "Detailed info"
228
- * }).annotations
229
- * // { note: "This is important", description: "Detailed info" }
230
- */
231
- get annotations(): Record<string, any>;
232
- /**
233
- * Returns all comments (build-time metadata) as a plain object, with keys in canonical
234
- * order.
235
- *
236
- * @example
237
- * const comments = Meta.make({
238
- * "#note": "Internal use only"
239
- * }).comments
240
- * // { note: "Internal use only" }
241
- */
242
- get comments(): Record<string, any>;
243
- /**
244
- * Returns all core metadata fields (`name` and `namespace`) as a plain object that can be
245
- * embedded into a k8s manifest, with keys in canonical order.
246
- *
247
- * @example
248
- * const core = meta.core // { name: "my-resource", namespace: "default" }
249
- */
250
- get core(): { [key in Key.Special]?: string; };
251
- /**
252
- * Returns all metadata key-value pairs as a flat JavaScript object, with each key prefixed
253
- * appropriately.
254
- *
255
- * @example
256
- * const all = Meta.make({
257
- * "%app": "my-app",
258
- * "^note": "This is important",
259
- * name: "my-resource"
260
- * }).values
261
- * // { "%app": "my-app", "^note": "This is important", "name": "my-resource" }
262
- */
263
- get values(): {
264
- [k: string]: string;
265
- };
266
- private get _keys();
267
- }
65
+ [Symbol.iterator](): Generator<[`%${string}` | `^${string}` | `#${string}`, string], void, unknown>;
268
66
  /**
269
- * Creates a Meta instance with a single key-value pair.
67
+ * Creates a deep clone of this object.
68
+ *
69
+ * @returns
70
+ */
71
+ clone(): Metadata;
72
+ /**
73
+ * Deletes a single value key from the metadata.
270
74
  *
271
75
  * @example
272
- * const meta = Meta.make("%app", "my-app")
76
+ * meta.delete("name") // deletes core metadata 'name'
77
+ * meta.delete("%app") // deletes label 'app'
273
78
  *
274
- * @param key The value key
79
+ * @param key The value key to delete
80
+ */
81
+ delete(key: Metadata_Key_sValue): Metadata;
82
+ /**
83
+ * Deletes specific keys under a domain prefix.
84
+ *
85
+ * @example
86
+ * meta.delete("example.com/", "key1", "key2") // deletes specific keys in section
87
+ *
88
+ * @param ns The section key namespace
89
+ * @param keys Specific value keys within the section to delete
90
+ */
91
+ delete(ns: Metadata_Key_sDomain, keys: Metadata_Key_sValue[]): Metadata;
92
+ /**
93
+ * Deletes all keys within a section namespace.
94
+ *
95
+ * @example
96
+ * meta.delete("example.com/") // deletes all keys in section
97
+ *
98
+ * @param ns The section key namespace to delete
99
+ */
100
+ delete(ns: Metadata_Key_sDomain): Metadata;
101
+ /**
102
+ * Adds a single key-value pair to the metadata. Throws if the key already exists.
103
+ *
104
+ * @example
105
+ * meta.add("%app", "my-app") // adds label
106
+ * meta.add("name", "my-resource") // adds core metadata
107
+ *
108
+ * @param key The value key to add
275
109
  * @param value The value to associate with the key
276
110
  */
277
- function make(key: Key.Value, value: string): Meta;
111
+ add(key: Metadata_Key_sValue, value?: string): Metadata;
278
112
  /**
279
- * Creates a Meta instance with key-value pairs within a section namespace.
113
+ * Adds a nested object of key-value pairs within a section namespace. Throws if any key already
114
+ * exists.
280
115
  *
281
116
  * @example
282
- * const meta = Meta.make("example.com/", { "%label": "value" })
117
+ * meta.add("example.com/", { "%label": "value", "^annotation": "data" })
283
118
  *
284
119
  * @param key The section key namespace
285
120
  * @param value Nested object containing key-value pairs
286
121
  */
287
- function make(key: Key.Domain, value: MetaInputParts.Nested): Meta;
122
+ add<Domain extends NotPrefixed<Domain>>(key: Domain, value: MetaInputParts.Nested): Metadata;
288
123
  /**
289
- * Creates a Meta instance from an input object or returns an empty Meta if no input provided.
124
+ * Adds multiple key-value pairs from an input object. Throws if any key already exists.
290
125
  *
291
126
  * @example
292
- * const meta = Meta.make({ "%app": "my-app", name: "resource" })
293
- * const empty = Meta.make()
127
+ * meta.add({ "%app": "my-app", name: "my-resource" })
294
128
  *
295
- * @param input Object or map containing key-value pairs
129
+ * @param input Object or map containing key-value pairs to add
130
+ */
131
+ add(input: Metadata_Input): Metadata;
132
+ /**
133
+ * Compares this Metadata instance to another for equality. Two instances are equal if they
134
+ * contain the same key-value pairs.
135
+ *
136
+ * @param other The other Metadata instance or input to compare against
137
+ * @returns Whether the two Metadata instances are equal
138
+ */
139
+ equals(other: Metadata_Input): boolean;
140
+ /**
141
+ * Overwrites a single key-value pair, replacing any existing value.
142
+ *
143
+ * @example
144
+ * meta.overwrite("%app", "new-app") // replaces existing label value
145
+ *
146
+ * @param key The value key to overwrite
147
+ * @param value The new value (undefined removes the key)
148
+ */
149
+ overwrite(key: Metadata_Key_sValue, value: string | undefined): Metadata;
150
+ /**
151
+ * Overwrites key-value pairs within a section namespace.
152
+ *
153
+ * @example
154
+ * meta.overwrite("example.com/", { "%label": "new-value" })
155
+ *
156
+ * @param key The section key namespace
157
+ * @param value Nested object containing key-value pairs to overwrite
158
+ */
159
+ overwrite<Domain extends NotPrefixed<Domain>>(key: Domain, value: MetaInputParts.Nested): Metadata;
160
+ /**
161
+ * Overwrites multiple key-value pairs from an input object.
162
+ *
163
+ * @example
164
+ * meta.overwrite({ "%app": "new-app", name: "new-name" })
165
+ *
166
+ * @param input Object or map containing key-value pairs to overwrite
167
+ */
168
+ overwrite(input?: Metadata_Input): Metadata;
169
+ /**
170
+ * Checks if a key with a given domain prefix exists in the metadata.
171
+ *
172
+ * @example
173
+ * meta.has("example.com/") // Checks for any key with this domain
174
+ * meta.has("%app") // Checks for the label 'app'
175
+ *
176
+ * @param domainPrefix The domain prefix to check for
177
+ * @returns True if any keys exist under the specified domain prefix, false otherwise
178
+ */
179
+ has<Domain extends NotPrefixed<Domain>>(domainPrefix: Domain): boolean;
180
+ /** @param key */
181
+ has(key: Metadata_Key_sValue): boolean;
182
+ /**
183
+ * Retrieves the value for the specified key. Throws if the key doesn't exist.
184
+ *
185
+ * @example
186
+ * const appName = meta.get("%app")
187
+ *
188
+ * @param key The value key to retrieve
189
+ * @returns The value associated with the key
190
+ * @throws {K8tsMetadataError} If the key is not found
191
+ */
192
+ get(key: Metadata_Key_sValue): string;
193
+ /**
194
+ * Attempts to retrieve the value for the specified key, returning a fallback if not found.
195
+ *
196
+ * @example
197
+ * const appName = meta.tryGet("%app", "default-app")
198
+ *
199
+ * @param key The value key to retrieve
200
+ * @param fallback Optional fallback value if key doesn't exist
201
+ * @returns The value associated with the key, or the fallback value
202
+ * @throws {K8tsMetadataError} If a domain key is provided instead of a value key
203
+ */
204
+ tryGet(key: Metadata_Key_sValue, fallback?: string): string | undefined;
205
+ private get _parsedPairs();
206
+ private _matchDomainPrefixes;
207
+ /**
208
+ * Creates a new Metadata instance containing only some of the keys. You can pass both entire
209
+ * keys and domain prefixes to include all keys under that domain.
210
+ *
211
+ * @example
212
+ * const subset = meta.pick("%app", "name", "example.com/")
213
+ *
214
+ * @param keySpecs Keys or domain prefixes to include in the result
215
+ * @returns A new Metadata instance with only the picked keys
216
+ */
217
+ pick(...keySpecs: (Metadata_Key_sDomain | Metadata_Key_sValue)[]): Metadata;
218
+ private _prefixed;
219
+ /**
220
+ * Returns all labels as a plain object that can be embedded into a k8s manifest, with keys in
221
+ * canonical order.
222
+ *
223
+ * @example
224
+ * const labels = Metadata.make({
225
+ * "%app": "my-app",
226
+ * "%tier": "backend"
227
+ * }).labels
228
+ * // { app: "my-app", tier: "backend" }
229
+ */
230
+ get labels(): Record<string, any>;
231
+ /**
232
+ * Returns all annotations as a plain object that can be embedded into a k8s manifest, with keys
233
+ * in canonical order.
234
+ *
235
+ * @example
236
+ * const annotations = Metadata.make({
237
+ * "^note": "This is important",
238
+ * "^description": "Detailed info"
239
+ * }).annotations
240
+ * // { note: "This is important", description: "Detailed info" }
241
+ */
242
+ get annotations(): Record<string, any>;
243
+ /**
244
+ * Returns all comments (build-time metadata) as a plain object, with keys in canonical order.
245
+ *
246
+ * @example
247
+ * const comments = Metadata.make({
248
+ * "#note": "Internal use only"
249
+ * }).comments
250
+ * // { note: "Internal use only" }
251
+ */
252
+ get comments(): Record<string, any>;
253
+ /**
254
+ * Returns all metadata key-value pairs as a flat JavaScript object, with each key prefixed
255
+ * appropriately.
256
+ *
257
+ * @example
258
+ * const all = Metadata.make({
259
+ * "%app": "my-app",
260
+ * "^note": "This is important",
261
+ * name: "my-resource"
262
+ * }).values
263
+ * // { "%app": "my-app", "^note": "This is important", "name": "my-resource" }
296
264
  */
297
- function make(input?: InputMeta): Meta;
265
+ get record(): {
266
+ [k: string]: string;
267
+ };
268
+ private get _keys();
298
269
  }
299
- export {};
300
270
  //# sourceMapping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