Skip to content

Commit 357a9cf

Browse files
jirenJustinBeckwith
authored andcommitted
feat: add support for appengine legacy url encoding (#456)
1 parent 771b634 commit 357a9cf

File tree

7 files changed

+716
-1
lines changed

7 files changed

+716
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
"compile": "tsc -p . && cp -r src/v1 build/src && cp -r proto* build && cp test/*.js build/test",
4040
"prepare": "npm run compile",
4141
"pretest": "npm run compile",
42-
"proto": "npm run proto:datastore",
42+
"proto": "npm run proto:datastore && npm run proto:appenginekey",
4343
"proto:datastore": "mkdir -p proto && pbjs -t static-module -w commonjs -p node_modules/google-proto-files google/datastore/v1/datastore.proto | pbts -i long -o proto/datastore.d.ts -",
44+
"proto:appenginekey": "mkdir -p proto && pbjs -t static-module -w commonjs protos/app_engine_key.proto | pbts -o proto/app_engine_key.d.ts -",
4445
"docs-test": "linkinator docs",
4546
"predocs-test": "npm run docs"
4647
},

proto/app_engine_key.d.ts

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
import * as $protobuf from "protobufjs";
2+
/** Properties of a Reference. */
3+
export interface IReference {
4+
5+
/** Reference app */
6+
app: string;
7+
8+
/** Reference namespace */
9+
namespace?: (string|null);
10+
11+
/** Reference path */
12+
path: IPath;
13+
14+
/** Reference databaseId */
15+
databaseId?: (string|null);
16+
}
17+
18+
/** Represents a Reference. */
19+
export class Reference implements IReference {
20+
21+
/**
22+
* Constructs a new Reference.
23+
* @param [properties] Properties to set
24+
*/
25+
constructor(properties?: IReference);
26+
27+
/** Reference app. */
28+
public app: string;
29+
30+
/** Reference namespace. */
31+
public namespace: string;
32+
33+
/** Reference path. */
34+
public path: IPath;
35+
36+
/** Reference databaseId. */
37+
public databaseId: string;
38+
39+
/**
40+
* Creates a new Reference instance using the specified properties.
41+
* @param [properties] Properties to set
42+
* @returns Reference instance
43+
*/
44+
public static create(properties?: IReference): Reference;
45+
46+
/**
47+
* Encodes the specified Reference message. Does not implicitly {@link Reference.verify|verify} messages.
48+
* @param message Reference message or plain object to encode
49+
* @param [writer] Writer to encode to
50+
* @returns Writer
51+
*/
52+
public static encode(message: IReference, writer?: $protobuf.Writer): $protobuf.Writer;
53+
54+
/**
55+
* Encodes the specified Reference message, length delimited. Does not implicitly {@link Reference.verify|verify} messages.
56+
* @param message Reference message or plain object to encode
57+
* @param [writer] Writer to encode to
58+
* @returns Writer
59+
*/
60+
public static encodeDelimited(message: IReference, writer?: $protobuf.Writer): $protobuf.Writer;
61+
62+
/**
63+
* Decodes a Reference message from the specified reader or buffer.
64+
* @param reader Reader or buffer to decode from
65+
* @param [length] Message length if known beforehand
66+
* @returns Reference
67+
* @throws {Error} If the payload is not a reader or valid buffer
68+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
69+
*/
70+
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): Reference;
71+
72+
/**
73+
* Decodes a Reference message from the specified reader or buffer, length delimited.
74+
* @param reader Reader or buffer to decode from
75+
* @returns Reference
76+
* @throws {Error} If the payload is not a reader or valid buffer
77+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
78+
*/
79+
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): Reference;
80+
81+
/**
82+
* Verifies a Reference message.
83+
* @param message Plain object to verify
84+
* @returns `null` if valid, otherwise the reason why it is not
85+
*/
86+
public static verify(message: { [k: string]: any }): (string|null);
87+
88+
/**
89+
* Creates a Reference message from a plain object. Also converts values to their respective internal types.
90+
* @param object Plain object
91+
* @returns Reference
92+
*/
93+
public static fromObject(object: { [k: string]: any }): Reference;
94+
95+
/**
96+
* Creates a plain object from a Reference message. Also converts values to other types if specified.
97+
* @param message Reference
98+
* @param [options] Conversion options
99+
* @returns Plain object
100+
*/
101+
public static toObject(message: Reference, options?: $protobuf.IConversionOptions): { [k: string]: any };
102+
103+
/**
104+
* Converts this Reference to JSON.
105+
* @returns JSON object
106+
*/
107+
public toJSON(): { [k: string]: any };
108+
}
109+
110+
/** Properties of a Path. */
111+
export interface IPath {
112+
113+
/** Path element */
114+
element?: (Path.IElement[]|null);
115+
}
116+
117+
/** Represents a Path. */
118+
export class Path implements IPath {
119+
120+
/**
121+
* Constructs a new Path.
122+
* @param [properties] Properties to set
123+
*/
124+
constructor(properties?: IPath);
125+
126+
/** Path element. */
127+
public element: Path.IElement[];
128+
129+
/**
130+
* Creates a new Path instance using the specified properties.
131+
* @param [properties] Properties to set
132+
* @returns Path instance
133+
*/
134+
public static create(properties?: IPath): Path;
135+
136+
/**
137+
* Encodes the specified Path message. Does not implicitly {@link Path.verify|verify} messages.
138+
* @param message Path message or plain object to encode
139+
* @param [writer] Writer to encode to
140+
* @returns Writer
141+
*/
142+
public static encode(message: IPath, writer?: $protobuf.Writer): $protobuf.Writer;
143+
144+
/**
145+
* Encodes the specified Path message, length delimited. Does not implicitly {@link Path.verify|verify} messages.
146+
* @param message Path message or plain object to encode
147+
* @param [writer] Writer to encode to
148+
* @returns Writer
149+
*/
150+
public static encodeDelimited(message: IPath, writer?: $protobuf.Writer): $protobuf.Writer;
151+
152+
/**
153+
* Decodes a Path message from the specified reader or buffer.
154+
* @param reader Reader or buffer to decode from
155+
* @param [length] Message length if known beforehand
156+
* @returns Path
157+
* @throws {Error} If the payload is not a reader or valid buffer
158+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
159+
*/
160+
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): Path;
161+
162+
/**
163+
* Decodes a Path message from the specified reader or buffer, length delimited.
164+
* @param reader Reader or buffer to decode from
165+
* @returns Path
166+
* @throws {Error} If the payload is not a reader or valid buffer
167+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
168+
*/
169+
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): Path;
170+
171+
/**
172+
* Verifies a Path message.
173+
* @param message Plain object to verify
174+
* @returns `null` if valid, otherwise the reason why it is not
175+
*/
176+
public static verify(message: { [k: string]: any }): (string|null);
177+
178+
/**
179+
* Creates a Path message from a plain object. Also converts values to their respective internal types.
180+
* @param object Plain object
181+
* @returns Path
182+
*/
183+
public static fromObject(object: { [k: string]: any }): Path;
184+
185+
/**
186+
* Creates a plain object from a Path message. Also converts values to other types if specified.
187+
* @param message Path
188+
* @param [options] Conversion options
189+
* @returns Plain object
190+
*/
191+
public static toObject(message: Path, options?: $protobuf.IConversionOptions): { [k: string]: any };
192+
193+
/**
194+
* Converts this Path to JSON.
195+
* @returns JSON object
196+
*/
197+
public toJSON(): { [k: string]: any };
198+
}
199+
200+
export namespace Path {
201+
202+
/** Properties of an Element. */
203+
interface IElement {
204+
205+
/** Element type */
206+
type: string;
207+
208+
/** Element id */
209+
id?: (number|Long|null);
210+
211+
/** Element name */
212+
name?: (string|null);
213+
}
214+
215+
/** Represents an Element. */
216+
class Element implements IElement {
217+
218+
/**
219+
* Constructs a new Element.
220+
* @param [properties] Properties to set
221+
*/
222+
constructor(properties?: Path.IElement);
223+
224+
/** Element type. */
225+
public type: string;
226+
227+
/** Element id. */
228+
public id: (number|Long);
229+
230+
/** Element name. */
231+
public name: string;
232+
233+
/**
234+
* Creates a new Element instance using the specified properties.
235+
* @param [properties] Properties to set
236+
* @returns Element instance
237+
*/
238+
public static create(properties?: Path.IElement): Path.Element;
239+
240+
/**
241+
* Encodes the specified Element message. Does not implicitly {@link Path.Element.verify|verify} messages.
242+
* @param message Element message or plain object to encode
243+
* @param [writer] Writer to encode to
244+
* @returns Writer
245+
*/
246+
public static encode(message: Path.IElement, writer?: $protobuf.Writer): $protobuf.Writer;
247+
248+
/**
249+
* Encodes the specified Element message, length delimited. Does not implicitly {@link Path.Element.verify|verify} messages.
250+
* @param message Element message or plain object to encode
251+
* @param [writer] Writer to encode to
252+
* @returns Writer
253+
*/
254+
public static encodeDelimited(message: Path.IElement, writer?: $protobuf.Writer): $protobuf.Writer;
255+
256+
/**
257+
* Decodes an Element message from the specified reader or buffer.
258+
* @param reader Reader or buffer to decode from
259+
* @param [length] Message length if known beforehand
260+
* @returns Element
261+
* @throws {Error} If the payload is not a reader or valid buffer
262+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
263+
*/
264+
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): Path.Element;
265+
266+
/**
267+
* Decodes an Element message from the specified reader or buffer, length delimited.
268+
* @param reader Reader or buffer to decode from
269+
* @returns Element
270+
* @throws {Error} If the payload is not a reader or valid buffer
271+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
272+
*/
273+
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): Path.Element;
274+
275+
/**
276+
* Verifies an Element message.
277+
* @param message Plain object to verify
278+
* @returns `null` if valid, otherwise the reason why it is not
279+
*/
280+
public static verify(message: { [k: string]: any }): (string|null);
281+
282+
/**
283+
* Creates an Element message from a plain object. Also converts values to their respective internal types.
284+
* @param object Plain object
285+
* @returns Element
286+
*/
287+
public static fromObject(object: { [k: string]: any }): Path.Element;
288+
289+
/**
290+
* Creates a plain object from an Element message. Also converts values to other types if specified.
291+
* @param message Element
292+
* @param [options] Conversion options
293+
* @returns Plain object
294+
*/
295+
public static toObject(message: Path.Element, options?: $protobuf.IConversionOptions): { [k: string]: any };
296+
297+
/**
298+
* Converts this Element to JSON.
299+
* @returns JSON object
300+
*/
301+
public toJSON(): { [k: string]: any };
302+
}
303+
}

protos/app_engine_key.proto

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
syntax = "proto2";
2+
3+
message Reference {
4+
required string app = 13;
5+
optional string namespace = 20;
6+
required Path path = 14;
7+
optional string database_id = 23;
8+
}
9+
10+
message Path {
11+
repeated group Element = 1 {
12+
required string type = 2;
13+
optional int64 id = 3;
14+
optional string name = 4;
15+
}
16+
}

0 commit comments

Comments
 (0)