1// Copyright 2018 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package checker
16
17import (
18	"github.com/google/cel-go/checker/decls"
19	"github.com/google/cel-go/common/operators"
20	"github.com/google/cel-go/common/overloads"
21
22	exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
23)
24
25// StandardDeclarations returns the Decls for all functions and constants in the evaluator.
26func StandardDeclarations() []*exprpb.Decl {
27	// Some shortcuts we use when building declarations.
28	paramA := decls.NewTypeParamType("A")
29	typeParamAList := []string{"A"}
30	listOfA := decls.NewListType(paramA)
31	paramB := decls.NewTypeParamType("B")
32	typeParamABList := []string{"A", "B"}
33	mapOfAB := decls.NewMapType(paramA, paramB)
34
35	var idents []*exprpb.Decl
36	for _, t := range []*exprpb.Type{
37		decls.Int, decls.Uint, decls.Bool,
38		decls.Double, decls.Bytes, decls.String} {
39		idents = append(idents,
40			decls.NewIdent(FormatCheckedType(t), decls.NewTypeType(t), nil))
41	}
42	idents = append(idents,
43		decls.NewIdent("list", decls.NewTypeType(listOfA), nil),
44		decls.NewIdent("map", decls.NewTypeType(mapOfAB), nil),
45		decls.NewIdent("null_type", decls.NewTypeType(decls.Null), nil),
46		decls.NewIdent("type", decls.NewTypeType(decls.NewTypeType(nil)), nil))
47
48	// Booleans
49	// TODO: allow the conditional to return a heterogenous type.
50	return append(idents, []*exprpb.Decl{
51		decls.NewFunction(operators.Conditional,
52			decls.NewParameterizedOverload(overloads.Conditional,
53				[]*exprpb.Type{decls.Bool, paramA, paramA}, paramA,
54				typeParamAList)),
55
56		decls.NewFunction(operators.LogicalAnd,
57			decls.NewOverload(overloads.LogicalAnd,
58				[]*exprpb.Type{decls.Bool, decls.Bool}, decls.Bool)),
59
60		decls.NewFunction(operators.LogicalOr,
61			decls.NewOverload(overloads.LogicalOr,
62				[]*exprpb.Type{decls.Bool, decls.Bool}, decls.Bool)),
63
64		decls.NewFunction(operators.LogicalNot,
65			decls.NewOverload(overloads.LogicalNot,
66				[]*exprpb.Type{decls.Bool}, decls.Bool)),
67
68		decls.NewFunction(operators.NotStrictlyFalse,
69			decls.NewOverload(overloads.NotStrictlyFalse,
70				[]*exprpb.Type{decls.Bool}, decls.Bool)),
71
72		// Relations.
73
74		decls.NewFunction(operators.Less,
75			decls.NewOverload(overloads.LessBool,
76				[]*exprpb.Type{decls.Bool, decls.Bool}, decls.Bool),
77			decls.NewOverload(overloads.LessInt64,
78				[]*exprpb.Type{decls.Int, decls.Int}, decls.Bool),
79			decls.NewOverload(overloads.LessUint64,
80				[]*exprpb.Type{decls.Uint, decls.Uint}, decls.Bool),
81			decls.NewOverload(overloads.LessDouble,
82				[]*exprpb.Type{decls.Double, decls.Double}, decls.Bool),
83			decls.NewOverload(overloads.LessString,
84				[]*exprpb.Type{decls.String, decls.String}, decls.Bool),
85			decls.NewOverload(overloads.LessBytes,
86				[]*exprpb.Type{decls.Bytes, decls.Bytes}, decls.Bool),
87			decls.NewOverload(overloads.LessTimestamp,
88				[]*exprpb.Type{decls.Timestamp, decls.Timestamp}, decls.Bool),
89			decls.NewOverload(overloads.LessDuration,
90				[]*exprpb.Type{decls.Duration, decls.Duration}, decls.Bool)),
91
92		decls.NewFunction(operators.LessEquals,
93			decls.NewOverload(overloads.LessEqualsBool,
94				[]*exprpb.Type{decls.Bool, decls.Bool}, decls.Bool),
95			decls.NewOverload(overloads.LessEqualsInt64,
96				[]*exprpb.Type{decls.Int, decls.Int}, decls.Bool),
97			decls.NewOverload(overloads.LessEqualsUint64,
98				[]*exprpb.Type{decls.Uint, decls.Uint}, decls.Bool),
99			decls.NewOverload(overloads.LessEqualsDouble,
100				[]*exprpb.Type{decls.Double, decls.Double}, decls.Bool),
101			decls.NewOverload(overloads.LessEqualsString,
102				[]*exprpb.Type{decls.String, decls.String}, decls.Bool),
103			decls.NewOverload(overloads.LessEqualsBytes,
104				[]*exprpb.Type{decls.Bytes, decls.Bytes}, decls.Bool),
105			decls.NewOverload(overloads.LessEqualsTimestamp,
106				[]*exprpb.Type{decls.Timestamp, decls.Timestamp}, decls.Bool),
107			decls.NewOverload(overloads.LessEqualsDuration,
108				[]*exprpb.Type{decls.Duration, decls.Duration}, decls.Bool)),
109
110		decls.NewFunction(operators.Greater,
111			decls.NewOverload(overloads.GreaterBool,
112				[]*exprpb.Type{decls.Bool, decls.Bool}, decls.Bool),
113			decls.NewOverload(overloads.GreaterInt64,
114				[]*exprpb.Type{decls.Int, decls.Int}, decls.Bool),
115			decls.NewOverload(overloads.GreaterUint64,
116				[]*exprpb.Type{decls.Uint, decls.Uint}, decls.Bool),
117			decls.NewOverload(overloads.GreaterDouble,
118				[]*exprpb.Type{decls.Double, decls.Double}, decls.Bool),
119			decls.NewOverload(overloads.GreaterString,
120				[]*exprpb.Type{decls.String, decls.String}, decls.Bool),
121			decls.NewOverload(overloads.GreaterBytes,
122				[]*exprpb.Type{decls.Bytes, decls.Bytes}, decls.Bool),
123			decls.NewOverload(overloads.GreaterTimestamp,
124				[]*exprpb.Type{decls.Timestamp, decls.Timestamp}, decls.Bool),
125			decls.NewOverload(overloads.GreaterDuration,
126				[]*exprpb.Type{decls.Duration, decls.Duration}, decls.Bool)),
127
128		decls.NewFunction(operators.GreaterEquals,
129			decls.NewOverload(overloads.GreaterEqualsBool,
130				[]*exprpb.Type{decls.Bool, decls.Bool}, decls.Bool),
131			decls.NewOverload(overloads.GreaterEqualsInt64,
132				[]*exprpb.Type{decls.Int, decls.Int}, decls.Bool),
133			decls.NewOverload(overloads.GreaterEqualsUint64,
134				[]*exprpb.Type{decls.Uint, decls.Uint}, decls.Bool),
135			decls.NewOverload(overloads.GreaterEqualsDouble,
136				[]*exprpb.Type{decls.Double, decls.Double}, decls.Bool),
137			decls.NewOverload(overloads.GreaterEqualsString,
138				[]*exprpb.Type{decls.String, decls.String}, decls.Bool),
139			decls.NewOverload(overloads.GreaterEqualsBytes,
140				[]*exprpb.Type{decls.Bytes, decls.Bytes}, decls.Bool),
141			decls.NewOverload(overloads.GreaterEqualsTimestamp,
142				[]*exprpb.Type{decls.Timestamp, decls.Timestamp}, decls.Bool),
143			decls.NewOverload(overloads.GreaterEqualsDuration,
144				[]*exprpb.Type{decls.Duration, decls.Duration}, decls.Bool)),
145
146		decls.NewFunction(operators.Equals,
147			decls.NewParameterizedOverload(overloads.Equals,
148				[]*exprpb.Type{paramA, paramA}, decls.Bool,
149				typeParamAList)),
150
151		decls.NewFunction(operators.NotEquals,
152			decls.NewParameterizedOverload(overloads.NotEquals,
153				[]*exprpb.Type{paramA, paramA}, decls.Bool,
154				typeParamAList)),
155
156		// Algebra.
157
158		decls.NewFunction(operators.Subtract,
159			decls.NewOverload(overloads.SubtractInt64,
160				[]*exprpb.Type{decls.Int, decls.Int}, decls.Int),
161			decls.NewOverload(overloads.SubtractUint64,
162				[]*exprpb.Type{decls.Uint, decls.Uint}, decls.Uint),
163			decls.NewOverload(overloads.SubtractDouble,
164				[]*exprpb.Type{decls.Double, decls.Double}, decls.Double),
165			decls.NewOverload(overloads.SubtractTimestampTimestamp,
166				[]*exprpb.Type{decls.Timestamp, decls.Timestamp}, decls.Duration),
167			decls.NewOverload(overloads.SubtractTimestampDuration,
168				[]*exprpb.Type{decls.Timestamp, decls.Duration}, decls.Timestamp),
169			decls.NewOverload(overloads.SubtractDurationDuration,
170				[]*exprpb.Type{decls.Duration, decls.Duration}, decls.Duration)),
171
172		decls.NewFunction(operators.Multiply,
173			decls.NewOverload(overloads.MultiplyInt64,
174				[]*exprpb.Type{decls.Int, decls.Int}, decls.Int),
175			decls.NewOverload(overloads.MultiplyUint64,
176				[]*exprpb.Type{decls.Uint, decls.Uint}, decls.Uint),
177			decls.NewOverload(overloads.MultiplyDouble,
178				[]*exprpb.Type{decls.Double, decls.Double}, decls.Double)),
179
180		decls.NewFunction(operators.Divide,
181			decls.NewOverload(overloads.DivideInt64,
182				[]*exprpb.Type{decls.Int, decls.Int}, decls.Int),
183			decls.NewOverload(overloads.DivideUint64,
184				[]*exprpb.Type{decls.Uint, decls.Uint}, decls.Uint),
185			decls.NewOverload(overloads.DivideDouble,
186				[]*exprpb.Type{decls.Double, decls.Double}, decls.Double)),
187
188		decls.NewFunction(operators.Modulo,
189			decls.NewOverload(overloads.ModuloInt64,
190				[]*exprpb.Type{decls.Int, decls.Int}, decls.Int),
191			decls.NewOverload(overloads.ModuloUint64,
192				[]*exprpb.Type{decls.Uint, decls.Uint}, decls.Uint)),
193
194		decls.NewFunction(operators.Add,
195			decls.NewOverload(overloads.AddInt64,
196				[]*exprpb.Type{decls.Int, decls.Int}, decls.Int),
197			decls.NewOverload(overloads.AddUint64,
198				[]*exprpb.Type{decls.Uint, decls.Uint}, decls.Uint),
199			decls.NewOverload(overloads.AddDouble,
200				[]*exprpb.Type{decls.Double, decls.Double}, decls.Double),
201			decls.NewOverload(overloads.AddString,
202				[]*exprpb.Type{decls.String, decls.String}, decls.String),
203			decls.NewOverload(overloads.AddBytes,
204				[]*exprpb.Type{decls.Bytes, decls.Bytes}, decls.Bytes),
205			decls.NewParameterizedOverload(overloads.AddList,
206				[]*exprpb.Type{listOfA, listOfA}, listOfA,
207				typeParamAList),
208			decls.NewOverload(overloads.AddTimestampDuration,
209				[]*exprpb.Type{decls.Timestamp, decls.Duration}, decls.Timestamp),
210			decls.NewOverload(overloads.AddDurationTimestamp,
211				[]*exprpb.Type{decls.Duration, decls.Timestamp}, decls.Timestamp),
212			decls.NewOverload(overloads.AddDurationDuration,
213				[]*exprpb.Type{decls.Duration, decls.Duration}, decls.Duration)),
214
215		decls.NewFunction(operators.Negate,
216			decls.NewOverload(overloads.NegateInt64,
217				[]*exprpb.Type{decls.Int}, decls.Int),
218			decls.NewOverload(overloads.NegateDouble,
219				[]*exprpb.Type{decls.Double}, decls.Double)),
220
221		// Index.
222
223		decls.NewFunction(operators.Index,
224			decls.NewParameterizedOverload(overloads.IndexList,
225				[]*exprpb.Type{listOfA, decls.Int}, paramA,
226				typeParamAList),
227			decls.NewParameterizedOverload(overloads.IndexMap,
228				[]*exprpb.Type{mapOfAB, paramA}, paramB,
229				typeParamABList)),
230		//decls.NewOverload(overloads.IndexMessage,
231		//	[]*expr.Type{decls.Dyn, decls.String}, decls.Dyn)),
232
233		// Collections.
234
235		decls.NewFunction(overloads.Size,
236			decls.NewInstanceOverload(overloads.SizeStringInst,
237				[]*exprpb.Type{decls.String}, decls.Int),
238			decls.NewInstanceOverload(overloads.SizeBytesInst,
239				[]*exprpb.Type{decls.Bytes}, decls.Int),
240			decls.NewParameterizedInstanceOverload(overloads.SizeListInst,
241				[]*exprpb.Type{listOfA}, decls.Int, typeParamAList),
242			decls.NewParameterizedInstanceOverload(overloads.SizeMapInst,
243				[]*exprpb.Type{mapOfAB}, decls.Int, typeParamABList),
244			decls.NewOverload(overloads.SizeString,
245				[]*exprpb.Type{decls.String}, decls.Int),
246			decls.NewOverload(overloads.SizeBytes,
247				[]*exprpb.Type{decls.Bytes}, decls.Int),
248			decls.NewParameterizedOverload(overloads.SizeList,
249				[]*exprpb.Type{listOfA}, decls.Int, typeParamAList),
250			decls.NewParameterizedOverload(overloads.SizeMap,
251				[]*exprpb.Type{mapOfAB}, decls.Int, typeParamABList)),
252
253		decls.NewFunction(operators.In,
254			decls.NewParameterizedOverload(overloads.InList,
255				[]*exprpb.Type{paramA, listOfA}, decls.Bool,
256				typeParamAList),
257			decls.NewParameterizedOverload(overloads.InMap,
258				[]*exprpb.Type{paramA, mapOfAB}, decls.Bool,
259				typeParamABList)),
260
261		// Deprecated 'in()' function.
262
263		decls.NewFunction(overloads.DeprecatedIn,
264			decls.NewParameterizedOverload(overloads.InList,
265				[]*exprpb.Type{paramA, listOfA}, decls.Bool,
266				typeParamAList),
267			decls.NewParameterizedOverload(overloads.InMap,
268				[]*exprpb.Type{paramA, mapOfAB}, decls.Bool,
269				typeParamABList)),
270		//decls.NewOverload(overloads.InMessage,
271		//	[]*expr.Type{Dyn, decls.String},decls.Bool)),
272
273		// Conversions to type.
274
275		decls.NewFunction(overloads.TypeConvertType,
276			decls.NewParameterizedOverload(overloads.TypeConvertType,
277				[]*exprpb.Type{paramA}, decls.NewTypeType(paramA), typeParamAList)),
278
279		// Conversions to int.
280
281		decls.NewFunction(overloads.TypeConvertInt,
282			decls.NewOverload(overloads.IntToInt, []*exprpb.Type{decls.Int}, decls.Int),
283			decls.NewOverload(overloads.UintToInt, []*exprpb.Type{decls.Uint}, decls.Int),
284			decls.NewOverload(overloads.DoubleToInt, []*exprpb.Type{decls.Double}, decls.Int),
285			decls.NewOverload(overloads.StringToInt, []*exprpb.Type{decls.String}, decls.Int),
286			decls.NewOverload(overloads.TimestampToInt, []*exprpb.Type{decls.Timestamp}, decls.Int),
287			decls.NewOverload(overloads.DurationToInt, []*exprpb.Type{decls.Duration}, decls.Int)),
288
289		// Conversions to uint.
290
291		decls.NewFunction(overloads.TypeConvertUint,
292			decls.NewOverload(overloads.UintToUint, []*exprpb.Type{decls.Uint}, decls.Uint),
293			decls.NewOverload(overloads.IntToUint, []*exprpb.Type{decls.Int}, decls.Uint),
294			decls.NewOverload(overloads.DoubleToUint, []*exprpb.Type{decls.Double}, decls.Uint),
295			decls.NewOverload(overloads.StringToUint, []*exprpb.Type{decls.String}, decls.Uint)),
296
297		// Conversions to double.
298
299		decls.NewFunction(overloads.TypeConvertDouble,
300			decls.NewOverload(overloads.DoubleToDouble, []*exprpb.Type{decls.Double}, decls.Double),
301			decls.NewOverload(overloads.IntToDouble, []*exprpb.Type{decls.Int}, decls.Double),
302			decls.NewOverload(overloads.UintToDouble, []*exprpb.Type{decls.Uint}, decls.Double),
303			decls.NewOverload(overloads.StringToDouble, []*exprpb.Type{decls.String}, decls.Double)),
304
305		// Conversions to bool.
306
307		decls.NewFunction(overloads.TypeConvertBool,
308			decls.NewOverload(overloads.BoolToBool, []*exprpb.Type{decls.Bool}, decls.Bool),
309			decls.NewOverload(overloads.StringToBool, []*exprpb.Type{decls.String}, decls.Bool)),
310
311		// Conversions to string.
312
313		decls.NewFunction(overloads.TypeConvertString,
314			decls.NewOverload(overloads.StringToString, []*exprpb.Type{decls.String}, decls.String),
315			decls.NewOverload(overloads.BoolToString, []*exprpb.Type{decls.Bool}, decls.String),
316			decls.NewOverload(overloads.IntToString, []*exprpb.Type{decls.Int}, decls.String),
317			decls.NewOverload(overloads.UintToString, []*exprpb.Type{decls.Uint}, decls.String),
318			decls.NewOverload(overloads.DoubleToString, []*exprpb.Type{decls.Double}, decls.String),
319			decls.NewOverload(overloads.BytesToString, []*exprpb.Type{decls.Bytes}, decls.String),
320			decls.NewOverload(overloads.TimestampToString, []*exprpb.Type{decls.Timestamp}, decls.String),
321			decls.NewOverload(overloads.DurationToString, []*exprpb.Type{decls.Duration}, decls.String)),
322
323		// Conversions to bytes.
324
325		decls.NewFunction(overloads.TypeConvertBytes,
326			decls.NewOverload(overloads.BytesToBytes, []*exprpb.Type{decls.Bytes}, decls.Bytes),
327			decls.NewOverload(overloads.StringToBytes, []*exprpb.Type{decls.String}, decls.Bytes)),
328
329		// Conversions to timestamps.
330
331		decls.NewFunction(overloads.TypeConvertTimestamp,
332			decls.NewOverload(overloads.TimestampToTimestamp,
333				[]*exprpb.Type{decls.Timestamp}, decls.Timestamp),
334			decls.NewOverload(overloads.StringToTimestamp,
335				[]*exprpb.Type{decls.String}, decls.Timestamp),
336			decls.NewOverload(overloads.IntToTimestamp,
337				[]*exprpb.Type{decls.Int}, decls.Timestamp)),
338
339		// Conversions to durations.
340
341		decls.NewFunction(overloads.TypeConvertDuration,
342			decls.NewOverload(overloads.DurationToDuration,
343				[]*exprpb.Type{decls.Duration}, decls.Duration),
344			decls.NewOverload(overloads.StringToDuration,
345				[]*exprpb.Type{decls.String}, decls.Duration),
346			decls.NewOverload(overloads.IntToDuration,
347				[]*exprpb.Type{decls.Int}, decls.Duration)),
348
349		// Conversions to Dyn.
350
351		decls.NewFunction(overloads.TypeConvertDyn,
352			decls.NewParameterizedOverload(overloads.ToDyn,
353				[]*exprpb.Type{paramA}, decls.Dyn,
354				typeParamAList)),
355
356		// String functions.
357
358		decls.NewFunction(overloads.Contains,
359			decls.NewInstanceOverload(overloads.ContainsString,
360				[]*exprpb.Type{decls.String, decls.String}, decls.Bool)),
361		decls.NewFunction(overloads.EndsWith,
362			decls.NewInstanceOverload(overloads.EndsWithString,
363				[]*exprpb.Type{decls.String, decls.String}, decls.Bool)),
364		decls.NewFunction(overloads.Matches,
365			decls.NewInstanceOverload(overloads.MatchesString,
366				[]*exprpb.Type{decls.String, decls.String}, decls.Bool)),
367		decls.NewFunction(overloads.StartsWith,
368			decls.NewInstanceOverload(overloads.StartsWithString,
369				[]*exprpb.Type{decls.String, decls.String}, decls.Bool)),
370
371		// Date/time functions.
372
373		decls.NewFunction(overloads.TimeGetFullYear,
374			decls.NewInstanceOverload(overloads.TimestampToYear,
375				[]*exprpb.Type{decls.Timestamp}, decls.Int),
376			decls.NewInstanceOverload(overloads.TimestampToYearWithTz,
377				[]*exprpb.Type{decls.Timestamp, decls.String}, decls.Int)),
378
379		decls.NewFunction(overloads.TimeGetMonth,
380			decls.NewInstanceOverload(overloads.TimestampToMonth,
381				[]*exprpb.Type{decls.Timestamp}, decls.Int),
382			decls.NewInstanceOverload(overloads.TimestampToMonthWithTz,
383				[]*exprpb.Type{decls.Timestamp, decls.String}, decls.Int)),
384
385		decls.NewFunction(overloads.TimeGetDayOfYear,
386			decls.NewInstanceOverload(overloads.TimestampToDayOfYear,
387				[]*exprpb.Type{decls.Timestamp}, decls.Int),
388			decls.NewInstanceOverload(overloads.TimestampToDayOfYearWithTz,
389				[]*exprpb.Type{decls.Timestamp, decls.String}, decls.Int)),
390
391		decls.NewFunction(overloads.TimeGetDayOfMonth,
392			decls.NewInstanceOverload(overloads.TimestampToDayOfMonthZeroBased,
393				[]*exprpb.Type{decls.Timestamp}, decls.Int),
394			decls.NewInstanceOverload(overloads.TimestampToDayOfMonthZeroBasedWithTz,
395				[]*exprpb.Type{decls.Timestamp, decls.String}, decls.Int)),
396
397		decls.NewFunction(overloads.TimeGetDate,
398			decls.NewInstanceOverload(overloads.TimestampToDayOfMonthOneBased,
399				[]*exprpb.Type{decls.Timestamp}, decls.Int),
400			decls.NewInstanceOverload(overloads.TimestampToDayOfMonthOneBasedWithTz,
401				[]*exprpb.Type{decls.Timestamp, decls.String}, decls.Int)),
402
403		decls.NewFunction(overloads.TimeGetDayOfWeek,
404			decls.NewInstanceOverload(overloads.TimestampToDayOfWeek,
405				[]*exprpb.Type{decls.Timestamp}, decls.Int),
406			decls.NewInstanceOverload(overloads.TimestampToDayOfWeekWithTz,
407				[]*exprpb.Type{decls.Timestamp, decls.String}, decls.Int)),
408
409		decls.NewFunction(overloads.TimeGetHours,
410			decls.NewInstanceOverload(overloads.TimestampToHours,
411				[]*exprpb.Type{decls.Timestamp}, decls.Int),
412			decls.NewInstanceOverload(overloads.TimestampToHoursWithTz,
413				[]*exprpb.Type{decls.Timestamp, decls.String}, decls.Int),
414			decls.NewInstanceOverload(overloads.DurationToHours,
415				[]*exprpb.Type{decls.Duration}, decls.Int)),
416
417		decls.NewFunction(overloads.TimeGetMinutes,
418			decls.NewInstanceOverload(overloads.TimestampToMinutes,
419				[]*exprpb.Type{decls.Timestamp}, decls.Int),
420			decls.NewInstanceOverload(overloads.TimestampToMinutesWithTz,
421				[]*exprpb.Type{decls.Timestamp, decls.String}, decls.Int),
422			decls.NewInstanceOverload(overloads.DurationToMinutes,
423				[]*exprpb.Type{decls.Duration}, decls.Int)),
424
425		decls.NewFunction(overloads.TimeGetSeconds,
426			decls.NewInstanceOverload(overloads.TimestampToSeconds,
427				[]*exprpb.Type{decls.Timestamp}, decls.Int),
428			decls.NewInstanceOverload(overloads.TimestampToSecondsWithTz,
429				[]*exprpb.Type{decls.Timestamp, decls.String}, decls.Int),
430			decls.NewInstanceOverload(overloads.DurationToSeconds,
431				[]*exprpb.Type{decls.Duration}, decls.Int)),
432
433		decls.NewFunction(overloads.TimeGetMilliseconds,
434			decls.NewInstanceOverload(overloads.TimestampToMilliseconds,
435				[]*exprpb.Type{decls.Timestamp}, decls.Int),
436			decls.NewInstanceOverload(overloads.TimestampToMillisecondsWithTz,
437				[]*exprpb.Type{decls.Timestamp, decls.String}, decls.Int),
438			decls.NewInstanceOverload(overloads.DurationToMilliseconds,
439				[]*exprpb.Type{decls.Duration}, decls.Int))}...)
440}
441