UNPKG

@mysten/sui

Version:
1 lines 9.29 kB
{"version":3,"file":"duration.mjs","names":[],"sources":["../../../../../src/grpc/proto/google/protobuf/duration.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// @generated by protobuf-ts 2.9.6 with parameter force_server_none,optimize_code_size,ts_nocheck\n// @generated from protobuf file \"google/protobuf/duration.proto\" (package \"google.protobuf\", syntax proto3)\n// tslint:disable\n// @ts-nocheck\n//\n// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc. All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n// * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n// * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n// * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\nimport { typeofJsonValue } from '@protobuf-ts/runtime';\nimport type { JsonValue } from '@protobuf-ts/runtime';\nimport type { JsonReadOptions } from '@protobuf-ts/runtime';\nimport type { JsonWriteOptions } from '@protobuf-ts/runtime';\nimport { PbLong } from '@protobuf-ts/runtime';\nimport { MessageType } from '@protobuf-ts/runtime';\n/**\n * A Duration represents a signed, fixed-length span of time represented\n * as a count of seconds and fractions of seconds at nanosecond\n * resolution. It is independent of any calendar and concepts like \"day\"\n * or \"month\". It is related to Timestamp in that the difference between\n * two Timestamp values is a Duration and it can be added or subtracted\n * from a Timestamp. Range is approximately +-10,000 years.\n *\n * # Examples\n *\n * Example 1: Compute Duration from two Timestamps in pseudo code.\n *\n * Timestamp start = ...;\n * Timestamp end = ...;\n * Duration duration = ...;\n *\n * duration.seconds = end.seconds - start.seconds;\n * duration.nanos = end.nanos - start.nanos;\n *\n * if (duration.seconds < 0 && duration.nanos > 0) {\n * duration.seconds += 1;\n * duration.nanos -= 1000000000;\n * } else if (duration.seconds > 0 && duration.nanos < 0) {\n * duration.seconds -= 1;\n * duration.nanos += 1000000000;\n * }\n *\n * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.\n *\n * Timestamp start = ...;\n * Duration duration = ...;\n * Timestamp end = ...;\n *\n * end.seconds = start.seconds + duration.seconds;\n * end.nanos = start.nanos + duration.nanos;\n *\n * if (end.nanos < 0) {\n * end.seconds -= 1;\n * end.nanos += 1000000000;\n * } else if (end.nanos >= 1000000000) {\n * end.seconds += 1;\n * end.nanos -= 1000000000;\n * }\n *\n * Example 3: Compute Duration from datetime.timedelta in Python.\n *\n * td = datetime.timedelta(days=3, minutes=10)\n * duration = Duration()\n * duration.FromTimedelta(td)\n *\n * # JSON Mapping\n *\n * In JSON format, the Duration type is encoded as a string rather than an\n * object, where the string ends in the suffix \"s\" (indicating seconds) and\n * is preceded by the number of seconds, with nanoseconds expressed as\n * fractional seconds. For example, 3 seconds with 0 nanoseconds should be\n * encoded in JSON format as \"3s\", while 3 seconds and 1 nanosecond should\n * be expressed in JSON format as \"3.000000001s\", and 3 seconds and 1\n * microsecond should be expressed in JSON format as \"3.000001s\".\n *\n *\n * @generated from protobuf message google.protobuf.Duration\n */\nexport interface Duration {\n\t/**\n\t * Signed seconds of the span of time. Must be from -315,576,000,000\n\t * to +315,576,000,000 inclusive. Note: these bounds are computed from:\n\t * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years\n\t *\n\t * @generated from protobuf field: int64 seconds = 1;\n\t */\n\tseconds: bigint;\n\t/**\n\t * Signed fractions of a second at nanosecond resolution of the span\n\t * of time. Durations less than one second are represented with a 0\n\t * `seconds` field and a positive or negative `nanos` field. For durations\n\t * of one second or more, a non-zero value for the `nanos` field must be\n\t * of the same sign as the `seconds` field. Must be from -999,999,999\n\t * to +999,999,999 inclusive.\n\t *\n\t * @generated from protobuf field: int32 nanos = 2;\n\t */\n\tnanos: number;\n}\n// @generated message type with reflection information, may provide speed optimized methods\nclass Duration$Type extends MessageType<Duration> {\n\tconstructor() {\n\t\tsuper('google.protobuf.Duration', [\n\t\t\t{\n\t\t\t\tno: 1,\n\t\t\t\tname: 'seconds',\n\t\t\t\tkind: 'scalar',\n\t\t\t\tT: 3 /*ScalarType.INT64*/,\n\t\t\t\tL: 0 /*LongType.BIGINT*/,\n\t\t\t},\n\t\t\t{ no: 2, name: 'nanos', kind: 'scalar', T: 5 /*ScalarType.INT32*/ },\n\t\t]);\n\t}\n\t/**\n\t * Encode `Duration` to JSON string like \"3.000001s\".\n\t */\n\tinternalJsonWrite(message: Duration, options: JsonWriteOptions): JsonValue {\n\t\tlet s = PbLong.from(message.seconds).toNumber();\n\t\tif (s > 315576000000 || s < -315576000000) throw new Error('Duration value out of range.');\n\t\tlet text = message.seconds.toString();\n\t\tif (s === 0 && message.nanos < 0) text = '-' + text;\n\t\tif (message.nanos !== 0) {\n\t\t\tlet nanosStr = Math.abs(message.nanos).toString();\n\t\t\tnanosStr = '0'.repeat(9 - nanosStr.length) + nanosStr;\n\t\t\tif (nanosStr.substring(3) === '000000') nanosStr = nanosStr.substring(0, 3);\n\t\t\telse if (nanosStr.substring(6) === '000') nanosStr = nanosStr.substring(0, 6);\n\t\t\ttext += '.' + nanosStr;\n\t\t}\n\t\treturn text + 's';\n\t}\n\t/**\n\t * Decode `Duration` from JSON string like \"3.000001s\"\n\t */\n\tinternalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Duration): Duration {\n\t\tif (typeof json !== 'string')\n\t\t\tthrow new Error(\n\t\t\t\t'Unable to parse Duration from JSON ' + typeofJsonValue(json) + '. Expected string.',\n\t\t\t);\n\t\tlet match = json.match(/^(-?)([0-9]+)(?:\\.([0-9]+))?s/);\n\t\tif (match === null)\n\t\t\tthrow new Error('Unable to parse Duration from JSON string. Invalid format.');\n\t\tif (!target) target = this.create();\n\t\tlet [, sign, secs, nanos] = match;\n\t\tlet longSeconds = PbLong.from(sign + secs);\n\t\tif (longSeconds.toNumber() > 315576000000 || longSeconds.toNumber() < -315576000000)\n\t\t\tthrow new Error('Unable to parse Duration from JSON string. Value out of range.');\n\t\ttarget.seconds = longSeconds.toBigInt();\n\t\tif (typeof nanos == 'string') {\n\t\t\tlet nanosStr = sign + nanos + '0'.repeat(9 - nanos.length);\n\t\t\ttarget.nanos = parseInt(nanosStr);\n\t\t}\n\t\treturn target;\n\t}\n}\n/**\n * @generated MessageType for protobuf message google.protobuf.Duration\n */\nexport const Duration = new Duration$Type();\n"],"mappings":";;;AAiIA,IAAM,gBAAN,cAA4B,YAAsB;CACjD,cAAc;AACb,QAAM,4BAA4B,CACjC;GACC,IAAI;GACJ,MAAM;GACN,MAAM;GACN,GAAG;GACH,GAAG;GACH,EACD;GAAE,IAAI;GAAG,MAAM;GAAS,MAAM;GAAU,GAAG;GAAwB,CACnE,CAAC;;;;;CAKH,kBAAkB,SAAmB,S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