1 | /**
|
2 | * Copyright 2020 Google LLC
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | export interface Bindings {
|
17 | [index: string]: string | number;
|
18 | }
|
19 | export declare class PathTemplate {
|
20 | private data;
|
21 | private bindings;
|
22 | segments: string[];
|
23 | size: number;
|
24 | /**
|
25 | * @param {String} data the of the template
|
26 | *
|
27 | * @constructor
|
28 | */
|
29 | constructor(data: string);
|
30 | /**
|
31 | * Matches a fully-qualified path template string.
|
32 | *
|
33 | * @param {String} path a fully-qualified path template string
|
34 | * Object} contains const names matched to binding values
{ |
35 | * @throws {TypeError} if path can't be matched to this template
|
36 | */
|
37 | match(path: string): Bindings;
|
38 | /**
|
39 | * Renders a path template using the provided bindings.
|
40 | *
|
41 | * @param {Object} bindings a mapping of const names to binding strings
|
42 | * @return {String} a rendered representation of the path template
|
43 | * @throws {TypeError} if a key is missing, or if a sub-template cannot be
|
44 | * parsed
|
45 | */
|
46 | render(bindings: Bindings): string;
|
47 | /**
|
48 | * Renders the path template.
|
49 | *
|
50 | * @return {string} contains const names matched to binding values
|
51 | */
|
52 | inspect(): string;
|
53 | /**
|
54 | * Parse the path template.
|
55 | *
|
56 | * @return {string[]} return segments of the input path.
|
57 | * For example: 'buckets/{hello}'' will give back ['buckets', {hello=*}]
|
58 | */
|
59 | private parsePathTemplate;
|
60 | }
|